Bug 1944981 - [devtools] Expose a targetType attribute on all target actor forms. r=devtools-reviewers,bomsy

This will help distinguish targets by types in the frontend, as well as in Vs Code.

Differential Revision: https://phabricator.services.mozilla.com/D236268
This commit is contained in:
Alexandre Poirot
2025-02-11 13:41:36 +00:00
parent 83d08122aa
commit 40e54fc01c
7 changed files with 24 additions and 0 deletions

View File

@@ -104,6 +104,8 @@ class WorkerDescriptorFront extends DescriptorMixin(
this.targetForm.threadActor = workerTargetForm.threadActor;
this.targetForm.tracerActor = workerTargetForm.tracerActor;
this.targetForm.targetType = workerTargetForm.targetType;
if (this.isDestroyedOrBeingDestroyed()) {
return this;
}

View File

@@ -69,6 +69,8 @@ class WorkerDescriptorActor extends Actor {
threadActor: this._threadActor,
tracerActor: this._tracerActor,
targetType: this._targetType,
id: this._dbg.id,
url: this._dbg.url,
origin: this._dbg.principal.origin,
@@ -124,6 +126,8 @@ class WorkerDescriptorActor extends Actor {
consoleActor: this._consoleActor,
threadActor: this._threadActor,
tracerActor: this._tracerActor,
targetType: this._targetType,
};
}
@@ -141,6 +145,8 @@ class WorkerDescriptorActor extends Actor {
this._threadActor = workerTargetForm.threadActor;
this._tracerActor = workerTargetForm.tracerActor;
this._targetType = workerTargetForm.targetType;
this._transport = transport;
return {
@@ -150,6 +156,8 @@ class WorkerDescriptorActor extends Actor {
threadActor: this._threadActor,
tracerActor: this._tracerActor,
targetType: this._targetType,
url: this._dbg.url,
};
} catch (error) {

View File

@@ -165,6 +165,8 @@ class ContentProcessTargetActor extends BaseTargetActor {
return {
actor: this.actorID,
targetType: this.targetType,
isXpcShellTarget: this.isXpcShellTarget,
processID: Services.appinfo.processID,
remoteType: Services.appinfo.remoteType,

View File

@@ -107,6 +107,7 @@ class WebExtensionContentScriptTargetActor extends BaseTargetActor {
return {
actor: this.actorID,
addonId: this.addonId,
targetType: this.targetType,
// Use the related extension as content script title
// as content scripts have no name, they are just a group of JS files

View File

@@ -679,6 +679,8 @@ class WindowGlobalTargetActor extends BaseTargetActor {
const response = {
actor: this.actorID,
targetType: this.targetType,
browsingContextID,
processID: Services.appinfo.processID,
// True for targets created by JSWindowActors, see constructor JSDoc.

View File

@@ -105,6 +105,7 @@ class WorkerTargetActor extends BaseTargetActor {
form() {
return {
actor: this.actorID,
targetType: this.targetType,
consoleActor: this._consoleActor?.actorID,
threadActor: this.threadActor?.actorID,

View File

@@ -709,6 +709,14 @@ class TargetCommand extends EventEmitter {
}
getTargetType(target) {
const { targetType } = target.targetForm;
if (targetType) {
return targetType;
}
// @backward-compat { version 137 } This can be removed as target.targetForm.targetType
// will always be defined. We can then remove TargetCommand.getTargetType and TargetMixin.setTargetType
// and instead have a getter like this `TargetMixin.targetType() this.targetForm.targetType`.
const { typeName } = target;
if (typeName == "windowGlobalTarget") {
return TargetCommand.TYPES.FRAME;