protected void initJavaScript() throws Exception { // Initializes the thread model org.mozilla.javascript.Context jsContext = org.mozilla.javascript.Context.enter(); try { ScriptableObject rootScope = jsContext.initStandardObjects(); ScriptableObject.defineClass(rootScope, HttpCookieStore.class); jsContext.evaluateString( rootScope, "var cookies = new HttpCookieStore();", "cookies", 1, null); HttpCookieStore cookies = (HttpCookieStore) rootScope.get("cookies", rootScope); cookies.putAll(this.cookies); this.cookies = cookies; ScriptableObject.defineClass(rootScope, JavaScriptThreadModel.class); jsContext.evaluateString( rootScope, "var threadModel = new JavaScriptThreadModel(this);", "threadModel", 1, null); threadModel = (ThreadModel) rootScope.get("threadModel", rootScope); threadModel.init(); ScriptableObject.defineClass(rootScope, XMLHttpRequestClient.class); ScriptableObject.defineClass(rootScope, XMLHttpRequestExchange.class); jsContext.evaluateString( rootScope, "var xhrClient = new XMLHttpRequestClient(2);", "xhrClient", 1, null); xhrClient = (XMLHttpRequestClient) rootScope.get("xhrClient", rootScope); xhrClient.start(); } finally { org.mozilla.javascript.Context.exit(); } }
@After public void destroyCometDServer() throws Exception { destroyPage(); server.stop(); server.join(); cookies.clear(); }