From: <rb...@us...> - 2014-03-14 18:29:49
|
Revision: 9178 http://sourceforge.net/p/htmlunit/code/9178 Author: rbri Date: 2014-03-14 18:29:43 +0000 (Fri, 14 Mar 2014) Log Message: ----------- window.navigate(url) for IE browsers added Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2014-03-13 20:29:17 UTC (rev 9177) +++ trunk/htmlunit/src/changes/changes.xml 2014-03-14 18:29:43 UTC (rev 9178) @@ -8,6 +8,9 @@ <body> <release version="2.15" date="???" description="Bugfixes"> + <action type="add" dev="rbri"> + JavaScript: window.navigate(url) for IE browsers added. + </action> <action type="fix" dev="rbri" issue="1583" due-to="Carsten Steul"> Optimized image data handling; the finalizer needed for the ImageInputStream no longer stops the image node itself from being gc'ed. Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java 2014-03-13 20:29:17 UTC (rev 9177) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java 2014-03-14 18:29:43 UTC (rev 9178) @@ -958,6 +958,17 @@ } /** + * Loads the new HTML document corresponding to the specified URL. + * @param url the location of the new HTML document to load + * @throws IOException if loading the specified location fails + * @see <a href="http://msdn.microsoft.com/en-us/library/ms536638%28VS.85%29.aspx">MSDN Documentation</a> + */ + @JsxFunction(@WebBrowser(IE)) + public void navigate(final String url) throws IOException { + getLocation().assign(url); + } + + /** * Does nothing. * @param width the width offset * @param height the height offset Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java 2014-03-13 20:29:17 UTC (rev 9177) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java 2014-03-14 18:29:43 UTC (rev 9178) @@ -52,6 +52,7 @@ * @author Ahmed Ashour * @author Daniel Gredler * @author Frank Danek + * @author Ronald Brill */ @RunWith(BrowserRunner.class) public class Window3Test extends WebDriverTestCase { @@ -1450,4 +1451,28 @@ driver.findElement(By.id("clickme")).click(); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "First", IE = "Second") + public void navigate() throws Exception { + final String firstContent + = "<html><head><title>First</title><script>\n" + + " function test() {\n" + + " if (window.navigate) {\n" + + " window.navigate('" + URL_SECOND + "');\n" + + " }\n" + + " }\n" + + "</script></head><body onload='test()'>\n" + + "</body></html>"; + + final String secondContent = "<html><head><title>Second</title></head><body></body></html>"; + + getMockWebConnection().setResponse(URL_SECOND, secondContent); + + final WebDriver driver = loadPage2(firstContent, URL_FIRST); + assertEquals(getExpectedAlerts()[0], driver.getTitle()); + } } |