From: <asa...@us...> - 2017-04-28 06:52:37
|
Revision: 14276 http://sourceforge.net/p/htmlunit/code/14276 Author: asashour Date: 2017-04-28 06:52:34 +0000 (Fri, 28 Apr 2017) Log Message: ----------- JavaScript: add URLUnencoded (IE only) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DocumentTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java 2017-04-28 06:27:42 UTC (rev 14275) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java 2017-04-28 06:52:34 UTC (rev 14276) @@ -980,4 +980,22 @@ return uniqueID_; } + /** + * Returns the value of the {@code URL} property. + * @return the value of the {@code URL} property + */ + @JsxGetter(propertyName = "URL") + public String getURL() { + return getPage().getUrl().toExternalForm(); + } + + /** + * Returns the value of the {@code URLUnencoded} property. + * @return the value of the {@code URLUnencoded} property + */ + @JsxGetter(value = @WebBrowser(IE), propertyName = "URLUnencoded") + public String getURLUnencoded() { + return getURL(); + } + } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java 2017-04-28 06:27:42 UTC (rev 14275) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java 2017-04-28 06:52:34 UTC (rev 14276) @@ -80,6 +80,8 @@ import com.gargoylesoftware.htmlunit.httpclient.HtmlUnitBrowserCompatCookieSpec; import com.gargoylesoftware.htmlunit.javascript.PostponedAction; import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; +import com.gargoylesoftware.htmlunit.javascript.configuration.CanSetReadOnly; +import com.gargoylesoftware.htmlunit.javascript.configuration.CanSetReadOnlyStatus; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; @@ -677,15 +679,6 @@ } /** - * Returns the value of the {@code URL} property. - * @return the value of the {@code URL} property - */ - @JsxGetter(propertyName = "URL") - public String getURL() { - return getPage().getUrl().toExternalForm(); - } - - /** * Returns the value of the {@code all} property. * @return the value of the {@code all} property */ @@ -969,6 +962,7 @@ */ @Override @JsxGetter(@WebBrowser(FF)) + @CanSetReadOnly(CanSetReadOnlyStatus.EXCEPTION) public HTMLElement getBody() { return super.getBody(); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DocumentTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DocumentTest.java 2017-04-28 06:27:42 UTC (rev 14275) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DocumentTest.java 2017-04-28 06:52:34 UTC (rev 14276) @@ -2335,4 +2335,32 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = {"§§URL§§", "undefined"}, + IE = {"§§URL§§", "§§URL§§"}) + public void urlUnencoded() throws Exception { + final String html = "<html>\n" + + "<head>\n" + + " <script>\n" + + " function test() {\n" + + " alert(document.URL);\n" + + " alert(document.URLUnencoded);\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + "</body>\n" + + "</html>"; + + final URL url = new URL(URL_FIRST, "abc%20def"); + expandExpectedAlertsVariables(url); + + final WebDriver driver = loadPage2(html, url); + verifyAlerts(driver, getExpectedAlerts()); + } + } |