Hi,
can you first explain what you want to do. The javadoc says to javascript package: "users of HtmlUnit shouldn't need
anything in this package" as it is used internally to execute the javascript found in the html pages.
Marc.
Marc A. Donis wrote:
> Hi.
> I'm new to htmlunit. I'm trying to use the host objects provided with
> it to simulate browser behavior, but I'm having a lot of trouble. In
> particular:
>
> Window window = new Window();
> URL url = new URL("http://someplace.com/something.html");
> DomNode domNode = new HtmlPage(url, new
> StringWebResponse(stringForURL(url)), new TopLevelWindow("WebWindow",
> new WebClient()));
> window.setDomNode(domNode);
>
> Context jsContext = Context.enter();
> Scriptable jsScope = jsContext.initStandardObjects();
> jsScope.setParentScope(window); // window is the scope of execution
>
> Script javascript = jsContext.compileString("alert('hoho');",
> url.toString(), 1, null);
> javascript.exec(jsContext, jsScope);
> This little bit of code is supposed to execute the "alert('hoho');" code
> in the second to last line, but instead it results in an infinite loop.
> Removing the jsScope.setParentScope(window) line results (obviously) in
> the alert function call being undefined, which is no good either.
> Removing this line and substituting "Scriptable jsScope =
> jsContext.initStandardObjects(window);" immediately above it results in
> the same infinite loop.
>
> What am I doing wrong here?
>
>
> Many thanks for any help,
> Marc
>
|