Package net.sourceforge.htmlunit.corejs.javascript

Examples of net.sourceforge.htmlunit.corejs.javascript.ContextFactory


        final String scriptName = requestSettings.getUrl().toString();
        final String scriptSource = response.getContentAsString();

        // skip if it is already formatted? => TODO

        final ContextFactory factory = new ContextFactory();
        final ContextAction action = new ContextAction() {
            public Object run(final Context cx) {
                cx.setOptimizationLevel(-1);
                final Script script = cx.compileString(scriptSource, scriptName, 0, null);
                return cx.decompileScript(script, 4);
            }
        };

        try {
            final String decompileScript = (String) factory.call(action);
            final WebResponseData wrd = new WebResponseData(decompileScript.getBytes(), response.getStatusCode(),
                response.getStatusMessage(), response.getResponseHeaders());
            return new WebResponseImpl(wrd, response.getRequestSettings().getUrl(),
                response.getRequestSettings().getHttpMethod(), response.getLoadTime());
        }
View Full Code Here


            doSend(Context.getCurrentContext());
        }
        else {
            // Create and start a thread in which to execute the request.
            final Object startingScope = getWindow();
            final ContextFactory cf = client.getJavaScriptEngine().getContextFactory();
            final ContextAction action = new ContextAction() {
                public Object run(final Context cx) {
                    cx.putThreadLocal(JavaScriptEngine.KEY_STARTING_SCOPE, startingScope);
                    doSend(cx);
                    return null;
                }
            };
            final JavaScriptJob job = new JavaScriptJob() {
                public void run() {
                    cf.call(action);
                }
                @Override
                public String toString() {
                    return "XMLHttpRequest Job " + getId();
                }
View Full Code Here

            public Object run(final Context cx) {
                return jsElt.fireEvent(event);
            }
        };

        final ContextFactory cf = client.getJavaScriptEngine().getContextFactory();
        final ScriptResult result = (ScriptResult) cf.call(action);
        if (event.isAborted(result)) {
            preventDefault();
        }
        return result;
    }
View Full Code Here

                    public Object run(final Context cx) {
                        callback_.call(cx, scope, scope, args);
                        return null;
                    }
                };
                final ContextFactory cf = client.getJavaScriptEngine().getContextFactory();
                cf.call(action);
            }
            catch (final IOException e) {
                LOG.error("Behavior #default#download: Cannot download " + url_, e);
            }
        }
View Full Code Here

TOP

Related Classes of net.sourceforge.htmlunit.corejs.javascript.ContextFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.