| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../../resources/js-test-pre.js"></script> |
| </head> |
| <body> |
| <div>Test for Bugzilla bug:<a href="https://bugs.webkit.org/show_bug.cgi?id=90341"> 90341:</a> createAttribute/setAttributeNode does not properly normalize case.</div> |
| <div id="test" style="background-color: red"> </div> |
| <script> |
| function runTest() |
| { |
| description("This test verifies that the setAttributeNode() API checks for existing attributes case-insensitively. Thus the value of an existing attribute with the same name but in a different case should get replaced by the new value specified via the setAttributeNode() method."); |
| |
| var test = document.getElementById("test"); |
| var newStyleAttr = document.createAttribute("STYLE"); |
| newStyleAttr.value = "background-color: green"; |
| test.setAttributeNode(newStyleAttr); |
| shouldBe("test.getAttribute('style')", "test.getAttribute('STYLE')"); |
| shouldBe("test.getAttributeNode('style')", "test.getAttributeNode('STYLE')"); |
| |
| |
| debug("Verifying that attributes with the same name but different namespaces are treated as unique entities. For the following test two different attribute values should be returned."); |
| var newAttr1 = document.createAttributeNS("ns1", "prefix1:newattr"); |
| newAttr1.value = "newattr1"; |
| test.setAttributeNode(newAttr1); |
| var newAttr2 = document.createAttributeNS("ns2", "prefix2:newattr"); |
| newAttr2.value = "newattr2"; |
| test.setAttributeNode(newAttr2); |
| shouldBe("test.getAttributeNodeNS('ns1', 'newattr').value", "'newattr1'"); |
| shouldBe("test.getAttributeNodeNS('ns2', 'newattr').value", "'newattr2'"); |
| |
| debug("Verifying that attributes with same name but different case and having same namespaces are treated as same. In the following test the new attribute should overwrite the value of the existing one."); |
| var newAttr3 = document.createAttributeNS("ns1", "prefix2:NEWATTR"); |
| newAttr3.value = "newattr3"; |
| test.setAttributeNode(newAttr3); |
| |
| shouldBeEqualToString("test.getAttributeNodeNS('ns1', 'NEWATTR').value", "newattr3"); |
| shouldBeEqualToString("test.getAttributeNodeNS('ns1', 'newattr').value", "newattr1"); |
| |
| test.style.display = 'none'; |
| } |
| runTest(); |
| </script> |
| <script src="../../../resources/js-test-post.js"></script> |
| </body> |
| </html> |