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

Unified Diff: LayoutTests/fast/dom/script-tests/childnode-before.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-before.js
diff --git a/LayoutTests/fast/dom/script-tests/childnode-before.js b/LayoutTests/fast/dom/script-tests/childnode-before.js
new file mode 100644
index 0000000000000000000000000000000000000000..cbd52add1f940870f0f8fc564c57a29cab60b2b0
--- /dev/null
+++ b/LayoutTests/fast/dom/script-tests/childnode-before.js
@@ -0,0 +1,29 @@
+function testBefore(node, parent, type) {
+test(function() {
+assert_true("before" in node);
+assert_equals(typeof node.before, "function");
+assert_equals(node.before.length, 0);
+}, type + " should support before()");
+test(function() {
+var x, y;
+if (type == 'element' || type == 'document-fragment') {
+ 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");
+node.before(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");
+}, "before() should work for " + type);
+}

Powered by Google App Engine
This is Rietveld 408576698