test_cloneAndImportNode.html (1394B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=882541 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 882541</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 <script type="application/javascript"> 12 13 /** Test for Bug 882541 */ 14 var div = document.createElement("div"); 15 div.appendChild(document.createElement("span")); 16 17 var div2; 18 19 div2 = div.cloneNode(); 20 is(div2.childNodes.length, 0, "cloneNode() should do a shallow clone"); 21 22 div2 = div.cloneNode(undefined); 23 is(div2.childNodes.length, 0, "cloneNode(undefined) should do a shallow clone"); 24 25 div2 = div.cloneNode(true); 26 is(div2.childNodes.length, 1, "cloneNode(true) should do a deep clone"); 27 28 div2 = document.importNode(div); 29 is(div2.childNodes.length, 0, "importNode(node) should do a deep import"); 30 31 div2 = document.importNode(div, undefined); 32 is(div2.childNodes.length, 0, "importNode(undefined) should do a shallow import"); 33 34 div2 = document.importNode(div, true); 35 is(div2.childNodes.length, 1, "importNode(true) should do a deep import"); 36 37 </script> 38 </head> 39 <body> 40 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=882541">Mozilla Bug 882541</a> 41 <p id="display"></p> 42 <div id="content" style="display: none"> 43 44 </div> 45 <pre id="test"> 46 </pre> 47 </body> 48 </html>