From: <asa...@us...> - 2013-09-20 23:48:44
|
Revision: 8500 http://sourceforge.net/p/htmlunit/code/8500 Author: asashour Date: 2013-09-20 23:48:39 +0000 (Fri, 20 Sep 2013) Log Message: ----------- JavaScript: HTMLStyleElement.type is writable Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/CookieManager.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlStyle.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLStyleElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLStyleElementTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-09-18 20:45:37 UTC (rev 8499) +++ trunk/htmlunit/src/changes/changes.xml 2013-09-20 23:48:39 UTC (rev 8500) @@ -8,6 +8,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> + <action type="fix" dev="asashour"> + JavaScript: HTMLStyleElement.type is writable. + </action> <action type="fix" dev="rbri"> JavaScript: Missing setter for element.outerHTML in FF17 fixed. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/CookieManager.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/CookieManager.java 2013-09-18 20:45:37 UTC (rev 8499) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/CookieManager.java 2013-09-20 23:48:39 UTC (rev 8500) @@ -27,7 +27,7 @@ import org.apache.commons.collections.set.ListOrderedSet; import org.apache.commons.lang3.StringUtils; -import org.apache.http.client.params.CookiePolicy; +import org.apache.http.client.config.CookieSpecs; import org.apache.http.cookie.CookieOrigin; import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.CookieSpecRegistry; @@ -48,9 +48,9 @@ /** * HtmlUnit's cookie policy is to be browser-compatible. Code which requires access to * HtmlUnit's cookie policy should use this constant, rather than making assumptions and using - * one of the HttpClient {@link CookiePolicy} constants directly. + * one of the HttpClient {@link CookieSpecs} constants directly. */ - public static final String HTMLUNIT_COOKIE_POLICY = CookiePolicy.BROWSER_COMPATIBILITY; + public static final String HTMLUNIT_COOKIE_POLICY = CookieSpecs.BROWSER_COMPATIBILITY; /** Whether or not cookies are enabled. */ private boolean cookiesEnabled_; Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlStyle.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlStyle.java 2013-09-18 20:45:37 UTC (rev 8499) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlStyle.java 2013-09-20 23:48:39 UTC (rev 8500) @@ -57,6 +57,15 @@ } /** + * Sets the value of the attribute "type". + * + * @param type the new type + */ + public final void setTypeAttribute(final String type) { + setAttribute("type", type); + } + + /** * Returns the value of the attribute "media". Refer to the * <a href='http://www.w3.org/TR/html401/'>HTML 4.01</a> * documentation for details on the use of this attribute. Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLStyleElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLStyleElement.java 2013-09-18 20:45:37 UTC (rev 8499) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLStyleElement.java 2013-09-20 23:48:39 UTC (rev 8500) @@ -25,6 +25,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlStyle; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter; import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser; import com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleSheet; @@ -91,6 +92,16 @@ } /** + * Sets the type of this style. + * @param type the new type + */ + @JsxSetter() + public void setType(final String type) { + final HtmlStyle style = (HtmlStyle) getDomNodeOrDie(); + style.setTypeAttribute(type); + } + + /** * Returns the media of this style. * @return the media */ Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLStyleElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLStyleElementTest.java 2013-09-18 20:45:37 UTC (rev 8499) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLStyleElementTest.java 2013-09-20 23:48:39 UTC (rev 8500) @@ -166,4 +166,28 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "", "text/css" }) + public void type_setter() throws Exception { + final String html + = "<html><head><title>foo</title>\n" + + "<style id='style_none'></style>\n" + + + "<script>\n" + + "function doTest() {\n" + + " style = document.getElementById('style_none');\n" + + " alert(style.type);\n" + + " style.type = 'text/css';\n" + + " alert(style.type);\n" + + "}\n" + + "</script>\n" + + "</head><body onload='doTest()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } } |