Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Errors
- This test failed 1 times in the preceding 30 days. quicksearch this test
- Manifest: dom/base/test/chrome/chrome.toml
<?xml version="1.0"?>
                 type="text/css"?>
<!--
-->
  <!-- test results are displayed in the html:body -->
  </body>
  <!-- test code goes here -->
  <script type="application/javascript"><![CDATA[
    SimpleTest.waitForExplicitFinish();
    const OUTER_URL = "chrome://mochitests/content/chrome/dom/base/test/chrome/file_document-element-inserted.xhtml";
    const INNER_URL = "chrome://mochitests/content/chrome/dom/base/test/chrome/file_document-element-inserted-inner.xhtml";
    async function waitForEvent(url) {
      return new Promise(resolve => {
        SpecialPowers.addObserver(function inserted(document) {
          is(document.documentURI, url, "Correct URL");
          is(document.readyState, "loading", "Correct readyState");
          SpecialPowers.removeObserver(inserted, "document-element-inserted");
          resolve();
        }, "document-element-inserted");
      })
    }
    // Load a XUL document that also has an iframe to a subdocument, and
    // expect both events to fire with the docs in the correct state.
    async function testEvents() {
      info(`Waiting for events after loading ${OUTER_URL}`);
      let win = window.browsingContext.topChromeWindow.openDialog(OUTER_URL, "_blank", "chrome,dialog=no,all");
      await waitForEvent(OUTER_URL);
      await waitForEvent(INNER_URL);
      win.close();
    }
    (async function() {
      // Test the same document twice to make to make sure we are
      // firing properly when loading the protype document.
      await testEvents();
      await testEvents();
      SimpleTest.finish();
    })();
  ]]></script>
</window>