test_bug459848.html (1483B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=459848 5 --> 6 <head> 7 <title>Test for Bug 459848</title> 8 <script 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=459848">Mozilla Bug 459848</a> 13 <p id="display"></p> 14 <div id="content" style="display: none"> 15 16 </div> 17 <pre id="test"> 18 <script type="application/javascript"> 19 20 /** Test for Bug 459848 */ 21 22 var ifr1, irf2; 23 var doc1, doc2; 24 25 function testDocument(d) { 26 d.documentElement.setAttribute("onload", "this.setAttribute('didRun', 'true');"); 27 var e = d.createEvent("Events"); 28 e.initEvent("load", true, true); 29 d.documentElement.dispatchEvent(e); 30 } 31 32 function testDoc2() { 33 testDocument(doc2); 34 isnot(doc2.documentElement.getAttribute("didRun"), "true", 35 "Shouldn't have run an event listener"); 36 SimpleTest.finish(); 37 } 38 39 function startTest() { 40 var ifr1 = document.getElementById('iframe1'); 41 var ifr2 = document.getElementById('iframe2'); 42 doc1 = ifr1.contentDocument; 43 doc2 = ifr2.contentDocument; 44 45 testDocument(doc1); 46 is(doc1.documentElement.getAttribute("didRun"), "true", 47 "Should have run an event listener"); 48 49 ifr2.remove(); 50 setTimeout(testDoc2, 0); 51 } 52 SimpleTest.waitForExplicitFinish(); 53 addLoadEvent(startTest); 54 55 </script> 56 </pre> 57 <iframe id="iframe1"></iframe> 58 <iframe id="iframe2"></iframe> 59 </body> 60 </html>