OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/testharness.js"></script> |
| 3 <script src="../../../resources/testharnessreport.js"></script> |
| 4 <script> |
| 5 |
| 6 function test_append(node, nodeName) { |
| 7 |
| 8 test(function() { |
| 9 var parent = node.cloneNode(); |
| 10 parent.append(); |
| 11 assert_equals(parent.childNodes.length, 0); |
| 12 assert_array_equals(parent.childNodes, []); |
| 13 }, nodeName + '.append() without any argument, on a parent having no child.'
); |
| 14 |
| 15 test(function() { |
| 16 if (nodeName != 'Document') { |
| 17 var parent = node.cloneNode(); |
| 18 parent.append(null); |
| 19 assert_equals(parent.childNodes.length, 1); |
| 20 assert_equals(parent.childNodes[0].textContent, 'null'); |
| 21 } |
| 22 }, nodeName + '.append() with null as an argument, on a parent having no chi
ld.'); |
| 23 |
| 24 test(function() { |
| 25 if (nodeName != 'Document') { |
| 26 var parent = node.cloneNode(); |
| 27 parent.append('text'); |
| 28 assert_equals(parent.childNodes.length, 1); |
| 29 assert_equals(parent.childNodes[0].textContent, 'text'); |
| 30 } |
| 31 }, nodeName + '.append() with only text as an argument, on a parent having n
o child.'); |
| 32 |
| 33 test(function() { |
| 34 var parent = node.cloneNode(); |
| 35 var x = document.createElement('x'); |
| 36 parent.append(x); |
| 37 assert_equals(parent.childNodes.length, 1); |
| 38 assert_array_equals(parent.childNodes, [x]); |
| 39 }, nodeName + '.append() with only one element as an argument, on a parent h
aving no child.'); |
| 40 |
| 41 test(function() { |
| 42 if (nodeName != 'Document') { |
| 43 var parent = node.cloneNode(); |
| 44 var child = document.createElement('test'); |
| 45 parent.appendChild(child); |
| 46 parent.append(null); |
| 47 assert_equals(parent.childNodes.length, 2); |
| 48 assert_equals(parent.childNodes[0], child); |
| 49 assert_equals(parent.childNodes[1].textContent, 'null'); |
| 50 } |
| 51 }, nodeName + '.append() with null as an argument, on a parent having a chil
d.'); |
| 52 |
| 53 test(function() { |
| 54 if (nodeName != 'Document') { |
| 55 var parent = node.cloneNode(); |
| 56 var x = document.createElement('x'); |
| 57 var child = document.createElement('test'); |
| 58 parent.appendChild(child); |
| 59 parent.append(x, 'text'); |
| 60 assert_equals(parent.childNodes.length, 3); |
| 61 assert_equals(parent.childNodes[0], child); |
| 62 assert_equals(parent.childNodes[1], x); |
| 63 assert_equals(parent.childNodes[2].textContent, 'text'); |
| 64 } |
| 65 }, nodeName + '.append() with one element and text as argument, on a parent
having a child.'); |
| 66 } |
| 67 |
| 68 test_append(document.createElement('div'), 'Element'); |
| 69 test_append(document, 'Document'); |
| 70 test_append(document.createDocumentFragment(), 'DocumentFrgment'); |
| 71 </script> |
| 72 </html> |
OLD | NEW |