Index: LayoutTests/fast/dom/script-tests/childnode-replace-with.js |
diff --git a/LayoutTests/fast/dom/script-tests/childnode-replace-with.js b/LayoutTests/fast/dom/script-tests/childnode-replace-with.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9c227b2f4c32eb20703f37349f49ad6f9517dcc8 |
--- /dev/null |
+++ b/LayoutTests/fast/dom/script-tests/childnode-replace-with.js |
@@ -0,0 +1,24 @@ |
+function testReplaceWith(node, parent, type) { |
+test(function() { |
+assert_true("replaceWith" in node); |
+assert_equals(typeof node.replaceWith, "function"); |
+assert_equals(node.replaceWith.length, 0); |
+}, type + " should support replaceWith()"); |
+test(function() { |
+var x; |
+if (type == 'element' || type == 'document-fragment') { |
+ x = document.createElement('x'); |
+} |
+if (type == 'comment') { |
+ x = document.createComment('x'); |
+} |
+if (type == 'text') { |
+ x = document.createTextNode('x'); |
+} |
+parent.appendChild(node); |
+assert_equals(node.parentNode, parent, "Appended node should have a parent"); |
+assert_array_equals(parentNode.childNodes, [node], "ParentNode should have 1 child node"); |
+node.replaceWith(x); |
+assert_array_equals(parentNode.childNodes, [x], "ParentNode should have 1 child x"); |
+}, "replaceWith() should work for " + type); |
+} |