| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <meta charset=utf-8> | |
| 3 <title>Node.appendChild</title> | |
| 4 <link rel=help href="https://dom.spec.whatwg.org/#dom-node-appendchild"> | |
| 5 <script src="../../../../resources/testharness.js"></script> | |
| 6 <script src="../../../../resources/testharnessreport.js"></script> | |
| 7 <div id="log"></div> | |
| 8 <iframe src=about:blank></iframe> | |
| 9 <script> | |
| 10 // TODO: Exhaustive tests | |
| 11 function testLeaf(node, desc) { | |
| 12 // WebIDL. | |
| 13 test(function() { | |
| 14 assert_throws(new TypeError(), function() { node.appendChild(null) }) | |
| 15 }, "Appending null to a " + desc) | |
| 16 | |
| 17 // Pre-insert step 1. | |
| 18 test(function() { | |
| 19 assert_throws("HIERARCHY_REQUEST_ERR", function() { node.appendChild(documen
t.createTextNode("fail")) }) | |
| 20 }, "Appending to a " + desc) | |
| 21 } | |
| 22 | |
| 23 // WebIDL. | |
| 24 test(function() { | |
| 25 assert_throws(new TypeError(), function() { document.body.appendChild(null) }) | |
| 26 assert_throws(new TypeError(), function() { document.body.appendChild({'a':'b'
}) }) | |
| 27 }, "WebIDL tests") | |
| 28 | |
| 29 // WebIDL and pre-insert step 1. | |
| 30 test(function() { | |
| 31 testLeaf(document.createTextNode("Foo"), "text node") | |
| 32 testLeaf(document.createComment("Foo"), "comment") | |
| 33 testLeaf(document.doctype, "doctype") | |
| 34 }, "Appending to a leaf node.") | |
| 35 | |
| 36 // Pre-insert step 5. | |
| 37 test(function() { | |
| 38 var frameDoc = frames[0].document | |
| 39 assert_throws("HIERARCHY_REQUEST_ERR", function() { document.body.appendChild(
frameDoc) }) | |
| 40 }, "Appending a document") | |
| 41 | |
| 42 // Pre-insert step 8. | |
| 43 test(function() { | |
| 44 var frameDoc = frames[0].document | |
| 45 var s = frameDoc.createElement("a") | |
| 46 assert_equals(s.ownerDocument, frameDoc) | |
| 47 document.body.appendChild(s) | |
| 48 assert_equals(s.ownerDocument, document) | |
| 49 }, "Adopting an orphan") | |
| 50 test(function() { | |
| 51 var frameDoc = frames[0].document | |
| 52 var s = frameDoc.createElement("b") | |
| 53 assert_equals(s.ownerDocument, frameDoc) | |
| 54 frameDoc.body.appendChild(s) | |
| 55 assert_equals(s.ownerDocument, frameDoc) | |
| 56 document.body.appendChild(s) | |
| 57 assert_equals(s.ownerDocument, document) | |
| 58 }, "Adopting a non-orphan") | |
| 59 </script> | |
| OLD | NEW |