tor-browser

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

commit 5d3f9fe93efd8813fcef143738d60bc3f1ac0d7f
parent fa5bbfd5adef3cc4f78198c79dc526286387553f
Author: Lorenz A <me@lorenzackermann.xyz>
Date:   Wed,  3 Dec 2025 11:26:15 +0000

Bug 1709063 - Stop exposing toolbox.resourceCommand. r=devtools-reviewers,jdescottes,extension-reviewers,robwu

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

Diffstat:
Mdevtools/client/debugger/panel.js | 2+-
Mdevtools/client/framework/test/head.js | 2+-
Mdevtools/client/framework/toolbox.js | 41+++++++++++++++++++++--------------------
Mdevtools/client/inspector/changes/ChangesView.js | 2+-
Mdevtools/client/inspector/compatibility/CompatibilityView.js | 2+-
Mdevtools/client/inspector/inspector.js | 14++++++++------
Mdevtools/client/inspector/markup/markup.js | 2+-
Mdevtools/client/inspector/shared/highlighters-overlay.js | 2+-
Mdevtools/client/inspector/test/browser_inspector_fission_frame_navigation.js | 2+-
Mdevtools/client/netmonitor/src/har/har-automation.js | 4++--
Mdevtools/client/netmonitor/test/browser_net_clear.js | 4++--
Mdevtools/client/netmonitor/test/browser_net_pause.js | 4++--
Mdevtools/client/storage/ui.js | 6+++---
Mdevtools/client/styleeditor/StyleEditorUI.sys.mjs | 26++++++++++++++------------
Mtoolkit/components/extensions/ExtensionParent.sys.mjs | 8++++----
15 files changed, 63 insertions(+), 58 deletions(-)

diff --git a/devtools/client/debugger/panel.js b/devtools/client/debugger/panel.js @@ -101,7 +101,7 @@ class DebuggerPanel { await this.panelWin.Debugger.bootstrap({ commands: this.commands, fluentBundles: fluentL10n.getBundles(), - resourceCommand: this.toolbox.resourceCommand, + resourceCommand: this.commands.resourceCommand, workers: { sourceMapLoader: this.toolbox.sourceMapLoader, parserWorker: this.toolbox.parserWorker, diff --git a/devtools/client/framework/test/head.js b/devtools/client/framework/test/head.js @@ -141,7 +141,7 @@ function createScript(url) { function waitForSourceLoad(toolbox, url) { info(`Waiting for source ${url} to be available...`); return new Promise(resolve => { - const { resourceCommand } = toolbox; + const { resourceCommand } = toolbox.commands; function onAvailable(sources) { for (const source of sources) { diff --git a/devtools/client/framework/toolbox.js b/devtools/client/framework/toolbox.js @@ -947,9 +947,6 @@ Toolbox.prototype = { // Mount toolbox React components and update all its state that can be updated synchronously. this.onReactLoaded = this._initializeReactComponent(); - // Bug 1709063: Use commands.resourceCommand instead of toolbox.resourceCommand - this.resourceCommand = this.commands.resourceCommand; - this.commands.targetCommand.on( "target-thread-wrong-order-on-resume", this._onTargetThreadFrontResumeWrongOrder.bind(this) @@ -982,10 +979,10 @@ Toolbox.prototype = { const watchedResources = [ // Watch for console API messages, errors and network events in order to populate // the error count icon in the toolbox. - this.resourceCommand.TYPES.CONSOLE_MESSAGE, - this.resourceCommand.TYPES.ERROR_MESSAGE, - this.resourceCommand.TYPES.DOCUMENT_EVENT, - this.resourceCommand.TYPES.THREAD_STATE, + this.commands.resourceCommand.TYPES.CONSOLE_MESSAGE, + this.commands.resourceCommand.TYPES.ERROR_MESSAGE, + this.commands.resourceCommand.TYPES.DOCUMENT_EVENT, + this.commands.resourceCommand.TYPES.THREAD_STATE, ]; let tracerInitialization; @@ -995,7 +992,9 @@ Toolbox.prototype = { false ) ) { - watchedResources.push(this.resourceCommand.TYPES.JSTRACER_STATE); + watchedResources.push( + this.commands.resourceCommand.TYPES.JSTRACER_STATE + ); tracerInitialization = this.commands.tracerCommand.initialize(); this.onTracerToggled = this.onTracerToggled.bind(this); this.commands.tracerCommand.on("toggle", this.onTracerToggled); @@ -1007,10 +1006,12 @@ Toolbox.prototype = { // as tabs, in order to ensure there is always at least one listener existing // for network events across the lifetime of the various panels, so stopping // the resource command from clearing out its cache of network event resources. - watchedResources.push(this.resourceCommand.TYPES.NETWORK_EVENT); + watchedResources.push( + this.commands.resourceCommand.TYPES.NETWORK_EVENT + ); } - const onResourcesWatched = this.resourceCommand.watchResources( + const onResourcesWatched = this.commands.resourceCommand.watchResources( watchedResources, { onAvailable: this._onResourceAvailable, @@ -4411,14 +4412,14 @@ Toolbox.prototype = { }); const watchedResources = [ - this.resourceCommand.TYPES.CONSOLE_MESSAGE, - this.resourceCommand.TYPES.ERROR_MESSAGE, - this.resourceCommand.TYPES.DOCUMENT_EVENT, - this.resourceCommand.TYPES.THREAD_STATE, + this.commands.resourceCommand.TYPES.CONSOLE_MESSAGE, + this.commands.resourceCommand.TYPES.ERROR_MESSAGE, + this.commands.resourceCommand.TYPES.DOCUMENT_EVENT, + this.commands.resourceCommand.TYPES.THREAD_STATE, ]; if (!this.isBrowserToolbox) { - watchedResources.push(this.resourceCommand.TYPES.NETWORK_EVENT); + watchedResources.push(this.commands.resourceCommand.TYPES.NETWORK_EVENT); } if ( @@ -4427,11 +4428,11 @@ Toolbox.prototype = { false ) ) { - watchedResources.push(this.resourceCommand.TYPES.JSTRACER_STATE); + watchedResources.push(this.commands.resourceCommand.TYPES.JSTRACER_STATE); this.commands.tracerCommand.off("toggle", this.onTracerToggled); } - this.resourceCommand.unwatchResources(watchedResources, { + this.commands.resourceCommand.unwatchResources(watchedResources, { onAvailable: this._onResourceAvailable, }); @@ -4521,7 +4522,6 @@ Toolbox.prototype = { this._win = null; this._toolPanels.clear(); this._descriptorFront = null; - this.resourceCommand = null; this.commands = null; this._visibleIframes.clear(); @@ -4958,7 +4958,7 @@ Toolbox.prototype = { _onResourceAvailable(resources) { let errors = this._errorCount || 0; - const { TYPES } = this.resourceCommand; + const { TYPES } = this.commands.resourceCommand; for (const resource of resources) { const { resourceType } = resource; if ( @@ -5047,7 +5047,8 @@ Toolbox.prototype = { for (const { update } of resources) { // In order to match webconsole behaviour, we treat 4xx and 5xx network calls as errors. if ( - update.resourceType === this.resourceCommand.TYPES.NETWORK_EVENT && + update.resourceType === + this.commands.resourceCommand.TYPES.NETWORK_EVENT && update.resourceUpdates.status && update.resourceUpdates.status.toString().match(REGEX_4XX_5XX) ) { diff --git a/devtools/client/inspector/changes/ChangesView.js b/devtools/client/inspector/changes/ChangesView.js @@ -78,7 +78,7 @@ class ChangesView { } get resourceCommand() { - return this.inspector.toolbox.resourceCommand; + return this.inspector.commands.resourceCommand; } init() { diff --git a/devtools/client/inspector/compatibility/CompatibilityView.js b/devtools/client/inspector/compatibility/CompatibilityView.js @@ -68,7 +68,7 @@ class CompatibilityView { } get resourceCommand() { - return this.inspector.toolbox.resourceCommand; + return this.inspector.commands.resourceCommand; } async #init() { diff --git a/devtools/client/inspector/inspector.js b/devtools/client/inspector/inspector.js @@ -254,7 +254,7 @@ class Inspector extends EventEmitter { onDestroyed: this.#onTargetDestroyed, }); - const { TYPES } = this.toolbox.resourceCommand; + const { TYPES } = this.commands.resourceCommand; this.#watchedResources = [ // To observe CSS change before opening changes view. TYPES.CSS_CHANGE, @@ -272,7 +272,7 @@ class Inspector extends EventEmitter { this.#watchedResources.push(TYPES.ROOT_NODE); } - await this.toolbox.resourceCommand.watchResources(this.#watchedResources, { + await this.commands.resourceCommand.watchResources(this.#watchedResources, { onAvailable: this.onResourceAvailable, }); @@ -370,7 +370,7 @@ class Inspector extends EventEmitter { if ( resource.resourceType === - this.toolbox.resourceCommand.TYPES.ROOT_NODE && + this.commands.resourceCommand.TYPES.ROOT_NODE && // It might happen that the ROOT_NODE resource (which is a Front) is already // destroyed, and in such case we want to ignore it. !resource.isDestroyed() && @@ -383,14 +383,16 @@ class Inspector extends EventEmitter { // Only consider top level document, and ignore remote iframes top document if ( resource.resourceType === - this.toolbox.resourceCommand.TYPES.DOCUMENT_EVENT && + this.commands.resourceCommand.TYPES.DOCUMENT_EVENT && resource.name === "will-navigate" && isTopLevelTarget ) { this.#onWillNavigate(); } - if (resource.resourceType === this.toolbox.resourceCommand.TYPES.REFLOW) { + if ( + resource.resourceType === this.commands.resourceCommand.TYPES.REFLOW + ) { this.emit("reflow"); if (resource.targetFront === this.selection?.nodeFront?.targetFront) { // This event will be fired whenever a reflow is detected in the target front of the @@ -1824,7 +1826,7 @@ class Inspector extends EventEmitter { onSelected: this.#onTargetSelected, onDestroyed: this.#onTargetDestroyed, }); - const { resourceCommand } = this.toolbox; + const { resourceCommand } = this.commands; resourceCommand.unwatchResources(this.#watchedResources, { onAvailable: this.onResourceAvailable, }); diff --git a/devtools/client/inspector/markup/markup.js b/devtools/client/inspector/markup/markup.js @@ -387,7 +387,7 @@ class MarkupView extends EventEmitter { mutations: this._onWalkerMutations, }); - this.resourceCommand = this.inspector.toolbox.resourceCommand; + this.resourceCommand = this.inspector.commands.resourceCommand; this.resourceCommand.watchResources( [this.resourceCommand.TYPES.ROOT_NODE], { diff --git a/devtools/client/inspector/shared/highlighters-overlay.js b/devtools/client/inspector/shared/highlighters-overlay.js @@ -200,7 +200,7 @@ class HighlightersOverlay { // Add inspector events, not specific to a given view. this.inspector.on("markupmutation", this.onMarkupMutation); - this.resourceCommand = this.inspector.toolbox.resourceCommand; + this.resourceCommand = this.inspector.commands.resourceCommand; this.resourceCommand.watchResources( [this.resourceCommand.TYPES.ROOT_NODE], { onAvailable: this.#onResourceAvailable } diff --git a/devtools/client/inspector/test/browser_inspector_fission_frame_navigation.js b/devtools/client/inspector/test/browser_inspector_fission_frame_navigation.js @@ -104,7 +104,7 @@ async function navigateIframeTo(inspector, url) { info("Navigate the test iframe to " + url); const { commands } = inspector; - const { resourceCommand } = inspector.toolbox; + const { resourceCommand } = inspector.commands; const onTargetProcessed = waitForTargetProcessed(commands, url); const { onResource: onNewRoot } = await resourceCommand.waitForNextResource( diff --git a/devtools/client/netmonitor/src/har/har-automation.js b/devtools/client/netmonitor/src/har/har-automation.js @@ -63,8 +63,8 @@ HarAutomation.prototype = { // Automation async startMonitoring() { - await this.toolbox.resourceCommand.watchResources( - [this.toolbox.resourceCommand.TYPES.DOCUMENT_EVENT], + await this.commands.resourceCommand.watchResources( + [this.commands.resourceCommand.TYPES.DOCUMENT_EVENT], { onAvailable: resources => { // Only consider top level document, and ignore remote iframes top document diff --git a/devtools/client/netmonitor/test/browser_net_clear.js b/devtools/client/netmonitor/test/browser_net_clear.js @@ -129,8 +129,8 @@ add_task(async function () { function assertNetworkEventResourceState(expectedNoOfNetworkEventResources) { const actualNoOfNetworkEventResources = - toolbox.resourceCommand.getAllResources( - toolbox.resourceCommand.TYPES.NETWORK_EVENT + toolbox.commands.resourceCommand.getAllResources( + toolbox.commands.resourceCommand.TYPES.NETWORK_EVENT ).length; is( diff --git a/devtools/client/netmonitor/test/browser_net_pause.js b/devtools/client/netmonitor/test/browser_net_pause.js @@ -132,8 +132,8 @@ async function performRequestAndWait(tab, monitor, requestURL) { */ async function performPausedRequest(tab, monitor, toolbox) { const { onResource: waitForEventWhenPaused } = - await toolbox.resourceCommand.waitForNextResource( - toolbox.resourceCommand.TYPES.NETWORK_EVENT, + await toolbox.commands.resourceCommand.waitForNextResource( + toolbox.commands.resourceCommand.TYPES.NETWORK_EVENT, { ignoreExistingResources: true, } diff --git a/devtools/client/storage/ui.js b/devtools/client/storage/ui.js @@ -319,7 +319,7 @@ class StorageUI { this._onResourceListAvailable = this._onResourceListAvailable.bind(this); - const { resourceCommand } = this._toolbox; + const { resourceCommand } = this._commands; this._listenedResourceTypes = [ // The first item in this list will be the first selected storage item @@ -334,7 +334,7 @@ class StorageUI { if (this._commands.descriptorFront.isWebExtensionDescriptor) { this._listenedResourceTypes.push(resourceCommand.TYPES.EXTENSION_STORAGE); } - await this._toolbox.resourceCommand.watchResources( + await this._commands.resourceCommand.watchResources( this._listenedResourceTypes, { onAvailable: this._onResourceListAvailable, @@ -447,7 +447,7 @@ class StorageUI { } this._destroyed = true; - const { resourceCommand } = this._toolbox; + const { resourceCommand } = this._commands; resourceCommand.unwatchResources(this._listenedResourceTypes, { onAvailable: this._onResourceListAvailable, }); diff --git a/devtools/client/styleeditor/StyleEditorUI.sys.mjs b/devtools/client/styleeditor/StyleEditorUI.sys.mjs @@ -203,8 +203,8 @@ export class StyleEditorUI extends EventEmitter { } } - await this.#toolbox.resourceCommand.watchResources( - [this.#toolbox.resourceCommand.TYPES.DOCUMENT_EVENT], + await this.#commands.resourceCommand.watchResources( + [this.#commands.resourceCommand.TYPES.DOCUMENT_EVENT], { onAvailable: this.#onResourceAvailable } ); await this.#commands.targetCommand.watchTargets({ @@ -214,8 +214,8 @@ export class StyleEditorUI extends EventEmitter { }); this.#startLoadingStyleSheets(); - await this.#toolbox.resourceCommand.watchResources( - [this.#toolbox.resourceCommand.TYPES.STYLESHEET], + await this.#commands.resourceCommand.watchResources( + [this.#commands.resourceCommand.TYPES.STYLESHEET], { onAvailable: this.#onResourceAvailable, onUpdated: this.#onResourceUpdated, @@ -501,8 +501,8 @@ export class StyleEditorUI extends EventEmitter { // same stylesheet resources from ResourceCommand, but `_addStyleSheet` will trigger // or ignore the additional source-map mapping. this.#root.classList.add("loading"); - for (const resource of this.#toolbox.resourceCommand.getAllResources( - this.#toolbox.resourceCommand.TYPES.STYLESHEET + for (const resource of this.#commands.resourceCommand.getAllResources( + this.#commands.resourceCommand.TYPES.STYLESHEET )) { await this.#handleStyleSheetResource(resource); } @@ -1644,7 +1644,8 @@ export class StyleEditorUI extends EventEmitter { const promises = []; for (const resource of resources) { if ( - resource.resourceType === this.#toolbox.resourceCommand.TYPES.STYLESHEET + resource.resourceType === + this.#commands.resourceCommand.TYPES.STYLESHEET ) { const onStyleSheetHandled = this.#handleStyleSheetResource(resource); @@ -1685,7 +1686,7 @@ export class StyleEditorUI extends EventEmitter { for (const { resource, update } of updates) { if ( - update.resourceType === this.#toolbox.resourceCommand.TYPES.STYLESHEET + update.resourceType === this.#commands.resourceCommand.TYPES.STYLESHEET ) { const editor = this.editors.find( e => e.resourceId === update.resourceId @@ -1724,7 +1725,8 @@ export class StyleEditorUI extends EventEmitter { #onResourceDestroyed = resources => { for (const resource of resources) { if ( - resource.resourceType !== this.#toolbox.resourceCommand.TYPES.STYLESHEET + resource.resourceType !== + this.#commands.resourceCommand.TYPES.STYLESHEET ) { continue; } @@ -1854,10 +1856,10 @@ export class StyleEditorUI extends EventEmitter { } destroy() { - this.#toolbox.resourceCommand.unwatchResources( + this.#commands.resourceCommand.unwatchResources( [ - this.#toolbox.resourceCommand.TYPES.DOCUMENT_EVENT, - this.#toolbox.resourceCommand.TYPES.STYLESHEET, + this.#commands.resourceCommand.TYPES.DOCUMENT_EVENT, + this.#commands.resourceCommand.TYPES.STYLESHEET, ], { onAvailable: this.#onResourceAvailable, diff --git a/toolkit/components/extensions/ExtensionParent.sys.mjs b/toolkit/components/extensions/ExtensionParent.sys.mjs @@ -862,8 +862,8 @@ class DevToolsExtensionPageContextParent extends ExtensionPageContextParent { if (!this._onNavigatedListeners) { this._onNavigatedListeners = new Set(); - await this.devToolsToolbox.resourceCommand.watchResources( - [this.devToolsToolbox.resourceCommand.TYPES.DOCUMENT_EVENT], + await this.devToolsToolbox.commands.resourceCommand.watchResources( + [this.devToolsToolbox.commands.resourceCommand.TYPES.DOCUMENT_EVENT], { onAvailable: this._onResourceAvailable, ignoreExistingResources: true, @@ -916,8 +916,8 @@ class DevToolsExtensionPageContextParent extends ExtensionPageContextParent { } if (this._onNavigatedListeners) { - this.devToolsToolbox.resourceCommand.unwatchResources( - [this.devToolsToolbox.resourceCommand.TYPES.DOCUMENT_EVENT], + this.devToolsToolbox.commands.resourceCommand.unwatchResources( + [this.devToolsToolbox.commands.resourceCommand.TYPES.DOCUMENT_EVENT], { onAvailable: this._onResourceAvailable } ); }