Chromium Code Reviews| Index: LayoutTests/fast/dom/ChildNode/after.html |
| diff --git a/LayoutTests/fast/dom/ChildNode/after.html b/LayoutTests/fast/dom/ChildNode/after.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..298bfd5e61ff986bce6ef627033a893a22d70f73 |
| --- /dev/null |
| +++ b/LayoutTests/fast/dom/ChildNode/after.html |
| @@ -0,0 +1,100 @@ |
| +<!DOCTYPE html> |
| +<script src="../../../resources/testharness.js"></script> |
| +<script src="../../../resources/testharnessreport.js"></script> |
| +<script> |
| + |
| +function test_after(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.after(); |
| + assert_equals(parent.innerHTML, innerHTML); |
| + }, nodeName + '.after() without any argument.'); |
| + |
| + test(function() { |
| + var parent = document.createElement('div'); |
| + parent.appendChild(child); |
| + child.after(null); |
| + var expected = innerHTML + 'null'; |
| + assert_equals(parent.innerHTML, expected); |
| + }, nodeName + '.after() with null as an argument.'); |
|
philipj_slow
2015/07/03 21:52:05
after() with the empty string as an argument would
Paritosh Kumar
2015/07/06 09:02:26
Done.
|
| + |
| + test(function() { |
| + var parent = document.createElement('div'); |
| + parent.appendChild(child); |
| + child.after('text'); |
| + var expected = innerHTML + 'text'; |
| + assert_equals(parent.innerHTML, expected); |
| + }, nodeName + '.after() with only text as an argument.'); |
| + |
| + test(function() { |
| + var parent = document.createElement('div'); |
| + var x = document.createElement('x'); |
| + parent.appendChild(child); |
| + child.after(x); |
| + var expected = innerHTML + '<x></x>'; |
| + assert_equals(parent.innerHTML, expected); |
| + }, nodeName + '.after() with only one element as an argument.'); |
| + |
| + test(function() { |
| + var parent = document.createElement('div'); |
| + var x = document.createElement('x'); |
| + parent.appendChild(child); |
| + child.after(x, 'text'); |
| + var expected = innerHTML + '<x></x>text'; |
| + assert_equals(parent.innerHTML, expected); |
| + }, nodeName + '.after() 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.after(x, y, z); |
| + var expected = innerHTML + '<x></x><y></y><z></z>'; |
| + assert_equals(parent.innerHTML, expected); |
| + }, nodeName + '.after() containing sibling of child as arguments.'); |
|
philipj_slow
2015/07/03 21:52:05
In before.html the equivalent test is called '.bef
Paritosh Kumar
2015/07/06 09:02:27
Done.
philipj_slow
2015/07/06 12:02:40
Oh, it should be a plural "siblings" here and in t
|
| + |
| + test(function() { |
| + var parent = document.createElement('div'); |
| + var x = document.createElement('x'); |
| + var y = document.createElement('y'); |
| + parent.appendChild(child); |
| + parent.appendChild(x); |
| + parent.appendChild(document.createTextNode('text')); |
| + parent.appendChild(y); |
| + child.after(x, 'text'); |
| + var expected = innerHTML + '<x></x>texttext<y></y>'; |
| + assert_equals(parent.innerHTML, expected); |
| + }, nodeName + '.after() with one sibling of child and text as arguments.'); |
|
philipj_slow
2015/07/03 21:52:05
A test that includes the context object itself as
Paritosh Kumar
2015/07/06 09:02:27
Done.
|
| + |
| + test(function() { |
| + var x = document.createElement('x'); |
| + var y = document.createElement('y'); |
| + x.after(y); |
| + assert_equals(x.nextSibling, null); |
| + }, nodeName + '.after() on a child without any parent.'); |
| +} |
| + |
| +test_after('Comment'); |
| +test_after('Element'); |
| +test_after('Text'); |
| + |
| +</script> |
| +</html> |