1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/events/test/test_bug367781.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,53 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=367781 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 367781</title> 1.11 + <script type="text/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=367781">Mozilla Bug 367781</a> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"> 1.18 + 1.19 +</div> 1.20 +<pre id="test"> 1.21 +<script class="testbody" type="text/javascript"> 1.22 + 1.23 +/** Test for Bug **/ 1.24 +var eventCounter = 0; 1.25 + 1.26 +function handler(e) { 1.27 + if (e.type == "DOMNodeInserted") { 1.28 + ++eventCounter; 1.29 + } 1.30 +} 1.31 + 1.32 +function doTest() { 1.33 + var i1 = document.getElementById('i1'); 1.34 + var i2 = document.getElementById('i2'); 1.35 + var pre = i1.contentDocument.getElementsByTagName("pre")[0]; 1.36 + pre.addEventListener("DOMNodeInserted", handler, false); 1.37 + pre.textContent = pre.textContent + pre.textContent; 1.38 + ok(eventCounter == 1, "DOMNodeInserted should have been dispatched"); 1.39 + 1.40 + pre.parentNode.removeChild(pre); 1.41 + i2.contentDocument.adoptNode(pre); 1.42 + i2.contentDocument.body.appendChild(pre); 1.43 + ok(eventCounter == 2, "DOMNodeInserted should have been dispatched in the new document"); 1.44 +} 1.45 + 1.46 +SimpleTest.waitForExplicitFinish(); 1.47 +addLoadEvent(doTest); 1.48 +addLoadEvent(SimpleTest.finish); 1.49 + 1.50 +</script> 1.51 +</pre> 1.52 +<iframe id="i1" src="data:text/html,<html><body><pre>Foobar</pre></body></html>"></iframe> 1.53 +<iframe id="i2" src="data:text/html,<html><body></body></html>"></iframe> 1.54 +</body> 1.55 +</html> 1.56 +