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_prepend(node, nodeName) { | |
7 | |
8 test(function() { | |
9 var parent = node.cloneNode(); | |
10 parent.prepend(); | |
11 assert_array_equals(parent.childNodes, []); | |
12 }, nodeName + '.prepend() without any argument, on a parent having no child.
'); | |
13 | |
14 test(function() { | |
15 var parent = node.cloneNode(); | |
16 parent.prepend(null); | |
17 assert_equals(parent.childNodes[0].textContent, 'null'); | |
18 }, nodeName + '.prepend() with null as an argument, on a parent having no ch
ild.'); | |
19 | |
20 test(function() { | |
21 var parent = node.cloneNode(); | |
22 parent.prepend(undefined); | |
23 assert_equals(parent.childNodes[0].textContent, 'undefined'); | |
24 }, nodeName + '.prepend() with undefined as an argument, on a parent having
no child.'); | |
25 | |
26 test(function() { | |
27 var parent = node.cloneNode(); | |
28 parent.prepend('text'); | |
29 assert_equals(parent.childNodes[0].textContent, 'text'); | |
30 }, nodeName + '.prepend() with only text as an argument, on a parent having
no child.'); | |
31 | |
32 test(function() { | |
33 var parent = node.cloneNode(); | |
34 var x = document.createElement('x'); | |
35 parent.prepend(x); | |
36 assert_array_equals(parent.childNodes, [x]); | |
37 }, nodeName + '.prepend() with only one element as an argument, on a parent
having no child.'); | |
38 | |
39 test(function() { | |
40 var parent = node.cloneNode(); | |
41 var child = document.createElement('test'); | |
42 parent.appendChild(child); | |
43 parent.prepend(null); | |
44 assert_equals(parent.childNodes[0].textContent, 'null'); | |
45 assert_equals(parent.childNodes[1], child); | |
46 }, nodeName + '.prepend() with null as an argument, on a parent having a chi
ld.'); | |
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.prepend(child, x); | |
55 assert_array_equals(parent.childNodes, [child, x]); | |
56 }, nodeName + '.prepend() 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.prepend(x, 'text'); | |
64 assert_equals(parent.childNodes[0], x); | |
65 assert_equals(parent.childNodes[1].textContent, 'text'); | |
66 assert_equals(parent.childNodes[2], child); | |
67 }, nodeName + '.prepend() with one element and text as argument, on a parent
having a child.'); | |
68 } | |
69 | |
70 test_prepend(document.createElement('div'), 'Element'); | |
71 test_prepend(document.createDocumentFragment(), 'DocumentFrgment'); | |
72 </script> | |
73 </html> | |
OLD | NEW |