CharacterData-appendChild.html (1158B)
1 <!DOCTYPE html> 2 <meta charset=utf-8> 3 <title>Node.appendChild applied to CharacterData</title> 4 <link rel=help href="https://dom.spec.whatwg.org/#dom-node-appendchild"> 5 <link rel=help href="https://dom.spec.whatwg.org/#introduction-to-the-dom"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <div id="log"></div> 9 <script> 10 function create(type) { 11 switch (type) { 12 case "Text": return document.createTextNode("test"); break; 13 case "Comment": return document.createComment("test"); break; 14 case "ProcessingInstruction": return document.createProcessingInstruction("target", "test"); break; 15 } 16 } 17 18 function testNode(type1, type2) { 19 test(function() { 20 var node1 = create(type1); 21 var node2 = create(type2); 22 assert_throws_dom("HierarchyRequestError", function () { 23 node1.appendChild(node2); 24 }, "CharacterData type " + type1 + " must not have children"); 25 }, type1 + ".appendChild(" + type2 + ")"); 26 } 27 28 var types = ["Text", "Comment", "ProcessingInstruction"]; 29 types.forEach(function(type1) { 30 types.forEach(function(type2) { 31 testNode(type1, type2); 32 }); 33 }); 34 </script>