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_after(node, nodeName) { | |
7 var child; | |
8 var innerHtml; | |
philipj_slow
2015/06/12 16:12:33
Maybe capitalize as innerHTML to match the API.
Paritosh Kumar
2015/06/15 08:55:23
Done.
| |
9 if (nodeName == 'Comment') { | |
10 child = document.createComment('test'); | |
11 innerHtml = '<!--test-->'; | |
12 } else if (nodeName == 'Element') { | |
13 child = document.createElement('test'); | |
14 innerHtml = '<test></test>'; | |
15 } else { | |
16 child = document.createTextNode('test'); | |
17 innerHtml = 'test'; | |
18 } | |
19 | |
20 test(function() { | |
21 var parent = node.cloneNode(); | |
22 parent.appendChild(child); | |
23 child.after(); | |
24 expected = innerHtml; | |
25 assert_equals(parent.innerHTML, expected); | |
26 }, nodeName + '.after() with empty argument.'); | |
philipj_slow
2015/06/12 16:12:33
s/empty/no/ to distinguish it from an empty string
Paritosh Kumar
2015/06/15 08:55:23
Thanks. Using 'without any argument'.
| |
27 | |
28 test(function() { | |
29 var parent = node.cloneNode(); | |
30 parent.appendChild(child); | |
31 child.after(null); | |
32 expected = innerHtml + 'null'; | |
33 assert_equals(parent.innerHTML, expected); | |
34 }, nodeName + '.after() with null as an argument.'); | |
35 | |
36 test(function() { | |
37 var parent = node.cloneNode(); | |
38 parent.appendChild(child); | |
39 child.after('text'); | |
40 expected = innerHtml + 'text'; | |
41 assert_equals(parent.innerHTML, expected); | |
42 }, nodeName + '.after() with only text as an argument.'); | |
43 | |
44 test(function() { | |
45 var parent = node.cloneNode(); | |
46 var x = document.createElement('x'); | |
47 parent.appendChild(child); | |
48 child.after(x); | |
49 expected = innerHtml + '<x></x>'; | |
50 assert_equals(parent.innerHTML, expected); | |
51 }, nodeName + '.after() with only one element as an argument.'); | |
52 | |
53 test(function() { | |
54 var parent = node.cloneNode(); | |
55 var x = document.createElement('x'); | |
56 parent.appendChild(child); | |
57 child.after(x, 'text'); | |
58 expected = innerHtml + '<x></x>text'; | |
59 assert_equals(parent.innerHTML, expected); | |
60 }, nodeName + '.after() with only one element and text as argument.'); | |
philipj_slow
2015/06/12 16:12:33
I think drop the "only" in the name of this test.
Paritosh Kumar
2015/06/15 08:55:23
Yeah. Thanks.
| |
61 } | |
62 | |
63 test_after(document.createElement('div'), 'Comment'); | |
64 test_after(document.createElement('div'), 'Element'); | |
65 test_after(document.createElement('div'), 'Text'); | |
66 | |
67 </script> | |
68 </html> | |
OLD | NEW |