mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Add tests for get/set/removeAttributeNode()
Fixes https://github.com/w3c/web-platform-tests/issues/2262
This commit is contained in:
parent
f078f8fdf4
commit
c11b756973
2 changed files with 79 additions and 0 deletions
14
tests/wpt/metadata/dom/nodes/attributes.html.ini
Normal file
14
tests/wpt/metadata/dom/nodes/attributes.html.ini
Normal file
|
@ -0,0 +1,14 @@
|
|||
[attributes.html]
|
||||
type: testharness
|
||||
[Basic functionality of setAttributeNode]
|
||||
expected: FAIL
|
||||
|
||||
[Basic functionality of removeAttributeNode]
|
||||
expected: FAIL
|
||||
|
||||
[setAttributeNode on bound attribute should throw InUseAttributeError]
|
||||
expected: FAIL
|
||||
|
||||
[Basic functionality of setAttributeNodeNS]
|
||||
expected: FAIL
|
||||
|
|
@ -394,4 +394,69 @@ test(function() {
|
|||
el.removeAttribute("foo")
|
||||
assert_equals(attr.ownerElement, null)
|
||||
}, "Attribute loses its owner when removed")
|
||||
|
||||
test(function() {
|
||||
var el = document.createElement("div")
|
||||
el.setAttribute("foo", "bar")
|
||||
var attr = el.attributes[0]
|
||||
var attrNode = el.getAttributeNode("foo");
|
||||
var attrNodeNS = el.getAttributeNodeNS("", "foo");
|
||||
assert_equals(attr, attrNode);
|
||||
assert_equals(attr, attrNodeNS);
|
||||
el.setAttributeNS("x", "foo2", "bar2");
|
||||
var attr2 = el.attributes[1];
|
||||
var attrNodeNS2 = el.getAttributeNodeNS("x", "foo2");
|
||||
assert_equals(attr2, attrNodeNS2);
|
||||
}, "Basic functionality of getAttributeNode/getAttributeNodeNS")
|
||||
|
||||
test(function() {
|
||||
var el = document.createElement("div")
|
||||
el.setAttribute("foo", "bar")
|
||||
var attrNode = el.getAttributeNode("foo");
|
||||
var attrNodeNS = el.getAttributeNodeNS("", "foo");
|
||||
assert_equals(attrNode, attrNodeNS);
|
||||
el.removeAttribute("foo");
|
||||
var el2 = document.createElement("div");
|
||||
el2.setAttributeNode(attrNode);
|
||||
assert_equals(attrNode, el2.getAttributeNode("foo"));
|
||||
assert_equals(attrNode, el2.attributes[0]);
|
||||
assert_equals(attrNode.ownerElement, el2);
|
||||
assert_equals(attrNode.value, "bar");
|
||||
|
||||
var el3 = document.createElement("div");
|
||||
el2.removeAttribute("foo");
|
||||
el3.setAttribute("foo", "baz");
|
||||
el3.setAttributeNode(attrNode);
|
||||
assert_equals(el3.getAttribute("foo"), "bar");
|
||||
}, "Basic functionality of setAttributeNode")
|
||||
|
||||
test(function() {
|
||||
var el = document.createElement("div")
|
||||
el.setAttributeNS("x", "foo", "bar")
|
||||
var attrNode = el.getAttributeNodeNS("x", "foo");
|
||||
el.removeAttribute("foo");
|
||||
var el2 = document.createElement("div");
|
||||
el2.setAttributeNS("x", "foo", "baz");
|
||||
el2.setAttributeNodeNS(attrNode);
|
||||
assert_equals(el2.getAttributeNS("x", "foo"), "bar");
|
||||
}, "Basic functionality of setAttributeNodeNS")
|
||||
|
||||
test(function() {
|
||||
var el = document.createElement("div")
|
||||
el.setAttribute("foo", "bar")
|
||||
var attrNode = el.getAttributeNode("foo");
|
||||
el.removeAttributeNode(attrNode);
|
||||
var el2 = document.createElement("div");
|
||||
el2.setAttributeNode(attrNode);
|
||||
assert_equals(el2.attributes[0], attrNode);
|
||||
assert_equals(el.attributes.length, 0);
|
||||
}, "Basic functionality of removeAttributeNode")
|
||||
|
||||
test(function() {
|
||||
var el = document.createElement("div")
|
||||
el.setAttribute("foo", "bar")
|
||||
var attrNode = el.getAttributeNode("foo");
|
||||
var el2 = document.createElement("div");
|
||||
assert_throws("INUSE_ATTRIBUTE_ERR", function(){el2.setAttributeNode(attrNode)});
|
||||
}, "setAttributeNode on bound attribute should throw InUseAttributeError")
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue