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); |
+} |