Index: LayoutTests/fast/dom/ChildNode/before.html |
diff --git a/LayoutTests/fast/dom/ChildNode/before.html b/LayoutTests/fast/dom/ChildNode/before.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..86bd8348a139cd571ecdacdbc378a6ead91db8bd |
--- /dev/null |
+++ b/LayoutTests/fast/dom/ChildNode/before.html |
@@ -0,0 +1,68 @@ |
+<!DOCTYPE html> |
+<script src="../../../resources/testharness.js"></script> |
+<script src="../../../resources/testharnessreport.js"></script> |
+<script> |
+ |
+function test_before(node, nodeName) { |
+ var child; |
+ var innerHtml; |
+ if (nodeName == 'Comment') { |
+ child = document.createComment('test'); |
+ innerHtml = '<!--test-->'; |
+ } else if (nodeName == 'Element') { |
+ child = document.createElement('test'); |
+ innerHtml = '<test></test>'; |
+ } else { |
+ child = document.createTextNode('test'); |
+ innerHtml = 'test'; |
+ } |
+ |
+ test(function() { |
+ var parent = node.cloneNode(); |
+ parent.appendChild(child); |
+ child.before(); |
+ expected = innerHtml; |
+ assert_equals(parent.innerHTML, expected); |
+ }, nodeName + '.before() with empty argument.'); |
+ |
+ test(function() { |
+ var parent = node.cloneNode(); |
+ parent.appendChild(child); |
+ child.before(null); |
+ expected = 'null' + innerHtml; |
+ assert_equals(parent.innerHTML, expected); |
+ }, nodeName + '.before() with null as an argument.'); |
+ |
+ test(function() { |
+ var parent = node.cloneNode(); |
+ parent.appendChild(child); |
+ child.before('text'); |
+ expected = 'text' + innerHtml; |
+ assert_equals(parent.innerHTML, expected); |
+ }, nodeName + '.before() with only text as an argument.'); |
+ |
+ test(function() { |
+ var parent = node.cloneNode(); |
+ var x = document.createElement('x'); |
+ parent.appendChild(child); |
+ child.before(x); |
+ expected = '<x></x>' + innerHtml; |
+ assert_equals(parent.innerHTML, expected); |
+ }, nodeName + '.before() with only one element as an argument.'); |
+ |
+ test(function() { |
+ var parent = node.cloneNode(); |
+ var x = document.createElement('x'); |
+ parent.appendChild(child); |
+ child.before(x, 'text'); |
+ expected = '<x></x>text' + innerHtml; |
+ assert_equals(parent.innerHTML, expected); |
+ }, nodeName + '.before() with only one element and text as argument.'); |
+} |
+ |
+test_before(document.createElement('div'), 'Comment'); |
+test_before(document.createElement('div'), 'Element'); |
+test_before(document.createElement('div'), 'Text'); |
+ |
+</script> |
+</html> |