tor-browser

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

browser_onbeforeunload_parent.js (1225B)


      1 "use strict";
      2 
      3 // We need to test a lot of permutations here, and there isn't any sensible way
      4 // to split them up or run them faster.
      5 requestLongerTimeout(6);
      6 
      7 Services.scriptloader.loadSubScript(
      8  getRootDirectory(gTestPath) + "head_browser_onbeforeunload.js",
      9  this
     10 );
     11 
     12 add_task(async function () {
     13  await SpecialPowers.pushPrefEnv({
     14    set: [["dom.require_user_interaction_for_beforeunload", false]],
     15  });
     16 
     17  for (let actions of PERMUTATIONS) {
     18    info(
     19      `Testing frame actions: [${actions.map(action =>
     20        ACTION_NAMES.get(action)
     21      )}]`
     22    );
     23 
     24    info(`Testing tab close from parent process`);
     25    await doTest(actions, -1, tab => {
     26      let eventLoopSpun = false;
     27      Services.tm.dispatchToMainThread(() => {
     28        eventLoopSpun = true;
     29      });
     30 
     31      BrowserTestUtils.removeTab(tab);
     32 
     33      let result = { eventLoopSpun };
     34 
     35      // Make an extra couple of trips through the event loop to give us time
     36      // to process SpecialPowers.spawn responses before resolving.
     37      return new Promise(resolve => {
     38        executeSoon(() => {
     39          executeSoon(() => resolve(result));
     40        });
     41      });
     42    });
     43  }
     44 });
     45 
     46 add_task(async function cleanup() {
     47  await TabPool.cleanup();
     48 });