Bug 1314125 - Make PopupNotifications use tabbrowser's selectedBrowser frameLoader instead of docShellIsActive to determine the currently selected tab. r=mikedeboer
authorMike Conley <mconley@mozilla.com>
Mon, 31 Oct 2016 17:02:33 -0400
changeset 347431 2d12319aff8360717b0536da121a405c4939f0ca
parent 347430 fa12b3d50c180d26e6cae83e290da3067479c279
child 347432 d6b8b95e97b180f3294872ca26a8ab49fd1b2975
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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;