Bug 1085691, fix notification indicator when browser window in background, r=dolske
authorShane Caraveo <scaraveo@mozilla.com>
Mon, 17 Nov 2014 14:48:14 -0800
changeset 240428 297245ad4574e26c6bf0e6130e4d4d0132b7710f
parent 240427 ad799d59abdc6cdc7eba6d283711018b288322df
child 240429 048183c75118618446e404aca685ca45fe08efab
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske
bugs1085691
milestone36.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 1085691, fix notification indicator when browser window in background, r=dolske
toolkit/modules/PopupNotifications.jsm
--- a/toolkit/modules/PopupNotifications.jsm
+++ b/toolkit/modules/PopupNotifications.jsm
@@ -309,39 +309,36 @@ PopupNotifications.prototype = {
 
     let existingNotification = this.getNotification(id, browser);
     if (existingNotification)
       this._remove(existingNotification);
 
     let notifications = this._getNotificationsForBrowser(browser);
     notifications.push(notification);
 
-    let isActive = this._isActiveBrowser(browser);
+    let isActiveBrowser = this._isActiveBrowser(browser);
     let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
-    if (isActive && fm.activeWindow == this.window) {
-      // show panel now
-      this._update(notifications, notification.anchorElement, true);
-    } else {
-      // Otherwise, update() will display the notification the next time the
-      // relevant tab/window is selected.
+    let isActiveWindow = fm.activeWindow == this.window;
 
-      // If the tab is selected but the window is in the background, let the OS
-      // tell the user that there's a notification waiting in that window.
-      // At some point we might want to do something about background tabs here
-      // too. When the user switches to this window, we'll show the panel if
-      // this browser is a tab (thus showing the anchor icon). For
-      // non-tabbrowser browsers, we need to make the icon visible now or the
-      // user will not be able to open the panel.
-      if (!notification.dismissed && isActive) {
-        this.window.getAttention();
+    if (isActiveBrowser) {
+      if (isActiveWindow) {
+        // show panel now
+        this._update(notifications, notification.anchorElement, true);
+      } else {
+        // indicate attention and update the icon if necessary
+        if (!notification.dismissed) {
+          this.window.getAttention();
+        }
         if (notification.anchorElement.parentNode != this.iconBox) {
           this._updateAnchorIcon(notifications, notification.anchorElement);
         }
+        this._notify("backgroundShow");
       }
 
+    } else {
       // Notify observers that we're not showing the popup (useful for testing)
       this._notify("backgroundShow");
     }
 
     return notification;
   },
 
   /**