Bug 1583444 - Stop using window.top in WebConsole codebase r=nchevobbe
authorJulian Descottes <jdescottes@mozilla.com>
Mon, 30 Sep 2019 09:51:44 +0000
changeset 495616 b4dca3917f04471ed4af04cba7b040ee10fad7e8
parent 495615 c6d0570a09eed3bb6e15073d61175ff4e312407b
child 495617 6f09a19d3fa4c010f16ad16c0996041f9e0d638b
push id114140
push userdvarga@mozilla.com
push dateWed, 02 Oct 2019 18:04:51 +0000
treeherdermozilla-inbound@32eb0ea893f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnchevobbe
bugs1583444
milestone71.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 1583444 - Stop using window.top in WebConsole codebase r=nchevobbe This changesets removes some webconsole callsites that were relying on window.top, but didn't trigger any regression. Differential Revision: https://phabricator.services.mozilla.com/D46957
devtools/client/webconsole/webconsole-ui.js
devtools/client/webconsole/webconsole.js
--- a/devtools/client/webconsole/webconsole-ui.js
+++ b/devtools/client/webconsole/webconsole-ui.js
@@ -392,20 +392,19 @@ class WebConsoleUI {
     }
 
     shortcuts.on(clearShortcut, event => this.clearOutput(true, event));
 
     if (this.isBrowserConsole) {
       // Make sure keyboard shortcuts work immediately after opening
       // the Browser Console (Bug 1461366).
       this.window.focus();
-
       shortcuts.on(
         l10n.getStr("webconsole.close.key"),
-        this.window.top.close.bind(this.window.top)
+        this.window.close.bind(this.window)
       );
 
       ZoomKeys.register(this.window, shortcuts);
       shortcuts.on("CmdOrCtrl+Alt+R", quickRestart);
     } else if (Services.prefs.getBoolPref(PREF_SIDEBAR_ENABLED)) {
       shortcuts.on("Esc", event => {
         this.wrapper.dispatchSidebarClose();
         if (this.jsterm) {
--- a/devtools/client/webconsole/webconsole.js
+++ b/devtools/client/webconsole/webconsole.js
@@ -29,16 +29,21 @@ loader.lazyRequireGetter(
   "devtools/client/shared/view-source"
 );
 loader.lazyRequireGetter(
   this,
   "openDocLink",
   "devtools/client/shared/link",
   true
 );
+loader.lazyRequireGetter(
+  this,
+  "DevToolsUtils",
+  "devtools/shared/DevToolsUtils"
+);
 const EventEmitter = require("devtools/shared/event-emitter");
 
 var gHudId = 0;
 const isMacOS = Services.appinfo.OS === "Darwin";
 
 /**
  * A WebConsole instance is an interactive console initialized *per target*
  * that displays console log data as well as provides an interactive terminal to
@@ -59,17 +64,17 @@ class WebConsole {
    *        The window of the web console owner.
    * @param bool isBrowserConsole
    */
   constructor(toolbox, iframeWindow, chromeWindow, isBrowserConsole = false) {
     this.toolbox = toolbox;
     this.iframeWindow = iframeWindow;
     this.chromeWindow = chromeWindow;
     this.hudId = "hud_" + ++gHudId;
-    this.browserWindow = this.chromeWindow.top;
+    this.browserWindow = DevToolsUtils.getTopWindow(this.chromeWindow);
     this.isBrowserConsole = isBrowserConsole;
 
     const element = this.browserWindow.document.documentElement;
     if (element.getAttribute("windowtype") != gDevTools.chromeWindowType) {
       this.browserWindow = Services.wm.getMostRecentWindow(
         gDevTools.chromeWindowType
       );
     }
@@ -90,17 +95,17 @@ class WebConsole {
    * the Browser Toolbox), there is no browser window, so an alternative window
    * hosts the utilities there.
    * @type nsIDOMWindow
    */
   get chromeUtilsWindow() {
     if (this.browserWindow) {
       return this.browserWindow;
     }
-    return this.chromeWindow.top;
+    return DevToolsUtils.getTopWindow(this.chromeWindow);
   }
 
   get gViewSourceUtils() {
     return this.chromeUtilsWindow.gViewSourceUtils;
   }
 
   /**
    * Initialize the Web Console instance.