Bug 1318273 - Improve the use of SpecialPowers.pushPrefEnv() - part 1, r=qdot

This commit is contained in:
Andrea Marchesini 2016-11-17 19:36:01 +01:00
parent af66848eae
commit cf2ad8072f
72 changed files with 179 additions and 293 deletions

View File

@ -480,11 +480,9 @@ function* test_delayed_tabattr_removal() {
}
add_task(function*() {
yield new Promise((resolve) => {
SpecialPowers.pushPrefEnv({"set": [
["browser.tabs.showAudioPlayingIcon", true],
]}, resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [
["browser.tabs.showAudioPlayingIcon", true],
]});
});
requestLongerTimeout(2);

View File

@ -99,9 +99,9 @@ function waitForSomeTabToLoad() {
* Ensure the Mixed Content Blocker is enabled.
*/
add_task(function* test_initialize() {
yield new Promise(resolve => SpecialPowers.pushPrefEnv({
yield SpecialPowers.pushPrefEnv({
"set": [["security.mixed_content.block_active_content", true]],
}, resolve));
});
});
/**

View File

@ -17,9 +17,9 @@ function waitForInsecureLoginFormsStateChange(browser, count) {
* Checks the insecure login forms logic for the identity block.
*/
add_task(function* test_simple() {
yield new Promise(resolve => SpecialPowers.pushPrefEnv({
yield SpecialPowers.pushPrefEnv({
"set": [["security.insecure_password.ui.enabled", true]],
}, resolve));
});
for (let [origin, expectWarning] of [
["http://example.com", true],
@ -82,9 +82,9 @@ add_task(function* test_simple() {
* blocking messages when mixed active content is loaded.
*/
add_task(function* test_mixedcontent() {
yield new Promise(resolve => SpecialPowers.pushPrefEnv({
yield SpecialPowers.pushPrefEnv({
"set": [["security.mixed_content.block_active_content", false]],
}, resolve));
});
// Load the page with the subframe in a new tab.
let testUrlPath = "://example.com" + TEST_URL_PATH;

View File

@ -15,14 +15,12 @@ const gHttpTestUrl = "http://example.com/browser/browser/base/content/test/gener
var gTestBrowser = null;
add_task(function *() {
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({
"set": [
["security.mixed_content.block_active_content", true],
["security.mixed_content.block_display_content", false]
]
}, resolve);
});
yield SpecialPowers.pushPrefEnv({
"set": [
["security.mixed_content.block_active_content", true],
["security.mixed_content.block_display_content", false]
]});
let url = gHttpTestUrl
yield BrowserTestUtils.withNewTab({gBrowser, url}, function*() {
gTestBrowser = gBrowser.selectedBrowser;

View File

@ -17,13 +17,11 @@ var gTestBrowser = null;
add_task(function *() {
let url = gHttpTestRoot1 + "file_mixedContentFromOnunload.html";
yield BrowserTestUtils.withNewTab({gBrowser, url}, function*() {
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({
"set": [
["security.mixed_content.block_active_content", true],
["security.mixed_content.block_display_content", false]
]
}, resolve);
yield SpecialPowers.pushPrefEnv({
"set": [
["security.mixed_content.block_active_content", true],
["security.mixed_content.block_display_content", false]
]
});
gTestBrowser = gBrowser.selectedBrowser;
// Navigation from an http page to a https page with no mixed content

View File

@ -18,10 +18,7 @@ function waitForSecurityChange(numChanges = 1) {
}
add_task(function* test_fetch() {
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({ set: [['privacy.trackingprotection.enabled', true]] },
resolve);
});
yield SpecialPowers.pushPrefEnv({ set: [['privacy.trackingprotection.enabled', true]] });
yield BrowserTestUtils.withNewTab({ gBrowser, url: URL }, function* (newTabBrowser) {
let securityChange = waitForSecurityChange();

View File

@ -23,11 +23,9 @@ var with_new_tab_opened = Task.async(function* (options, taskFn) {
});
add_task(function*() {
yield new Promise((resolve) => {
SpecialPowers.pushPrefEnv({"set": [
["view_source.tab", true],
]}, resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [
["view_source.tab", true],
]});
});
add_task(function* test_regular_page() {

View File

@ -91,8 +91,7 @@ registerCleanupFunction(function() {
});
function pushPrefs(...aPrefs) {
return new Promise(resolve =>
SpecialPowers.pushPrefEnv({"set": aPrefs}, resolve));
return SpecialPowers.pushPrefEnv({"set": aPrefs});
}
/**

View File

@ -28,7 +28,7 @@ add_task(function* () {
*/
add_task(function* () {
let input = "To be or not to be-that is the question";
yield new Promise(resolve => SpecialPowers.pushPrefEnv({set: [["keyword.enabled", false]]}, resolve));
yield SpecialPowers.pushPrefEnv({set: [["keyword.enabled", false]]});
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:newtab", false);
// NB: CPOW usage because new tab pages can be preloaded, in which case no
// load events fire.

View File

@ -5,7 +5,7 @@
* "example" and hit enter, the browser loads and the URL bar is updated accordingly.
*/
add_task(function* () {
yield new Promise(resolve => SpecialPowers.pushPrefEnv({set: [["keyword.enabled", false]]}, resolve));
yield SpecialPowers.pushPrefEnv({set: [["keyword.enabled", false]]});
yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, function* (browser) {
gURLBar.value = "example";
gURLBar.select();

View File

@ -6,14 +6,11 @@ const BASE_URI = "http://mochi.test:8888/browser/browser/components/"
+ "contextualidentity/test/browser/empty_file.html";
add_task(function* setup() {
yield new Promise((resolve) => {
SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true]
]}, resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true]
]});
});
add_task(function* test() {
info("Creating a tab with UCI = 1...");
let tab1 = gBrowser.addTab(BASE_URI, {userContextId: 1});

View File

@ -21,11 +21,9 @@ function* openTabInUserContext(uri, userContextId) {
add_task(function* setup() {
// make sure userContext is enabled.
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true]
]}, resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true]
]});
});
add_task(function* test() {

View File

@ -85,15 +85,13 @@ function generateKeyInfo(aData) {
add_task(function* setup() {
// Make sure userContext is enabled.
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": [
[ "privacy.userContext.enabled", true ],
[ "media.mediasource.enabled", true ],
[ "media.eme.apiVisible", true ],
[ "media.mediasource.webm.enabled", true ],
[ "media.clearkey.persistent-license.enabled", true ],
]}, resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [
[ "privacy.userContext.enabled", true ],
[ "media.mediasource.enabled", true ],
[ "media.eme.apiVisible", true ],
[ "media.mediasource.webm.enabled", true ],
[ "media.clearkey.persistent-license.enabled", true ],
]});
});
add_task(function* test() {

View File

@ -77,11 +77,9 @@ function loadFaviconHandler(metadata, response) {
add_task(function* setup() {
// Make sure userContext is enabled.
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true]
]}, resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true]
]});
// Create a http server for the image cache test.
if (!gHttpServer) {

View File

@ -318,11 +318,9 @@ function* test_storage_cleared() {
add_task(function* setup() {
// Make sure userContext is enabled.
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true]
]}, resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true]
]});
// Create a http server for the image cache test.
if (!gHttpServer) {

View File

@ -23,12 +23,10 @@ function openTabInUserContext(uri, userContextId) {
add_task(function* setup() {
// make sure userContext is enabled.
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true],
["dom.ipc.processCount", 1]
]}, resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true],
["dom.ipc.processCount", 1]
]});
});
let infos = [];

View File

@ -27,12 +27,10 @@ function openTabInUserContext(uri, userContextId) {
add_task(function* setup() {
// make sure userContext is enabled.
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true],
["dom.ipc.processCount", 1]
]}, resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true],
["dom.ipc.processCount", 1]
]});
});
add_task(function* test() {

View File

@ -13,12 +13,10 @@ const BASE_URI = "http://mochi.test:8888/browser/browser/components/"
add_task(function* setup() {
// make sure userContext is enabled.
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true],
["browser.link.open_newwindow", 3],
]}, resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true],
["browser.link.open_newwindow", 3],
]});
});
add_task(function* test() {

View File

@ -7,12 +7,10 @@ const BASE_URI = "http://mochi.test:8888/browser/browser/components/"
+ "contextualidentity/test/browser/empty_file.html";
add_task(function* setup() {
yield new Promise((resolve) => {
SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true],
["browser.link.open_newwindow", 2],
]}, resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true],
["browser.link.open_newwindow", 2],
]});
});

View File

@ -208,12 +208,10 @@ function* setDownloadDir() {
});
}
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": [
["browser.download.folderList", 2],
["browser.download.dir", tmpDir, Ci.nsIFile],
]}, resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [
["browser.download.folderList", 2],
["browser.download.dir", tmpDir, Ci.nsIFile],
]});
}

View File

@ -15,11 +15,10 @@ function makeBookmarkFor(url, keyword) {
add_task(function* openKeywordBookmarkWithWindowOpen() {
// This is the current default, but let's not assume that...
yield new Promise((resolve, reject) => {
SpecialPowers.pushPrefEnv({ 'set': [[ 'browser.link.open_newwindow', 3 ],
[ 'dom.disable_open_during_load', true ]] },
resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [
[ 'browser.link.open_newwindow', 3 ],
[ 'dom.disable_open_during_load', true ]
]});
let moztab;
let tabOpened = BrowserTestUtils.openNewForegroundTab(gBrowser, "about:mozilla")

View File

@ -10,7 +10,7 @@ add_task(function* () {
var contextMenu;
// We want select events to be fired.
yield new Promise(resolve => SpecialPowers.pushPrefEnv({"set": [["dom.select_events.enabled", true]]}, resolve));
yield SpecialPowers.pushPrefEnv({set: [["dom.select_events.enabled", true]]});
let envService = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
let originalValue = envService.get("XPCSHELL_TEST_PROFILE_DIR");

View File

@ -544,9 +544,7 @@ function modifySessionStorage(browser, data, options = {}) {
}
function pushPrefs(...aPrefs) {
return new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": aPrefs}, resolve);
});
return SpecialPowers.pushPrefEnv({"set": aPrefs});
}
function popPrefs() {

View File

@ -28,10 +28,7 @@ function promiseReportCallMade(aValue) {
}
function pushPrefs(...aPrefs) {
return new Promise((resolve) => {
SpecialPowers.pushPrefEnv({"set": aPrefs}, resolve);
resolve();
});
return SpecialPowers.pushPrefEnv({"set": aPrefs});
}
function popPrefs() {

View File

@ -63,7 +63,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=995943
}
function pushPrefs(prefs) {
return new Promise(function(resolve) { SpecialPowers.pushPrefEnv({ set: prefs }, resolve); });
return SpecialPowers.pushPrefEnv({ set: prefs });
}
function popPrefs() {

View File

@ -236,11 +236,9 @@ promise_test(function(t) {
// This is to test that we don't temporarily clear the flag when forcing
// an unthrottled sample.
promise_test(function(t) {
return new Promise(function(resolve) {
// Needs scrollbars to cause overflow.
SpecialPowers.pushPrefEnv({ set: [["ui.showHideScrollbars", 1]] },
resolve);
}).then(function() {
// Needs scrollbars to cause overflow.
return SpecialPowers.pushPrefEnv({ set: [["ui.showHideScrollbars", 1]] })
.then(function() {
var div = addDiv(t, { style: 'animation: rotate 100s' });
var animation = div.getAnimations()[0];

View File

@ -6,9 +6,7 @@
'use strict';
function waitForSetPref(pref, value) {
return new Promise(function(resolve, reject) {
SpecialPowers.pushPrefEnv({ 'set': [[pref, value]] }, resolve);
});
return SpecialPowers.pushPrefEnv({ 'set': [[pref, value]] });
}
/*

View File

@ -26,8 +26,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1276553
/** Test for Bug 1276553 **/
function run() {
new Promise(resolve => SpecialPowers.pushPrefEnv(
{'set' : [[ 'browser.groupedhistory.enabled', true ]]}, resolve))
SpecialPowers.pushPrefEnv(
{'set' : [[ 'browser.groupedhistory.enabled', true ]]})
.then(() => test(false))
.then(() => test(true))
.then(() => {

View File

@ -93,12 +93,9 @@ Test swapFrameLoaders with different frame types and remoteness
}
add_task(function*() {
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv(
{ "set": [["dom.mozBrowserFramesEnabled", true],
["network.disable.ipc.security", true]] },
resolve);
});
yield SpecialPowers.pushPrefEnv(
{ "set": [["dom.mozBrowserFramesEnabled", true],
["network.disable.ipc.security", true]] });
});
add_task(function*() {

View File

@ -1,21 +1,16 @@
function specialPowersLock(orientation) {
return new Promise(function(resolve, reject) {
SpecialPowers.pushPrefEnv({
'set': [ ["dom.screenorientation.testing.non_fullscreen_lock_allow", true] ]
}, function() {
var p = screen.orientation.lock(orientation);
resolve(p);
});
return SpecialPowers.pushPrefEnv({
'set': [ ["dom.screenorientation.testing.non_fullscreen_lock_allow", true] ]
}).then(function() => {
var p = screen.orientation.lock(orientation);
});
}
function specialPowersUnlock() {
return new Promise(function(resolve, reject) {
SpecialPowers.pushPrefEnv({
'set': [ ["dom.screenorientation.testing.non_fullscreen_lock_allow", true] ]
}, function() {
screen.orientation.unlock();
resolve();
});
return SpecialPowers.pushPrefEnv({
'set': [ ["dom.screenorientation.testing.non_fullscreen_lock_allow", true] ]
}).then(function() {
screen.orientation.unlock();
resolve();
});
}

View File

@ -61,8 +61,7 @@ const CROSS_ORIGIN = "http://example.com" + SJS_PATH;
SimpleTest.waitForExplicitFinish();
new Promise(resolve =>
SpecialPowers.pushPrefEnv({"set": [["network.prefetch-next.aggressive", true]]}, resolve))
SpecialPowers.pushPrefEnv({"set": [["network.prefetch-next.aggressive", true]]})
// test same origin
.then(() => testPrefetchEvent(SAME_ORIGIN + "?statusCode=200&cacheControl=no-cache", false, false))

View File

@ -20,9 +20,7 @@ https://bugzilla.mozilla.org/1281963
// Set a pref value asynchronously, returning a promise that resolves
// when it succeeds.
let setPref = function* (key, value) {
return new Promise(function(resolve, reject) {
SpecialPowers.pushPrefEnv({"set": [[key, value]]}, resolve);
});
return SpecialPowers.pushPrefEnv({"set": [[key, value]]});
};
// Run a test to see that we don't expose the supported mimeTypes

View File

@ -11,12 +11,9 @@
<body>
<script type="application/javascript;version=1.8">
add_task(function*() {
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv(
{ "set": [["dom.mozBrowserFramesEnabled", true],
["network.disable.ipc.security", true]] },
resolve);
});
yield SpecialPowers.pushPrefEnv(
{ "set": [["dom.mozBrowserFramesEnabled", true],
["network.disable.ipc.security", true]] });
});
add_task(function*() {

View File

@ -11,12 +11,9 @@
<body>
<script type="application/javascript;version=1.8">
add_task(function*() {
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv(
{ "set": [["dom.mozBrowserFramesEnabled", true],
["network.disable.ipc.security", true]] },
resolve);
});
yield SpecialPowers.pushPrefEnv(
{ "set": [["dom.mozBrowserFramesEnabled", true],
["network.disable.ipc.security", true]] });
});
add_task(function*() {

View File

@ -18,16 +18,12 @@
function runTests(testFile, order) {
function setupPrefs() {
return new Promise(function(resolve, reject) {
SpecialPowers.pushPrefEnv({
"set": [["dom.caches.enabled", true],
["dom.caches.testing.enabled", true],
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.testing.enabled", true],
["dom.serviceWorkers.exemptFromPerDomainMax", true]]
}, function() {
resolve();
});
return SpecialPowers.pushPrefEnv({
"set": [["dom.caches.enabled", true],
["dom.caches.testing.enabled", true],
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.testing.enabled", true],
["dom.serviceWorkers.exemptFromPerDomainMax", true]]
});
}

View File

@ -1,7 +1,5 @@
function pushPrefs(...aPrefs) {
return new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": aPrefs}, resolve);
});
return SpecialPowers.pushPrefEnv({"set": aPrefs});
}
function promiseWaitForEvent(object, eventName, capturing = false, chrome = false) {

View File

@ -237,4 +237,4 @@ add_task(test_domainPolicy);
registerCleanupFunction(()=>{
deactivateDomainPolicy();
})
})

View File

@ -41,23 +41,17 @@ function check_ogg(v, enabled, finish) {
}
function opus_enable() {
return new Promise(function(resolve, reject) {
SpecialPowers.pushPrefEnv({"set": [['media.opus.enabled', true]]},
function() {
check("audio/ogg; codecs=opus", "probably");
resolve();
});
});
return SpecialPowers.pushPrefEnv({"set": [['media.opus.enabled', true]]})
.then(function() {
check("audio/ogg; codecs=opus", "probably");
});
}
function opus_disable() {
return new Promise(function(resolve, reject) {
SpecialPowers.pushPrefEnv({"set": [['media.opus.enabled', false]]},
function() {
check("audio/ogg; codecs=opus", "");
resolve();
});
});
return SpecialPowers.pushPrefEnv({"set": [['media.opus.enabled', false]]})
.then(function() {
check("audio/ogg; codecs=opus", "");
});
}
function unspported_ogg() {

View File

@ -13,9 +13,7 @@
var manager = new MediaTestManager;
function SetPrefs(prefs) {
return new Promise(function(resolve, reject) {
SpecialPowers.pushPrefEnv({"set": prefs}, function() { resolve(); });
});
return SpecialPowers.pushPrefEnv({"set": prefs});
}
function observe() {

View File

@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=489415
<script type="text/javascript">
SimpleTest.waitForExplicitFinish();
var pushPrefs = (...p) => new Promise(r => SpecialPowers.pushPrefEnv({set: p}, r));
var pushPrefs = (...p) => SpecialPowers.pushPrefEnv({set: p});
var throwOutside = e => setTimeout(() => { throw e; });
// Generate a random key. The first load with that key will return

View File

@ -21,7 +21,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=489415
<script type="text/javascript">
SimpleTest.waitForExplicitFinish();
var pushPrefs = (...p) => new Promise(r => SpecialPowers.pushPrefEnv({set: p}, r));
var pushPrefs = (...p) => SpecialPowers.pushPrefEnv({set: p});
var v1 = document.getElementById("v1");
var v2 = document.getElementById("v2");

View File

@ -230,7 +230,7 @@ function createHTML(options) {
return scriptsReady.then(() => realCreateHTML(options));
}
var pushPrefs = (...p) => new Promise(r => SpecialPowers.pushPrefEnv({set: p}, r));
var pushPrefs = (...p) => SpecialPowers.pushPrefEnv({set: p});
// noGum - Helper to detect whether active guM tracks still exist.
//

View File

@ -1823,11 +1823,9 @@ var setupIceServerConfig = useIceServer => {
// We disable ICE support for HTTP proxy when using a TURN server, because
// mochitest uses a fake HTTP proxy to serve content, which will eat our STUN
// packets for TURN TCP.
var enableHttpProxy = enable => new Promise(resolve => {
var enableHttpProxy = enable =>
SpecialPowers.pushPrefEnv(
{'set': [['media.peerconnection.disable_http_proxy', !enable]]},
resolve);
});
{'set': [['media.peerconnection.disable_http_proxy', !enable]]});
var spawnIceServer = () => new Promise( (resolve, reject) => {
iceServerWebsocket = new WebSocket("ws://localhost:8191/");

View File

@ -25,7 +25,7 @@ function mustFailWith(msg, reason, constraint, f) {
});
}
var pushPrefs = (...p) => new Promise(r => SpecialPowers.pushPrefEnv({set: p}, r));
var pushPrefs = (...p) => SpecialPowers.pushPrefEnv({set: p});
runTest(() =>
pushPrefs(["media.navigator.streams.fake", true])

View File

@ -11,7 +11,7 @@
bug: "1211656"
});
var pushPrefs = (...p) => new Promise(r => SpecialPowers.pushPrefEnv({set: p}, r));
var pushPrefs = (...p) => SpecialPowers.pushPrefEnv({set: p});
/**
* Run a test to verify that we can complete a start and stop media playback

View File

@ -37,7 +37,7 @@ function OnDeviceChangeEventNotReceived() {
]);
}
var pushPrefs = (...p) => new Promise(r => SpecialPowers.pushPrefEnv({set: p}, r));
var pushPrefs = (...p) => SpecialPowers.pushPrefEnv({set: p});
var videoTracks;

View File

@ -105,8 +105,7 @@ runNetworkTest(() => {
JSON.stringify(toComparable(config)), "getConfiguration");
pc.close();
var push = prefs => new Promise(resolve =>
SpecialPowers.pushPrefEnv(prefs, resolve));
var push = prefs => SpecialPowers.pushPrefEnv(prefs);
Promise.resolve()
// This set of tests are setting the about:config User preferences for default

View File

@ -66,7 +66,7 @@ runNetworkTest(() => {
}
]);
var pushPrefs = (...p) => new Promise(r => SpecialPowers.pushPrefEnv({set: p}, r));
var pushPrefs = (...p) => SpecialPowers.pushPrefEnv({set: p});
return pushPrefs(['media.peerconnection.dtmf.enabled', true])
.then(() => { test.run() })

View File

@ -28,7 +28,7 @@ function PC_BOTH_WAIT_FOR_ICE_FAILED(test) {
.then(() => ok(true, "ICE on both sides must fail."));
}
var pushPrefs = (...p) => new Promise(r => SpecialPowers.pushPrefEnv({set: p}, r));
var pushPrefs = (...p) => SpecialPowers.pushPrefEnv({set: p});
var test;
runNetworkTest(options =>

View File

@ -14,7 +14,7 @@
});
var test;
var pushPrefs = (...p) => new Promise(r => SpecialPowers.pushPrefEnv({set: p}, r));
var pushPrefs = (...p) => SpecialPowers.pushPrefEnv({set: p});
function selectRecvSsrc(pc, index) {
var receivers = pc._pc.getReceivers();

View File

@ -1,8 +1,8 @@
add_task(function*() {
// Make the min_background_timeout_value very high to avoid problems on slow machines
yield new Promise(resolve => SpecialPowers.pushPrefEnv({
yield SpecialPowers.pushPrefEnv({
'set': [['dom.min_background_timeout_value', 3000]]
}, resolve));
});
// Make a new tab, and put it in the background
yield BrowserTestUtils.withNewTab("about:blank", function*(browser) {

View File

@ -25,18 +25,16 @@ add_task(function* () {
});
add_task(function*() {
yield new Promise((resolve) => {
SpecialPowers.pushPrefEnv({
"set": [
["general.smoothScroll", true],
["general.smoothScroll.other", true],
["general.smoothScroll.mouseWheel", true],
["general.smoothScroll.other.durationMaxMS", 2000],
["general.smoothScroll.other.durationMinMS", 1999],
["general.smoothScroll.mouseWheel.durationMaxMS", 2000],
["general.smoothScroll.mouseWheel.durationMinMS", 1999],
]}, resolve);
});
yield SpecialPowers.pushPrefEnv({
"set": [
["general.smoothScroll", true],
["general.smoothScroll.other", true],
["general.smoothScroll.mouseWheel", true],
["general.smoothScroll.other.durationMaxMS", 2000],
["general.smoothScroll.other.durationMinMS", 1999],
["general.smoothScroll.mouseWheel.durationMaxMS", 2000],
["general.smoothScroll.mouseWheel.durationMinMS", 1999],
]});
});
/*

View File

@ -66,9 +66,7 @@ var aboutNewTabService = Cc["@mozilla.org/browser/aboutnewtab-service;1"]
.getService(Ci.nsIAboutNewTabService);
function pushPrefs(...aPrefs) {
return new Promise((resolve) => {
SpecialPowers.pushPrefEnv({"set": aPrefs}, resolve);
});
return SpecialPowers.pushPrefEnv({"set": aPrefs});
}
/*

View File

@ -1,7 +1,5 @@
add_task(function* () {
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": [["browser.autofocus", false]]}, resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [["browser.autofocus", false]]});
const url = "data:text/html,<!DOCTYPE html><html><body><input autofocus><button autofocus></button><textarea autofocus></textarea><select autofocus></select></body></html>";

View File

@ -12,13 +12,11 @@ function testScript(script) {
}
function setupPrefs() {
return new Promise(function(resolve, reject) {
SpecialPowers.pushPrefEnv({
"set": [["dom.requestcontext.enabled", true],
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.testing.enabled", true],
["dom.serviceWorkers.exemptFromPerDomainMax", true]]
}, resolve);
return SpecialPowers.pushPrefEnv({
"set": [["dom.requestcontext.enabled", true],
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.testing.enabled", true],
["dom.serviceWorkers.exemptFromPerDomainMax", true]]
});
}

View File

@ -26,9 +26,7 @@ if (inFrame) {
}
function setCookieBehavior(behavior) {
return new Promise((resolve, reject) => {
SpecialPowers.pushPrefEnv({"set": [[kPrefName, behavior]]}, resolve);
});
return SpecialPowers.pushPrefEnv({"set": [[kPrefName, behavior]]});
}
function runIFrame(url) {

View File

@ -13,9 +13,7 @@
<script>
add_task(function* () {
// Push the correct preferences for the test
yield new Promise((done) => {
SpecialPowers.pushPrefEnv({'set': [['dom.select_events.enabled', true]]}, done);
});
yield SpecialPowers.pushPrefEnv({'set': [['dom.select_events.enabled', true]]});
// Start the actual test
yield new Promise((done) => {

View File

@ -8,11 +8,8 @@
const ACCEPT_SESSION = 2;
add_task(function*() {
yield new Promise((resolve, reject) => {
SpecialPowers.pushPrefEnv({"set": [["network.cookie.lifetimePolicy",
ACCEPT_SESSION]]},
resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [["network.cookie.lifetimePolicy",
ACCEPT_SESSION]]});
// Before setting permission
yield new Promise((resolve) => {

View File

@ -40,11 +40,8 @@
}
function httpsOnly() {
var promise = new Promise(function(resolve) {
SpecialPowers.pushPrefEnv({'set': [["dom.serviceWorkers.testing.enabled", false]] }, resolve);
});
return promise.then(function() {
return SpecialPowers.pushPrefEnv({'set': [["dom.serviceWorkers.testing.enabled", false]] })
.then(function() {
return navigator.serviceWorker.register("/worker.js");
}).then(function(w) {
ok(false, "non-HTTPS pages cannot register ServiceWorkers");

View File

@ -50,10 +50,7 @@ function removeAddon(addon)
}
add_task(function* test_addon_shims() {
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({set: [["dom.ipc.shims.enabledWarnings", true]]},
resolve);
});
yield SpecialPowers.pushPrefEnv({set: [["dom.ipc.shims.enabledWarnings", true]]});
let addon = yield addAddon(ADDON_URL);
yield window.runAddonShimTests({ok: ok, is: is, info: info});

View File

@ -48,9 +48,9 @@ add_task(function* test_simple() {
* Moving back in history should set hasInsecureLoginForms to true again.
*/
add_task(function* test_subframe_navigation() {
yield new Promise(resolve => SpecialPowers.pushPrefEnv({
yield SpecialPowers.pushPrefEnv({
"set": [["security.mixed_content.block_active_content", false]],
}, resolve));
});
// Load the page with the subframe in a new tab.
let tab = gBrowser.addTab("https" + testUrlPath + "insecure_test.html");

View File

@ -21,7 +21,7 @@ function promiseObserve(name)
add_task(function* ()
{
yield new Promise(resolve => SpecialPowers.pushPrefEnv({"set": [["places.history.enabled", false]]}, resolve));
yield SpecialPowers.pushPrefEnv({"set": [["places.history.enabled", false]]});
let visitUriPromise = promiseObserve("uri-visit-saved");

View File

@ -106,8 +106,7 @@ add_task(function* test() {
let multiprocess = Services.appinfo.browserTabsRemoteAutostart;
// Set these prefs to ensure that we get measurements.
const prefs = {"set": [["javascript.options.mem.notify", true]]};
yield new Promise(resolve => SpecialPowers.pushPrefEnv(prefs, resolve));
yield SpecialPowers.pushPrefEnv({"set": [["javascript.options.mem.notify", true]]});
function runRemote(f) {
gBrowser.selectedBrowser.messageManager.loadFrameScript(`data:,(${f})()`, false);

View File

@ -1,9 +1,7 @@
let tempFile;
add_task(function* setup() {
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": [["ui.tooltipDelay", 0]]}, resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [["ui.tooltipDelay", 0]]});
tempFile = createTempFile();
registerCleanupFunction(function() {
tempFile.remove(true);

View File

@ -184,9 +184,7 @@ function* openDocumentSelect(aURI, aCSSSelector) {
}
function pushPrefs(...aPrefs) {
return new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": aPrefs}, resolve);
});
return SpecialPowers.pushPrefEnv({"set": aPrefs});
}
function waitForPrefChange(pref) {

View File

@ -61,12 +61,11 @@ function play_non_autoplay_audio() {
}
add_task(function* setup_test_preference() {
yield new Promise(resolve => {
yield
SpecialPowers.pushPrefEnv({"set": [
["dom.audiochannel.audioCompeting", true],
["dom.ipc.processCount", 1]
]}, resolve);
});
]});
});
add_task(function* cross_tabs_audio_competing() {

View File

@ -32,12 +32,10 @@ function check_audio_suspended(suspendedType) {
}
add_task(function* setup_test_preference() {
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": [
["media.useAudioChannelService.testing", true],
["media.block-autoplay-until-in-foreground", true]
]}, resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [
["media.useAudioChannelService.testing", true],
["media.block-autoplay-until-in-foreground", true]
]});
});
add_task(function* block_autoplay_media() {

View File

@ -2,7 +2,7 @@ requestLongerTimeout(2);
add_task(function* ()
{
function pushPref(name, value) {
return new Promise(resolve => SpecialPowers.pushPrefEnv({"set": [[name, value]]}, resolve));
return SpecialPowers.pushPrefEnv({"set": [[name, value]]});
}
yield pushPref("general.autoScroll", true);

View File

@ -75,11 +75,9 @@ function* test_visibility(url, browser) {
}
add_task(function*() {
yield new Promise((resolve) => {
SpecialPowers.pushPrefEnv({"set": [
["media.useAudioChannelService.testing", true]
]}, resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [
["media.useAudioChannelService.testing", true]
]});
});
add_task(function* test_page() {

View File

@ -155,11 +155,9 @@ function* suspended_block(url, browser) {
}
add_task(function* setup_test_preference() {
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": [
["media.useAudioChannelService.testing", true]
]}, resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [
["media.useAudioChannelService.testing", true]
]});
});
add_task(function* test_suspended_pause() {

View File

@ -275,11 +275,9 @@ function* suspended_block(url, browser) {
}
add_task(function* setup_test_preference() {
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": [
["media.useAudioChannelService.testing", true]
]}, resolve);
});
yield SpecialPowers.pushPrefEnv({"set": [
["media.useAudioChannelService.testing", true]
]});
});
add_task(function* test_suspended_pause() {

View File

@ -105,10 +105,8 @@
function onLoad() {
Task.spawn(function* () {
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv(
{ set: [["findbar.entireword", true]] }, resolve);
});
yield SpecialPowers.pushPrefEnv(
{ set: [["findbar.entireword", true]] });
gFindBar = document.getElementById("FindToolbar");
for (let browserId of ["content", "content-remote"]) {