Bug 1589908 - The Worker name should be reflected in the threads pane r=bhackett

Differential Revision: https://phabricator.services.mozilla.com/D52444

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Bryan Kok 2019-12-18 10:12:15 +00:00
parent 2dd64e92cd
commit 4072abcd72
6 changed files with 10 additions and 2 deletions

View File

@ -97,7 +97,9 @@ export function createThread(actor: string, target: Target): Thread {
actor, actor,
url: target.url, url: target.url,
type: getTargetType(target), type: getTargetType(target),
name: target.name, name: target.isWorkerTarget
? target.workerName || target.name
: target.name,
serviceWorkerStatus: target.debuggerServiceWorkerStatus, serviceWorkerStatus: target.debuggerServiceWorkerStatus,
}; };
} }

View File

@ -195,6 +195,7 @@ export type Target = {
destroy: () => void, destroy: () => void,
threadFront: ThreadFront, threadFront: ThreadFront,
name: string, name: string,
workerName?: string,
isBrowsingContext: boolean, isBrowsingContext: boolean,
isContentProcess: boolean, isContentProcess: boolean,
isWorkerTarget: boolean, isWorkerTarget: boolean,

View File

@ -125,13 +125,15 @@ const WorkerTargetActor = protocol.ActorClassWithSpec(workerTargetSpec, {
} }
return connectToWorker(this.conn, this._dbg, this.actorID, options).then( return connectToWorker(this.conn, this._dbg, this.actorID, options).then(
({ threadActor, transport, consoleActor }) => { ({ workerName, threadActor, transport, consoleActor }) => {
this._workerName = workerName;
this._threadActor = threadActor; this._threadActor = threadActor;
this._transport = transport; this._transport = transport;
this._consoleActor = consoleActor; this._consoleActor = consoleActor;
return { return {
type: "connected", type: "connected",
workerName: this._workerName,
threadActor: this._threadActor, threadActor: this._threadActor,
consoleActor: this._consoleActor, consoleActor: this._consoleActor,
}; };

View File

@ -156,6 +156,7 @@ function connectToWorker(connection, dbg, id, options) {
connection.setForwarding(id, transport); connection.setForwarding(id, transport);
resolve({ resolve({
workerName: message.workerName,
threadActor: message.threadActor, threadActor: message.threadActor,
consoleActor: message.consoleActor, consoleActor: message.consoleActor,
transport: transport, transport: transport,

View File

@ -123,6 +123,7 @@ this.addEventListener("message", function(event) {
JSON.stringify({ JSON.stringify({
type: "connected", type: "connected",
id: packet.id, id: packet.id,
workerName: consoleActor.evaluateJS({ text: "self.name" }).result,
threadActor: threadActor.actorID, threadActor: threadActor.actorID,
consoleActor: consoleActor.actorID, consoleActor: consoleActor.actorID,
}) })

View File

@ -78,6 +78,7 @@ class WorkerTargetFront extends TargetMixin(
const connectResponse = await this.connect({}); const connectResponse = await this.connect({});
// Set the console actor ID on the form to expose it to Target.attachConsole // Set the console actor ID on the form to expose it to Target.attachConsole
// Set the ThreadActor on the target form so it is accessible by getFront // Set the ThreadActor on the target form so it is accessible by getFront
this.workerName = connectResponse.workerName;
this.targetForm.consoleActor = connectResponse.consoleActor; this.targetForm.consoleActor = connectResponse.consoleActor;
this.targetForm.threadActor = connectResponse.threadActor; this.targetForm.threadActor = connectResponse.threadActor;
this._threadActor = connectResponse.threadActor; this._threadActor = connectResponse.threadActor;