|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=548463 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 548463</title> |
|
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
10 </head> |
|
11 <body> |
|
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=548463">Mozilla Bug 548463</a> |
|
13 <p id="display"></p> |
|
14 <iframe id="otherDoc"></iframe> |
|
15 <div id="content" style="display: none"> |
|
16 <p id="elem1"></p> |
|
17 <p id="elem2"></p> |
|
18 </div> |
|
19 <div id="otherContent" style="display: none"> |
|
20 </div> |
|
21 <pre id="test"> |
|
22 <script type="application/javascript"> |
|
23 |
|
24 /** Test for Bug 548463 **/ |
|
25 |
|
26 var otherDoc = document.getElementById("otherDoc").contentDocument; |
|
27 var content = document.getElementById("content"); |
|
28 var elem1 = document.getElementById("elem1"); |
|
29 var elem2 = document.getElementById("elem2"); |
|
30 |
|
31 function testAdoptFromDOMNodeRemoved(nodeToAppend, nodeRemoved, nodeToAdopt) |
|
32 { |
|
33 function reparent(event) |
|
34 { |
|
35 if (event.target == nodeRemoved) { |
|
36 nodeRemoved.removeEventListener("DOMNodeRemoved", arguments.callee, false); |
|
37 otherDoc.adoptNode(nodeToAdopt); |
|
38 } |
|
39 } |
|
40 nodeRemoved.addEventListener("DOMNodeRemoved", reparent, false); |
|
41 |
|
42 var thrown = false; |
|
43 try { |
|
44 document.getElementById("otherContent").appendChild(nodeToAppend); |
|
45 } |
|
46 catch (e) { |
|
47 thrown = true; |
|
48 } |
|
49 |
|
50 ok(!thrown, "adoptNode while appending should not throw"); |
|
51 } |
|
52 |
|
53 var frag = document.createDocumentFragment(); |
|
54 frag.appendChild(elem1); |
|
55 frag.appendChild(elem2); |
|
56 testAdoptFromDOMNodeRemoved(frag, elem1, elem2); |
|
57 |
|
58 content.appendChild(elem1); |
|
59 testAdoptFromDOMNodeRemoved(elem1, elem1, content); |
|
60 |
|
61 content.appendChild(elem1); |
|
62 |
|
63 var thrown = false; |
|
64 |
|
65 function changeOwnerDocument() |
|
66 { |
|
67 SpecialPowers.wrap(elem1).setUserData("foo", null, null); |
|
68 otherDoc.adoptNode(elem1); |
|
69 } |
|
70 SpecialPowers.wrap(elem1).setUserData("foo", "bar", changeOwnerDocument); |
|
71 try { |
|
72 document.adoptNode(elem1); |
|
73 } |
|
74 catch (e) { |
|
75 thrown = true; |
|
76 } |
|
77 |
|
78 ok(!thrown, "adoptNode while adopting should not throw"); |
|
79 |
|
80 </script> |
|
81 </pre> |
|
82 </body> |
|
83 </html> |