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('after' in node); | |
9 assert_equals(typeof node.after, 'function'); | |
10 assert_equals(node.after.length, 0); | |
philipj_slow
2015/06/09 12:48:31
This makes me thing that after() can be called wit
Paritosh Kumar
2015/06/12 15:55:36
Thanks. Updated.
| |
11 }, "Comment should support after()"); | |
philipj_slow
2015/06/09 12:48:31
This and the following tests are on the same form,
Paritosh Kumar
2015/06/12 15:55:37
Done.
| |
12 | |
13 test(function() { | |
14 var node = document.createElement('node'); | |
15 assert_true('after' in node); | |
16 assert_equals(typeof node.after, 'function'); | |
17 assert_equals(node.after.length, 0); | |
18 }, "Element should support after()"); | |
19 | |
20 test(function() { | |
21 var node = document.createTextNode('node'); | |
22 assert_true('after' in node); | |
23 assert_equals(typeof node.after, 'function'); | |
24 assert_equals(node.after.length, 0); | |
25 }, "Text should support after()"); | |
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 var z = document.createComment('z'); | |
33 | |
34 test.after(x, 'y', z); | |
35 | |
36 assert_equals(parent.childNodes.length, 4, 'parent should have 4 children'); | |
philipj_slow
2015/06/09 12:48:31
I think you could write these assertions using tes
Paritosh Kumar
2015/06/12 15:55:37
Done.
| |
37 assert_equals(parent.firstChild, test, 'parent\'s first child should be test') ; | |
38 assert_equals(parent.childNodes[1], x, 'parent\'s second child should be x'); | |
39 assert_equals(parent.childNodes[2].data, 'y', 'parent\'s third child should be "y"'); | |
40 assert_equals(parent.lastChild, z, 'parent\'s last child should be z'); | |
41 | |
42 z.after('a'); | |
43 assert_equals(parent.lastChild.data, 'a', 'parent\'s third child should be "a" '); | |
44 }, "after() should work for Comment"); | |
45 | |
46 test(function() { | |
47 var parent = document.createElement('div'); | |
48 var test = document.createElement('test'); | |
49 parent.appendChild(test); | |
50 var x = document.createElement('x'); | |
51 var z = document.createElement('z'); | |
52 | |
53 test.after(x, 'y', z); | |
54 | |
55 assert_equals(parent.childNodes.length, 4, 'parent should have 4 children'); | |
56 assert_equals(parent.firstChild, test, 'parent\'s first child should be test') ; | |
57 assert_equals(parent.childNodes[1], x, 'parent\'s second child should be x'); | |
58 assert_equals(parent.childNodes[2].data, 'y', 'parent\'s third child should be "y"'); | |
59 assert_equals(parent.lastChild, z, 'parent\'s last child should be z'); | |
60 | |
61 z.after('a'); | |
62 assert_equals(parent.lastChild.data, 'a', 'parent\'s third child should be "a" '); | |
63 }, "after() should work for Element"); | |
64 | |
65 test(function() { | |
66 var parent = document.createElement('div'); | |
67 var test = document.createTextNode('test'); | |
68 parent.appendChild(test); | |
69 var x = document.createTextNode('x'); | |
70 var z = document.createTextNode('z'); | |
71 | |
72 test.after(x, 'y', z); | |
73 | |
74 assert_equals(parent.childNodes.length, 4, 'parent should have 4 children'); | |
75 assert_equals(parent.firstChild, test, 'parent\'s first child should be test') ; | |
76 assert_equals(parent.childNodes[1], x, 'parent\'s second child should be x'); | |
77 assert_equals(parent.childNodes[2].data, 'y', 'parent\'s third child should be "y"'); | |
78 assert_equals(parent.lastChild, z, 'parent\'s last child should be z'); | |
79 | |
80 z.after('a'); | |
81 assert_equals(parent.lastChild.data, 'a', 'parent\'s third child should be "a" '); | |
82 }, "after() should work for Text"); | |
83 </script> | |
84 </html> | |
OLD | NEW |