Bug 1395807 - Waiting for "sync-pane-loaded" event for fixing browser_notification_open_settings intermittent r=jaws
authorRicky Chien <ricky060709@gmail.com>
Tue, 05 Sep 2017 15:51:41 +0800
changeset 428753 76dfca6d5a333c2594f011e988c8433c6e494a50
parent 428752 023df6da913b1312cc6a602307d6e9d237703f22
child 428754 6f185e25c9d716565d4ffbd033e796f7a54df040
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1395807
milestone57.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 1395807 - Waiting for "sync-pane-loaded" event for fixing browser_notification_open_settings intermittent r=jaws MozReview-Commit-ID: 3gCKPsmz3tb
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
@@ -4,37 +4,43 @@ var notificationURL = "http://example.or
 var expectedURL = "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);
     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");
+    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);
 
   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);
+
       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;
@@ -44,16 +50,17 @@ add_task(async function test_settingsOpe
       let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, expectedURL);
       let openSettingsMenuItem = alertWindow.document.getElementById("openSettingsMenuItem");
       openSettingsMenuItem.click();
 
       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);
     });
   } finally {
     info("Removing notification permission");
     pm.remove(makeURI(notificationURL), "desktop-notification");
   }
 });