Bug 1346286 - Remove CPOWs from browser_bug578534.js. r=Felipe draft
authorBlake Kaplan <mrbkap@gmail.com>
Fri, 17 Feb 2017 16:52:09 -0800
changeset 499546 4343d59563b60a4b32dd904b7be14a86ff126002
parent 499545 0686a05899b0070f1673ce14340d6256409ab5aa
child 499547 3cf6bf2c48622e9c9af2ed473e40f791ab2b414a
push id49450
push userbmo:mrbkap@mozilla.com
push dateWed, 15 Mar 2017 23:51:54 +0000
reviewersFelipe
bugs1346286, 578534
milestone55.0a1
Bug 1346286 - Remove CPOWs from browser_bug578534.js. r=Felipe MozReview-Commit-ID: FSfxudfBSC9
browser/base/content/test/general/browser_bug578534.js
--- a/browser/base/content/test/general/browser_bug578534.js
+++ b/browser/base/content/test/general/browser_bug578534.js
@@ -1,28 +1,23 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-function test() {
+add_task(function* test() {
   let uriString = "http://example.com/";
   let cookieBehavior = "network.cookie.cookieBehavior";
   let uriObj = Services.io.newURI(uriString)
   let cp = Components.classes["@mozilla.org/cookie/permission;1"]
                      .getService(Components.interfaces.nsICookiePermission);
 
-  Services.prefs.setIntPref(cookieBehavior, 2);
-
+  yield SpecialPowers.pushPrefEnv({ set: [[ cookieBehavior, 2 ]] });
   cp.setAccess(uriObj, cp.ACCESS_ALLOW);
-  gBrowser.selectedTab = gBrowser.addTab(uriString);
-  waitForExplicitFinish();
-  BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(onTabLoaded);
 
-  function onTabLoaded() {
-    is(gBrowser.selectedBrowser.contentWindow.navigator.cookieEnabled, true,
-       "navigator.cookieEnabled should be true");
-    // Clean up
-    gBrowser.removeTab(gBrowser.selectedTab);
-    Services.prefs.setIntPref(cookieBehavior, 0);
-    cp.setAccess(uriObj, cp.ACCESS_DEFAULT);
-    finish();
-  }
-}
+  yield BrowserTestUtils.withNewTab({ gBrowser, url: uriString }, function* (browser) {
+    yield ContentTask.spawn(browser, null, function() {
+      is(content.navigator.cookieEnabled, true,
+         "navigator.cookieEnabled should be true");
+    });
+  });
+
+  cp.setAccess(uriObj, cp.ACCESS_DEFAULT);
+});