tor-browser

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

commit 6fc4d80da972add168853e007d931a7c65f0a1cd
parent 0cedc90ce15498dcb3566eec4f6a26a68066b668
Author: agoloman <agoloman@mozilla.com>
Date:   Tue,  2 Dec 2025 02:55:01 +0200

Revert "Bug 1709063 - Stop exposing toolbox.resourceCommand. r=devtools-reviewers,jdescottes" for causing bc failures @browser_ext_devtools_network_targetSwitch.js.

This reverts commit 645ce0098b3f0587ee4da48124a29dce418b50e6.

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++++++++++++--------------
14 files changed, 54 insertions(+), 59 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.commands.resourceCommand, + resourceCommand: this.toolbox.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.commands; + const { resourceCommand } = toolbox; function onAvailable(sources) { for (const source of sources) { diff --git a/devtools/client/framework/toolbox.js b/devtools/client/framework/toolbox.js @@ -947,6 +947,9 @@ 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) @@ -979,10 +982,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.commands.resourceCommand.TYPES.CONSOLE_MESSAGE, - this.commands.resourceCommand.TYPES.ERROR_MESSAGE, - this.commands.resourceCommand.TYPES.DOCUMENT_EVENT, - this.commands.resourceCommand.TYPES.THREAD_STATE, + this.resourceCommand.TYPES.CONSOLE_MESSAGE, + this.resourceCommand.TYPES.ERROR_MESSAGE, + this.resourceCommand.TYPES.DOCUMENT_EVENT, + this.resourceCommand.TYPES.THREAD_STATE, ]; let tracerInitialization; @@ -992,9 +995,7 @@ Toolbox.prototype = { false ) ) { - watchedResources.push( - this.commands.resourceCommand.TYPES.JSTRACER_STATE - ); + watchedResources.push(this.resourceCommand.TYPES.JSTRACER_STATE); tracerInitialization = this.commands.tracerCommand.initialize(); this.onTracerToggled = this.onTracerToggled.bind(this); this.commands.tracerCommand.on("toggle", this.onTracerToggled); @@ -1006,12 +1007,10 @@ 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.commands.resourceCommand.TYPES.NETWORK_EVENT - ); + watchedResources.push(this.resourceCommand.TYPES.NETWORK_EVENT); } - const onResourcesWatched = this.commands.resourceCommand.watchResources( + const onResourcesWatched = this.resourceCommand.watchResources( watchedResources, { onAvailable: this._onResourceAvailable, @@ -4412,14 +4411,14 @@ Toolbox.prototype = { }); const watchedResources = [ - this.commands.resourceCommand.TYPES.CONSOLE_MESSAGE, - this.commands.resourceCommand.TYPES.ERROR_MESSAGE, - this.commands.resourceCommand.TYPES.DOCUMENT_EVENT, - this.commands.resourceCommand.TYPES.THREAD_STATE, + this.resourceCommand.TYPES.CONSOLE_MESSAGE, + this.resourceCommand.TYPES.ERROR_MESSAGE, + this.resourceCommand.TYPES.DOCUMENT_EVENT, + this.resourceCommand.TYPES.THREAD_STATE, ]; if (!this.isBrowserToolbox) { - watchedResources.push(this.commands.resourceCommand.TYPES.NETWORK_EVENT); + watchedResources.push(this.resourceCommand.TYPES.NETWORK_EVENT); } if ( @@ -4428,11 +4427,11 @@ Toolbox.prototype = { false ) ) { - watchedResources.push(this.commands.resourceCommand.TYPES.JSTRACER_STATE); + watchedResources.push(this.resourceCommand.TYPES.JSTRACER_STATE); this.commands.tracerCommand.off("toggle", this.onTracerToggled); } - this.commands.resourceCommand.unwatchResources(watchedResources, { + this.resourceCommand.unwatchResources(watchedResources, { onAvailable: this._onResourceAvailable, }); @@ -4522,6 +4521,7 @@ 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.commands.resourceCommand; + const { TYPES } = this.resourceCommand; for (const resource of resources) { const { resourceType } = resource; if ( @@ -5047,8 +5047,7 @@ 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.commands.resourceCommand.TYPES.NETWORK_EVENT && + update.resourceType === this.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.commands.resourceCommand; + return this.inspector.toolbox.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.commands.resourceCommand; + return this.inspector.toolbox.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.commands.resourceCommand; + const { TYPES } = this.toolbox.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.commands.resourceCommand.watchResources(this.#watchedResources, { + await this.toolbox.resourceCommand.watchResources(this.#watchedResources, { onAvailable: this.onResourceAvailable, }); @@ -370,7 +370,7 @@ class Inspector extends EventEmitter { if ( resource.resourceType === - this.commands.resourceCommand.TYPES.ROOT_NODE && + this.toolbox.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,16 +383,14 @@ class Inspector extends EventEmitter { // Only consider top level document, and ignore remote iframes top document if ( resource.resourceType === - this.commands.resourceCommand.TYPES.DOCUMENT_EVENT && + this.toolbox.resourceCommand.TYPES.DOCUMENT_EVENT && resource.name === "will-navigate" && isTopLevelTarget ) { this.#onWillNavigate(); } - if ( - resource.resourceType === this.commands.resourceCommand.TYPES.REFLOW - ) { + if (resource.resourceType === this.toolbox.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 @@ -1826,7 +1824,7 @@ class Inspector extends EventEmitter { onSelected: this.#onTargetSelected, onDestroyed: this.#onTargetDestroyed, }); - const { resourceCommand } = this.commands; + const { resourceCommand } = this.toolbox; resourceCommand.unwatchResources(this.#watchedResources, { onAvailable: this.onResourceAvailable, }); diff --git a/devtools/client/inspector/markup/markup.js b/devtools/client/inspector/markup/markup.js @@ -386,7 +386,7 @@ class MarkupView extends EventEmitter { mutations: this._onWalkerMutations, }); - this.resourceCommand = this.inspector.commands.resourceCommand; + this.resourceCommand = this.inspector.toolbox.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.commands.resourceCommand; + this.resourceCommand = this.inspector.toolbox.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.commands; + const { resourceCommand } = inspector.toolbox; 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.commands.resourceCommand.watchResources( - [this.commands.resourceCommand.TYPES.DOCUMENT_EVENT], + await this.toolbox.resourceCommand.watchResources( + [this.toolbox.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.commands.resourceCommand.getAllResources( - toolbox.commands.resourceCommand.TYPES.NETWORK_EVENT + toolbox.resourceCommand.getAllResources( + toolbox.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.commands.resourceCommand.waitForNextResource( - toolbox.commands.resourceCommand.TYPES.NETWORK_EVENT, + await toolbox.resourceCommand.waitForNextResource( + toolbox.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._commands; + const { resourceCommand } = this._toolbox; 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._commands.resourceCommand.watchResources( + await this._toolbox.resourceCommand.watchResources( this._listenedResourceTypes, { onAvailable: this._onResourceListAvailable, @@ -447,7 +447,7 @@ class StorageUI { } this._destroyed = true; - const { resourceCommand } = this._commands; + const { resourceCommand } = this._toolbox; 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.#commands.resourceCommand.watchResources( - [this.#commands.resourceCommand.TYPES.DOCUMENT_EVENT], + await this.#toolbox.resourceCommand.watchResources( + [this.#toolbox.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.#commands.resourceCommand.watchResources( - [this.#commands.resourceCommand.TYPES.STYLESHEET], + await this.#toolbox.resourceCommand.watchResources( + [this.#toolbox.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.#commands.resourceCommand.getAllResources( - this.#commands.resourceCommand.TYPES.STYLESHEET + for (const resource of this.#toolbox.resourceCommand.getAllResources( + this.#toolbox.resourceCommand.TYPES.STYLESHEET )) { await this.#handleStyleSheetResource(resource); } @@ -1640,8 +1640,7 @@ export class StyleEditorUI extends EventEmitter { const promises = []; for (const resource of resources) { if ( - resource.resourceType === - this.#commands.resourceCommand.TYPES.STYLESHEET + resource.resourceType === this.#toolbox.resourceCommand.TYPES.STYLESHEET ) { const onStyleSheetHandled = this.#handleStyleSheetResource(resource); @@ -1682,7 +1681,7 @@ export class StyleEditorUI extends EventEmitter { for (const { resource, update } of updates) { if ( - update.resourceType === this.#commands.resourceCommand.TYPES.STYLESHEET + update.resourceType === this.#toolbox.resourceCommand.TYPES.STYLESHEET ) { const editor = this.editors.find( e => e.resourceId === update.resourceId @@ -1721,8 +1720,7 @@ export class StyleEditorUI extends EventEmitter { #onResourceDestroyed = resources => { for (const resource of resources) { if ( - resource.resourceType !== - this.#commands.resourceCommand.TYPES.STYLESHEET + resource.resourceType !== this.#toolbox.resourceCommand.TYPES.STYLESHEET ) { continue; } @@ -1852,10 +1850,10 @@ export class StyleEditorUI extends EventEmitter { } destroy() { - this.#commands.resourceCommand.unwatchResources( + this.#toolbox.resourceCommand.unwatchResources( [ - this.#commands.resourceCommand.TYPES.DOCUMENT_EVENT, - this.#commands.resourceCommand.TYPES.STYLESHEET, + this.#toolbox.resourceCommand.TYPES.DOCUMENT_EVENT, + this.#toolbox.resourceCommand.TYPES.STYLESHEET, ], { onAvailable: this.#onResourceAvailable,