Chromium Code Reviews| 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..ad0be530a2ee3442297e23a7686ba4dcc825d08a |
| --- /dev/null |
| +++ b/LayoutTests/fast/dom/ChildNode/before.html |
| @@ -0,0 +1,100 @@ |
| +<!DOCTYPE html> |
| +<script src="../../../resources/testharness.js"></script> |
| +<script src="../../../resources/testharnessreport.js"></script> |
| +<script> |
| + |
| +function test_before(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 = document.createElement('div'); |
| + parent.appendChild(child); |
| + child.before(); |
| + assert_equals(parent.innerHTML, innerHTML); |
| + }, nodeName + '.before() without any argument.'); |
| + |
| + test(function() { |
| + var parent = document.createElement('div'); |
| + parent.appendChild(child); |
| + child.before(null); |
| + var expected = 'null' + innerHTML; |
| + assert_equals(parent.innerHTML, expected); |
| + }, nodeName + '.before() with null as an argument.'); |
|
philipj_slow
2015/07/03 21:52:05
The comments for after.html mostly apply here as w
Paritosh Kumar
2015/07/06 09:02:27
Done.
|
| + |
| + test(function() { |
| + var parent = document.createElement('div'); |
| + parent.appendChild(child); |
| + child.before('text'); |
| + var expected = 'text' + innerHTML; |
| + assert_equals(parent.innerHTML, expected); |
| + }, nodeName + '.before() with only text as an argument.'); |
| + |
| + test(function() { |
| + var parent = document.createElement('div'); |
| + var x = document.createElement('x'); |
| + parent.appendChild(child); |
| + child.before(x); |
| + var expected = '<x></x>' + innerHTML; |
| + assert_equals(parent.innerHTML, expected); |
| + }, nodeName + '.before() with only one element as an argument.'); |
| + |
| + test(function() { |
| + var parent = document.createElement('div'); |
| + var x = document.createElement('x'); |
| + parent.appendChild(child); |
| + child.before(x, 'text'); |
| + var expected = '<x></x>text' + innerHTML; |
| + assert_equals(parent.innerHTML, expected); |
| + }, nodeName + '.before() with one element and text as arguments.'); |
| + |
| + test(function() { |
| + var parent = document.createElement('div'); |
| + var x = document.createElement('x'); |
| + var y = document.createElement('y'); |
| + var z = document.createElement('z'); |
| + parent.appendChild(y); |
| + parent.appendChild(child); |
| + parent.appendChild(x); |
| + child.before(x, y, z); |
| + var expected = '<x></x><y></y><z></z>' + innerHTML; |
| + assert_equals(parent.innerHTML, expected); |
| + }, nodeName + '.before() with all sibling of child as arguments.'); |
| + |
| + test(function() { |
| + var parent = document.createElement('div'); |
| + var x = document.createElement('x'); |
| + parent.appendChild(x); |
| + parent.appendChild(document.createTextNode('text')); |
| + var y = document.createElement('y'); |
| + parent.appendChild(y); |
| + parent.appendChild(child); |
| + child.before(x, 'text'); |
| + var expected = 'text<y></y><x></x>text' + innerHTML; |
| + assert_equals(parent.innerHTML, expected); |
| + }, nodeName + '.before() with one sibling of child and text as arguments.'); |
| + |
| + test(function() { |
| + var x = document.createElement('x'); |
| + var y = document.createElement('y'); |
| + x.before(y); |
| + assert_equals(x.previousSibling, null); |
| + }, nodeName + '.before() on a child without any parent.'); |
| +} |
| + |
| +test_before('Comment'); |
| +test_before('Element'); |
| +test_before('Text'); |
| + |
| +</script> |
| +</html> |