Bug 1647727 - beta patch - make SelectParent find ZoomManager on the top window (fix dropdowns in add-on manager), r=emilio, a=jcristau
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 24 Jun 2020 11:04:42 +0000
changeset 600875 9ec0743afec64d78dd18cae6dded9a53ef616266
parent 600874 b5978abe3238692e75bb2877def29ac83148d777
child 600876 2c4b83fa228b35762d6c17179c8e39f28c7eeba8
push id2364
push userjcristau@mozilla.com
push dateThu, 25 Jun 2020 15:29:58 +0000
treeherdermozilla-release@52486654c09a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio, jcristau
bugs1647727
milestone78.0
Bug 1647727 - beta patch - make SelectParent find ZoomManager on the top window (fix dropdowns in add-on manager), r=emilio, a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D80846
toolkit/actors/SelectParent.jsm
--- a/toolkit/actors/SelectParent.jsm
+++ b/toolkit/actors/SelectParent.jsm
@@ -715,37 +715,46 @@ class SelectParent extends JSWindowActor
           browser = browser.outerBrowser;
         }
 
         if (!browser.hasAttribute("selectmenulist")) {
           return;
         }
 
         let document = browser.ownerDocument;
-        let window = document.defaultView;
         let menulist = document.getElementById(
           browser.getAttribute("selectmenulist")
         );
 
         if (!this._menulist) {
           // Cache the menulist to have access to it
           // when the document is gone (eg: Tab closed)
           this._menulist = menulist;
         }
 
         let data = message.data;
         menulist.menupopup.style.direction = data.style.direction;
 
-        let zoom = window.ZoomManager.getZoomForBrowser(browser);
+        let { ZoomManager } = browser.ownerGlobal;
+        if (!ZoomManager) {
+          let bc = topBrowsingContext;
+          // The toplevel window doesn't have an embedding element. As long
+          // as there is an embedder element, find *its* top browsing context.
+          while (bc.embedderElement) {
+            bc = bc.embedderElement.ownerGlobal.docShell.browsingContext.top;
+          }
+          // Then grab the zoom manager in that top window.
+          ({ ZoomManager } = bc.associatedWindow);
+        }
         SelectParentHelper.populate(
           menulist,
           data.options.options,
           data.options.uniqueStyles,
           data.selectedIndex,
-          zoom,
+          ZoomManager.getZoomForBrowser(browser),
           data.defaultStyle,
           data.style
         );
         SelectParentHelper.open(
           browser,
           menulist,
           data.rect,
           data.isOpenedViaTouch,