blob: 0fcd79670903289de3a7c805bb1396e82ab98ade [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
<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);
if (window.testRunner) {
shouldBe("test.getAttribute('style')", "test.getAttribute('STYLE')");
shouldBe("test.getAttributeNode('style').value", "test.getAttributeNode('STYLE').value");
}
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", "newattr");
newAttr1.prefix = "prefix1";
newAttr1.value = "newattr1";
test.setAttributeNode(newAttr1);
var newAttr2 = document.createAttributeNS("ns2", "newattr");
newAttr2.prefix = "prefix2";
newAttr2.value = "newattr2";
test.setAttributeNode(newAttr2);
if (window.testRunner) {
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", "NEWATTR");
newAttr3.prefix = "prefix2";
newAttr3.value = "newattr3";
test.setAttributeNode(newAttr3);
if (window.testRunner) {
shouldBe("test.getAttributeNodeNS('ns1', 'newattr').value", "'newattr3'");
isSuccessfullyParsed();
test.style.display = 'none';
}
}
</script>
</head>
<body onload="runTest()">
<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">&nbsp;</div>
<div id="description"></div>
<div id="console"></div>
</body>
</html>