tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_destroying_iframes.js (1008B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 "use strict";
      4 
      5 // Frequent promise rejections which are not impacting the load of the toolbox.
      6 const { PromiseTestUtils } = ChromeUtils.importESModule(
      7  "resource://testing-common/PromiseTestUtils.sys.mjs"
      8 );
      9 PromiseTestUtils.allowMatchingRejectionsGlobally(/NS_ERROR_FAILURE/);
     10 
     11 // Testing that there's no breaking exception when destroying
     12 // an iframe early after its creation.
     13 
     14 add_task(async function () {
     15  const { tab } = await openInspectorForURL("about:blank");
     16  const browser = tab.linkedBrowser;
     17 
     18  // Create/remove an extra one now, after the load event.
     19  for (let i = 0; i < 10; i++) {
     20    await SpecialPowers.spawn(browser, [], async function () {
     21      const iframe = content.document.createElement("iframe");
     22      const loaded = new Promise(res => (iframe.onload = res));
     23      content.document.body.appendChild(iframe);
     24      await loaded;
     25      iframe.remove();
     26    });
     27  }
     28 });