Do not use ECMAScript contexts from other than the main thread

(DocumentWindow::enter, DocumentWindow::exit, ECMAScriptContext::dispatchEvent): Check if called from the main thread
src/Test.glut.cpp (isMainThread): New
src/Test.glut.cpp (init): Set MainThread flag to the caller