# HG changeset patch # User Brian Grinstead # Date 1518020579 28800 # Node ID ea1b54a019d09b60dde7f1b8b4d7577c11fe352f # Parent 085e0ebedd25f2e9a4605b09526784294a6f7c98 Bug 1436076 - Part 3 - Miscellaneous HUDService cleanups;r=nchevobbe MozReview-Commit-ID: 6i4c48HKXhp diff --git a/devtools/client/locales/en-US/webconsole.properties b/devtools/client/locales/en-US/webconsole.properties --- a/devtools/client/locales/en-US/webconsole.properties +++ b/devtools/client/locales/en-US/webconsole.properties @@ -16,21 +16,16 @@ timestampFormat=%02S:%02S:%02S.%03S helperFuncUnsupportedTypeError=Can’t call pprint on this type of object. # LOCALIZATION NOTE (NetworkPanel.durationMS): this string is used to # show the duration between two network events (e.g request and response # header or response header and response body). Parameters: %S is the duration. NetworkPanel.durationMS=%Sms ConsoleAPIDisabled=The Web Console logging API (console.log, console.info, console.warn, console.error) has been disabled by a script on this page. -# LOCALIZATION NOTE (webConsoleWindowTitleAndURL): the Web Console floating -# panel title. For RTL languages you need to set the LRM in the string to give -# the URL the correct direction. Parameters: %S is the web page URL. -webConsoleWindowTitleAndURL=Web Console - %S - # LOCALIZATION NOTE (webConsoleXhrIndicator): the indicator displayed before # a URL in the Web Console that was requested using an XMLHttpRequest. # Should probably be the same as &btnConsoleXhr; in webConsole.dtd webConsoleXhrIndicator=XHR # LOCALIZATION NOTE (webConsoleMixedContentWarning): the message displayed # after a URL in the Web Console that has been flagged for Mixed Content (i.e. # http content in an https page). diff --git a/devtools/client/webconsole/hudservice.js b/devtools/client/webconsole/hudservice.js --- 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);