Bug 1463128 - Rename WebConsoleUI.owner into WebConsoleUI.hud; r=bgrins.
☠☠ backed out by cfbfd4a35ce0 ☠ ☠
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Tue, 26 Feb 2019 14:39:03 +0000
changeset 519103 c504e9730eac775c01fe9384fc5fbb0d03103e73
parent 519102 71c093a6dace9b1b4f376ae623b38f6e7f2fcbbe
child 519104 97a1eeb8db6515ba11a95c99278bd9b20b6b248a
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1463128
milestone67.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 1463128 - Rename WebConsoleUI.owner into WebConsoleUI.hud; r=bgrins. Renaming this property makes it easier to grasp what it represents (instead of the vague `owner` term). Differential Revision: https://phabricator.services.mozilla.com/D20678
devtools/client/debugger/new/test/mochitest/helpers.js
devtools/client/webconsole/components/ConfirmDialog.js
devtools/client/webconsole/components/JSTerm.js
devtools/client/webconsole/main.js
devtools/client/webconsole/test/mochitest/head.js
devtools/client/webconsole/webconsole-ui.js
devtools/client/webconsole/webconsole-wrapper.js
--- a/devtools/client/debugger/new/test/mochitest/helpers.js
+++ b/devtools/client/debugger/new/test/mochitest/helpers.js
@@ -1525,22 +1525,22 @@ async function getDebuggerSplitConsole(d
   await toolbox.openSplitConsole();
   return toolbox.getPanel("webconsole");
 }
 
 async function openConsoleContextMenu(hud, element) {
   const onConsoleMenuOpened = hud.ui.wrapper.once("menu-open");
   synthesizeContextMenuEvent(element);
   await onConsoleMenuOpened;
-  const doc = hud.ui.wrapper.owner.chromeWindow.document;
+  const doc = hud.chromeWindow.document;
   return doc.getElementById("webconsole-menu");
 }
 
 function hideConsoleContextMenu(hud) {
-  const doc = hud.ui.wrapper.owner.chromeWindow.document;
+  const doc = hud.chromeWindow.document;
   const popup = doc.getElementById("webconsole-menu");
   if (!popup) {
     return Promise.resolve();
   }
 
   const onPopupHidden = once(popup, "popuphidden");
   popup.hidePopup();
   return onPopupHidden;
--- a/devtools/client/webconsole/components/ConfirmDialog.js
+++ b/devtools/client/webconsole/components/ConfirmDialog.js
@@ -1,16 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 loader.lazyRequireGetter(this, "PropTypes", "devtools/client/shared/vendor/react-prop-types");
-loader.lazyRequireGetter(this, "gDevTools", "devtools/client/framework/devtools", true);
 loader.lazyRequireGetter(this, "HTMLTooltip", "devtools/client/shared/widgets/tooltip/HTMLTooltip", true);
 loader.lazyRequireGetter(this, "createPortal", "devtools/client/shared/vendor/react-dom", true);
 
 // React & Redux
 const { Component } = require("devtools/client/shared/vendor/react");
 const dom = require("devtools/client/shared/vendor/react-dom-factories");
 const { connect } = require("devtools/client/shared/vendor/react-redux");
 
@@ -48,17 +47,17 @@ class ConfirmDialog extends Component {
 
     this.cancel = this.cancel.bind(this);
     this.confirm = this.confirm.bind(this);
     this.onLearnMoreClick = this.onLearnMoreClick.bind(this);
   }
 
   componentDidMount() {
     const doc = this.props.webConsoleUI.document;
-    const toolbox = gDevTools.getToolbox(this.props.webConsoleUI.owner.target);
+    const toolbox = this.props.webConsoleUI.wrapper.toolbox;
     const tooltipDoc = toolbox ? toolbox.doc : doc;
     // The popup will be attached to the toolbox document or HUD document in the case
     // such as the browser console which doesn't have a toolbox.
     this.tooltip = new HTMLTooltip(tooltipDoc, {
       className: "invoke-confirm",
     });
   }
 
--- a/devtools/client/webconsole/components/JSTerm.js
+++ b/devtools/client/webconsole/components/JSTerm.js
@@ -9,17 +9,16 @@ const Services = require("Services");
 
 loader.lazyServiceGetter(this, "clipboardHelper",
                          "@mozilla.org/widget/clipboardhelper;1",
                          "nsIClipboardHelper");
 loader.lazyRequireGetter(this, "Debugger", "Debugger");
 loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter");
 loader.lazyRequireGetter(this, "AutocompletePopup", "devtools/client/shared/autocomplete-popup");
 loader.lazyRequireGetter(this, "PropTypes", "devtools/client/shared/vendor/react-prop-types");
-loader.lazyRequireGetter(this, "gDevTools", "devtools/client/framework/devtools", true);
 loader.lazyRequireGetter(this, "KeyCodes", "devtools/client/shared/keycodes", true);
 loader.lazyRequireGetter(this, "Editor", "devtools/client/shared/sourceeditor/editor");
 loader.lazyRequireGetter(this, "Telemetry", "devtools/client/shared/telemetry");
 loader.lazyRequireGetter(this, "saveScreenshot", "devtools/shared/screenshot/save");
 loader.lazyRequireGetter(this, "focusableSelector", "devtools/client/shared/focus", true);
 
 const l10n = require("devtools/client/webconsole/webconsole-l10n");
 
@@ -120,17 +119,17 @@ class JSTerm extends Component {
       onSelect: this.onAutocompleteSelect.bind(this),
       onClick: this.acceptProposedCompletion.bind(this),
       listId: "webConsole_autocompletePopupListBox",
       position: "bottom",
       autoSelect: true,
     };
 
     const doc = this.webConsoleUI.document;
-    const toolbox = gDevTools.getToolbox(this.webConsoleUI.owner.target);
+    const toolbox = this.webConsoleUI.wrapper.toolbox;
     const tooltipDoc = toolbox ? toolbox.doc : doc;
     // The popup will be attached to the toolbox document or HUD document in the case
     // such as the browser console which doesn't have a toolbox.
     this.autocompletePopup = new AutocompletePopup(tooltipDoc, autocompleteOptions);
 
     if (this.props.codeMirrorEnabled) {
       if (this.node) {
         const onArrowUp = () => {
@@ -535,17 +534,17 @@ class JSTerm extends Component {
         case "error":
           try {
             errorMessage = l10n.getStr(helperResult.message);
           } catch (ex) {
             errorMessage = helperResult.message;
           }
           break;
         case "help":
-          this.webConsoleUI.owner.openLink(HELP_URL);
+          this.webConsoleUI.hud.openLink(HELP_URL);
           break;
         case "copyValueToClipboard":
           clipboardHelper.copyString(helperResult.value);
           break;
         case "screenshotOutput":
           const { args, value } = helperResult;
           const results = await saveScreenshot(this.webConsoleUI.window, args, value);
           this.screenshotNotify(results);
@@ -592,32 +591,32 @@ class JSTerm extends Component {
     // Append executed expression into the history list.
     this.props.appendToHistory(executeString);
 
     WebConsoleUtils.usageCount++;
     this.setInputValue("");
     this.clearCompletion();
 
     let selectedNodeActor = null;
-    const inspectorSelection = this.webConsoleUI.owner.getInspectorSelection();
+    const inspectorSelection = this.webConsoleUI.hud.getInspectorSelection();
     if (inspectorSelection && inspectorSelection.nodeFront) {
       selectedNodeActor = inspectorSelection.nodeFront.actorID;
     }
 
     const { ConsoleCommand } = require("devtools/client/webconsole/types");
     const cmdMessage = new ConsoleCommand({
       messageText: executeString,
       timeStamp: Date.now(),
     });
     this.webConsoleUI.proxy.dispatchMessageAdd(cmdMessage);
 
     let mappedExpressionRes = null;
     try {
       mappedExpressionRes =
-        await this.webConsoleUI.owner.getMappedExpression(executeString);
+        await this.webConsoleUI.hud.getMappedExpression(executeString);
     } catch (e) {
       console.warn("Error when calling getMappedExpression", e);
     }
 
     executeString = mappedExpressionRes ? mappedExpressionRes.expression : executeString;
 
     const options = {
       selectedNodeActor,
--- a/devtools/client/webconsole/main.js
+++ b/devtools/client/webconsole/main.js
@@ -3,18 +3,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
  /* global BrowserLoader */
 
 "use strict";
 
 const { BrowserLoader } = ChromeUtils.import("resource://devtools/client/shared/browser-loader.js");
 
-this.WebConsoleWrapper = function(parentNode, hud, toolbox, owner, document) {
+this.WebConsoleWrapper = function(parentNode, webConsoleUI, toolbox, document) {
   // Initialize module loader and load all modules of the new inline
   // preview feature. The entire code-base doesn't need any extra
   // privileges and runs entirely in content scope.
   const WebConsoleWrapper = BrowserLoader({
     baseURI: "resource://devtools/client/webconsole/",
     window,
   }).require("./webconsole-wrapper");
-  return new WebConsoleWrapper(parentNode, hud, toolbox, owner, document);
+  return new WebConsoleWrapper(parentNode, webConsoleUI, toolbox, document);
 };
--- a/devtools/client/webconsole/test/mochitest/head.js
+++ b/devtools/client/webconsole/test/mochitest/head.js
@@ -275,30 +275,30 @@ function findMessages(hud, text, selecto
  * @param element element
  *        The dom element on which the context menu event should be synthesized.
  * @return promise
  */
 async function openContextMenu(hud, element) {
   const onConsoleMenuOpened = hud.ui.wrapper.once("menu-open");
   synthesizeContextMenuEvent(element);
   await onConsoleMenuOpened;
-  const doc = hud.ui.wrapper.owner.chromeWindow.document;
+  const doc = hud.chromeWindow.document;
   return doc.getElementById("webconsole-menu");
 }
 
 /**
  * Hide the webconsole context menu popup. Returns a promise that will resolve when the
  * context menu popup is hidden or immediately if the popup can't be found.
  *
  * @param object hud
  *        The web console.
  * @return promise
  */
 function hideContextMenu(hud) {
-  const doc = hud.ui.wrapper.owner.chromeWindow.document;
+  const doc = hud.chromeWindow.document;
   const popup = doc.getElementById("webconsole-menu");
   if (!popup) {
     return Promise.resolve();
   }
 
   const onPopupHidden = once(popup, "popuphidden");
   popup.hidePopup();
   return onPopupHidden;
--- a/devtools/client/webconsole/webconsole-ui.js
+++ b/devtools/client/webconsole/webconsole-ui.js
@@ -27,23 +27,23 @@ const PREF_SIDEBAR_ENABLED = "devtools.w
  * that displays console log data as well as provides an interactive terminal to
  * manipulate the target's document content.
  *
  * The WebConsoleUI is responsible for the actual Web Console UI
  * implementation.
  */
 class WebConsoleUI {
   /*
-   * @param {object} webConsoleOwner: The WebConsole owner object.
+   * @param {WebConsole} hud: The WebConsole owner object.
    */
-  constructor(webConsoleOwner) {
-    this.owner = webConsoleOwner;
-    this.hudId = this.owner.hudId;
-    this.isBrowserConsole = this.owner._browserConsole;
-    this.window = this.owner.iframeWindow;
+  constructor(hud) {
+    this.hud = hud;
+    this.hudId = this.hud.hudId;
+    this.isBrowserConsole = this.hud._browserConsole;
+    this.window = this.hud.iframeWindow;
 
     this._onToolboxPrefChanged = this._onToolboxPrefChanged.bind(this);
     this._onPanelSelected = this._onPanelSelected.bind(this);
     this._onChangeSplitConsoleState = this._onChangeSplitConsoleState.bind(this);
 
     EventEmitter.decorate(this);
   }
 
@@ -81,24 +81,24 @@ class WebConsoleUI {
     this._destroyer = defer();
     Services.prefs.removeObserver(PREF_MESSAGE_TIMESTAMP, this._onToolboxPrefChanged);
     this.React = this.ReactDOM = this.FrameView = null;
     if (this.jsterm) {
       this.jsterm.destroy();
       this.jsterm = null;
     }
 
-    const toolbox = gDevTools.getToolbox(this.owner.target);
+    const toolbox = gDevTools.getToolbox(this.hud.target);
     if (toolbox) {
       toolbox.off("webconsole-selected", this._onPanelSelected);
       toolbox.off("split-console", this._onChangeSplitConsoleState);
       toolbox.off("select", this._onChangeSplitConsoleState);
     }
 
-    this.window = this.owner = this.wrapper = null;
+    this.window = this.hud = this.wrapper = null;
 
     const onDestroy = () => {
       this._destroyer.resolve(null);
     };
     if (this.proxy) {
       this.proxy.disconnect().then(onDestroy);
       this.proxy = null;
     } else {
@@ -146,17 +146,17 @@ class WebConsoleUI {
         type: "inspectObject",
         object: objectActor,
       },
     }, true);
     return this.wrapper;
   }
 
   logWarningAboutReplacedAPI() {
-    return this.owner.target.logWarningInPage(l10n.getStr("ConsoleAPIDisabled"),
+    return this.hud.target.logWarningInPage(l10n.getStr("ConsoleAPIDisabled"),
       "ConsoleAPIDisabled");
   }
 
   /**
    * Setter for saving of network request and response bodies.
    *
    * @param boolean value
    *        The new value you want to set.
@@ -185,17 +185,17 @@ class WebConsoleUI {
    *         result.
    */
   _initConnection() {
     if (this._initDefer) {
       return this._initDefer.promise;
     }
 
     this._initDefer = defer();
-    this.proxy = new WebConsoleConnectionProxy(this, this.owner.target);
+    this.proxy = new WebConsoleConnectionProxy(this, this.hud.target);
 
     this.proxy.connect().then(() => {
       // on success
       this._initDefer.resolve(this);
     }, (reason) => {
       // on failure
       // TODO Print a message to console
       this._initDefer.reject(reason);
@@ -205,20 +205,20 @@ class WebConsoleUI {
   }
 
   _initUI() {
     this.document = this.window.document;
     this.rootElement = this.document.documentElement;
 
     this.outputNode = this.document.getElementById("app-wrapper");
 
-    const toolbox = gDevTools.getToolbox(this.owner.target);
+    const toolbox = gDevTools.getToolbox(this.hud.target);
 
     this.wrapper = new this.window.WebConsoleWrapper(
-      this.outputNode, this, toolbox, this.owner, this.document);
+      this.outputNode, this, toolbox, this.document);
 
     this._initShortcuts();
     this._initOutputSyntaxHighlighting();
 
     if (toolbox) {
       toolbox.on("webconsole-selected", this._onPanelSelected);
       toolbox.on("split-console", this._onChangeSplitConsoleState);
       toolbox.on("select", this._onChangeSplitConsoleState);
@@ -294,18 +294,18 @@ class WebConsoleUI {
    *
    * @param string uri
    *        New page location.
    * @param string title
    *        New page title.
    */
   onLocationChange(uri, title) {
     this.contentLocation = uri;
-    if (this.owner.onLocationChange) {
-      this.owner.onLocationChange(uri, title);
+    if (this.hud.onLocationChange) {
+      this.hud.onLocationChange(uri, title);
     }
   }
 
   /**
    * Release an actor.
    *
    * @private
    * @param string actor
--- a/devtools/client/webconsole/webconsole-wrapper.js
+++ b/devtools/client/webconsole/webconsole-wrapper.js
@@ -23,23 +23,30 @@ const App = createFactory(require("devto
 const ObjectClient = require("devtools/shared/client/object-client");
 const LongStringClient = require("devtools/shared/client/long-string-client");
 loader.lazyRequireGetter(this, "Constants", "devtools/client/webconsole/constants");
 loader.lazyRequireGetter(this, "getElementText", "devtools/client/webconsole/utils/clipboard", true);
 
 let store = null;
 
 class WebConsoleWrapper {
-  constructor(parentNode, webConsoleUI, toolbox, owner, document) {
+  /**
+   *
+   * @param {HTMLElement} parentNode
+   * @param {WebConsoleUI} webConsoleUI
+   * @param {Toolbox} toolbox
+   * @param {Document} document
+   */
+  constructor(parentNode, webConsoleUI, toolbox, document) {
     EventEmitter.decorate(this);
 
     this.parentNode = parentNode;
     this.webConsoleUI = webConsoleUI;
     this.toolbox = toolbox;
-    this.owner = owner;
+    this.hud = this.webConsoleUI.hud;
     this.document = document;
 
     this.init = this.init.bind(this);
 
     this.queuedMessageAdds = [];
     this.queuedMessageUpdates = [];
     this.queuedRequestUpdates = [];
     this.throttledDispatchPromise = null;
@@ -48,54 +55,54 @@ class WebConsoleWrapper {
   }
 
   init() {
     return new Promise((resolve) => {
       const attachRefToWebConsoleUI = (id, node) => {
         this.webConsoleUI[id] = node;
       };
       const { webConsoleUI } = this;
-      const debuggerClient = this.owner.target.client;
+      const debuggerClient = this.hud.target.client;
 
       const serviceContainer = {
         attachRefToWebConsoleUI,
         emitNewMessage: (node, messageId, timeStamp) => {
           webConsoleUI.emit("new-messages", new Set([{
             node,
             messageId,
             timeStamp,
           }]));
         },
         proxy: webConsoleUI.proxy,
         openLink: (url, e) => {
-          webConsoleUI.owner.openLink(url, e);
+          webConsoleUI.hud.openLink(url, e);
         },
         canRewind: () => {
           if (!(
-            webConsoleUI.owner
-            && webConsoleUI.owner.target
-            && webConsoleUI.owner.target.traits
+            webConsoleUI.hud
+            && webConsoleUI.hud.target
+            && webConsoleUI.hud.target.traits
           )) {
             return false;
           }
 
-          return webConsoleUI.owner.target.traits.canRewind;
+          return webConsoleUI.hud.target.traits.canRewind;
         },
         createElement: nodename => {
           return this.document.createElement(nodename);
         },
         getLongString: (grip) => {
           return webConsoleUI.proxy.webConsoleClient.getString(grip);
         },
         requestData(id, type) {
           return webConsoleUI.proxy.networkDataProvider.requestData(id, type);
         },
         onViewSource(frame) {
-          if (webConsoleUI && webConsoleUI.owner && webConsoleUI.owner.viewSource) {
-            webConsoleUI.owner.viewSource(frame.url, frame.line);
+          if (webConsoleUI && webConsoleUI.hud && webConsoleUI.hud.viewSource) {
+            webConsoleUI.hud.viewSource(frame.url, frame.line);
           }
         },
         recordTelemetryEvent: (eventName, extra = {}) => {
           this.telemetry.recordEvent(eventName, "webconsole", null, {
             ...extra,
             "session_id": this.toolbox && this.toolbox.sessionId || -1,
           });
         },
@@ -123,17 +130,17 @@ class WebConsoleWrapper {
          * Retrieve the FrameActor ID given a frame depth, or the selected one if no
          * frame depth given.
          *
          * @param {Number} frame: optional frame depth.
          * @return {String|null}: The FrameActor ID for the given frame depth (or the
          *                        selected frame if it exists).
          */
         getFrameActor: (frame = null) => {
-          const state = this.owner.getDebuggerFrames();
+          const state = this.hud.getDebuggerFrames();
           if (!state) {
             return null;
           }
 
           const grip = Number.isInteger(frame)
             ? state.frames[frame]
             : state.frames[state.selected];
           return grip ? grip.actor : null;
@@ -150,17 +157,17 @@ class WebConsoleWrapper {
           return webConsoleUI.jsterm && webConsoleUI.jsterm.getInputValue();
         },
 
         getInputCursor: () => {
           return webConsoleUI.jsterm && webConsoleUI.jsterm.getSelectionStart();
         },
 
         getSelectedNodeActor: () => {
-          const inspectorSelection = this.owner.getInspectorSelection();
+          const inspectorSelection = this.hud.getInspectorSelection();
           if (inspectorSelection && inspectorSelection.nodeFront) {
             return inspectorSelection.nodeFront.actorID;
           }
           return null;
         },
 
         getJsTermTooltipAnchor: () => {
           if (jstermCodeMirror) {
@@ -213,27 +220,27 @@ class WebConsoleWrapper {
           openSidebar,
           rootActorId,
           executionPoint,
           toolbox: this.toolbox,
         });
 
         // Emit the "menu-open" event for testing.
         menu.once("open", () => this.emit("menu-open"));
-        menu.popup(screenX, screenY, { doc: this.owner.chromeWindow.document });
+        menu.popup(screenX, screenY, { doc: this.hud.chromeWindow.document });
 
         return menu;
       };
 
       serviceContainer.openEditContextMenu = (e) => {
         const { screenX, screenY } = e;
         const menu = createEditContextMenu(window, "webconsole-menu");
         // Emit the "menu-open" event for testing.
         menu.once("open", () => this.emit("menu-open"));
-        menu.popup(screenX, screenY, { doc: this.owner.chromeWindow.document });
+        menu.popup(screenX, screenY, { doc: this.hud.chromeWindow.document });
 
         return menu;
       };
 
       if (this.toolbox) {
         this.toolbox.threadClient.addListener("paused", this.dispatchPaused.bind(this));
         this.toolbox.threadClient.addListener(
           "progress", this.dispatchProgress.bind(this));