From: <rb...@us...> - 2013-07-27 09:15:27
|
Revision: 8426 http://sourceforge.net/p/htmlunit/code/8426 Author: rbri Date: 2013-07-27 09:15:21 +0000 (Sat, 27 Jul 2013) Log Message: ----------- attr.baseURI not supported for FF; more test cases added Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Attr.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-27 06:28:42 UTC (rev 8425) +++ trunk/htmlunit/src/changes/changes.xml 2013-07-27 09:15:21 UTC (rev 8426) @@ -8,6 +8,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> + <action type="fix" dev="rbri"> + attr.baseURI not supported for FF. + </action> <action type="fix" dev="rbri" issue="1525"> node.baseName not supported for XML nodes (IE). </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-27 06:28:42 UTC (rev 8425) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Attr.java 2013-07-27 09:15:21 UTC (rev 8426) @@ -15,6 +15,7 @@ package com.gargoylesoftware.htmlunit.javascript.host; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ATTR_FIRST_LAST_CHILD_RETURNS_NULL; +import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.CHROME; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE; import net.sourceforge.htmlunit.corejs.javascript.Scriptable; @@ -187,4 +188,13 @@ public Object getBaseName() { return Undefined.instance; } + + /** + * Returns the Base URI as a string. + * @return the Base URI as a string + */ + @JsxGetter({ @WebBrowser(FF), @WebBrowser(CHROME) }) + public String getBaseURI() { + return getDomNodeOrDie().getPage().getUrl().toExternalForm(); + } } 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-27 06:28:42 UTC (rev 8425) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/AttrTest.java 2013-07-27 09:15:21 UTC (rev 8426) @@ -283,8 +283,8 @@ * @throws Exception if the test fails */ @Test - @Alerts(IE = {"[object], undefined" }, - DEFAULT = {"[object Attr], undefined" }) + @Alerts(IE = {"[object]", "undefined" }, + DEFAULT = {"[object Attr]", "undefined" }) public void html_baseName() throws Exception { html("baseName"); } @@ -293,8 +293,8 @@ * @throws Exception if the test fails */ @Test - @Alerts(IE = {"[object], undefined" }, - DEFAULT = {"[object Attr], undefined" }) + @Alerts(IE = {"[object]", "undefined" }, + DEFAULT = {"[object Attr]", "http://localhost:12345/" }) public void html_baseURI() throws Exception { html("baseURI"); } @@ -303,18 +303,38 @@ * @throws Exception if the test fails */ @Test - @Alerts(IE = {"[object], undefined" }, - DEFAULT = {"[object Attr], null" }) + @Alerts(IE = {"[object]", "undefined" }, + DEFAULT = {"[object Attr]", "null" }) public void html_namespaceURI() throws Exception { html("namespaceURI"); } + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(IE = {"[object]", "undefined" }, + DEFAULT = {"[object Attr]", "testattr" }) + public void html_localName() throws Exception { + html("localName"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(IE = {"[object]", "undefined" }, + DEFAULT = {"[object Attr]", "null" }) + public void html_prefix() throws Exception { + html("prefix"); + } + 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" + + " debug(document.getElementById('tester').attributes.getNamedItem('testAttr'));\n" + " }\n" + " function debug(e) {\n" + " alert(e);\n" @@ -344,7 +364,7 @@ */ @Test @Alerts(IE = {"[object]", "undefined" }, - DEFAULT = {"[object Attr]", "undefined" }) + DEFAULT = {"[object Attr]", "http://localhost:12345/foo.xml" }) public void xml_baseURI() throws Exception { xml("baseURI"); } @@ -359,6 +379,26 @@ xml("namespaceURI"); } + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(IE = {"[object]", "undefined" }, + DEFAULT = {"[object Attr]", "testAttr" }) + public void xml_localName() throws Exception { + xml("localName"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(IE = {"[object]", "" }, + DEFAULT = {"[object Attr]", "null" }) + public void xml_prefix() throws Exception { + xml("prefix"); + } + private void xml(final String methodName) throws Exception { final String html = "<html>\n" |