diff --git a/devtools/server/actors/network-monitor/network-event-actor.js b/devtools/server/actors/network-monitor/network-event-actor.js index 6f6fd6ea6f67..30561c7feb38 100644 --- a/devtools/server/actors/network-monitor/network-event-actor.js +++ b/devtools/server/actors/network-monitor/network-event-actor.js @@ -98,12 +98,6 @@ const NetworkEventActor = protocol.ActorClassWithSpec(networkEventSpec, { * Returns a grip for this actor. */ asResource() { - // The browsingContextID is used by the ResourceCommand on the client - // to find the related Target Front. - const browsingContextID = this._browsingContextID - ? this._browsingContextID - : -1; - // Ensure that we have a browsing context ID for all requests when debugging a tab (=`browserId` is defined). // Only privileged requests debugged via the Browser Toolbox (=`browserId` null) can be unrelated to any browsing context. if (!this._browsingContextID && this._networkEventWatcher.browserId) { @@ -111,6 +105,18 @@ const NetworkEventActor = protocol.ActorClassWithSpec(networkEventSpec, { `Got a request ${this._request.url} without a browsingContextID set` ); } + + // The browsingContextID is used by the ResourceCommand on the client + // to find the related Target Front. + // + // For now in the browser toolbox (where watcher.browserId is undefined), + // do not relate requests to any WindowGlobalTargetActor + // as we are still using a unique target (ParentProcessTargetActor) for everything. + const browsingContextID = + this._browsingContextID && this._networkEventWatcher.browserId + ? this._browsingContextID + : -1; + return { resourceType: NETWORK_EVENT, browsingContextID, diff --git a/devtools/server/actors/resources/network-events.js b/devtools/server/actors/resources/network-events.js index 0eb8d84f1fcb..f130e0e5d5c1 100644 --- a/devtools/server/actors/resources/network-events.js +++ b/devtools/server/actors/resources/network-events.js @@ -154,7 +154,8 @@ class NetworkEventWatcher { return; } // If we persist, we will keep all requests allocated. - if (this.persist) { + // For now, consider that the Browser console and toolbox persist all the requests. + if (this.persist || this.watcherActor.context.type == "all") { return; } // If the watcher is bound to one browser element (i.e. a tab), ignore @@ -189,7 +190,7 @@ class NetworkEventWatcher { } else if ( child.innerWindowId != innerWindowId && windowGlobal.browsingContext == - this.watcherActor.browserElement.browsingContext + this.watcherActor.browserElement?.browsingContext ) { child.destroy(); } diff --git a/devtools/server/actors/watcher.js b/devtools/server/actors/watcher.js index 94a5e452f58a..0afe10e71848 100644 --- a/devtools/server/actors/watcher.js +++ b/devtools/server/actors/watcher.js @@ -229,8 +229,8 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, { [Resources.TYPES.LOCAL_STORAGE]: shouldEnableAllWatchers, [Resources.TYPES.SESSION_STORAGE]: shouldEnableAllWatchers, [Resources.TYPES.PLATFORM_MESSAGE]: true, - [Resources.TYPES.NETWORK_EVENT]: shouldEnableAllWatchers, - [Resources.TYPES.NETWORK_EVENT_STACKTRACE]: shouldEnableAllWatchers, + [Resources.TYPES.NETWORK_EVENT]: true, + [Resources.TYPES.NETWORK_EVENT_STACKTRACE]: true, [Resources.TYPES.REFLOW]: true, [Resources.TYPES.STYLESHEET]: shouldEnableAllWatchers, [Resources.TYPES.SOURCE]: shouldEnableAllWatchers, diff --git a/devtools/shared/commands/resource/resource-command.js b/devtools/shared/commands/resource/resource-command.js index 436ae899e5fe..6c0eaf541863 100644 --- a/devtools/shared/commands/resource/resource-command.js +++ b/devtools/shared/commands/resource/resource-command.js @@ -822,10 +822,7 @@ class ResourceCommand { return null; } - if ( - innerWindowId && - this.targetCommand.descriptorFront.isServerTargetSwitchingEnabled() - ) { + if (innerWindowId && this.targetCommand.isServerTargetSwitchingEnabled()) { return this.watcherFront.getWindowGlobalTargetByInnerWindowId( innerWindowId );