From b459f53a11232cdd78a7c514ea4299e99cb3f66a Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Mon, 24 Jun 2019 13:47:53 -0700 Subject: [PATCH] Bug 1561061: Move SpecialPowers pref env code to parent and make sane-ish. r=aswan Differential Revision: https://phabricator.services.mozilla.com/D35706 --HG-- extra : rebase_source : ec33af8c17048c3828d4ca4643e2e17bd2a854c0 extra : source : c2d0956f41d82e76c682f829807e818863cd802a --- browser/base/content/test/general/head.js | 8 +- .../browser_inspector_extension_sidebar.js | 2 +- devtools/client/shared/test/shared-head.js | 8 +- dom/base/test/chrome/test_bug914381.html | 2 +- ..._exception_options_from_jsimplemented.html | 4 +- ...promise_rejections_from_jsimplemented.html | 6 +- dom/canvas/test/test_hitregion_event.html | 2 +- dom/html/test/file_fullscreen-denied.html | 1 + .../test/test_eme_request_notifications.html | 2 +- .../test_background_loading_iframes.html | 2 +- layout/base/tests/test_bug394057.html | 4 +- .../content/SpecialPowersAPI.jsm | 244 ++---------------- .../content/SpecialPowersAPIParent.jsm | 227 +++++++++++++--- .../mochitest/test_ext_storage_cleanup.html | 4 +- 14 files changed, 227 insertions(+), 289 deletions(-) diff --git a/browser/base/content/test/general/head.js b/browser/base/content/test/general/head.js index 6c881d367dde..8b65cbb0d728 100644 --- a/browser/base/content/test/general/head.js +++ b/browser/base/content/test/general/head.js @@ -161,15 +161,11 @@ function setTestPluginEnabledState(newEnabledState, pluginName) { } function pushPrefs(...aPrefs) { - return new Promise(resolve => { - SpecialPowers.pushPrefEnv({"set": aPrefs}, resolve); - }); + return SpecialPowers.pushPrefEnv({"set": aPrefs}); } function popPrefs() { - return new Promise(resolve => { - SpecialPowers.popPrefEnv(resolve); - }); + return SpecialPowers.popPrefEnv(); } function updateBlocklist(aCallback) { diff --git a/devtools/client/inspector/extensions/test/browser_inspector_extension_sidebar.js b/devtools/client/inspector/extensions/test/browser_inspector_extension_sidebar.js index e06ef6309036..761d308228d6 100644 --- a/devtools/client/inspector/extensions/test/browser_inspector_extension_sidebar.js +++ b/devtools/client/inspector/extensions/test/browser_inspector_extension_sidebar.js @@ -273,7 +273,7 @@ add_task(async function testActiveTabOnNonExistingSidebar() { // to simulate the scenario where an extension has installed a sidebar // which has been saved in the preference but it doesn't exist anymore. await SpecialPowers.pushPrefEnv({ - set: [["devtools.inspector.activeSidebar"], "unexisting-sidebar-id"], + set: [["devtools.inspector.activeSidebar", "unexisting-sidebar-id"]], }); const res = await openInspectorForURL("about:blank"); diff --git a/devtools/client/shared/test/shared-head.js b/devtools/client/shared/test/shared-head.js index 4f419abd30bd..1dc40d6d8cf6 100644 --- a/devtools/client/shared/test/shared-head.js +++ b/devtools/client/shared/test/shared-head.js @@ -456,6 +456,8 @@ var closeTabAndToolbox = async function(tab = gBrowser.selectedTab) { } await removeTab(tab); + + await new Promise(resolve => setTimeout(resolve, 0)); }; /** @@ -596,10 +598,8 @@ function waitForClipboardPromise(setup, expected) { * @return {Promise} resolves when the preferences have been updated */ function pushPref(preferenceName, value) { - return new Promise(resolve => { - const options = {"set": [[preferenceName, value]]}; - SpecialPowers.pushPrefEnv(options, resolve); - }); + const options = {"set": [[preferenceName, value]]}; + return SpecialPowers.pushPrefEnv(options); } /** diff --git a/dom/base/test/chrome/test_bug914381.html b/dom/base/test/chrome/test_bug914381.html index 8c2601f405b6..7f8448ad2c9f 100644 --- a/dom/base/test/chrome/test_bug914381.html +++ b/dom/base/test/chrome/test_bug914381.html @@ -34,7 +34,7 @@ function createFileWithData(fileData) { /** Test for Bug 914381. File's created in JS using an nsIFile should allow mozGetFullPathInternal calls to succeed **/ var file = createFileWithData("Test bug 914381"); -SpecialPowers.pushPrefEnv({ set: [ "dom.file.createInChild" ]}) +SpecialPowers.pushPrefEnv({ set: [["dom.file.createInChild", true]]}) .then(() => { return File.createFromNsIFile(file); }) diff --git a/dom/bindings/test/test_exception_options_from_jsimplemented.html b/dom/bindings/test/test_exception_options_from_jsimplemented.html index c19e35e29445..3bba95d831c1 100644 --- a/dom/bindings/test/test_exception_options_from_jsimplemented.html +++ b/dom/bindings/test/test_exception_options_from_jsimplemented.html @@ -16,10 +16,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592 function doTest() { var file = location.href; + var asyncFrame; /* Async parent frames from pushPrefEnv don't show up in e10s. */ - var isE10S = !SpecialPowers.isMainProcess(); - if (!isE10S && SpecialPowers.getBoolPref("javascript.options.asyncstack")) { + if (SpecialPowers.getBoolPref("javascript.options.asyncstack")) { asyncFrame = `Async*@${file}:153:17 `; } else { diff --git a/dom/bindings/test/test_promise_rejections_from_jsimplemented.html b/dom/bindings/test/test_promise_rejections_from_jsimplemented.html index d70beb6a467c..e21117199753 100644 --- a/dom/bindings/test/test_promise_rejections_from_jsimplemented.html +++ b/dom/bindings/test/test_promise_rejections_from_jsimplemented.html @@ -37,12 +37,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592 function doTest() { var t = new TestInterfaceJS(); - /* Async parent frames from pushPrefEnv don't show up in e10s. */ - var isE10S = !SpecialPowers.isMainProcess(); + + var asyncStack = SpecialPowers.getBoolPref("javascript.options.asyncstack"); var ourFile = location.href; var unwrapError = "Promise rejection value is a non-unwrappable cross-compartment wrapper."; - var parentFrame = (asyncStack && !isE10S) ? `Async*@${ourFile}:130:17 + var parentFrame = asyncStack ? `Async*@${ourFile}:130:17 ` : ""; Promise.all([ diff --git a/dom/canvas/test/test_hitregion_event.html b/dom/canvas/test/test_hitregion_event.html index 383523e269e7..d98b35b70614 100644 --- a/dom/canvas/test/test_hitregion_event.html +++ b/dom/canvas/test/test_hitregion_event.html @@ -16,7 +16,7 @@