From: <rb...@us...> - 2013-08-25 13:55:18
|
Revision: 8449 http://sourceforge.net/p/htmlunit/code/8449 Author: rbri Date: 2013-08-25 13:55:14 +0000 (Sun, 25 Aug 2013) Log Message: ----------- support for the type property of style elements added Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml 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-08-25 13:30:02 UTC (rev 8448) +++ trunk/htmlunit/src/changes/changes.xml 2013-08-25 13:55:14 UTC (rev 8449) @@ -8,8 +8,8 @@ <body> <release version="2.13" date="???" description="Bugfixes"> - <action type="fix" dev="rbri" issue="1535"> - Use the correct separator for headers in the preflight CORS request. + <action type="add" dev="rbri"> + JavaScript: support for the type property of style elements added. </action> <action type="fix" dev="rbri" issue="1534"> WebClient.getTopLevelWindows() returns a snapshot of the list of open top level windows. 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-08-25 13:30:02 UTC (rev 8448) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLStyleElement.java 2013-08-25 13:55:14 UTC (rev 8449) @@ -78,4 +78,14 @@ public CSSStyleSheet getStyleSheet() { return getSheet(); } + + /** + * Returns the type of this style. + * @return the type + */ + @JsxGetter() + public String getType() { + final HtmlStyle style = (HtmlStyle) getDomNodeOrDie(); + return style.getTypeAttribute(); + } } 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-08-25 13:30:02 UTC (rev 8448) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLStyleElementTest.java 2013-08-25 13:55:14 UTC (rev 8449) @@ -89,9 +89,9 @@ final String html = "<html><head><title>foo</title>\n" - + "<style id='style_none'>.a > .t { }</style>\n" - + "<style type='text/test' id='style_text'>.b > .t { }</style>\n" - + "<style type='text/html' id='style_html'>.c > .t { }</style>\n" + + "<style id='style_none'>my { }</style>\n" + + "<style type='text/test' id='style_text'>my { }</style>\n" + + "<style type='text/html' id='style_html'>my { }</style>\n" + "<script>\n" + "function doTest() {\n" @@ -108,4 +108,33 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "", "text/test", "text/css" }) + public void type() throws Exception { + final String html + = "<html><head><title>foo</title>\n" + + + "<style id='style_none'>.a > .t { }</style>\n" + + "<style type='text/test' id='style_text'>.b > .t { }</style>\n" + + "<style type='text/css' id='style_css'>.c > .t { }</style>\n" + + + "<script>\n" + + "function doTest() {\n" + + " style = document.getElementById('style_none');\n" + + " alert(style.type);\n" + + " style = document.getElementById('style_text');\n" + + " alert(style.type);\n" + + " style = document.getElementById('style_css');\n" + + " alert(style.type);\n" + + "}\n" + + "</script>\n" + + "</head><body onload='doTest()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } } |