Bug 1314125 - Make PopupNotifications use tabbrowser's selectedBrowser frameLoader instead of docShellIsActive to determine the currently selected tab. r?mikedeboer draft
authorMike Conley <mconley@mozilla.com>
Mon, 31 Oct 2016 17:02:33 -0400
changeset 432781 11125951039f305710b78564ac3a19c6af48c39c
parent 432751 151b7ba93a46601fedbfd60e8cc3fb2170ba2d8d
child 432787 6d9d913293cf60f8acbf438232331c37b8dfbc07
push id34420
push usermconley@mozilla.com
push dateWed, 02 Nov 2016 19:29:22 +0000
reviewersmikedeboer
bugs1314125
milestone52.0a1
Bug 1314125 - Make PopupNotifications use tabbrowser's selectedBrowser frameLoader instead of docShellIsActive to determine the currently selected tab. r?mikedeboer See inline documentation for why I'm using the frameLoader instead of just directly comparing the selectedBrowser to the browser requesting the prompt. MozReview-Commit-ID: D9ahuth6eLC
toolkit/modules/PopupNotifications.jsm
--- a/toolkit/modules/PopupNotifications.jsm
+++ b/toolkit/modules/PopupNotifications.jsm
@@ -1049,21 +1049,32 @@ PopupNotifications.prototype = {
         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);
+    // We compare on frameLoader instead of just comparing the
+    // selectedBrowser and browser directly because browser tabs in
+    // Responsive Design Mode put the actual web content into a
+    // mozbrowser iframe and proxy property read/write and method
+    // calls from the tab to that iframe. This is so that attempts
+    // to reload the tab end up reloading the content in
+    // Responsive Design Mode, and not the Responsive Design Mode
+    // viewer itself.
+    //
+    // This means that PopupNotifications can come up from a browser
+    // in Responsive Design Mode, but the selectedBrowser will not match
+    // the browser being passed into this function, despite the browser
+    // actually being within the selected tab. We workaround this by
+    // comparing frameLoader instead, which is proxied from the outer
+    // <xul:browser> to the inner mozbrowser <iframe>.
+    return this.tabbrowser.selectedBrowser.frameLoader == browser.frameLoader;
   },
 
   _onIconBoxCommand: function PopupNotifications_onIconBoxCommand(event) {
     // Left click, space or enter only
     let type = event.type;
     if (type == "click" && event.button != 0)
       return;