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