commit 645ce0098b3f0587ee4da48124a29dce418b50e6
parent 4e1d5ad706a238ce6e47afc444edef1f83955662
Author: Lorenz A <me@lorenzackermann.xyz>
Date: Mon, 1 Dec 2025 23:40:27 +0000
Bug 1709063 - Stop exposing toolbox.resourceCommand. r=devtools-reviewers,jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D274322
Diffstat:
14 files changed, 59 insertions(+), 54 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
@@ -386,7 +386,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);
}
@@ -1640,7 +1640,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);
@@ -1681,7 +1682,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
@@ -1720,7 +1721,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;
}
@@ -1850,10 +1852,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,