Bug 1558337 - Add a workaround for RDM for ContextMenuParent.jsm to make context menus work properly. r=NeilDeakin
authorMike Conley <mconley@mozilla.com>
Tue, 18 Jun 2019 21:12:01 +0000
changeset 479139 18dee3d299c1008e64b360f718ff7fc88d14e9f9
parent 479138 053143993e495d73d3729a2c5c2ac93e9ca64c8d
child 479140 75767e9242a57f3851a9f4b7557b034749d460eb
push id36170
push usercbrindusan@mozilla.com
push dateWed, 19 Jun 2019 03:56:45 +0000
treeherdermozilla-central@5f0f37756053 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeilDeakin
bugs1558337, 1559456
milestone69.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 1558337 - Add a workaround for RDM for ContextMenuParent.jsm to make context menus work properly. r=NeilDeakin This workaround hands the top-level browser to nsContextMenu rather than the mozbrowser in the RDM case. We need to do that since RDM does a lot of work to make the inner mozbrowser _seem_ like the top-level browser, including proxying messages from that top-most browser to the underlying mozbrowser. This workaround makes us consistent with that model, and will have to do until we can get bug 1559456 fixed. Depends on D35077 Differential Revision: https://phabricator.services.mozilla.com/D35078
browser/actors/ContextMenuParent.jsm
--- a/browser/actors/ContextMenuParent.jsm
+++ b/browser/actors/ContextMenuParent.jsm
@@ -13,16 +13,28 @@ class ContextMenuParent extends JSWindow
     // It's possible that the <xul:browser> associated with this
     // ContextMenu message doesn't belong to a window that actually
     // loads nsContextMenu.js. In that case, try to find the chromeEventHandler,
     // since that'll likely be the "top" <xul:browser>, and then use its window's
     // nsContextMenu instance instead.
     if (!win.openContextMenu) {
       let topBrowser = browser.ownerGlobal.docShell.chromeEventHandler;
       win = topBrowser.ownerGlobal;
+
+      // If this context menu happens to be for a tabbed browser window,
+      // we need to check to see if we're in Responsive Design Mode. This is
+      // because we need to convince nsContextMenu to use the top-level browser
+      // for the tab, rather than the mozbrowser iframe actually showing the
+      // web content. This is a workaround until we can get bug 1559456 fixed.
+      if (win.gBrowser) {
+        let tab = win.gBrowser.getTabForBrowser(browser);
+        if (tab && tab.isResponsiveDesignMode) {
+          browser = topBrowser;
+        }
+      }
     }
 
     win.openContextMenu(message, browser, this);
   }
 
   hiding() {
     try {
       this.sendAsyncMessage("ContextMenu:Hiding", {});