tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 369e73a43014a8fbdb63d60626eeb803daca96ad
parent fe243978fb5ce1c54509c34bfda7b9a140b0d7be
Author: Lorenz A <me@lorenzackermann.xyz>
Date:   Tue, 16 Dec 2025 08:05:07 +0000

Bug 2004242 - [devtools] Turn devtools/server/actors/webconsole/listeners/document-events.js into an ES class. r=devtools-reviewers,nchevobbe

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

Diffstat:
Mdevtools/server/actors/webconsole/listeners/document-events.js | 56++++++++++++++++++++++++++++----------------------------
1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/devtools/server/actors/webconsole/listeners/document-events.js b/devtools/server/actors/webconsole/listeners/document-events.js @@ -38,23 +38,21 @@ exports.WILL_NAVIGATE_TIME_SHIFT = WILL_NAVIGATE_TIME_SHIFT; /** * Forward `DOMContentLoaded` and `load` events with precise timing * of when events happened according to window.performance numbers. - * - * @constructor - * @param WindowGlobalTarget targetActor */ -function DocumentEventsListener(targetActor) { - this.targetActor = targetActor; - - EventEmitter.decorate(this); - this.onWillNavigate = this.onWillNavigate.bind(this); - this.onWindowReady = this.onWindowReady.bind(this); - this.onContentLoaded = this.onContentLoaded.bind(this); - this.onLoad = this.onLoad.bind(this); -} +class DocumentEventsListener extends EventEmitter { + /** + * @param {WindowGlobalTarget} targetActor + */ + constructor(targetActor) { + super(); -exports.DocumentEventsListener = DocumentEventsListener; + this.targetActor = targetActor; -DocumentEventsListener.prototype = { + this.onWillNavigate = this.onWillNavigate.bind(this); + this.onWindowReady = this.onWindowReady.bind(this); + this.onContentLoaded = this.onContentLoaded.bind(this); + this.onLoad = this.onLoad.bind(this); + } listen() { // When EFT is enabled, the Target Actor won't dispatch any will-navigate/window-ready event // Instead listen to WebProgressListener interface directly, so that we can later drop the whole @@ -88,7 +86,7 @@ DocumentEventsListener.prototype = { window: this.targetActor.window, isTopLevel: true, }); - }, + } onWillNavigate({ isTopLevel, newURI, navigationStart, isFrameSwitching }) { // Ignore iframes @@ -101,7 +99,7 @@ DocumentEventsListener.prototype = { newURI, isFrameSwitching, }); - }, + } onWindowReady({ window, isTopLevel, isFrameSwitching }) { // Ignore iframes @@ -157,7 +155,7 @@ DocumentEventsListener.prototype = { } else { this.onLoad({ target: window.document }, isFrameSwitching); } - }, + } onContentLoaded(event, isFrameSwitching) { if (this.destroyed) { @@ -169,7 +167,7 @@ DocumentEventsListener.prototype = { const window = event.target.defaultView; const time = this._getPerformanceTiming(window, "domInteractive"); this.emit("dom-interactive", { time, isFrameSwitching }); - }, + } onLoad(event, isFrameSwitching) { if (this.destroyed) { @@ -185,7 +183,7 @@ DocumentEventsListener.prototype = { isFrameSwitching, hasNativeConsoleAPI: this.hasNativeConsoleAPI(window), }); - }, + } onStateChange(progress, request, flag) { progress.QueryInterface(Ci.nsIDocShell); @@ -208,15 +206,15 @@ DocumentEventsListener.prototype = { hasNativeConsoleAPI: this.hasNativeConsoleAPI(window), }); } - }, + } /** * Tells if the window.console object is native or overwritten by script in * the page. * - * @param nsIDOMWindow window + * @param {Window} window * The window object you want to check. - * @return boolean + * @return {boolean} * True if the window.console object is native, or false otherwise. */ hasNativeConsoleAPI(window) { @@ -234,7 +232,7 @@ DocumentEventsListener.prototype = { // ignore } return isNative; - }, + } destroy() { // Also use a flag to silent onContentLoad and onLoad events @@ -252,7 +250,7 @@ DocumentEventsListener.prototype = { } catch (e) {} this.webProgress = null; } - }, + } /** * Safe getter for performance timings on the window object. @@ -275,10 +273,12 @@ DocumentEventsListener.prototype = { } return window.performance.timing[timing]; - }, + } - QueryInterface: ChromeUtils.generateQI([ + QueryInterface = ChromeUtils.generateQI([ "nsIWebProgressListener", "nsISupportsWeakReference", - ]), -}; + ]); +} + +exports.DocumentEventsListener = DocumentEventsListener;