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

Unified Diff: LayoutTests/fast/dom/script-tests/parentnode-prepend.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/parentnode-prepend.js
diff --git a/LayoutTests/fast/dom/script-tests/parentnode-prepend.js b/LayoutTests/fast/dom/script-tests/parentnode-prepend.js
new file mode 100644
index 0000000000000000000000000000000000000000..64e00392ee66d8979b02e5810ca99dcf36ce7547
--- /dev/null
+++ b/LayoutTests/fast/dom/script-tests/parentnode-prepend.js
@@ -0,0 +1,29 @@
+function testPrepend(node, parent, type) {
+test(function() {
+assert_true("prepend" in parent);
+assert_equals(typeof parent.prepend, "function");
+assert_equals(parent.prepend.length, 0);
+}, type + " should support prepend()");
+test(function() {
+var x, y;
+if (type == 'element' || type == 'document-fragment' || type == 'document') {
+ x = document.createElement('x');
+ y = document.createElement('y');
+}
+if (type == 'comment') {
+ x = document.createComment('x');
+ y = document.createComment('y');
+}
+if (type == 'text') {
+ x = document.createTextNode('x');
+ y = document.createTextNode('y');
+}
+parent.appendChild(node);
+assert_equals(node.parentNode, parent, "Appended node should have a parent");
+parent.prepend(x, y, 'z');
+assert_equals(parent.childNodes.length, 4, "Parent should have 4 children");
+assert_equals(parent.firstChild, x, "Parent's first child should be x");
+assert_equals(parent.childNodes[2].data, 'z', "Parent's third child's data should be z");
+assert_equals(parent.lastChild, node, "Parent's last child should be node");
+}, "prepend() should work for " + type);
+}

Powered by Google App Engine
This is Rietveld 408576698