Bug 1445261 - Change promiseTopicObserved with TestUtils.topicObserved for one occurrence r?johannh draft
authorAlex <alexandersonone@gmail.com>
Fri, 18 May 2018 09:16:48 -0700
changeset 798521 990aab74a22426745f6023b1e20848fc750c9ccc
parent 794586 ca13d24ebb3018531a01cd03fc4bf0a79dae7ed5
push id110777
push userbmo:alexandersonone@gmail.com
push dateTue, 22 May 2018 23:33:44 +0000
reviewersjohannh
bugs1445261
milestone62.0a1
Bug 1445261 - Change promiseTopicObserved with TestUtils.topicObserved for one occurrence r?johannh Removed the promiseTopicObserved function declaration from head.js. MozReview-Commit-ID: 9Oyd29fi9ef
browser/base/content/test/popupNotifications/browser_popupNotification_no_anchors.js
browser/base/content/test/popupNotifications/head.js
--- a/browser/base/content/test/popupNotifications/browser_popupNotification_no_anchors.js
+++ b/browser/base/content/test/popupNotifications/browser_popupNotification_no_anchors.js
@@ -162,17 +162,17 @@ var tests = [
     async run() {
       for (let persistent of [false, true]) {
         // Start editing the URL, ensuring that the awesomebar popup is hidden.
         gURLBar.select();
         EventUtils.sendString("*");
         EventUtils.synthesizeKey("KEY_Backspace");
 
         // Trying to show a notification should display nothing.
-        let notShowing = promiseTopicObserved("PopupNotifications-updateNotShowing");
+        let notShowing = TestUtils.topicObserved("PopupNotifications-updateNotShowing");
         this.notifyObj = new BasicNotification(this.id);
         this.notifyObj.anchorID = "geo-notification-icon";
         this.notifyObj.addOptions({ persistent });
         this.notification = showNotification(this.notifyObj);
         await notShowing;
 
         // Reverting the URL should show the notification.
         let shown = waitForNotificationPanel();
--- a/browser/base/content/test/popupNotifications/head.js
+++ b/browser/base/content/test/popupNotifications/head.js
@@ -1,34 +1,14 @@
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 ChromeUtils.defineModuleGetter(this, "PlacesUtils",
   "resource://gre/modules/PlacesUtils.jsm");
 
 /**
- * Allows waiting for an observer notification once.
- *
- * @param topic
- *        Notification topic to observe.
- *
- * @return {Promise}
- * @resolves The array [subject, data] from the observed notification.
- * @rejects Never.
- */
-function promiseTopicObserved(topic) {
-  return new Promise(resolve => {
-    info("Waiting for observer topic " + topic);
-    Services.obs.addObserver(function PTO_observe(obsSubject, obsTopic, obsData) {
-      Services.obs.removeObserver(PTO_observe, obsTopic);
-      resolve([obsSubject, obsData]);
-    }, topic);
-  });
-}
-
-/**
  * Called after opening a new window or switching windows, this will wait until
  * we are sure that an attempt to display a notification will not fail.
  */
 async function waitForWindowReadyForPopupNotifications(win) {
   // These are the same checks that PopupNotifications.jsm makes before it
   // allows a notification to open.
   await BrowserTestUtils.waitForCondition(
     () => win.gBrowser.selectedBrowser.docShellIsActive,