Bug 1689459 - [devtools] Enable server side NETWORK resources for the browser toolbox. r=bomsy

In this patch we need to ensure that all NETWORK resources work correctly for the browser toolbox.

The main fix was to ensure that all Network resources were emitted by browsingContextID set to -1,
otherwise the ResourceCommand may try to lookup for the related target and won't find it.
That's because the browser toolbox uses a unique target for all parent process requests,
and still doesn't use EFT. So same-process iframe should still be debugged by their parent document target.

Also ResourceCommand used isServerTargetSwitchingEnabled on descriptor front,
but for now, only TabDescriptorFront exposes this method.

Differential Revision: https://phabricator.services.mozilla.com/D103770
This commit is contained in:
Alexandre Poirot 2021-12-16 14:57:10 +00:00
Родитель 5fcf60819d
Коммит 6c77e27255
4 изменённых файлов: 18 добавлений и 14 удалений

Просмотреть файл

@ -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,

Просмотреть файл

@ -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();
}

Просмотреть файл

@ -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,

Просмотреть файл

@ -822,10 +822,7 @@ class ResourceCommand {
return null;
}
if (
innerWindowId &&
this.targetCommand.descriptorFront.isServerTargetSwitchingEnabled()
) {
if (innerWindowId && this.targetCommand.isServerTargetSwitchingEnabled()) {
return this.watcherFront.getWindowGlobalTargetByInnerWindowId(
innerWindowId
);