1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_bug548463.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,83 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=548463 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 548463</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=548463">Mozilla Bug 548463</a> 1.16 +<p id="display"></p> 1.17 +<iframe id="otherDoc"></iframe> 1.18 +<div id="content" style="display: none"> 1.19 + <p id="elem1"></p> 1.20 + <p id="elem2"></p> 1.21 +</div> 1.22 +<div id="otherContent" style="display: none"> 1.23 +</div> 1.24 +<pre id="test"> 1.25 +<script type="application/javascript"> 1.26 + 1.27 +/** Test for Bug 548463 **/ 1.28 + 1.29 +var otherDoc = document.getElementById("otherDoc").contentDocument; 1.30 +var content = document.getElementById("content"); 1.31 +var elem1 = document.getElementById("elem1"); 1.32 +var elem2 = document.getElementById("elem2"); 1.33 + 1.34 +function testAdoptFromDOMNodeRemoved(nodeToAppend, nodeRemoved, nodeToAdopt) 1.35 +{ 1.36 + function reparent(event) 1.37 + { 1.38 + if (event.target == nodeRemoved) { 1.39 + nodeRemoved.removeEventListener("DOMNodeRemoved", arguments.callee, false); 1.40 + otherDoc.adoptNode(nodeToAdopt); 1.41 + } 1.42 + } 1.43 + nodeRemoved.addEventListener("DOMNodeRemoved", reparent, false); 1.44 + 1.45 + var thrown = false; 1.46 + try { 1.47 + document.getElementById("otherContent").appendChild(nodeToAppend); 1.48 + } 1.49 + catch (e) { 1.50 + thrown = true; 1.51 + } 1.52 + 1.53 + ok(!thrown, "adoptNode while appending should not throw"); 1.54 +} 1.55 + 1.56 +var frag = document.createDocumentFragment(); 1.57 +frag.appendChild(elem1); 1.58 +frag.appendChild(elem2); 1.59 +testAdoptFromDOMNodeRemoved(frag, elem1, elem2); 1.60 + 1.61 +content.appendChild(elem1); 1.62 +testAdoptFromDOMNodeRemoved(elem1, elem1, content); 1.63 + 1.64 +content.appendChild(elem1); 1.65 + 1.66 +var thrown = false; 1.67 + 1.68 +function changeOwnerDocument() 1.69 +{ 1.70 + SpecialPowers.wrap(elem1).setUserData("foo", null, null); 1.71 + otherDoc.adoptNode(elem1); 1.72 +} 1.73 +SpecialPowers.wrap(elem1).setUserData("foo", "bar", changeOwnerDocument); 1.74 +try { 1.75 + document.adoptNode(elem1); 1.76 +} 1.77 +catch (e) { 1.78 + thrown = true; 1.79 +} 1.80 + 1.81 +ok(!thrown, "adoptNode while adopting should not throw"); 1.82 + 1.83 +</script> 1.84 +</pre> 1.85 +</body> 1.86 +</html>