no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / docshell / test / browser / browser_onbeforeunload_parent.js
blob72c50043349c1438fffdb8b66bf8d2fd9d17e7b8
1 "use strict";
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);
7 Services.scriptloader.loadSubScript(
8   getRootDirectory(gTestPath) + "head_browser_onbeforeunload.js",
9   this
12 add_task(async function () {
13   await SpecialPowers.pushPrefEnv({
14     set: [["dom.require_user_interaction_for_beforeunload", false]],
15   });
17   for (let actions of PERMUTATIONS) {
18     info(
19       `Testing frame actions: [${actions.map(action =>
20         ACTION_NAMES.get(action)
21       )}]`
22     );
24     info(`Testing tab close from parent process`);
25     await doTest(actions, -1, (tab, frames) => {
26       let eventLoopSpun = false;
27       Services.tm.dispatchToMainThread(() => {
28         eventLoopSpun = true;
29       });
31       BrowserTestUtils.removeTab(tab);
33       let result = { eventLoopSpun };
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 });
46 add_task(async function cleanup() {
47   await TabPool.cleanup();
48 });