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 draft
authorJared Wein <jwein@mozilla.com>
Mon, 24 Jul 2017 18:40:46 -0400
changeset 614762 9177edbe23d499861b999be4633057bf0f778e1f
parent 614761 83695d4b601f9d175804c64ebc7c8611065350cc
child 638948 1b6bb14f459d350cab98dc70bc5446c7885a5b9f
push id70106
push userbmo:jaws@mozilla.com
push dateMon, 24 Jul 2017 22:42:04 +0000
reviewersmconley
bugs1383709
milestone56.0a1
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);