From: <no...@us...> - 2003-07-18 13:01:09
|
Log Message: ----------- Added support for Window.setTimeout() Modified Files: -------------- /cvsroot/htmlunit/htmlunit/src/xdocs: changes.xml /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript/host: Window.java /cvsroot/htmlunit/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host: WindowTest.java Revision Data ------------- Index: changes.xml =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/xdocs/changes.xml,v retrieving revision 1.114 retrieving revision 1.115 diff -u -d -r1.114 -r1.115 --- changes.xml 16 Jul 2003 20:11:20 -0000 1.114 +++ changes.xml 18 Jul 2003 13:01:06 -0000 1.115 @@ -133,6 +133,9 @@ <action type="new" dev="mbowler"> Added read-only support for Document.cookie. </action> + <action type="new" dev="mbowler" id="675597"> + Added support for the javascript method Window.setTimeout() + </action> </release> </body> Index: Window.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- Window.java 4 Jul 2003 15:21:02 -0000 1.21 +++ Window.java 18 Jul 2003 13:01:06 -0000 1.22 @@ -217,9 +217,6 @@ */ public static Object jsFunction_setTimeout( final Context context, final Scriptable scriptable, final Object[] args, final Function function ) { - ((Window)scriptable).getLog().debug( "Window.setTimeout() not implemented" ); - return NOT_FOUND; -/* commented out for now as this doesn't work - come back to it later final String script = getStringArg(0, args, null); final int timeout = getIntArg(1, args, 0); @@ -229,17 +226,23 @@ try { Thread.sleep(timeout); + // Register this thread with the rhino engine + Context.enter(); final HtmlPage htmlPage = window.document_.getHtmlPage(); - htmlPage.executeJavaScriptIfPossible(script, "Window.setTimeout()", true, null); + htmlPage.executeJavaScriptIfPossible( + script, "Window.setTimeout()", true, htmlPage); } catch( final Exception e ) { window.getLog().error("Caught exception in Window.setTimeout()", e); } + finally { + // Deregister this thread with the rhino engine + Context.exit(); + } } }; new Thread(runnable).start(); return null; -*/ } Index: WindowTest.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/WindowTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- WindowTest.java 4 Jul 2003 15:21:02 -0000 1.3 +++ WindowTest.java 18 Jul 2003 13:01:06 -0000 1.4 @@ -447,10 +447,6 @@ public void testSetTimeout() throws Exception { - if(true) { - notImplemented(); - return; - } final WebClient webClient = new WebClient(); final FakeWebConnection webConnection = new FakeWebConnection( webClient ); final List collectedAlerts = Collections.synchronizedList(new ArrayList()); @@ -458,7 +454,7 @@ webClient.setAlertHandler(new CollectingAlertHandler(collectedAlerts)); final String firstContent - = "<html><body><script language='JavaScript'>window.setTimeout('alert(\"Yo!\")',0);" + = "<html><body><script language='JavaScript'>window.setTimeout('alert(\"Yo!\")',1);" + "</script></body></html>"; webConnection.setResponse( |