Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: LayoutTests/fast/dom/script-tests/childnode-replace-with.js

Issue 1085843002: Implement DOM: prepend, append, before, after & replaceWith (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
+}

Powered by Google App Engine
This is Rietveld 408576698