Bug 1318273 - Improve the use of SpecialPowers.pushPrefEnv() - part 2, r=qdot
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 18 Nov 2016 09:33:50 +0100
changeset 323282 671f0ae143a2678d3ec2a4218e2cfafc9424de44
parent 323281 a229803174c327c74cd4f15dd325b4b03d2528ce
child 323283 c21850fc2d088bd25b4cf1719075ba04af69f21c
push id21
push usermaklebus@msu.edu
push dateThu, 01 Dec 2016 06:22:08 +0000
reviewersqdot
bugs1318273
milestone53.0a1
Bug 1318273 - Improve the use of SpecialPowers.pushPrefEnv() - part 2, r=qdot
browser/components/sessionstore/test/head.js
browser/modules/test/browser_ProcessHangNotifications.js
dom/security/test/general/test_block_script_wrong_mime.html
dom/workers/test/serviceworkers/test_installation_simple.html
toolkit/components/places/tests/browser/browser_visituri_nohistory.js
toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js
--- a/browser/components/sessionstore/test/head.js
+++ b/browser/components/sessionstore/test/head.js
@@ -543,19 +543,17 @@ function modifySessionStorage(browser, d
   });
 }
 
 function pushPrefs(...aPrefs) {
   return SpecialPowers.pushPrefEnv({"set": aPrefs});
 }
 
 function popPrefs() {
-  return new Promise(resolve => {
-    SpecialPowers.popPrefEnv(resolve);
-  });
+  return SpecialPowers.popPrefEnv();
 }
 
 function* checkScroll(tab, expected, msg) {
   let browser = tab.linkedBrowser;
   yield TabStateFlusher.flush(browser);
 
   let scroll = JSON.parse(ss.getTabState(tab)).scroll || null;
   is(JSON.stringify(scroll), JSON.stringify(expected), msg);
--- a/browser/modules/test/browser_ProcessHangNotifications.js
+++ b/browser/modules/test/browser_ProcessHangNotifications.js
@@ -27,20 +27,17 @@ function promiseReportCallMade(aValue) {
   });
 }
 
 function pushPrefs(...aPrefs) {
   return SpecialPowers.pushPrefEnv({"set": aPrefs});
 }
 
 function popPrefs() {
-  return new Promise((resolve) => {
-    SpecialPowers.popPrefEnv(resolve);
-    resolve();
-  });
+  return SpecialPowers.popPrefEnv();
 }
 
 let gTestHangReport = {
   SLOW_SCRIPT: 1,
   PLUGIN_HANG: 2,
 
   TEST_CALLBACK_CANCELED: 1,
   TEST_CALLBACK_TERMSCRIPT: 2,
--- a/dom/security/test/general/test_block_script_wrong_mime.html
+++ b/dom/security/test/general/test_block_script_wrong_mime.html
@@ -86,15 +86,15 @@ function testWorkerImportScripts([mime, 
 
 SimpleTest.waitForExplicitFinish();
 SpecialPowers.pushPrefEnv({set: [["security.block_script_with_wrong_mime", true]]}, function() {
   Promise.all(MIMETypes.map(testScript)).then(() => {
     return Promise.all(MIMETypes.map(testWorker));
   }).then(() => {
     return Promise.all(MIMETypes.map(testWorkerImportScripts));
   }).then(() => {
-    SpecialPowers.popPrefEnv(SimpleTest.finish);
-  });
+    return SpecialPowers.popPrefEnv();
+  }).then(SimpleTest.finish);
 });
 
 </script>
 </body>
 </html>
--- a/dom/workers/test/serviceworkers/test_installation_simple.html
+++ b/dom/workers/test/serviceworkers/test_installation_simple.html
@@ -43,17 +43,17 @@
     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");
     }, function(e) {
       ok(e.name === "SecurityError", "Should fail with a SecurityError");
     }).then(function() {
-      return new Promise((resolve) => SpecialPowers.popPrefEnv(resolve));
+      return SpecialPowers.popPrefEnv();
     });
   }
 
   function realWorker() {
     var p = navigator.serviceWorker.register("worker.js", { scope: "realworker" });
     return p.then(function(wr) {
       ok(wr instanceof ServiceWorkerRegistration, "Register a ServiceWorker");
 
--- a/toolkit/components/places/tests/browser/browser_visituri_nohistory.js
+++ b/toolkit/components/places/tests/browser/browser_visituri_nohistory.js
@@ -22,17 +22,17 @@ function promiseObserve(name)
 add_task(function* ()
 {
   yield SpecialPowers.pushPrefEnv({"set": [["places.history.enabled", false]]});
 
   let visitUriPromise = promiseObserve("uri-visit-saved");
 
   yield BrowserTestUtils.openNewForegroundTab(gBrowser, INITIAL_URL);
 
-  yield new Promise(resolve => SpecialPowers.popPrefEnv(resolve));
+  yield SpecialPowers.popPrefEnv();
 
   let browserLoadedPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
   gBrowser.loadURI(FINAL_URL);
   yield browserLoadedPromise;
 
   let subject = yield visitUriPromise;
   let uri = subject.QueryInterface(Ci.nsIURI);
   is(uri.spec, FINAL_URL, "received expected visit");
--- a/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js
+++ b/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js
@@ -122,17 +122,17 @@ body > div > div {width: 1000px;height: 
 
     is(document.activeElement, gBrowser.selectedBrowser, "Browser still focused after autoscroll started");
 
     yield BrowserTestUtils.synthesizeMouse("#" + test.elem, 100, 100,
                                            { type: "mousemove", clickCount: "0" },
                                            gBrowser.selectedBrowser);
 
     if (prefsChanged) {
-      yield new Promise(resolve => SpecialPowers.popPrefEnv(resolve));
+      yield SpecialPowers.popPrefEnv();
     }
 
     // Start checking for the scroll.
     let firstTimestamp = undefined;
     let timeCompensation;
     do {
       let timestamp = yield new Promise(resolve => window.requestAnimationFrame(resolve));
       if (firstTimestamp === undefined) {