|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=367781 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 367781</title> |
|
8 <script type="text/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=367781">Mozilla Bug 367781</a> |
|
13 <p id="display"></p> |
|
14 <div id="content" style="display: none"> |
|
15 |
|
16 </div> |
|
17 <pre id="test"> |
|
18 <script class="testbody" type="text/javascript"> |
|
19 |
|
20 /** Test for Bug **/ |
|
21 var eventCounter = 0; |
|
22 |
|
23 function handler(e) { |
|
24 if (e.type == "DOMNodeInserted") { |
|
25 ++eventCounter; |
|
26 } |
|
27 } |
|
28 |
|
29 function doTest() { |
|
30 var i1 = document.getElementById('i1'); |
|
31 var i2 = document.getElementById('i2'); |
|
32 var pre = i1.contentDocument.getElementsByTagName("pre")[0]; |
|
33 pre.addEventListener("DOMNodeInserted", handler, false); |
|
34 pre.textContent = pre.textContent + pre.textContent; |
|
35 ok(eventCounter == 1, "DOMNodeInserted should have been dispatched"); |
|
36 |
|
37 pre.parentNode.removeChild(pre); |
|
38 i2.contentDocument.adoptNode(pre); |
|
39 i2.contentDocument.body.appendChild(pre); |
|
40 ok(eventCounter == 2, "DOMNodeInserted should have been dispatched in the new document"); |
|
41 } |
|
42 |
|
43 SimpleTest.waitForExplicitFinish(); |
|
44 addLoadEvent(doTest); |
|
45 addLoadEvent(SimpleTest.finish); |
|
46 |
|
47 </script> |
|
48 </pre> |
|
49 <iframe id="i1" src="data:text/html,<html><body><pre>Foobar</pre></body></html>"></iframe> |
|
50 <iframe id="i2" src="data:text/html,<html><body></body></html>"></iframe> |
|
51 </body> |
|
52 </html> |
|
53 |