test_document-element-inserted.xhtml (2174B)
1 <?xml version="1.0"?> 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" 4 type="text/css"?> 5 <!-- 6 https://bugzilla.mozilla.org/show_bug.cgi?id=1411707 7 --> 8 <window title="Mozilla Bug 1411707" 9 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 10 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 11 12 <!-- test results are displayed in the html:body --> 13 <body xmlns="http://www.w3.org/1999/xhtml"> 14 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1411707" 15 target="_blank">Mozilla Bug 1411707</a> 16 </body> 17 18 <!-- test code goes here --> 19 <script type="application/javascript"><![CDATA[ 20 SimpleTest.waitForExplicitFinish(); 21 22 const OUTER_URL = "chrome://mochitests/content/chrome/dom/base/test/chrome/file_document-element-inserted.xhtml"; 23 const INNER_URL = "chrome://mochitests/content/chrome/dom/base/test/chrome/file_document-element-inserted-inner.xhtml"; 24 25 async function waitForEvent(url) { 26 return new Promise(resolve => { 27 SpecialPowers.addObserver(function inserted(document) { 28 is(document.documentURI, url, "Correct URL"); 29 is(document.readyState, "loading", "Correct readyState"); 30 SpecialPowers.removeObserver(inserted, "document-element-inserted"); 31 resolve(); 32 }, "document-element-inserted"); 33 }) 34 } 35 36 // Load a XUL document that also has an iframe to a subdocument, and 37 // expect both events to fire with the docs in the correct state. 38 async function testEvents() { 39 info(`Waiting for events after loading ${OUTER_URL}`); 40 let win = window.browsingContext.topChromeWindow.openDialog(OUTER_URL, "_blank", "chrome,dialog=no,all"); 41 await waitForEvent(OUTER_URL); 42 await waitForEvent(INNER_URL); 43 win.close(); 44 } 45 46 (async function() { 47 // Test the same document twice to make to make sure we are 48 // firing properly when loading the protype document. 49 await testEvents(); 50 await testEvents(); 51 SimpleTest.finish(); 52 })(); 53 ]]></script> 54 </window>