Bug 1398491 - Use SpecialPowers.pushPermissions instead of Services.perms.add in browser_notification_open_settings.js. r=MattN
authorEdouard Oger <eoger@fastmail.com>
Mon, 09 Oct 2017 17:07:22 -0400
changeset 385259 6fe7c6bdbb5b4699d234d636ae502d70b4fa702a
parent 385258 50073b51fc10ce2ab6d4f8e51da29c9267108529
child 385260 09d2360fff588ec7c6bb534d952db6c336b894da
push id32650
push userarchaeopteryx@coole-files.de
push dateTue, 10 Oct 2017 09:13:16 +0000
treeherdermozilla-central@77a4c52e9987 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1398491
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1398491 - Use SpecialPowers.pushPermissions instead of Services.perms.add in browser_notification_open_settings.js. r=MattN MozReview-Commit-ID: NzlSA8Kt2t
browser/base/content/test/alerts/browser_notification_open_settings.js
--- a/browser/base/content/test/alerts/browser_notification_open_settings.js
+++ b/browser/base/content/test/alerts/browser_notification_open_settings.js
@@ -19,48 +19,48 @@ add_task(async function test_settingsOpe
     let tab = await tabPromise;
     ok(tab, "The notification settings tab opened");
     await syncPaneLoadedPromise;
     await BrowserTestUtils.removeTab(tab);
   });
 });
 
 add_task(async function test_settingsOpen_button() {
-  let pm = Services.perms;
   info("Adding notification permission");
-  pm.add(makeURI(notificationURL), "desktop-notification", pm.ALLOW_ACTION);
+  await new Promise(resolve => {
+    SpecialPowers.pushPermissions([{
+      type: "desktop-notification",
+      allow: true,
+      context: notificationURL,
+    }], resolve);
+  });
 
-  try {
-    await BrowserTestUtils.withNewTab({
-      gBrowser,
-      url: notificationURL
-    }, async function tabTask(aBrowser) {
-      // Ensure preferences is loaded before removing the tab.
-      let syncPaneLoadedPromise = TestUtils.topicObserved("sync-pane-loaded", () => true);
+  await BrowserTestUtils.withNewTab({
+    gBrowser,
+    url: notificationURL
+  }, async function tabTask(aBrowser) {
+    // Ensure preferences is loaded before removing the tab.
+    let syncPaneLoadedPromise = TestUtils.topicObserved("sync-pane-loaded", () => true);
 
-      info("Waiting for notification");
-      await openNotification(aBrowser, "showNotification2");
+    info("Waiting for notification");
+    await openNotification(aBrowser, "showNotification2");
 
-      let alertWindow = Services.wm.getMostRecentWindow("alert:alert");
-      if (!alertWindow) {
-        ok(true, "Notifications don't use XUL windows on all platforms.");
-        await closeNotification(aBrowser);
-        return;
-      }
-
-      let closePromise = promiseWindowClosed(alertWindow);
-      let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, expectedURL);
-      let openSettingsMenuItem = alertWindow.document.getElementById("openSettingsMenuItem");
-      openSettingsMenuItem.click();
+    let alertWindow = Services.wm.getMostRecentWindow("alert:alert");
+    if (!alertWindow) {
+      ok(true, "Notifications don't use XUL windows on all platforms.");
+      await closeNotification(aBrowser);
+      return;
+    }
 
-      info("Waiting for notification settings tab");
-      let tab = await tabPromise;
-      ok(tab, "The notification settings tab opened");
+    let closePromise = promiseWindowClosed(alertWindow);
+    let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, expectedURL);
+    let openSettingsMenuItem = alertWindow.document.getElementById("openSettingsMenuItem");
+    openSettingsMenuItem.click();
 
-      await syncPaneLoadedPromise;
-      await closePromise;
-      await BrowserTestUtils.removeTab(tab);
-    });
-  } finally {
-    info("Removing notification permission");
-    pm.remove(makeURI(notificationURL), "desktop-notification");
-  }
+    info("Waiting for notification settings tab");
+    let tab = await tabPromise;
+    ok(tab, "The notification settings tab opened");
+
+    await syncPaneLoadedPromise;
+    await closePromise;
+    await BrowserTestUtils.removeTab(tab);
+  });
 });