OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <meta charset=utf-8> | |
3 <title>DocumentType.prepend</title> | |
4 <link rel=help href="https://dom.spec.whatwg.org/#dom-parentnode-prepend"> | |
5 <script src="../../../../resources/testharness.js"></script> | |
6 <script src="../../../../resources/testharnessreport.js"></script> | |
7 <script> | |
8 | |
9 function test_prepend_on_Document() { | |
10 | |
11 var node = document.implementation.createDocument(null, null); | |
12 test(function() { | |
13 var parent = node.cloneNode(); | |
14 parent.prepend(); | |
15 assert_array_equals(parent.childNodes, []); | |
16 }, 'Document.prepend() without any argument, on a Document having no child.'
); | |
17 | |
18 test(function() { | |
19 var parent = node.cloneNode(); | |
20 var x = document.createElement('x'); | |
21 parent.prepend(x); | |
22 assert_array_equals(parent.childNodes, [x]); | |
23 }, 'Document.prepend() with only one element as an argument, on a Document h
aving no child.'); | |
24 | |
25 test(function() { | |
26 var parent = node.cloneNode(); | |
27 var x = document.createElement('x'); | |
28 var y = document.createElement('y'); | |
29 parent.appendChild(x); | |
30 assert_throws('HierarchyRequestError', function() { parent.prepend(y); }
); | |
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.prepend('text
'); }); | |
37 assert_array_equals(parent.childNodes, []); | |
38 }, 'Document.prepend() with text as an argument, on a Document having no chi
ld.'); | |
39 | |
40 test(function() { | |
41 var parent = node.cloneNode(); | |
42 var x = document.createElement('x'); | |
43 var y = document.createElement('y'); | |
44 assert_throws('HierarchyRequestError', function() { parent.prepend(x, y)
; }); | |
45 assert_array_equals(parent.childNodes, []); | |
46 }, 'Document.prepend() with two elements as the argument, on a Document havi
ng no child.'); | |
47 | |
48 } | |
49 | |
50 test_prepend_on_Document(); | |
51 | |
52 </script> | |
53 </html> | |
OLD | NEW |