From: <asa...@us...> - 2013-01-10 04:09:54
|
Revision: 7982 http://sourceforge.net/p/htmlunit/code/7982 Author: asashour Date: 2013-01-10 04:09:49 +0000 (Thu, 10 Jan 2013) Log Message: ----------- Adding test case for "% class cast exception fix" Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java 2013-01-09 20:12:17 UTC (rev 7981) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java 2013-01-10 04:09:49 UTC (rev 7982) @@ -195,7 +195,7 @@ * @return all the descendant elements with the specified tag name */ @JsxFunction - public Object getElementsByTagName(final String tagName) { + public HTMLCollection getElementsByTagName(final String tagName) { final String tagNameLC = tagName.toLowerCase(); if (elementsByTagName_ == null) { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java 2013-01-09 20:12:17 UTC (rev 7981) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java 2013-01-10 04:09:49 UTC (rev 7982) @@ -2511,8 +2511,8 @@ */ @Test @Alerts(IE = {"", "#0000aa", "#000000", "#ffebcd", "#ab00e0", "#b00e00" }, -// IE9 = {"", "#0000aa", "#0", "blanchedalmond", "#ab00e", "#b00e0" }, - FF = {"", "#0000aa", "x", "BlanchedAlmond", "aBlue", "bluex" }, + IE9 = {"", "#0000aa", "#0", "blanchedalmond", "#ab00e", "#b00e0" }, + DEFAULT = {"", "#0000aa", "x", "BlanchedAlmond", "aBlue", "bluex" }, FF3_6 = {"", "#0000aa", "#000000", "#ffebcd", "#ab00e0", "#b00e00" }) public void setColorAttribute() throws Exception { final String html = @@ -2635,7 +2635,7 @@ * @throws Exception on test failure */ @Test - @Alerts(IE = "", FF = "t") + @Alerts(IE = "", DEFAULT = "t") public void setAttribute_class() throws Exception { final String html = "<html><head>\n" + "<script>\n" @@ -2695,7 +2695,7 @@ * @throws Exception on test failure */ @Test - @Alerts(FF = { "null", "", "null", "undefined" }, IE = { "", "", "null", "undefined" }) + @Alerts(DEFAULT = { "null", "", "null", "undefined" }, IE = { "", "", "null", "undefined" }) public void getAttribute2() throws Exception { final String html = "<html>\n" + "<head>\n" @@ -3761,4 +3761,38 @@ loadPageWithAlerts2(html); } + /** + * @throws Exception if the test fails + */ + @Test + @Alerts("null") + public void getAttribute_in_xml() throws Exception { + final String html = "<html><head><title>foo</title><script>\n" + + " function test() {\n" + + " var text='<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\\n';\n" + + " text += '<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://myNS\">\\n';\n" + + " text += ' <xsl:template match=\"/\">\\n';\n" + + " text += \" <html xmlns='http://www.w3.org/1999/xhtml'>\\n\";\n" + + " text += ' <body>\\n';\n" + + " text += ' </body>\\n';\n" + + " text += ' </html>\\n';\n" + + " text += ' </xsl:template>\\n';\n" + + " text += '</xsl:stylesheet>';\n" + + " if (window.ActiveXObject) {\n" + + " var doc=new ActiveXObject('Microsoft.XMLDOM');\n" + + " doc.async=false;\n" + + " doc.loadXML(text);\n" + + " } else {\n" + + " var parser=new DOMParser();\n" + + " var doc=parser.parseFromString(text,'text/xml');\n" + + " }\n" + + " try {\n" + + " alert(doc.documentElement.getElementsByTagName('html').item(0).getAttribute('hi'));\n" + + " } catch (e) { alert('exception'); }\n" + + " }\n" + + "</script></head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } } |