Bug 1584346 - Make RDM UI's getViewportBrowser return the browser tab if fission-enabled r=mconley,bradwerth
authorMicah Tigley <mtigley@mozilla.com>
Tue, 10 Dec 2019 22:05:03 +0000
changeset 506315 160a1414094801bf8bad94166d5aa6ac14a6ca3a
parent 506314 7cfe8f83fb9f5b9b1ef4744092b3757fff47d652
child 506316 8b88919d7bd105f01caeab317698e21aeac707b6
push id36902
push useraciure@mozilla.com
push dateWed, 11 Dec 2019 03:34:51 +0000
treeherdermozilla-central@7635669b8d72 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley, bradwerth
bugs1584346, 1585096
milestone73.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 1584346 - Make RDM UI's getViewportBrowser return the browser tab if fission-enabled r=mconley,bradwerth This revision modifies RDM UI’s `getViewportBrowser` to return the tab’s <browser> instead of the <mozbrowser> this.toolWindow’s [getViewportBrowser method](https://searchfox.org/mozilla-central/source/devtools/client/responsive/index.js#176) returns. If the pref `devtools.responsive.browserUI.enabled` is set to true, this will cause this.toolWindow to be null because this object is set during the [swap step when RDM is initialized](https://searchfox.org/mozilla-central/source/devtools/client/responsive/ui.js#150). Since we're not doing away with swap/tunnel until work on RDM fission is complete, we should still preserve the toolWindow property on RDM UI. For context, this.toolWindow is a reference to the RDM UI’s window, which also happens to be populated with other properties such as `getViewportBrowser` (the function causing the issue), `getViewportSize`, `addInitialViewport`, etc… It’s responsible for holding the RDM UI chrome:// document which is also where the <mozbrowser> iframe is contained. Please see: https://searchfox.org/mozilla-central/source/devtools/client/responsive/index.js for reference on where these properties are added. Also, now that the RDM fission work requires the removal of <mozbrowser>, this.toolWindow won't be needed to get access to the toolbar UI. The RDM toolbar will be embedded into the browser UI and can be referenced with `this.rdmFrame`. So this means toolWindow along with any parts of the code using it should be removed when fission work is complete. I believe [Bug 1585096](https://bugzilla.mozilla.org/show_bug.cgi?id=1585096) would be the correct place to do this. Differential Revision: https://phabricator.services.mozilla.com/D56602
devtools/client/responsive/ui.js
--- a/devtools/client/responsive/ui.js
+++ b/devtools/client/responsive/ui.js
@@ -88,16 +88,18 @@ class ResponsiveUI {
     // Flag set when destruction has ended.
     this.destroyed = false;
     /**
      * A window reference for the chrome:// document that displays the responsive
      * design tool.  It is safe to reference this window directly even with e10s,
      * as the tool UI is always loaded in the parent process.  The web content
      * contained *within* the tool UI on the other hand is loaded in the child
      * process.
+     *
+     * TODO: we should remove this as part of Bug 1585096
      */
     this.toolWindow = null;
     // The iframe containing the RDM UI.
     this.rdmFrame = null;
 
     // Promise resovled when the UI init has completed.
     this.inited = this.init();
 
@@ -839,17 +841,20 @@ class ResponsiveUI {
     await this.inited;
     this.toolWindow.setViewportSize(size);
   }
 
   /**
    * Helper for tests/reloading the viewport. Assumes a single viewport for now.
    */
   getViewportBrowser() {
-    return this.toolWindow.getViewportBrowser();
+    if (!this.isBrowserUIEnabled) {
+      return this.toolWindow.getViewportBrowser();
+    }
+    return this.tab.linkedBrowser;
   }
 
   /**
    * Helper for contacting the viewport content. Assumes a single viewport for now.
    */
   getViewportMessageManager() {
     return this.getViewportBrowser().messageManager;
   }