From: <rb...@us...> - 2013-07-26 19:25:30
|
Revision: 8424 http://sourceforge.net/p/htmlunit/code/8424 Author: rbri Date: 2013-07-26 19:25:24 +0000 (Fri, 26 Jul 2013) Log Message: ----------- node.baseName not supported for XML nodes (IE) Issue 1525 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Attr.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLAttr.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/AttrTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-07-26 16:42:06 UTC (rev 8423) +++ trunk/htmlunit/src/changes/changes.xml 2013-07-26 19:25:24 UTC (rev 8424) @@ -8,6 +8,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> + <action type="fix" dev="rbri" issue="1525"> + node.baseName not supported for XML nodes (IE). + </action> <action type="fix" dev="rbri" issue="1523" due-to="Chuck Dumont"> node.text is unsupported for text nodes in xml documents. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Attr.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Attr.java 2013-07-26 16:42:06 UTC (rev 8423) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Attr.java 2013-07-26 19:25:24 UTC (rev 8424) @@ -19,6 +19,7 @@ import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE; import net.sourceforge.htmlunit.corejs.javascript.Scriptable; import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject; +import net.sourceforge.htmlunit.corejs.javascript.Undefined; import com.gargoylesoftware.htmlunit.html.DomAttr; import com.gargoylesoftware.htmlunit.html.DomElement; @@ -178,4 +179,12 @@ public DomAttr getDomNodeOrDie() throws IllegalStateException { return super.getDomNodeOrDie(); } + + /** + * {@inheritDoc} + */ + @Override + public Object getBaseName() { + return Undefined.instance; + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLAttr.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLAttr.java 2013-07-26 16:42:06 UTC (rev 8423) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLAttr.java 2013-07-26 19:25:24 UTC (rev 8424) @@ -58,6 +58,15 @@ } /** + * Returns the base name of this element. + * @return the base name of this element + */ + @JsxGetter(@WebBrowser(IE)) + public Object getBaseName() { + return getDomNodeOrDie().getLocalName(); + } + + /** * {@inheritDoc} */ @Override Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/AttrTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/AttrTest.java 2013-07-26 16:42:06 UTC (rev 8423) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/AttrTest.java 2013-07-26 19:25:24 UTC (rev 8424) @@ -278,4 +278,102 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(IE = {"[object], undefined" }, + DEFAULT = {"[object Attr], undefined" }) + public void html_baseName() throws Exception { + html("baseName"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(IE = {"[object], undefined" }, + DEFAULT = {"[object Attr], undefined" }) + public void html_baseURI() throws Exception { + html("baseURI"); + } + + private void html(final String methodName) throws Exception { + final String html + = "<html>\n" + + "<script>\n" + + " function test() {\n" + + " debug(document.getElementById('tester').attributes.item(0));\n" + + " }\n" + + " function debug(e) {\n" + + " alert(e);\n" + + " alert(e." + methodName + ");\n" + + " }\n" + + "</script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + "<div id='tester' testAttr='test'></div>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(IE = {"[object]", "testAttr" }, + DEFAULT = {"[object Attr]", "undefined" }) + public void xml_baseName() throws Exception { + xml("baseName"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(IE = {"[object]", "testAttr" }, + DEFAULT = {"[object Attr]", "undefined" }) + public void xml_baseURI() throws Exception { + xml("baseURI"); + } + + private void xml(final String methodName) throws Exception { + final String html = + "<html>\n" + + " <head>\n" + + " <script>\n" + + " function test() {\n" + + " var request;\n" + + " if (window.XMLHttpRequest) {\n" + + " request = new XMLHttpRequest();\n" + + " } else if (window.ActiveXObject) {\n" + + " request = new ActiveXObject('Microsoft.XMLHTTP');\n" + + " }\n" + + " request.open('GET', 'foo.xml', false);\n" + + " request.send('');\n" + + " var doc = request.responseXML;\n" + + " debug(doc.documentElement.childNodes[0].attributes.item(0));\n" + + " }\n" + + " function debug(e) {\n" + + " try {\n" + + " alert(e);\n" + + " } catch(ex) {alert(ex)};\n" + + " alert(e." + methodName + ");\n" + + " }\n" + + " </script>\n" + + " </head>\n" + + " <body onload='test()'>\n" + + " </body>\n" + + "</html>"; + + final String xml = + "<xml>" + + "<div testAttr='test'></div>" + + "</xml>"; + + getMockWebConnection().setDefaultResponse(xml, "text/xml"); + loadPageWithAlerts2(html); + } } |