From: <rb...@us...> - 2013-07-24 19:05:29
|
Revision: 8420 http://sourceforge.net/p/htmlunit/code/8420 Author: rbri Date: 2013-07-24 19:05:25 +0000 (Wed, 24 Jul 2013) Log Message: ----------- base name support (wip) Issue 1525 Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Node.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/ElementTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Node.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Node.java 2013-07-21 21:23:24 UTC (rev 8419) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Node.java 2013-07-24 19:05:25 UTC (rev 8420) @@ -929,6 +929,20 @@ } /** + * Returns the base name of this element. + * @return the base name of this element + */ + @JsxGetter(@WebBrowser(IE)) + public Object getBaseName() { + final DomElement domElem = getDomNodeOrDie(); + final boolean isXmlPage = domElem.getOwnerDocument() instanceof XmlPage; + if (isXmlPage) { + return domElem.getLocalName(); + } + return Undefined.instance; + } + + /** * {@inheritDoc} */ @Override Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/ElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/ElementTest.java 2013-07-21 21:23:24 UTC (rev 8419) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/ElementTest.java 2013-07-24 19:05:25 UTC (rev 8420) @@ -465,6 +465,26 @@ "[object],undefined", "[object],undefined" }, + DEFAULT = {"[object HTMLDivElement],undefined", + "[object HTMLUnknownElement],undefined", + "[object Element],undefined", + "[object HTMLDivElement],undefined", + "[object HTMLUnknownElement],undefined" + }) + public void html_baseName() throws Exception { + html("baseName"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(IE = {"[object],undefined", + "[object],undefined", + "createElementNS() is not defined", + "[object],undefined", + "[object],undefined" + }, DEFAULT = {"[object HTMLDivElement],http://www.w3.org/1999/xhtml", "[object HTMLUnknownElement],http://www.w3.org/1999/xhtml", "[object Element],http://www.appcelerator.org", @@ -729,6 +749,24 @@ * @throws Exception if the test fails */ @Test + @Alerts(IE = {"[object]", "dIv", + "[object]", "html", + "[object]", "div", + "[object]", "dIv" + }, + DEFAULT = {"[object Element]", "undefined", + "[object HTMLHtmlElement]", "undefined", + "[object HTMLDivElement]", "undefined", + "[object HTMLUnknownElement]", "undefined" + }) + public void xml_baseName() throws Exception { + xml("baseName"); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts(IE = {"[object]", "", "[object]", "http://www.w3.org/1999/xhtml", "[object]", "http://www.w3.org/1999/xhtml", @@ -763,7 +801,9 @@ + " debug(doc.documentElement.childNodes[1].childNodes[1]);\n" + " }\n" + " function debug(e) {\n" - + " alert(e);\n" + + " try {\n" + + " alert(e);\n" + + " } catch(ex) {alert(ex)};\n" + " alert(e." + methodName + ");\n" + " }\n" + " </script>\n" |