Bug 1561970 - BrowserTabParent should ignore browser elements related to non-tab extension pages. r=mconley a=RyanVM
authorLuca Greco <lgreco@mozilla.com>
Tue, 09 Jul 2019 20:58:51 +0000
changeset 544628 ebdd702238d977554718d55ddacf6b56e8ac666b
parent 544627 127895e5664ce792527642f050ae218e29982784
child 544629 df88785f07c89fdbee528624bcb741f24cc3fe75
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley, RyanVM
bugs1561970
milestone69.0
Bug 1561970 - BrowserTabParent should ignore browser elements related to non-tab extension pages. r=mconley a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D37051
browser/actors/BrowserTabParent.jsm
--- a/browser/actors/BrowserTabParent.jsm
+++ b/browser/actors/BrowserTabParent.jsm
@@ -8,25 +8,35 @@ var EXPORTED_SYMBOLS = ["BrowserTabParen
 class BrowserTabParent extends JSWindowActorParent {
   receiveMessage(message) {
     let browser = this.manager.browsingContext.embedderElement;
     if (!browser) {
       return; // Can happen sometimes if browser is being destroyed
     }
 
     let gBrowser = browser.ownerGlobal.gBrowser;
+
     if (!gBrowser) {
       // Note: gBrowser might be null because this message might be received
       // from the extension process. There's still an embedderElement involved,
       // but it's the one coming from dummy.xul.
       // This should probably be fixed by adding support to specifying "group: 'browsers"
       // in the registerWindowActor options/. See bug 1557118.
       return;
     }
 
+    if (!gBrowser.tabpanels || !gBrowser.tabpanels.contains(browser)) {
+      // Note: This is ignoring browser elements related to extension pages that are not loaded
+      // as a browser tab (like sidebars, devtools panels and options pages embedded into
+      // about:addons, browserAction and pageAction popup panels.
+      // (Ideally we could call gBrowser.getTabForBrowser, but it returns undefined early in
+      // the tab browser creation and we would ignore browsers related to newly created tabs).
+      return;
+    }
+
     switch (message.name) {
       case "Browser:WindowCreated": {
         gBrowser.announceWindowCreated(browser, message.data.userContextId);
         break;
       }
 
       case "Browser:FirstPaint": {
         browser.ownerGlobal.gBrowserInit._firstBrowserPaintDeferred.resolve();