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_on_Document() { | |
7 | |
8 var node = document.implementation.createDocument(null, null); | |
9 test(function() { | |
10 var parent = node.cloneNode(); | |
11 parent.append(); | |
12 assert_equals(parent.childNodes.length, 0); | |
13 assert_array_equals(parent.childNodes, []); | |
14 }, 'Document.append() without any argument, on a Document having no child.') ; | |
15 | |
16 test(function() { | |
17 var parent = node.cloneNode(); | |
18 var x = document.createElement('x'); | |
19 parent.append(x); | |
20 assert_equals(parent.childNodes.length, 1); | |
philipj_slow
2015/07/06 14:21:33
Checking childNodes.length is redundant with asser
| |
21 assert_array_equals(parent.childNodes, [x]); | |
22 }, 'Document.append() with only one element as an argument, on a Document ha ving no child.'); | |
23 | |
24 test(function() { | |
25 var parent = node.cloneNode(); | |
26 var x = document.createElement('x'); | |
27 var y = document.createElement('y'); | |
28 parent.appendChild(x); | |
29 assert_throws('HierarchyRequestError', function() { parent.append(y); }, 'Only one element on document allowed.'); | |
30 assert_equals(parent.childNodes.length, 1); | |
31 assert_array_equals(parent.childNodes, [x]); | |
32 }, 'Document.append() with only one element as an argument, on a Document ha ving one child.'); | |
33 | |
34 test(function() { | |
35 var parent = node.cloneNode(); | |
36 assert_throws('HierarchyRequestError', function() { parent.append('text' ); }, 'Nodes of type \'#text\' may not be inserted inside nodes of type \'#docum ent\''); | |
philipj_slow
2015/07/06 14:21:33
This seems to be the message of the exception. I d
| |
37 assert_equals(parent.childNodes.length, 0); | |
38 assert_array_equals(parent.childNodes, []); | |
39 }, 'Document.append() with text as an argument, on a Document having no chi ld.'); | |
philipj_slow
2015/07/06 14:21:33
Two spaces in "with text"
| |
40 | |
41 test(function() { | |
42 var parent = node.cloneNode(); | |
43 var x = document.createElement('x'); | |
44 var y = document.createElement('y'); | |
45 assert_throws('HierarchyRequestError', function() { parent.append(x, y); }, 'Only one element on document allowed.'); | |
46 assert_equals(parent.childNodes.length, 0); | |
47 assert_array_equals(parent.childNodes, []); | |
48 }, 'Document.append() with only one element as an argument, on a Document ha ving no child.'); | |
philipj_slow
2015/07/06 14:21:33
Description is wrong, there are two arguments in t
| |
49 | |
50 } | |
51 | |
52 test_append_on_Document(); | |
53 | |
54 </script> | |
55 </html> | |
OLD | NEW |