From: Marc A. D. <ma...@ru...> - 2005-03-23 16:45:57
|
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 =3D new Window(); URL url =3D new URL("http://someplace.com/something.html"); DomNode domNode =3D new HtmlPage(url, new = StringWebResponse(stringForURL(url)), new TopLevelWindow("WebWindow", new WebClient())); window.setDomNode(domNode); Context jsContext =3D Context.enter(); Scriptable jsScope =3D jsContext.initStandardObjects(); jsScope.setParentScope(window); // window is the scope of = execution Script javascript =3D 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 =3D = jsContext.initStandardObjects(window);" immediately above it results in = the same infinite loop. What am I doing wrong here? Many thanks for any help, Marc |