ChildNode-remove.js (1665B)
1 function testRemove(node, parent, type) { 2 test(function() { 3 assert_true("remove" in node); 4 assert_equals(typeof node.remove, "function"); 5 assert_equals(node.remove.length, 0); 6 }, type + " should support remove()"); 7 test(function() { 8 assert_equals(node.parentNode, null, "Node should not have a parent"); 9 assert_equals(node.remove(), undefined); 10 assert_equals(node.parentNode, null, "Removed new node should not have a parent"); 11 }, "remove() should work if " + type + " doesn't have a parent"); 12 test(function() { 13 assert_equals(node.parentNode, null, "Node should not have a parent"); 14 parent.appendChild(node); 15 assert_equals(node.parentNode, parent, "Appended node should have a parent"); 16 assert_equals(node.remove(), undefined); 17 assert_equals(node.parentNode, null, "Removed node should not have a parent"); 18 assert_array_equals(parent.childNodes, [], "Parent should not have children"); 19 }, "remove() should work if " + type + " does have a parent"); 20 test(function() { 21 assert_equals(node.parentNode, null, "Node should not have a parent"); 22 var before = parent.appendChild(document.createComment("before")); 23 parent.appendChild(node); 24 var after = parent.appendChild(document.createComment("after")); 25 assert_equals(node.parentNode, parent, "Appended node should have a parent"); 26 assert_equals(node.remove(), undefined); 27 assert_equals(node.parentNode, null, "Removed node should not have a parent"); 28 assert_array_equals(parent.childNodes, [before, after], "Parent should have two children left"); 29 }, "remove() should work if " + type + " does have a parent and siblings"); 30 }