--- a/devtools/client/webconsole/hudservice.js
+++ b/devtools/client/webconsole/hudservice.js
@@ -1,38 +1,36 @@
/* 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";
-var WebConsoleUtils = require("devtools/client/webconsole/utils").Utils;
-const {extend} = require("devtools/shared/extend");
-var {TargetFactory} = require("devtools/client/framework/target");
-var {gDevToolsBrowser} = require("devtools/client/framework/devtools-browser");
-var {Tools} = require("devtools/client/definitions");
var Services = require("Services");
+loader.lazyRequireGetter(this, "Utils", "devtools/client/webconsole/utils", true);
+loader.lazyRequireGetter(this, "extend", "devtools/shared/extend", true);
+loader.lazyRequireGetter(this, "TargetFactory", "devtools/client/framework/target", true);
+loader.lazyRequireGetter(this, "gDevToolsBrowser", "devtools/client/framework/devtools-browser", true);
+loader.lazyRequireGetter(this, "Tools", "devtools/client/definitions", true);
loader.lazyRequireGetter(this, "Telemetry", "devtools/client/shared/telemetry");
loader.lazyRequireGetter(this, "WebConsoleFrame", "devtools/client/webconsole/webconsole", true);
loader.lazyRequireGetter(this, "NewWebConsoleFrame", "devtools/client/webconsole/new-webconsole", true);
loader.lazyRequireGetter(this, "gDevTools", "devtools/client/framework/devtools", true);
loader.lazyRequireGetter(this, "DebuggerServer", "devtools/server/main", true);
loader.lazyRequireGetter(this, "DebuggerClient", "devtools/shared/client/debugger-client", true);
loader.lazyRequireGetter(this, "showDoorhanger", "devtools/client/shared/doorhanger", true);
loader.lazyRequireGetter(this, "viewSource", "devtools/client/shared/view-source");
-const l10n = require("devtools/client/webconsole/webconsole-l10n");
+loader.lazyRequireGetter(this, "l10n", "devtools/client/webconsole/webconsole-l10n");
const BC_WINDOW_FEATURES = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
// The preference prefix for all of the Browser Console filters.
const BC_FILTER_PREFS_PREFIX = "devtools.browserconsole.filter.";
var gHudId = 0;
-// The HUD service
-
function HUD_SERVICE() {
this.consoles = new Map();
this.lastFinishedRequest = { callback: null };
}
HUD_SERVICE.prototype =
{
_browserConsoleID: null,
@@ -343,27 +341,16 @@ WebConsole.prototype = {
* @return object
* A promise for the initialization.
*/
init() {
return this.ui.init().then(() => this);
},
/**
- * Retrieve the Web Console panel title.
- *
- * @return string
- * The Web Console panel title.
- */
- getPanelTitle() {
- let url = this.ui ? this.ui.contentLocation : "";
- return l10n.getFormatStr("webConsoleWindowTitleAndURL", [url]);
- },
-
- /**
* The JSTerm object that manages the console's input.
* @see webconsole.js::JSTerm
* @type object
*/
get jsterm() {
return this.ui ? this.ui.jsterm : null;
},
@@ -559,17 +546,17 @@ WebConsole.prototype = {
if (!this._browserConsole) {
try {
await this.target.activeTab.focus();
} catch (ex) {
// Tab focus can fail if the tab or target is closed.
}
}
- let id = WebConsoleUtils.supportsString(this.hudId);
+ let id = Utils.supportsString(this.hudId);
Services.obs.notifyObservers(id, "web-console-destroyed");
})();
return this._destroyer;
},
};
/**
@@ -616,22 +603,20 @@ BrowserConsole.prototype = extend(WebCon
ShutdownObserver.init();
this.ui._filterPrefsPrefix = BC_FILTER_PREFS_PREFIX;
let window = this.iframeWindow;
// Make sure that the closing of the Browser Console window destroys this
// instance.
- let onClose = () => {
- window.removeEventListener("unload", onClose);
+ window.addEventListener("unload", () => {
window.removeEventListener("focus", onFocus);
this.destroy();
- };
- window.addEventListener("unload", onClose);
+ }, {once: true});
this._telemetry.toolOpened("browserconsole");
// Create an onFocus handler just to display the dev edition promo.
// This is to prevent race conditions in some environments.
// Hook to display promotional Developer Edition doorhanger. Only displayed once.
let onFocus = () => showDoorhanger({ window, type: "deveditionpromo" });
window.addEventListener("focus", onFocus);