Bug 1570242 - Fetch target from toolbox instead of memoizing it on console classes. r=nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D40017

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alexandre Poirot 2019-08-21 09:47:44 +00:00
parent 36ef7ebb68
commit 23fda7ab4b
5 changed files with 27 additions and 32 deletions

View File

@ -38,13 +38,18 @@ class BrowserConsole extends WebConsole {
* @param Boolean fissionSupport
*/
constructor(target, iframeWindow, chromeWindow, fissionSupport = false) {
super(target, iframeWindow, chromeWindow, true, fissionSupport);
super(null, iframeWindow, chromeWindow, true, fissionSupport);
this._browserConsoleTarget = target;
this._telemetry = new Telemetry();
this._bcInitializer = null;
this._bcDestroyer = null;
}
get target() {
return this._browserConsoleTarget;
}
/**
* Initialize the Browser Console instance.
*

View File

@ -65,7 +65,11 @@ WebConsolePanel.prototype = {
const chromeWindow = iframe.ownerDocument.defaultView;
// Open the Web Console.
this.hud = new WebConsole(this.target, webConsoleUIWindow, chromeWindow);
this.hud = new WebConsole(
this._toolbox,
webConsoleUIWindow,
chromeWindow
);
await this.hud.init();
// Pipe 'reloaded' event from WebConsoleUI to WebConsolePanel.

View File

@ -23,19 +23,10 @@ class WebConsoleConnectionProxy {
* @param RemoteTarget target
* The target that the console will connect to.
*/
constructor(webConsoleUI, target, isBrowserConsole, fissionSupport) {
constructor(webConsoleUI, target) {
this.webConsoleUI = webConsoleUI;
this.target = target;
this.isBrowserConsole = isBrowserConsole;
this.fissionSupport = fissionSupport;
/**
* The DebuggerClient object.
*
* @see DebuggerClient
* @type object
*/
this.client = target.client;
this.fissionSupport = this.webConsoleUI.fissionSupport;
this._connecter = null;
@ -68,6 +59,7 @@ class WebConsoleConnectionProxy {
this.target.on("navigate", this._onTabNavigated);
const connection = (async () => {
this.client = this.target.client;
this.webConsoleClient = await this.target.getFront("console");
this._addWebConsoleClientEventListeners();
await this._attachConsole();
@ -384,7 +376,6 @@ class WebConsoleConnectionProxy {
this.client = null;
this.webConsoleClient = null;
this.target = null;
this.webConsoleUI = null;
}
}

View File

@ -150,13 +150,14 @@ class WebConsoleUI {
toolbox.off("select", this._onChangeSplitConsoleState);
}
this.window = this.hud = this.wrapper = null;
for (const proxy of this.getAllProxies()) {
proxy.disconnect();
}
this.proxy = null;
this.additionalProxies = null;
// Nullify `hud` last as it nullify also target which is used on destroy
this.window = this.hud = this.wrapper = null;
}
/**
@ -257,12 +258,7 @@ class WebConsoleUI {
* A promise object that is resolved/reject based on the proxies connections.
*/
async _initConnection() {
this.proxy = new WebConsoleConnectionProxy(
this,
this.hud.target,
this.isBrowserConsole,
this.fissionSupport
);
this.proxy = new WebConsoleConnectionProxy(this, this.hud.target);
if (
this.fissionSupport &&
@ -291,12 +287,7 @@ class WebConsoleUI {
}
this.additionalProxies.push(
new WebConsoleConnectionProxy(
this,
targetFront,
this.isBrowserConsole,
this.fissionSupport
)
new WebConsoleConnectionProxy(this, targetFront)
);
}
}

View File

@ -51,8 +51,8 @@ const isMacOS = Services.appinfo.OS === "Darwin";
class WebConsole {
/*
* @constructor
* @param object target
* The target that the web console will connect to.
* @param object toolbox
* The toolbox where the web console is displayed.
* @param nsIDOMWindow iframeWindow
* The window where the web console UI is already loaded.
* @param nsIDOMWindow chromeWindow
@ -60,16 +60,16 @@ class WebConsole {
* @param bool isBrowserConsole
*/
constructor(
target,
toolbox,
iframeWindow,
chromeWindow,
isBrowserConsole = false,
fissionSupport = false
) {
this.toolbox = toolbox;
this.iframeWindow = iframeWindow;
this.chromeWindow = chromeWindow;
this.hudId = "hud_" + ++gHudId;
this.target = target;
this.browserWindow = this.chromeWindow.top;
this.isBrowserConsole = isBrowserConsole;
this.fissionSupport = fissionSupport;
@ -86,6 +86,10 @@ class WebConsole {
EventEmitter.decorate(this);
}
get target() {
return this.toolbox.target;
}
/**
* Getter for the window that can provide various utilities that the web
* console makes use of, like opening links, managing popups, etc. In