|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
SF.net SVN: htmlunit: [3140] trunk/htmlunit/srcRevision: 3140
http://htmlunit.svn.sourceforge.net/htmlunit/?rev=3140&view=rev Author: asashour Date: 2008-07-01 06:58:41 -0700 (Tue, 01 Jul 2008) Log Message: ----------- JavaScript: add support for script.text (#2005930). Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/HTMLScriptElement.java trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.xml trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/HTMLScriptElementTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2008-07-01 10:37:40 UTC (rev 3139) +++ trunk/htmlunit/src/changes/changes.xml 2008-07-01 13:58:41 UTC (rev 3140) @@ -7,6 +7,9 @@ <body> <release version="2.2-SNAPSHOT" description="Bugfixes (handling of ill formed HTML code, document.write, ...), speed improvements, and move to HtmlUnit-core-js (Rhino fork)"> + <action type="add" dev="asashour" id="2005930"> + JavaScript: add support for script.text. + </action> <action type="fix" dev="asashour" id="2006861"> Fix exception when opening about:blank with Firefox. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/HTMLScriptElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/HTMLScriptElement.java 2008-07-01 10:37:40 UTC (rev 3139) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/HTMLScriptElement.java 2008-07-01 13:58:41 UTC (rev 3140) @@ -17,6 +17,7 @@ import org.mozilla.javascript.Function; import com.gargoylesoftware.htmlunit.html.DomNode; +import com.gargoylesoftware.htmlunit.html.DomText; /** * The JavaScript object that represents an "HTMLScriptElement". @@ -54,6 +55,33 @@ } /** + * Returns the <tt>text</tt> attribute. + * @return the <tt>text</tt> attribute + */ + public String jsxGet_text() { + final DomNode firstChild = getHtmlElementOrDie().getFirstChild(); + if (firstChild != null) { + return firstChild.getNodeValue(); + } + return ""; + } + + /** + * Sets the <tt>text</tt> attribute. + * @param text the <tt>text</tt> attribute + */ + public void jsxSet_text(final String text) { + DomNode firstChild = getHtmlElementOrDie().getFirstChild(); + if (firstChild == null) { + firstChild = new DomText(getHtmlElementOrDie().getPage(), text); + getHtmlElementOrDie().appendChild(firstChild); + } + else { + firstChild.setNodeValue(text); + } + } + + /** * Returns the <tt>type</tt> attribute. * @return the <tt>type</tt> attribute */ Modified: trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.xml =================================================================== --- trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.xml 2008-07-01 10:37:40 UTC (rev 3139) +++ trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.xml 2008-07-01 13:58:41 UTC (rev 3140) @@ -1470,6 +1470,7 @@ </property> <property name="src" readable="true" writable="true"/> <property name="type" readable="true" writable="true"/> + <property name="text" readable="true" writable="true"/> </class> <class name="HTMLSelectElement" extends="FormField" classname="com.gargoylesoftware.htmlunit.javascript.host.HTMLSelectElement" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/HTMLScriptElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/HTMLScriptElementTest.java 2008-07-01 10:37:40 UTC (rev 3139) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/HTMLScriptElementTest.java 2008-07-01 13:58:41 UTC (rev 3140) @@ -213,4 +213,39 @@ assertEquals(expected, actual); } + /** + * @throws Exception if the test fails + */ + @Test + public void text() throws Exception { + text(BrowserVersion.INTERNET_EXPLORER_6_0); + text(BrowserVersion.INTERNET_EXPLORER_7_0); + text(BrowserVersion.FIREFOX_2); + } + + private void text(final BrowserVersion browserVersion) throws Exception { + final String html = + "<html>\n" + + " <head>\n" + + " <script>\n" + + " function test() {\n" + + " execMe('alert(1)');\n" + + " }\n" + + " function execMe(text) {\n" + + " document.head = document.getElementsByTagName('head')[0];\n" + + " var script = document.createElement('script');\n" + + " script.text = text;\n" + + " document.head.appendChild(script);\n" + + " document.head.removeChild(script);\n" + + " }\n" + + " </script>\n" + + " </head>\n" + + " <body onload='test()'>\n" + + " </body>\n" + + "</html>"; + final String[] expectedAlerts = {"1"}; + final List<String> collectedAlerts = new ArrayList<String>(); + loadPage(browserVersion, html, collectedAlerts); + assertEquals(expectedAlerts, collectedAlerts); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ HtmlUnit-develop mailing list HtmlUnit-develop@... https://lists.sourceforge.net/lists/listinfo/htmlunit-develop |
| Free Forum Powered by Nabble | Forum Help |