OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/testharness.js"></script> |
| 3 <script src="../../../resources/testharnessreport.js"></script> |
| 4 <script> |
| 5 |
| 6 test(function() { |
| 7 var node = document.createComment('node'); |
| 8 assert_true('replaceWith' in node); |
| 9 assert_equals(typeof node.replaceWith, 'function'); |
| 10 assert_equals(node.replaceWith.length, 0); |
| 11 }, 'Comment should support before()'); |
| 12 |
| 13 test(function() { |
| 14 var node = document.createElement('node'); |
| 15 assert_true('replaceWith' in node); |
| 16 assert_equals(typeof node.replaceWith, 'function'); |
| 17 assert_equals(node.replaceWith.length, 0); |
| 18 }, 'Element should support before()'); |
| 19 |
| 20 test(function() { |
| 21 var node = document.createTextNode('node'); |
| 22 assert_true('replaceWith' in node); |
| 23 assert_equals(typeof node.replaceWith, 'function'); |
| 24 assert_equals(node.replaceWith.length, 0); |
| 25 }, 'Text should support before()'); |
| 26 |
| 27 test(function() { |
| 28 var parent = document.createElement('div'); |
| 29 var test = document.createComment('test'); |
| 30 parent.appendChild(test); |
| 31 var x = document.createComment('x'); |
| 32 |
| 33 assert_equals(test.parentNode, parent, 'Appended node should have a parent'); |
| 34 assert_array_equals(parent.childNodes, [test], 'ParentNode should have 1 child
test'); |
| 35 test.replaceWith(x); |
| 36 assert_array_equals(parent.childNodes, [x], 'ParentNode should have 1 child no
de'); |
| 37 }, 'replaceWith() should work for Comment'); |
| 38 |
| 39 test(function() { |
| 40 var parent = document.createElement('div'); |
| 41 var test = document.createElement('test'); |
| 42 parent.appendChild(test); |
| 43 var x = document.createElement('x'); |
| 44 |
| 45 assert_equals(test.parentNode, parent, 'Appended node should have a parent'); |
| 46 assert_array_equals(parent.childNodes, [test], 'ParentNode should have 1 child
test'); |
| 47 test.replaceWith(x); |
| 48 assert_array_equals(parent.childNodes, [x], 'ParentNode should have 1 child no
de'); |
| 49 }, 'replaceWith() should work for Element'); |
| 50 |
| 51 test(function() { |
| 52 var parent = document.createElement('div'); |
| 53 var test = document.createTextNode('test'); |
| 54 parent.appendChild(test); |
| 55 var x = document.createTextNode('x'); |
| 56 |
| 57 assert_equals(test.parentNode, parent, 'Appended node should have a parent'); |
| 58 assert_array_equals(parent.childNodes, [test], 'ParentNode should have 1 child
test'); |
| 59 test.replaceWith(x); |
| 60 assert_array_equals(parent.childNodes, [x], 'ParentNode should have 1 child no
de'); |
| 61 }, 'replaceWith() should work for Text'); |
| 62 |
| 63 </script> |
| 64 </html> |
OLD | NEW |