OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <title>Node.removeChild</title> | |
3 <script src="../../../../resources/testharness.js"></script> | |
4 <script src="../../../../resources/testharnessreport.js"></script> | |
5 <script src="creators.js"></script> | |
6 <div id="log"></div> | |
7 <iframe src=about:blank></iframe> | |
8 <script> | |
9 var documents = [ | |
10 [function() { return document }, "the main document"], | |
11 [function() { return frames[0].document }, "a frame document"], | |
12 [function() { return document.implementation.createHTMLDocument() }, | |
13 "a synthetic document"], | |
14 ]; | |
15 | |
16 documents.forEach(function(d) { | |
17 var get = d[0], description = d[1] | |
18 for (var p in creators) { | |
19 var creator = creators[p]; | |
20 test(function() { | |
21 var doc = get(); | |
22 var s = doc[creator]("a") | |
23 assert_equals(s.ownerDocument, doc) | |
24 assert_throws("NOT_FOUND_ERR", function() { document.body.removeChild(s) }
) | |
25 assert_equals(s.ownerDocument, doc) | |
26 }, "Passing a detached " + p + " from " + description + | |
27 " to removeChild should not affect it.") | |
28 | |
29 test(function() { | |
30 var doc = get(); | |
31 var s = doc[creator]("b") | |
32 doc.documentElement.appendChild(s) | |
33 assert_equals(s.ownerDocument, doc) | |
34 assert_throws("NOT_FOUND_ERR", function() { document.body.removeChild(s) }
) | |
35 assert_equals(s.ownerDocument, doc) | |
36 }, "Passing a non-detached " + p + " from " + description + | |
37 " to removeChild should not affect it.") | |
38 | |
39 test(function() { | |
40 var doc = get(); | |
41 var s = doc[creator]("test") | |
42 doc.body.appendChild(s) | |
43 assert_equals(s.ownerDocument, doc) | |
44 assert_throws("NOT_FOUND_ERR", function() { s.removeChild(doc) }) | |
45 }, "Calling removeChild on a " + p + " from " + description + | |
46 " with no children should throw NOT_FOUND_ERR.") | |
47 } | |
48 }); | |
49 | |
50 test(function() { | |
51 assert_throws(new TypeError(), function() { document.body.removeChild(null) }) | |
52 assert_throws(new TypeError(), function() { document.body.removeChild({'a':'b'
}) }) | |
53 }, "Passing a value that is not a Node reference to removeChild should throw Typ
eError.") | |
54 </script> | |
OLD | NEW |