From: <asa...@us...> - 2012-11-26 08:22:55
|
Revision: 7773 http://sourceforge.net/p/htmlunit/code/7773 Author: asashour Date: 2012-11-26 08:22:49 +0000 (Mon, 26 Nov 2012) Log Message: ----------- JavaScript: XML: element.removeAttribute() is case-sensitive, thanks to jQuery. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/ElementTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-11-26 06:52:33 UTC (rev 7772) +++ trunk/htmlunit/src/changes/changes.xml 2012-11-26 08:22:49 UTC (rev 7773) @@ -8,6 +8,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> + <action type="fix" dev="asashour"> + JavaScript: XML: element.removeAttribute() is case-sensitive. + </action> <action type="fix" dev="asashour" issue="1464"> Correctly handle local file URL if it is in a separate driver (Windows). </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomElement.java 2012-11-26 06:52:33 UTC (rev 7772) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomElement.java 2012-11-26 08:22:49 UTC (rev 7773) @@ -226,8 +226,11 @@ * Removes an attribute specified by name from this element. * @param attributeName the attribute attributeName */ - public void removeAttribute(final String attributeName) { - attributes_.remove(attributeName.toLowerCase()); + public void removeAttribute(String attributeName) { + if (this instanceof HtmlElement) { + attributeName = attributeName.toLowerCase(); + } + attributes_.remove(attributeName); } /** 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 2012-11-26 06:52:33 UTC (rev 7772) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/ElementTest.java 2012-11-26 08:22:49 UTC (rev 7773) @@ -1076,4 +1076,45 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "ab", "ab" }) + public void removeAttribute_case_sensitive() 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" + + " request.open('GET', 'foo.xml', false);\n" + + " request.send('');\n" + + " var doc = request.responseXML;\n" + + " var e = doc.getElementsByTagName('title')[0];\n" + + " alert(e.getAttribute('normal'));\n" + + " e.removeAttribute('Normal');\n" + + " alert(e.getAttribute('normal'));\n" + + " }\n" + + " </script>\n" + + " </head>\n" + + " <body onload='test()'>\n" + + " </body>\n" + + "</html>"; + + final String xml + = "<books>\n" + + " <book>\n" + + " <title normal=\"ab\">Immortality</title>\n" + + " <author>John Smith</author>\n" + + " </book>\n" + + "</books>"; + + getMockWebConnection().setDefaultResponse(xml, "text/xml"); + loadPageWithAlerts2(html); + } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-26 06:52:33 UTC (rev 7772) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-26 08:22:49 UTC (rev 7773) @@ -1411,7 +1411,7 @@ * @throws Exception if an error occurs */ @Test - @Alerts(FF3_6 = "queue: .promise(obj) (0, 2, 2)", FF10 = "queue: delay() can be stopped (2, 3, 5)", + @Alerts(FF3_6 = "queue: .promise(obj) (0, 2, 2)", FF10 = "queue: delay() can be stopped (0, 3, 3)", CHROME = "queue: delay() can be stopped (0, 3, 3)", IE = "queue: .promise(obj) (0, 2, 2)") public void test_135() throws Exception { runTest(135); @@ -1572,7 +1572,6 @@ FF10 = "attributes: removeAttr(Multi String, variable space width) (0, 8, 8)", CHROME = "attributes: removeAttr(Multi String, variable space width) (0, 8, 8)", IE = "attributes: removeAttr(String) in XML (0, 7, 7)") - @NotYetImplemented public void test_149() throws Exception { runTest(149); } |