Bug 1383709 - Don't wait for the sync-pane-loaded notification in old prefs since it won't be fired when only viewing the Content pane. r=mconley
authorJared Wein <jwein@mozilla.com>
Mon, 24 Jul 2017 18:40:46 -0400
changeset 419805 35b75b53f9d362a04950c3914cca4d344e7c4e07
parent 419804 ec2adb85387e33602d4e7cdf6227c301b91f84e4
child 419806 a9de37a148b77e55d4222f07e7c869ef1beee672
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1383709
milestone56.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 1383709 - Don't wait for the sync-pane-loaded notification in old prefs since it won't be fired when only viewing the Content pane. r=mconley Waiting for this notification is only necessary in the 'new prefs', as detailed by the comment that I added in this patch. MozReview-Commit-ID: LpFwHrqNc0g
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
@@ -1,22 +1,28 @@
 "use strict";
 
 var notificationURL = "http://example.org/browser/browser/base/content/test/alerts/file_dom_notifications.html";
-var expectedURL = Services.prefs.getBoolPref("browser.preferences.useOldOrganization") ? "about:preferences#content"
-                                                                                       : "about:preferences#privacy";
+var useOldPrefs = Services.prefs.getBoolPref("browser.preferences.useOldOrganization");
+var expectedURL = useOldPrefs ? "about:preferences#content"
+                              : "about:preferences#privacy";
+
 
 add_task(async function test_settingsOpen_observer() {
   info("Opening a dummy tab so openPreferences=>switchToTabHavingURI doesn't use the blank tab.");
   await BrowserTestUtils.withNewTab({
     gBrowser,
     url: "about:robots"
   }, async function dummyTabTask(aBrowser) {
-    // Ensure preferences is loaded before removing the tab.
-    let syncPaneLoadedPromise = TestUtils.topicObserved("sync-pane-loaded", () => true);
+    // Ensure preferences is loaded before removing the tab. In the "new prefs", all categories
+    // get initialized on page load since we need to be able to search them. Sync is *very*
+    // slow to load and therefore we need to wait for it to load when testing the "new prefs".
+    // For "old prefs" we only load the actual visited categories so we don't have this problem,
+    // as well, the "sync-pane-loaded" notification is not sent on "old prefs".
+    let syncPaneLoadedPromise = useOldPrefs || TestUtils.topicObserved("sync-pane-loaded", () => true);
 
     let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, expectedURL);
     info("simulate a notifications-open-settings notification");
     let uri = NetUtil.newURI("https://example.com");
     let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
     Services.obs.notifyObservers(principal, "notifications-open-settings");
     let tab = await tabPromise;
     ok(tab, "The notification settings tab opened");
@@ -30,18 +36,22 @@ add_task(async function test_settingsOpe
   info("Adding notification permission");
   pm.add(makeURI(notificationURL), "desktop-notification", pm.ALLOW_ACTION);
 
   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);
+      // Ensure preferences is loaded before removing the tab. In the "new prefs", all categories
+      // get initialized on page load since we need to be able to search them. Sync is *very*
+      // slow to load and therefore we need to wait for it to load when testing the "new prefs".
+      // For "old prefs" we only load the actual visited categories so we don't have this problem,
+      // as well, the "sync-pane-loaded" notification is not sent on "old prefs".
+      let syncPaneLoadedPromise = useOldPrefs || TestUtils.topicObserved("sync-pane-loaded", () => true);
 
       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);