Bug 1056179 - WebRTC global indicator fails to open the sharing doorhanger if there's another notification before it, r=gavin, a=lmandel.
authorFlorian Quèze <florian@queze.net>
Wed, 24 Sep 2014 12:21:57 +0200
changeset 225216 c9a8fd295d5b93443bc7df9f51d914431f457c95
parent 225215 60c435a37668722e6aa91e296f97eca9368e2133
child 225217 957f0755a414c7d185c8c8ae917628b19531a53c
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin, lmandel
bugs1056179
milestone34.0a2
Bug 1056179 - WebRTC global indicator fails to open the sharing doorhanger if there's another notification before it, r=gavin, a=lmandel.
browser/base/content/test/popupNotifications/browser_popupNotification_4.js
toolkit/modules/PopupNotifications.jsm
--- a/browser/base/content/test/popupNotifications/browser_popupNotification_4.js
+++ b/browser/base/content/test/popupNotifications/browser_popupNotification_4.js
@@ -224,10 +224,35 @@ let tests = [
       // but from a setTimeout, which is inconvenient for the test.
       PopupNotifications._update();
 
       checkPopup(popup, this.notifyObj);
 
       this.notification.remove();
     },
     onHidden: function() { }
+  },
+  // A first dismissed notification shouldn't stop _update from showing a second notification
+  { id: "Test#12",
+    run: function () {
+      this.notifyObj1 = new BasicNotification(this.id);
+      this.notifyObj1.id += "_1";
+      this.notifyObj1.anchorID = "default-notification-icon";
+      this.notifyObj1.options.dismissed = true;
+      this.notification1 = showNotification(this.notifyObj1);
+
+      this.notifyObj2 = new BasicNotification(this.id);
+      this.notifyObj2.id += "_2";
+      this.notifyObj2.anchorID = "geo-notification-icon";
+      this.notifyObj2.options.dismissed = true;
+      this.notification2 = showNotification(this.notifyObj2);
+
+      this.notification2.dismissed = false;
+      PopupNotifications._update();
+    },
+    onShown: function (popup) {
+      checkPopup(popup, this.notifyObj2);
+      this.notification1.remove();
+      this.notification2.remove();
+    },
+    onHidden: function(popup) { }
   }
 ];
--- a/toolkit/modules/PopupNotifications.jsm
+++ b/toolkit/modules/PopupNotifications.jsm
@@ -681,32 +681,36 @@ PopupNotifications.prototype = {
       this._hideIcons();
     }
 
     let anchorElement = anchor, notificationsToShow = [];
     if (!notifications)
       notifications = this._currentNotifications;
     let haveNotifications = notifications.length > 0;
     if (haveNotifications) {
-      // Only show the notifications that have the passed-in anchor (or the
-      // first notification's anchor, if none was passed in). Other
-      // notifications will be shown once these are dismissed.
-      anchorElement = anchor || notifications[0].anchorElement;
+      // Filter out notifications that have been dismissed.
+      notificationsToShow = notifications.filter(function (n) {
+        return !n.dismissed && !n.options.neverShow;
+      });
+
+      // If no anchor has been passed in, use the anchor of the first
+      // showable notification.
+      if (!anchorElement && notificationsToShow.length)
+        anchorElement = notificationsToShow[0].anchorElement;
 
       if (useIconBox) {
         this._showIcons(notifications);
         this.iconBox.hidden = false;
       } else if (anchorElement) {
         this._updateAnchorIcon(notifications, anchorElement);
       }
 
-      // Also filter out notifications that have been dismissed.
-      notificationsToShow = notifications.filter(function (n) {
-        return !n.dismissed && n.anchorElement == anchorElement &&
-               !n.options.neverShow;
+      // Also filter out notifications that are for a different anchor.
+      notificationsToShow = notificationsToShow.filter(function (n) {
+        return n.anchorElement == anchorElement;
       });
     }
 
     if (notificationsToShow.length > 0) {
       this._showPanel(notificationsToShow, anchorElement);
     } else {
       // Notify observers that we're not showing the popup (useful for testing)
       this._notify("updateNotShowing");