Backed out changeset 30e050c04c4e draft
authorMike Conley <mconley@mozilla.com>
Mon, 31 Oct 2016 16:12:51 -0400
changeset 432751 151b7ba93a46601fedbfd60e8cc3fb2170ba2d8d
parent 432738 3bfde35a0d18a643485ffd5073f3bc6a79e0ae48
child 432752 7e16a8ec76a006cd7ce0932155fc2c9dd5cb3c71
child 432781 11125951039f305710b78564ac3a19c6af48c39c
push id34415
push usermconley@mozilla.com
push dateWed, 02 Nov 2016 17:54:28 +0000
milestone52.0a1
backs out30e050c04c4e32e77a7fa4afeb05c8c9f1093c30
Backed out changeset 30e050c04c4e MozReview-Commit-ID: HLTpejFKnY9
toolkit/modules/PopupNotifications.jsm
--- a/toolkit/modules/PopupNotifications.jsm
+++ b/toolkit/modules/PopupNotifications.jsm
@@ -414,17 +414,17 @@ PopupNotifications.prototype = {
 
     let existingNotification = this.getNotification(id, browser);
     if (existingNotification)
       this._remove(existingNotification);
 
     let notifications = this._getNotificationsForBrowser(browser);
     notifications.push(notification);
 
-    let isActiveBrowser = browser.docShellIsActive;
+    let isActiveBrowser = this._isActiveBrowser(browser);
     let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
     let isActiveWindow = fm.activeWindow == this.window;
 
     if (isActiveBrowser) {
       if (isActiveWindow) {
         // show panel now
         this._update(notifications, new Set([notification.anchorElement]), true);
       } else {
@@ -490,34 +490,34 @@ PopupNotifications.prototype = {
       }
 
       this._fireCallback(notification, NOTIFICATION_EVENT_REMOVED);
       return false;
     }, this);
 
     this._setNotificationsForBrowser(aBrowser, notifications);
 
-    if (aBrowser.docShellIsActive) {
+    if (this._isActiveBrowser(aBrowser)) {
       // get the anchor element if the browser has defined one so it will
       // _update will handle both the tabs iconBox and non-tab permission
       // anchors.
       this._update(notifications, this._getAnchorsForNotifications(notifications,
         getAnchorFromBrowser(aBrowser)));
     }
   },
 
   /**
    * Removes a Notification.
    * @param notification
    *        The Notification object to remove.
    */
   remove: function PopupNotifications_remove(notification) {
     this._remove(notification);
 
-    if (notification.browser.docShellIsActive) {
+    if (this._isActiveBrowser(notification.browser)) {
       let notifications = this._getNotificationsForBrowser(notification.browser);
       this._update(notifications);
     }
   },
 
   handleEvent: function (aEvent) {
     switch (aEvent.type) {
       case "popuphidden":
@@ -565,17 +565,17 @@ PopupNotifications.prototype = {
     let notifications = this._getNotificationsForBrowser(notification.browser);
     if (!notifications)
       return;
 
     var index = notifications.indexOf(notification);
     if (index == -1)
       return;
 
-    if (notification.browser.docShellIsActive)
+    if (this._isActiveBrowser(notification.browser))
       notification.anchorElement.removeAttribute(ICON_ATTRIBUTE_SHOWING);
 
     // remove the notification
     notifications.splice(index, 1);
     this._fireCallback(notification, NOTIFICATION_EVENT_REMOVED);
   },
 
   /**
@@ -1048,16 +1048,24 @@ PopupNotifications.prototype = {
       if (notification.anchorElement)
         anchors.add(notification.anchorElement)
     }
     if (defaultAnchor && !anchors.size)
       anchors.add(defaultAnchor);
     return anchors;
   },
 
+  _isActiveBrowser: function (browser) {
+    // Note: This helper only exists, because in e10s builds,
+    // we can't access the docShell of a browser from chrome.
+    return browser.docShell
+      ? browser.docShell.isActive
+      : (this.window.gBrowser.selectedBrowser == browser);
+  },
+
   _onIconBoxCommand: function PopupNotifications_onIconBoxCommand(event) {
     // Left click, space or enter only
     let type = event.type;
     if (type == "click" && event.button != 0)
       return;
 
     if (type == "keypress" &&
         !(event.charCode == Ci.nsIDOMKeyEvent.DOM_VK_SPACE ||