From: <rb...@us...> - 2018-03-14 19:32:29
|
Revision: 15168 http://sourceforge.net/p/htmlunit/code/15168 Author: rbri Date: 2018-03-14 19:32:27 +0000 (Wed, 14 Mar 2018) Log Message: ----------- setters for window.innerWidth/Height and window.outerWidth/Height 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/Window2Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2018-03-14 19:02:36 UTC (rev 15167) +++ trunk/htmlunit/src/changes/changes.xml 2018-03-14 19:32:27 UTC (rev 15168) @@ -8,6 +8,9 @@ <body> <release version="2.30" date="xx, 2018" description="Bugfixes, URLSearchParams implemented, start adding support of user defined iterators, CHROME 64"> + <action type="add" dev="rbri"> + Setters for window.innerWidth/Height and window.outerWidth/Height added. + </action> <action type="fix" dev="rbri" issue="1957"> Redirect of head requests should be head requests also. </action> 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 2018-03-14 19:02:36 UTC (rev 15167) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java 2018-03-14 19:32:27 UTC (rev 15168) @@ -1553,6 +1553,15 @@ } /** + * Sets the {@code innerWidth}. + * @param width the {@code innerWidth} + */ + @JsxSetter + public void setInnerWidth(final int width) { + getWebWindow().setInnerWidth(width); + } + + /** * Returns the {@code outerWidth}. * @return the {@code outerWidth} * @see <a href="http://www.mozilla.org/docs/dom/domref/dom_window_ref79.html">Mozilla doc</a> @@ -1563,6 +1572,15 @@ } /** + * Sets the {@code outerWidth}. + * @param width the {@code outerWidth} + */ + @JsxSetter + public void setOuterWidth(final int width) { + getWebWindow().setOuterWidth(width); + } + + /** * Returns the {@code innerHeight}. * @return the {@code innerHeight} * @see <a href="http://www.mozilla.org/docs/dom/domref/dom_window_ref27.html">Mozilla doc</a> @@ -1573,6 +1591,15 @@ } /** + * Sets the {@code innerHeight}. + * @param height the {@code innerHeight} + */ + @JsxSetter + public void setInneHeight(final int height) { + getWebWindow().setInnerHeight(height); + } + + /** * Returns the {@code outerHeight}. * @return the {@code outerHeight} * @see <a href="http://www.mozilla.org/docs/dom/domref/dom_window_ref78.html">Mozilla doc</a> @@ -1583,6 +1610,15 @@ } /** + * Sets the {@code outerHeight}. + * @param height the {@code outerHeight} + */ + @JsxSetter + public void setOuterHeight(final int height) { + getWebWindow().setOuterHeight(height); + } + + /** * Prints the current page. The current implementation does nothing. * @see <a href="http://www.mozilla.org/docs/dom/domref/dom_window_ref85.html"> * Mozilla documentation</a> Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java 2018-03-14 19:02:36 UTC (rev 15167) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java 2018-03-14 19:32:27 UTC (rev 15168) @@ -676,6 +676,78 @@ } /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"true", "1234"}) + public void setInnerWidth() throws Exception { + final String html + = "<html><body onload='test()'><script>\n" + + "function test() {\n" + + " alert(window.innerWidth > 0);\n" + + " window.innerWidth = 1234;\n" + + " alert(window.innerWidth);\n" + + "}\n" + + "</script>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"true", "1234"}) + public void setInnerHeight() throws Exception { + final String html + = "<html><body onload='test()'><script>\n" + + "function test() {\n" + + " alert(window.innerHeight > 0);\n" + + " window.innerHeight = 1234;\n" + + " alert(window.innerHeight);\n" + + "}\n" + + "</script>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"true", "1234"}) + public void setOuterWidth() throws Exception { + final String html + = "<html><body onload='test()'><script>\n" + + "function test() {\n" + + " alert(window.outerWidth > 0);\n" + + " window.outerWidth = 1234;\n" + + " alert(window.outerWidth);\n" + + "}\n" + + "</script>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"true", "1234"}) + public void setOuterHeight() throws Exception { + final String html + = "<html><body onload='test()'><script>\n" + + "function test() {\n" + + " alert(window.outerHeight > 0);\n" + + " window.outerHeight = 1234;\n" + + " alert(window.outerHeight);\n" + + "}\n" + + "</script>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } + + /** * Regression test for bug 2944261. * @throws Exception if the test fails */ |