Bug 1324497 - Wait for popupshow to fix intermittent in browser_popupNotification_checkbox.js. r=past draft
authorJohann Hofmann <jhofmann@mozilla.com>
Tue, 07 Feb 2017 20:27:53 +0100
changeset 480051 1e84ed697da5ed4903c2191a6e71422362767028
parent 479958 e677ba018b22558fef1d07b74d416fd3a28a5dc3
child 544861 987a52a741aeedfed8b944d42190f93d5bf5c922
push id44442
push userbmo:jhofmann@mozilla.com
push dateTue, 07 Feb 2017 19:28:51 +0000
reviewerspast
bugs1324497
milestone54.0a1
Bug 1324497 - Wait for popupshow to fix intermittent in browser_popupNotification_checkbox.js. r=past MozReview-Commit-ID: 3EvJ5Sr7vTM
browser/base/content/test/popupNotifications/browser_popupNotification_checkbox.js
browser/base/content/test/popupNotifications/head.js
--- a/browser/base/content/test/popupNotifications/browser_popupNotification_checkbox.js
+++ b/browser/base/content/test/popupNotifications/browser_popupNotification_checkbox.js
@@ -143,19 +143,21 @@ var tests = [
       checkPopup(popup, this.notifyObj);
       let notification = popup.childNodes[0];
       let checkbox = notification.checkbox;
       checkCheckbox(checkbox, "This is a checkbox");
       yield promiseElementVisible(checkbox);
       EventUtils.synthesizeMouseAtCenter(checkbox, {});
       dismissNotification(popup);
     },
-    onHidden(popup) {
+    *onHidden(popup) {
       let icon = document.getElementById("default-notification-icon");
+      let shown = waitForNotificationPanel();
       EventUtils.synthesizeMouseAtCenter(icon, {});
+      yield shown;
       let notification = popup.childNodes[0];
       let checkbox = notification.checkbox;
       checkCheckbox(checkbox, "This is a checkbox", true);
       checkMainAction(notification, true);
       gNotification.remove();
     }
   },
 ];
--- a/browser/base/content/test/popupNotifications/head.js
+++ b/browser/base/content/test/popupNotifications/head.js
@@ -96,18 +96,18 @@ function* runNextTest() {
     onPopupEvent("popupshown", function() {
       shownState = true;
       info("[" + nextTest.id + "] popup shown");
       Task.spawn(() => nextTest.onShown(this))
           .then(undefined, ex => Assert.ok(false, "onShown failed: " + ex));
     });
     onPopupEvent("popuphidden", function() {
       info("[" + nextTest.id + "] popup hidden");
-      nextTest.onHidden(this);
-      goNext();
+      Task.spawn(() => nextTest.onHidden(this))
+          .then(() => goNext(), ex => Assert.ok(false, "onHidden failed: " + ex));
     }, () => shownState);
     info("[" + nextTest.id + "] added listeners; panel is open: " + PopupNotifications.isPanelOpen);
   }
 
   info("[" + nextTest.id + "] running test");
   yield nextTest.run();
 }