зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 3 changesets (bug 1573779, bug 1662734) for Geckoview failures. CLOSED TREE
Backed out changeset 0adff4f08b28 (bug 1662734) Backed out changeset c6bb84f2a032 (bug 1573779) Backed out changeset 0c605800aa6b (bug 1573779)
This commit is contained in:
Родитель
1dc1662233
Коммит
f826d52619
|
@ -32,7 +32,7 @@ const workerComponentDataMiddleware = store => next => action => {
|
|||
|
||||
function getServiceWorkerStatus(worker) {
|
||||
const isActive = worker.state === Ci.nsIServiceWorkerInfo.STATE_ACTIVATED;
|
||||
const isRunning = !!worker.workerDescriptorFront;
|
||||
const isRunning = !!worker.workerTargetFront;
|
||||
|
||||
if (isActive && isRunning) {
|
||||
return SERVICE_WORKER_STATUSES.RUNNING;
|
||||
|
|
|
@ -35,7 +35,7 @@ add_task(async function() {
|
|||
serviceWorkers: [
|
||||
{
|
||||
name: WORKER_NAME,
|
||||
workerDescriptorFront: { actorID: WORKER_NAME },
|
||||
workerTargetFront: { actorID: WORKER_NAME },
|
||||
},
|
||||
],
|
||||
sharedWorkers: [],
|
||||
|
|
|
@ -106,7 +106,7 @@ async function testWorkerOnMockedRemoteClient(
|
|||
[propertyName]: [
|
||||
{
|
||||
name: workerName,
|
||||
workerDescriptorFront: {
|
||||
workerTargetFront: {
|
||||
actorID: workerName,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -71,7 +71,7 @@ class Worker extends PureComponent {
|
|||
return;
|
||||
}
|
||||
|
||||
services.openWorkerInDebugger(this.props.worker.workerDescriptorFront);
|
||||
services.openWorkerInDebugger(this.props.worker.workerTargetFront);
|
||||
}
|
||||
|
||||
viewSource() {
|
||||
|
@ -82,7 +82,7 @@ class Worker extends PureComponent {
|
|||
return;
|
||||
}
|
||||
|
||||
services.viewWorkerSource(this.props.worker.workerDescriptorFront);
|
||||
services.viewWorkerSource(this.props.worker.workerTargetFront);
|
||||
}
|
||||
|
||||
start() {
|
||||
|
@ -96,7 +96,7 @@ class Worker extends PureComponent {
|
|||
|
||||
isRunning() {
|
||||
// We know the worker is running if it has a worker actor.
|
||||
return !!this.props.worker.workerDescriptorFront;
|
||||
return !!this.props.worker.workerTargetFront;
|
||||
}
|
||||
|
||||
isActive() {
|
||||
|
|
|
@ -34,16 +34,16 @@ class ApplicationServices {
|
|||
return this._toolbox.selectTool(toolId, REASON);
|
||||
}
|
||||
|
||||
async openWorkerInDebugger(workerDescriptorFront) {
|
||||
async openWorkerInDebugger(workerTargetFront) {
|
||||
const debuggerPanel = await this.selectTool("jsdebugger");
|
||||
debuggerPanel.selectWorker(workerDescriptorFront);
|
||||
debuggerPanel.selectWorker(workerTargetFront);
|
||||
}
|
||||
|
||||
async viewWorkerSource(workerDescriptorFront) {
|
||||
async viewWorkerSource(workerTargetFront) {
|
||||
// NOTE: this falls back to view-source: if the source can't be inspected
|
||||
// within the debugger.
|
||||
this._toolbox.viewSourceInDebugger(
|
||||
workerDescriptorFront.url,
|
||||
workerTargetFront.url,
|
||||
1,
|
||||
1,
|
||||
null,
|
||||
|
|
|
@ -31,7 +31,7 @@ function buildWorkerDataFromFronts({ registration, workers }) {
|
|||
state: worker.state,
|
||||
stateText: worker.stateText,
|
||||
registrationFront: registration,
|
||||
workerDescriptorFront: worker.workerDescriptorFront,
|
||||
workerTargetFront: worker.workerTargetFront,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ const worker = {
|
|||
state: PropTypes.number.isRequired,
|
||||
stateText: PropTypes.string.isRequired,
|
||||
url: PropTypes.string.isRequired,
|
||||
workerDescriptorFront: PropTypes.object,
|
||||
workerTargetFront: PropTypes.object,
|
||||
registrationFront: PropTypes.object,
|
||||
};
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ exports[`Registration Renders the expected snapshot for a registration with a wo
|
|||
"state": 4,
|
||||
"stateText": "activated",
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerDescriptorFront": "",
|
||||
"workerTargetFront": "",
|
||||
}
|
||||
}
|
||||
/>
|
||||
|
@ -98,7 +98,7 @@ exports[`Registration Renders the expected snapshot for a registration with mult
|
|||
"state": 4,
|
||||
"stateText": "activated",
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerDescriptorFront": "",
|
||||
"workerTargetFront": "",
|
||||
}
|
||||
}
|
||||
/>
|
||||
|
@ -115,7 +115,7 @@ exports[`Registration Renders the expected snapshot for a registration with mult
|
|||
"state": 2,
|
||||
"stateText": "installed",
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerDescriptorFront": "",
|
||||
"workerTargetFront": "",
|
||||
}
|
||||
}
|
||||
/>
|
||||
|
@ -169,7 +169,7 @@ exports[`Registration Renders the expected snapshot when sw debugging is disable
|
|||
"state": 4,
|
||||
"stateText": "activated",
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerDescriptorFront": "",
|
||||
"workerTargetFront": "",
|
||||
}
|
||||
}
|
||||
/>
|
||||
|
|
|
@ -31,7 +31,7 @@ Array [
|
|||
"state": 4,
|
||||
"stateText": "activated",
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerDescriptorFront": "",
|
||||
"workerTargetFront": "",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ Array [
|
|||
"state": 4,
|
||||
"stateText": "activated",
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerDescriptorFront": "",
|
||||
"workerTargetFront": "",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ Array [
|
|||
"state": 2,
|
||||
"stateText": "installed",
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerDescriptorFront": "",
|
||||
"workerTargetFront": "",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ Array [
|
|||
"state": 4,
|
||||
"stateText": "activated",
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerDescriptorFront": "",
|
||||
"workerTargetFront": "",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ exports[`WorkersPage filters out workers from diferent domains 1`] = `
|
|||
"state": 4,
|
||||
"stateText": "activated",
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerDescriptorFront": "",
|
||||
"workerTargetFront": "",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -32,7 +32,7 @@ exports[`WorkersPage filters out workers from diferent domains 1`] = `
|
|||
"state": 4,
|
||||
"stateText": "activated",
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerDescriptorFront": "",
|
||||
"workerTargetFront": "",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -68,7 +68,7 @@ exports[`WorkersPage it renders a list with a single element if there's just 1 w
|
|||
"state": 4,
|
||||
"stateText": "activated",
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerDescriptorFront": "",
|
||||
"workerTargetFront": "",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -96,7 +96,7 @@ exports[`WorkersPage renders a list with multiple elements when there are multip
|
|||
"state": 4,
|
||||
"stateText": "activated",
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerDescriptorFront": "",
|
||||
"workerTargetFront": "",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -110,7 +110,7 @@ exports[`WorkersPage renders a list with multiple elements when there are multip
|
|||
"state": 2,
|
||||
"stateText": "installed",
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerDescriptorFront": "",
|
||||
"workerTargetFront": "",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -124,7 +124,7 @@ exports[`WorkersPage renders a list with multiple elements when there are multip
|
|||
"state": 4,
|
||||
"stateText": "activated",
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerDescriptorFront": "",
|
||||
"workerTargetFront": "",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -11,7 +11,7 @@ const EMPTY_WORKER_LIST = [];
|
|||
|
||||
const WORKER_RUNNING = {
|
||||
id: "id-worker-1-example",
|
||||
workerDescriptorFront: true,
|
||||
workerTargetFront: true,
|
||||
url: "http://example.com/worker.js",
|
||||
state: 4,
|
||||
stateText: "activated",
|
||||
|
@ -19,7 +19,7 @@ const WORKER_RUNNING = {
|
|||
|
||||
const WORKER_STOPPED = {
|
||||
id: "id-worker-1-example",
|
||||
workerDescriptorFront: false,
|
||||
workerTargetFront: false,
|
||||
url: "http://example.com/worker.js",
|
||||
state: 4,
|
||||
stateText: "activated",
|
||||
|
@ -27,7 +27,7 @@ const WORKER_STOPPED = {
|
|||
|
||||
const WORKER_WAITING = {
|
||||
id: "id-worker-1-example",
|
||||
workerDescriptorFront: false,
|
||||
workerTargetFront: false,
|
||||
url: "http://example.com/worker.js",
|
||||
state: 2,
|
||||
stateText: "installed",
|
||||
|
@ -40,7 +40,7 @@ const REGISTRATION_SINGLE_WORKER = {
|
|||
workers: [
|
||||
{
|
||||
id: "id-worker-1-example",
|
||||
workerDescriptorFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://example.com/worker.js",
|
||||
state: 4,
|
||||
stateText: "activated",
|
||||
|
@ -55,14 +55,14 @@ const REGISTRATION_MULTIPLE_WORKERS = {
|
|||
workers: [
|
||||
{
|
||||
id: "id-worker-1-example",
|
||||
workerDescriptorFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://example.com/worker.js",
|
||||
state: 4,
|
||||
stateText: "activated",
|
||||
},
|
||||
{
|
||||
id: "id-worker-2-example",
|
||||
workerDescriptorFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://example.com/worker.js",
|
||||
state: 2,
|
||||
stateText: "installed",
|
||||
|
@ -78,7 +78,7 @@ const SINGLE_WORKER_DEFAULT_DOMAIN_LIST = [
|
|||
workers: [
|
||||
{
|
||||
id: "id-worker-1-example",
|
||||
workerDescriptorFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://example.com/worker.js",
|
||||
state: 4,
|
||||
stateText: "activated",
|
||||
|
@ -95,7 +95,7 @@ const SINGLE_WORKER_DIFFERENT_DOMAIN_LIST = [
|
|||
workers: [
|
||||
{
|
||||
id: "id-worker-1-example",
|
||||
workerDescriptorFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://different-example.com/worker.js",
|
||||
state: 4,
|
||||
stateText: "activated",
|
||||
|
@ -112,7 +112,7 @@ const MULTIPLE_WORKER_LIST = [
|
|||
workers: [
|
||||
{
|
||||
id: "id-worker-1-example",
|
||||
workerDescriptorFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://example.com/worker.js",
|
||||
state: 4,
|
||||
stateText: "activated",
|
||||
|
@ -126,7 +126,7 @@ const MULTIPLE_WORKER_LIST = [
|
|||
workers: [
|
||||
{
|
||||
id: "id-worker-2-example",
|
||||
workerDescriptorFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://example.com/worker.js",
|
||||
state: 2,
|
||||
stateText: "installed",
|
||||
|
@ -140,7 +140,7 @@ const MULTIPLE_WORKER_LIST = [
|
|||
workers: [
|
||||
{
|
||||
id: "id-worker-3-example",
|
||||
workerDescriptorFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://example.com/worker.js",
|
||||
state: 4,
|
||||
stateText: "activated",
|
||||
|
@ -157,7 +157,7 @@ const MULTIPLE_WORKER_MIXED_DOMAINS_LIST = [
|
|||
workers: [
|
||||
{
|
||||
id: "id-worker-1-example",
|
||||
workerDescriptorFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://example.com/worker.js",
|
||||
state: 4,
|
||||
stateText: "activated",
|
||||
|
@ -171,7 +171,7 @@ const MULTIPLE_WORKER_MIXED_DOMAINS_LIST = [
|
|||
workers: [
|
||||
{
|
||||
id: "id-worker-2-example",
|
||||
workerDescriptorFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://example.com/worker.js",
|
||||
state: 4,
|
||||
stateText: "activated",
|
||||
|
@ -185,7 +185,7 @@ const MULTIPLE_WORKER_MIXED_DOMAINS_LIST = [
|
|||
workers: [
|
||||
{
|
||||
id: "id-worker-3-example",
|
||||
workerDescriptorFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://different-example.com/worker.js",
|
||||
state: 4,
|
||||
stateText: "activated",
|
||||
|
|
|
@ -54,14 +54,14 @@ add_task(async function() {
|
|||
id: "w1",
|
||||
state: Ci.nsIServiceWorkerInfo.STATE_ACTIVATED,
|
||||
url: "https://example.com/w1.js",
|
||||
workerDescriptorFront: { foo: "bar" },
|
||||
workerTargetFront: { foo: "bar" },
|
||||
stateText: "activated",
|
||||
},
|
||||
{
|
||||
id: "w2",
|
||||
state: Ci.nsIServiceWorkerInfo.STATE_INSTALLED,
|
||||
url: "https://example.com/w2.js",
|
||||
workerDescriptorFront: undefined,
|
||||
workerTargetFront: undefined,
|
||||
stateText: "installed",
|
||||
},
|
||||
],
|
||||
|
@ -78,7 +78,7 @@ add_task(async function() {
|
|||
{
|
||||
id: "w1",
|
||||
url: "https://example.com/w1.js",
|
||||
workerDescriptorFront: rawData[0].workers[0].workerDescriptorFront,
|
||||
workerTargetFront: rawData[0].workers[0].workerTargetFront,
|
||||
registrationFront: rawData[0].registration,
|
||||
state: Ci.nsIServiceWorkerInfo.STATE_ACTIVATED,
|
||||
stateText: "activated",
|
||||
|
@ -86,7 +86,7 @@ add_task(async function() {
|
|||
{
|
||||
id: "w2",
|
||||
url: "https://example.com/w2.js",
|
||||
workerDescriptorFront: undefined,
|
||||
workerTargetFront: undefined,
|
||||
registrationFront: rawData[0].registration,
|
||||
state: Ci.nsIServiceWorkerInfo.STATE_INSTALLED,
|
||||
stateText: "installed",
|
||||
|
|
|
@ -206,8 +206,8 @@ class DebuggerPanel {
|
|||
return this._actions.selectSourceURL(cx, url, { line, column });
|
||||
}
|
||||
|
||||
async selectWorker(workerDescriptorFront) {
|
||||
const threadActorID = workerDescriptorFront.threadFront?.actorID;
|
||||
async selectWorker(workerTargetFront) {
|
||||
const threadActorID = workerTargetFront.threadFront?.actorID;
|
||||
|
||||
const isThreadAvailable = this._selectors
|
||||
.getThreads(this._getState())
|
||||
|
@ -229,7 +229,7 @@ class DebuggerPanel {
|
|||
this.selectThread(threadActorID);
|
||||
|
||||
// select worker's source
|
||||
const source = this.getSourceByURL(workerDescriptorFront._url);
|
||||
const source = this.getSourceByURL(workerTargetFront._url);
|
||||
await this.selectSource(source.id, 1, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -418,17 +418,13 @@ var gDevToolsBrowser = (exports.gDevToolsBrowser = {
|
|||
* Open a window-hosted toolbox to debug the worker associated to the provided
|
||||
* worker actor.
|
||||
*
|
||||
* @param {WorkerDescriptorFront} workerDescriptorFront
|
||||
* descriptor front of the worker to debug
|
||||
* @param {WorkerTargetFront} workerTargetFront
|
||||
* worker actor front to debug
|
||||
* @param {String} toolId (optional)
|
||||
* The id of the default tool to show
|
||||
*/
|
||||
async openWorkerToolbox(workerDescriptorFront, toolId) {
|
||||
await gDevTools.showToolbox(
|
||||
workerDescriptorFront,
|
||||
toolId,
|
||||
Toolbox.HostType.WINDOW
|
||||
);
|
||||
async openWorkerToolbox(workerTarget, toolId) {
|
||||
await gDevTools.showToolbox(workerTarget, toolId, Toolbox.HostType.WINDOW);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,6 +8,5 @@ DevToolsModules(
|
|||
'process.js',
|
||||
'tab.js',
|
||||
'webextension.js',
|
||||
'worker.js',
|
||||
)
|
||||
|
||||
|
|
|
@ -66,11 +66,10 @@ class RootFront extends FrontClassWithSpec(rootSpec) {
|
|||
registrationFront.installingWorker,
|
||||
registrationFront.evaluatingWorker,
|
||||
]
|
||||
// filter out non-existing workers
|
||||
.filter(w => !!w)
|
||||
// build a worker object with its WorkerDescriptorFront
|
||||
.filter(w => !!w) // filter out non-existing workers
|
||||
// build a worker object with its WorkerTargetFront
|
||||
.map(workerFront => {
|
||||
const workerDescriptorFront = allWorkers.find(
|
||||
const workerTargetFront = allWorkers.find(
|
||||
targetFront => targetFront.id === workerFront.id
|
||||
);
|
||||
|
||||
|
@ -80,7 +79,7 @@ class RootFront extends FrontClassWithSpec(rootSpec) {
|
|||
state: workerFront.state,
|
||||
stateText: workerFront.stateText,
|
||||
url: workerFront.url,
|
||||
workerDescriptorFront,
|
||||
workerTargetFront,
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -137,7 +136,7 @@ class RootFront extends FrontClassWithSpec(rootSpec) {
|
|||
id: front.id,
|
||||
url: front.url,
|
||||
name: front.url,
|
||||
workerDescriptorFront: front,
|
||||
workerTargetFront: front,
|
||||
};
|
||||
|
||||
switch (front.type) {
|
||||
|
@ -275,7 +274,7 @@ class RootFront extends FrontClassWithSpec(rootSpec) {
|
|||
if (!worker) {
|
||||
return null;
|
||||
}
|
||||
return worker.workerDescriptorFront || worker.registrationFront;
|
||||
return worker.workerTargetFront || worker.registrationFront;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,4 +8,5 @@ DevToolsModules(
|
|||
'browsing-context.js',
|
||||
'content-process.js',
|
||||
'target-mixin.js',
|
||||
'worker.js',
|
||||
)
|
||||
|
|
|
@ -391,7 +391,7 @@ function TargetMixin(parentClass) {
|
|||
}
|
||||
|
||||
get isWorkerTarget() {
|
||||
return this.typeName === "workerDescriptor";
|
||||
return this.typeName === "workerTarget";
|
||||
}
|
||||
|
||||
get isLegacyAddon() {
|
||||
|
|
|
@ -4,17 +4,15 @@
|
|||
"use strict";
|
||||
|
||||
const { Ci } = require("chrome");
|
||||
const {
|
||||
workerDescriptorSpec,
|
||||
} = require("devtools/shared/specs/descriptors/worker");
|
||||
const { workerTargetSpec } = require("devtools/shared/specs/targets/worker");
|
||||
const {
|
||||
FrontClassWithSpec,
|
||||
registerFront,
|
||||
} = require("devtools/shared/protocol");
|
||||
const { TargetMixin } = require("devtools/client/fronts/targets/target-mixin");
|
||||
|
||||
class WorkerDescriptorFront extends TargetMixin(
|
||||
FrontClassWithSpec(workerDescriptorSpec)
|
||||
class WorkerTargetFront extends TargetMixin(
|
||||
FrontClassWithSpec(workerTargetSpec)
|
||||
) {
|
||||
constructor(client, targetFront, parentFront) {
|
||||
super(client, targetFront, parentFront);
|
||||
|
@ -62,11 +60,6 @@ class WorkerDescriptorFront extends TargetMixin(
|
|||
}
|
||||
|
||||
async attach() {
|
||||
// temporary, will be moved once we have a target actor
|
||||
return this.getTarget();
|
||||
}
|
||||
|
||||
async getTarget() {
|
||||
if (this._attach) {
|
||||
return this._attach;
|
||||
}
|
||||
|
@ -91,16 +84,9 @@ class WorkerDescriptorFront extends TargetMixin(
|
|||
return;
|
||||
}
|
||||
|
||||
// Immediately retrieve console and thread actors that will be later used by Target.
|
||||
let connectResponse;
|
||||
if (this.actorID.includes("workerDescriptor")) {
|
||||
connectResponse = await super.getTarget();
|
||||
} else {
|
||||
// Backwards compatibility for FF82 servers and below.
|
||||
// Can be deleted once FF83 is merged into release.
|
||||
connectResponse = await this.connect({});
|
||||
}
|
||||
|
||||
// Immediately call `connect` in other to fetch console and thread actors
|
||||
// that will be later used by Target.
|
||||
const connectResponse = await this.connect({});
|
||||
// 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
|
||||
this.targetForm.consoleActor = connectResponse.consoleActor;
|
||||
|
@ -149,5 +135,5 @@ class WorkerDescriptorFront extends TargetMixin(
|
|||
}
|
||||
}
|
||||
|
||||
exports.WorkerDescriptorFront = WorkerDescriptorFront;
|
||||
registerFront(exports.WorkerDescriptorFront);
|
||||
exports.WorkerTargetFront = WorkerTargetFront;
|
||||
registerFront(exports.WorkerTargetFront);
|
|
@ -36,47 +36,32 @@ add_task(async function() {
|
|||
// createWorker in the tab to be resolved.
|
||||
await createWorkerInTab(tab, WORKER1_URL);
|
||||
let { workers } = await listWorkers(target);
|
||||
let workerDescriptorFront1 = findWorker(workers, WORKER1_URL);
|
||||
await workerDescriptorFront1.attach();
|
||||
ok(
|
||||
workerDescriptorFront1.actorID,
|
||||
"front for worker in tab 1 has been attached"
|
||||
);
|
||||
let workerTargetFront1 = findWorker(workers, WORKER1_URL);
|
||||
await workerTargetFront1.attach();
|
||||
ok(workerTargetFront1.actorID, "front for worker in tab 1 has been attached");
|
||||
|
||||
executeSoon(() => {
|
||||
BrowserTestUtils.loadURI(tab.linkedBrowser, TAB2_URL);
|
||||
});
|
||||
await waitForWorkerClose(workerDescriptorFront1);
|
||||
ok(
|
||||
!!workerDescriptorFront1.actorID,
|
||||
"front for worker in tab 1 has been closed"
|
||||
);
|
||||
await waitForWorkerClose(workerTargetFront1);
|
||||
ok(!!workerTargetFront1.actorID, "front for worker in tab 1 has been closed");
|
||||
|
||||
await createWorkerInTab(tab, WORKER2_URL);
|
||||
({ workers } = await listWorkers(target));
|
||||
const workerDescriptorFront2 = findWorker(workers, WORKER2_URL);
|
||||
await workerDescriptorFront2.attach();
|
||||
ok(
|
||||
workerDescriptorFront2.actorID,
|
||||
"front for worker in tab 2 has been attached"
|
||||
);
|
||||
const workerTargetFront2 = findWorker(workers, WORKER2_URL);
|
||||
await workerTargetFront2.attach();
|
||||
ok(workerTargetFront2.actorID, "front for worker in tab 2 has been attached");
|
||||
|
||||
executeSoon(() => {
|
||||
tab.linkedBrowser.goBack();
|
||||
});
|
||||
await waitForWorkerClose(workerDescriptorFront2);
|
||||
ok(
|
||||
!!workerDescriptorFront2.actorID,
|
||||
"front for worker in tab 2 has been closed"
|
||||
);
|
||||
await waitForWorkerClose(workerTargetFront2);
|
||||
ok(!!workerTargetFront2.actorID, "front for worker in tab 2 has been closed");
|
||||
|
||||
({ workers } = await listWorkers(target));
|
||||
workerDescriptorFront1 = findWorker(workers, WORKER1_URL);
|
||||
await workerDescriptorFront1.attach();
|
||||
ok(
|
||||
workerDescriptorFront1.actorID,
|
||||
"front for worker in tab 1 has been attached"
|
||||
);
|
||||
workerTargetFront1 = findWorker(workers, WORKER1_URL);
|
||||
await workerTargetFront1.attach();
|
||||
ok(workerTargetFront1.actorID, "front for worker in tab 1 has been attached");
|
||||
|
||||
await target.destroy();
|
||||
SpecialPowers.setIntPref(MAX_TOTAL_VIEWERS, oldMaxTotalViewers);
|
||||
|
|
|
@ -17,19 +17,17 @@ var TAB_URL = EXAMPLE_URL + "doc_WorkerTargetActor.attachThread-tab.html";
|
|||
var WORKER_URL = "code_WorkerTargetActor.attachThread-worker.js";
|
||||
|
||||
add_task(async function testNormalExecution() {
|
||||
const {
|
||||
client,
|
||||
tab,
|
||||
workerDescriptorFront,
|
||||
toolbox,
|
||||
} = await initWorkerDebugger(TAB_URL, WORKER_URL);
|
||||
const { client, tab, workerTargetFront, toolbox } = await initWorkerDebugger(
|
||||
TAB_URL,
|
||||
WORKER_URL
|
||||
);
|
||||
|
||||
const hud = await getSplitConsole(toolbox);
|
||||
await executeAndWaitForMessage(hud, "this.location.toString()", WORKER_URL);
|
||||
ok(true, "Evaluating the global's location works");
|
||||
|
||||
terminateWorkerInTab(tab, WORKER_URL);
|
||||
await waitForWorkerClose(workerDescriptorFront);
|
||||
await waitForWorkerClose(workerTargetFront);
|
||||
await toolbox.destroy();
|
||||
await close(client);
|
||||
await removeTab(tab);
|
||||
|
|
|
@ -18,8 +18,8 @@ var WORKER_URL = "code_WorkerTargetActor.attachThread-worker.js";
|
|||
|
||||
add_task(async function testWhilePaused() {
|
||||
const dbg = await initWorkerDebugger(TAB_URL, WORKER_URL);
|
||||
const { client, tab, workerDescriptorFront, toolbox } = dbg;
|
||||
const workerThreadFront = await workerDescriptorFront.getFront("thread");
|
||||
const { client, tab, workerTargetFront, toolbox } = dbg;
|
||||
const workerThreadFront = await workerTargetFront.getFront("thread");
|
||||
|
||||
// Execute some basic math to make sure evaluations are working.
|
||||
const hud = await getSplitConsole(toolbox);
|
||||
|
@ -58,7 +58,7 @@ add_task(async function testWhilePaused() {
|
|||
await resume(dbg);
|
||||
|
||||
terminateWorkerInTab(tab, WORKER_URL);
|
||||
await waitForWorkerClose(workerDescriptorFront);
|
||||
await waitForWorkerClose(workerTargetFront);
|
||||
await toolbox.destroy();
|
||||
await close(client);
|
||||
await removeTab(tab);
|
||||
|
|
|
@ -19,7 +19,7 @@ var WORKER_URL = "code_WorkerTargetActor.attachThread-worker.js";
|
|||
// Test to see if creating the pause from the console works.
|
||||
add_task(async function testPausedByConsole() {
|
||||
const dbg = await initWorkerDebugger(TAB_URL, WORKER_URL);
|
||||
const { client, tab, workerDescriptorFront, toolbox } = dbg;
|
||||
const { client, tab, workerTargetFront, toolbox } = dbg;
|
||||
|
||||
const console = await getSplitConsole(toolbox);
|
||||
let executed = await executeAndWaitForMessage(console, "10000+1", "10001");
|
||||
|
@ -42,7 +42,7 @@ add_task(async function testPausedByConsole() {
|
|||
ok(executed, "Text for message appeared correct");
|
||||
|
||||
terminateWorkerInTab(tab, WORKER_URL);
|
||||
await waitForWorkerClose(workerDescriptorFront);
|
||||
await waitForWorkerClose(workerTargetFront);
|
||||
await toolbox.destroy();
|
||||
await close(client);
|
||||
await removeTab(tab);
|
||||
|
|
|
@ -25,12 +25,10 @@ const TAB_URL = EXAMPLE_URL + "doc_WorkerTargetActor.attachThread-tab.html";
|
|||
const WORKER_URL = "code_WorkerTargetActor.attachThread-worker.js";
|
||||
|
||||
add_task(async function testPausedByConsole() {
|
||||
const {
|
||||
client,
|
||||
tab,
|
||||
workerDescriptorFront,
|
||||
toolbox,
|
||||
} = await initWorkerDebugger(TAB_URL, WORKER_URL);
|
||||
const { client, tab, workerTargetFront, toolbox } = await initWorkerDebugger(
|
||||
TAB_URL,
|
||||
WORKER_URL
|
||||
);
|
||||
|
||||
info("Check Date objects can be used in the console");
|
||||
const console = await getSplitConsole(toolbox);
|
||||
|
@ -50,7 +48,7 @@ add_task(async function testPausedByConsole() {
|
|||
ok(executed, "Text for message appeared correct");
|
||||
|
||||
terminateWorkerInTab(tab, WORKER_URL);
|
||||
await waitForWorkerClose(workerDescriptorFront);
|
||||
await waitForWorkerClose(workerTargetFront);
|
||||
await toolbox.destroy();
|
||||
await close(client);
|
||||
await removeTab(tab);
|
||||
|
|
|
@ -122,9 +122,9 @@ function waitForWorkerListChanged(targetFront) {
|
|||
return targetFront.once("workerListChanged");
|
||||
}
|
||||
|
||||
async function waitForWorkerClose(workerDescriptorFront) {
|
||||
async function waitForWorkerClose(workerTargetFront) {
|
||||
info("Waiting for worker to close.");
|
||||
await workerDescriptorFront.once("close");
|
||||
await workerTargetFront.once("close");
|
||||
info("Worker did close.");
|
||||
}
|
||||
|
||||
|
@ -178,10 +178,10 @@ async function initWorkerDebugger(TAB_URL, WORKER_URL) {
|
|||
await createWorkerInTab(tab, WORKER_URL);
|
||||
|
||||
const { workers } = await listWorkers(target);
|
||||
const workerDescriptorFront = findWorker(workers, WORKER_URL);
|
||||
const workerTargetFront = findWorker(workers, WORKER_URL);
|
||||
|
||||
const toolbox = await gDevTools.showToolbox(
|
||||
workerDescriptorFront,
|
||||
workerTargetFront,
|
||||
"jsdebugger",
|
||||
Toolbox.HostType.WINDOW
|
||||
);
|
||||
|
@ -197,7 +197,7 @@ async function initWorkerDebugger(TAB_URL, WORKER_URL) {
|
|||
client,
|
||||
tab,
|
||||
target,
|
||||
workerDescriptorFront,
|
||||
workerTargetFront,
|
||||
toolbox,
|
||||
gDebugger,
|
||||
};
|
||||
|
|
|
@ -8,6 +8,5 @@ DevToolsModules(
|
|||
'process.js',
|
||||
'tab.js',
|
||||
'webextension.js',
|
||||
'worker.js',
|
||||
)
|
||||
|
||||
|
|
|
@ -1,253 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
* Target actor for any of the various kinds of workers.
|
||||
*
|
||||
* See devtools/docs/backend/actor-hierarchy.md for more details.
|
||||
*/
|
||||
|
||||
const { Ci } = require("chrome");
|
||||
const ChromeUtils = require("ChromeUtils");
|
||||
const { DevToolsServer } = require("devtools/server/devtools-server");
|
||||
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
const {
|
||||
workerDescriptorSpec,
|
||||
} = require("devtools/shared/specs/descriptors/worker");
|
||||
|
||||
loader.lazyRequireGetter(this, "ChromeUtils");
|
||||
|
||||
loader.lazyRequireGetter(
|
||||
this,
|
||||
"connectToWorker",
|
||||
"devtools/server/connectors/worker-connector",
|
||||
true
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
this,
|
||||
"swm",
|
||||
"@mozilla.org/serviceworkers/manager;1",
|
||||
"nsIServiceWorkerManager"
|
||||
);
|
||||
|
||||
const WorkerDescriptorActor = protocol.ActorClassWithSpec(
|
||||
workerDescriptorSpec,
|
||||
{
|
||||
initialize(conn, dbg) {
|
||||
protocol.Actor.prototype.initialize.call(this, conn);
|
||||
this._dbg = dbg;
|
||||
this._attached = false;
|
||||
this._threadActor = null;
|
||||
this._transport = null;
|
||||
|
||||
this._dbgListener = {
|
||||
onClose: this._onWorkerClose.bind(this),
|
||||
onError: this._onWorkerError.bind(this),
|
||||
};
|
||||
},
|
||||
|
||||
form() {
|
||||
const form = {
|
||||
actor: this.actorID,
|
||||
consoleActor: this._consoleActor,
|
||||
threadActor: this._threadActor,
|
||||
id: this._dbg.id,
|
||||
url: this._dbg.url,
|
||||
traits: {},
|
||||
type: this._dbg.type,
|
||||
};
|
||||
if (this._dbg.type === Ci.nsIWorkerDebugger.TYPE_SERVICE) {
|
||||
/**
|
||||
* With parent-intercept mode, the ServiceWorkerManager in content
|
||||
* processes don't maintain ServiceWorkerRegistrations; record the
|
||||
* ServiceWorker's ID, and this data will be merged with the
|
||||
* corresponding registration in the parent process.
|
||||
*/
|
||||
if (
|
||||
!swm.isParentInterceptEnabled() ||
|
||||
!DevToolsServer.isInChildProcess
|
||||
) {
|
||||
const registration = this._getServiceWorkerRegistrationInfo();
|
||||
form.scope = registration.scope;
|
||||
const newestWorker =
|
||||
registration.activeWorker ||
|
||||
registration.waitingWorker ||
|
||||
registration.installingWorker;
|
||||
form.fetch = newestWorker?.handlesFetchEvents;
|
||||
}
|
||||
}
|
||||
return form;
|
||||
},
|
||||
|
||||
attach() {
|
||||
if (this._dbg.isClosed) {
|
||||
return { error: "closed" };
|
||||
}
|
||||
|
||||
if (!this._attached) {
|
||||
const isServiceWorker =
|
||||
this._dbg.type == Ci.nsIWorkerDebugger.TYPE_SERVICE;
|
||||
if (isServiceWorker) {
|
||||
this._preventServiceWorkerShutdown();
|
||||
}
|
||||
this._dbg.addListener(this._dbgListener);
|
||||
this._attached = true;
|
||||
}
|
||||
|
||||
return {
|
||||
type: "attached",
|
||||
url: this._dbg.url,
|
||||
};
|
||||
},
|
||||
|
||||
detach() {
|
||||
if (!this._attached) {
|
||||
return { error: "wrongState" };
|
||||
}
|
||||
|
||||
this._detach();
|
||||
|
||||
return { type: "detached" };
|
||||
},
|
||||
|
||||
destroy() {
|
||||
if (this._attached) {
|
||||
this._detach();
|
||||
}
|
||||
protocol.Actor.prototype.destroy.call(this);
|
||||
},
|
||||
|
||||
async getTarget() {
|
||||
if (!this._attached) {
|
||||
return { error: "wrongState" };
|
||||
}
|
||||
|
||||
if (this._threadActor !== null) {
|
||||
return {
|
||||
type: "connected",
|
||||
threadActor: this._threadActor,
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const { transport, workerTargetForm } = await connectToWorker(
|
||||
this.conn,
|
||||
this._dbg,
|
||||
this.actorID,
|
||||
{}
|
||||
);
|
||||
|
||||
this._threadActor = workerTargetForm.threadActor;
|
||||
this._consoleActor = workerTargetForm.consoleActor;
|
||||
this._transport = transport;
|
||||
|
||||
return {
|
||||
type: "connected",
|
||||
threadActor: this._threadActor,
|
||||
consoleActor: this._consoleActor,
|
||||
url: this._dbg.url,
|
||||
};
|
||||
} catch (error) {
|
||||
return { error: error.toString() };
|
||||
}
|
||||
},
|
||||
|
||||
push() {
|
||||
if (this._dbg.type !== Ci.nsIWorkerDebugger.TYPE_SERVICE) {
|
||||
return { error: "wrongType" };
|
||||
}
|
||||
const registration = this._getServiceWorkerRegistrationInfo();
|
||||
const originAttributes = ChromeUtils.originAttributesToSuffix(
|
||||
this._dbg.principal.originAttributes
|
||||
);
|
||||
swm.sendPushEvent(originAttributes, registration.scope);
|
||||
return { type: "pushed" };
|
||||
},
|
||||
|
||||
_onWorkerClose() {
|
||||
if (this._attached) {
|
||||
this._detach();
|
||||
}
|
||||
|
||||
this.conn.sendActorEvent(this.actorID, "close");
|
||||
},
|
||||
|
||||
_onWorkerError(filename, lineno, message) {
|
||||
reportError("ERROR:" + filename + ":" + lineno + ":" + message + "\n");
|
||||
},
|
||||
|
||||
_getServiceWorkerRegistrationInfo() {
|
||||
return swm.getRegistrationByPrincipal(this._dbg.principal, this._dbg.url);
|
||||
},
|
||||
|
||||
_getServiceWorkerInfo() {
|
||||
const registration = this._getServiceWorkerRegistrationInfo();
|
||||
return registration.getWorkerByID(this._dbg.serviceWorkerID);
|
||||
},
|
||||
|
||||
_detach() {
|
||||
if (this._threadActor !== null) {
|
||||
this._transport.close();
|
||||
this._transport = null;
|
||||
this._threadActor = null;
|
||||
}
|
||||
|
||||
// If the worker is already destroyed, nsIWorkerDebugger.type throws
|
||||
// (_dbg.closed appears to be false when it throws)
|
||||
let type;
|
||||
try {
|
||||
type = this._dbg.type;
|
||||
} catch (e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
const isServiceWorker = type == Ci.nsIWorkerDebugger.TYPE_SERVICE;
|
||||
if (isServiceWorker) {
|
||||
this._allowServiceWorkerShutdown();
|
||||
}
|
||||
|
||||
this._dbg.removeListener(this._dbgListener);
|
||||
this._attached = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Automatically disable the internal sw timeout that shut them down by calling
|
||||
* nsIWorkerInfo.attachDebugger().
|
||||
* This can be removed when Bug 1496997 lands.
|
||||
*/
|
||||
_preventServiceWorkerShutdown() {
|
||||
if (swm.isParentInterceptEnabled()) {
|
||||
// In parentIntercept mode, the worker target actor cannot call attachDebugger
|
||||
// because this API can only be called from the parent process. This will be
|
||||
// done by the worker target front.
|
||||
return;
|
||||
}
|
||||
|
||||
const worker = this._getServiceWorkerInfo();
|
||||
if (worker) {
|
||||
worker.attachDebugger();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Allow the service worker to time out. See _preventServiceWorkerShutdown.
|
||||
*/
|
||||
_allowServiceWorkerShutdown() {
|
||||
if (swm.isParentInterceptEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const worker = this._getServiceWorkerInfo();
|
||||
if (worker) {
|
||||
worker.detachDebugger();
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
exports.WorkerDescriptorActor = WorkerDescriptorActor;
|
|
@ -218,8 +218,8 @@ exports.RootActor = protocol.ActorClassWithSpec(rootSpec, {
|
|||
if (this._addonTargetActorPool) {
|
||||
this._addonTargetActorPool.destroy();
|
||||
}
|
||||
if (this._workerDescriptorActorPool) {
|
||||
this._workerDescriptorActorPool.destroy();
|
||||
if (this._workerTargetActorPool) {
|
||||
this._workerTargetActorPool.destroy();
|
||||
}
|
||||
if (this._frameDescriptorActorPool) {
|
||||
this._frameDescriptorActorPool.destroy();
|
||||
|
@ -426,11 +426,11 @@ exports.RootActor = protocol.ActorClassWithSpec(rootSpec, {
|
|||
|
||||
// Do not destroy the pool before transfering ownership to the newly created
|
||||
// pool, so that we do not accidently destroy actors that are still in use.
|
||||
if (this._workerDescriptorActorPool) {
|
||||
this._workerDescriptorActorPool.destroy();
|
||||
if (this._workerTargetActorPool) {
|
||||
this._workerTargetActorPool.destroy();
|
||||
}
|
||||
|
||||
this._workerDescriptorActorPool = pool;
|
||||
this._workerTargetActorPool = pool;
|
||||
|
||||
return {
|
||||
workers: actors,
|
||||
|
|
|
@ -58,8 +58,8 @@ loader.lazyRequireGetter(
|
|||
);
|
||||
loader.lazyRequireGetter(
|
||||
this,
|
||||
"WorkerDescriptorActorList",
|
||||
"devtools/server/actors/worker/worker-descriptor-actor-list",
|
||||
"WorkerTargetActorList",
|
||||
"devtools/server/actors/worker/worker-target-actor-list",
|
||||
true
|
||||
);
|
||||
loader.lazyImporter(this, "ExtensionContent", EXTENSION_CONTENT_JSM);
|
||||
|
@ -294,9 +294,9 @@ const browsingContextTargetPrototype = {
|
|||
navigation: true,
|
||||
};
|
||||
|
||||
this._workerDescriptorActorList = null;
|
||||
this._workerDescriptorActorPool = null;
|
||||
this._onWorkerDescriptorActorListChanged = this._onWorkerDescriptorActorListChanged.bind(
|
||||
this._workerTargetActorList = null;
|
||||
this._workerTargetActorPool = null;
|
||||
this._onWorkerTargetActorListChanged = this._onWorkerTargetActorListChanged.bind(
|
||||
this
|
||||
);
|
||||
this.notifyResourceAvailable = this.notifyResourceAvailable.bind(this);
|
||||
|
@ -744,21 +744,18 @@ const browsingContextTargetPrototype = {
|
|||
return { frames: windows };
|
||||
},
|
||||
|
||||
ensureWorkerDescriptorActorList() {
|
||||
if (this._workerDescriptorActorList === null) {
|
||||
this._workerDescriptorActorList = new WorkerDescriptorActorList(
|
||||
this.conn,
|
||||
{
|
||||
type: Ci.nsIWorkerDebugger.TYPE_DEDICATED,
|
||||
window: this.window,
|
||||
}
|
||||
);
|
||||
ensureWorkerTargetActorList() {
|
||||
if (this._workerTargetActorList === null) {
|
||||
this._workerTargetActorList = new WorkerTargetActorList(this.conn, {
|
||||
type: Ci.nsIWorkerDebugger.TYPE_DEDICATED,
|
||||
window: this.window,
|
||||
});
|
||||
}
|
||||
return this._workerDescriptorActorList;
|
||||
return this._workerTargetActorList;
|
||||
},
|
||||
|
||||
pauseWorkersUntilAttach(shouldPause) {
|
||||
this.ensureWorkerDescriptorActorList().workerPauser.setPauseMatching(
|
||||
this.ensureWorkerTargetActorList().workerPauser.setPauseMatching(
|
||||
shouldPause
|
||||
);
|
||||
},
|
||||
|
@ -770,7 +767,7 @@ const browsingContextTargetPrototype = {
|
|||
};
|
||||
}
|
||||
|
||||
return this.ensureWorkerDescriptorActorList()
|
||||
return this.ensureWorkerTargetActorList()
|
||||
.getList()
|
||||
.then(actors => {
|
||||
const pool = new Pool(this.conn, "worker-targets");
|
||||
|
@ -780,12 +777,12 @@ const browsingContextTargetPrototype = {
|
|||
|
||||
// Do not destroy the pool before transfering ownership to the newly created
|
||||
// pool, so that we do not accidently destroy actors that are still in use.
|
||||
if (this._workerDescriptorActorPool) {
|
||||
this._workerDescriptorActorPool.destroy();
|
||||
if (this._workerTargetActorPool) {
|
||||
this._workerTargetActorPool.destroy();
|
||||
}
|
||||
|
||||
this._workerDescriptorActorPool = pool;
|
||||
this._workerDescriptorActorList.onListChanged = this._onWorkerDescriptorActorListChanged;
|
||||
this._workerTargetActorPool = pool;
|
||||
this._workerTargetActorList.onListChanged = this._onWorkerTargetActorListChanged;
|
||||
|
||||
return {
|
||||
workers: actors,
|
||||
|
@ -811,8 +808,8 @@ const browsingContextTargetPrototype = {
|
|||
return {};
|
||||
},
|
||||
|
||||
_onWorkerDescriptorActorListChanged() {
|
||||
this._workerDescriptorActorList.onListChanged = null;
|
||||
_onWorkerTargetActorListChanged() {
|
||||
this._workerTargetActorList.onListChanged = null;
|
||||
this.emit("workerListChanged");
|
||||
},
|
||||
|
||||
|
@ -1053,14 +1050,14 @@ const browsingContextTargetPrototype = {
|
|||
}
|
||||
|
||||
// Make sure that no more workerListChanged notifications are sent.
|
||||
if (this._workerDescriptorActorList !== null) {
|
||||
this._workerDescriptorActorList.destroy();
|
||||
this._workerDescriptorActorList = null;
|
||||
if (this._workerTargetActorList !== null) {
|
||||
this._workerTargetActorList.destroy();
|
||||
this._workerTargetActorList = null;
|
||||
}
|
||||
|
||||
if (this._workerDescriptorActorPool !== null) {
|
||||
this._workerDescriptorActorPool.destroy();
|
||||
this._workerDescriptorActorPool = null;
|
||||
if (this._workerTargetActorPool !== null) {
|
||||
this._workerTargetActorPool.destroy();
|
||||
this._workerTargetActorPool = null;
|
||||
}
|
||||
|
||||
if (this._dbg) {
|
||||
|
|
|
@ -28,8 +28,8 @@ const Targets = require("devtools/server/actors/targets/index");
|
|||
|
||||
loader.lazyRequireGetter(
|
||||
this,
|
||||
"WorkerDescriptorActorList",
|
||||
"devtools/server/actors/worker/worker-descriptor-actor-list",
|
||||
"WorkerTargetActorList",
|
||||
"devtools/server/actors/worker/worker-target-actor-list",
|
||||
true
|
||||
);
|
||||
loader.lazyRequireGetter(
|
||||
|
@ -72,7 +72,7 @@ const ContentProcessTargetActor = ActorClassWithSpec(contentProcessTargetSpec, {
|
|||
this._consoleScope = sandbox;
|
||||
|
||||
this._workerList = null;
|
||||
this._workerDescriptorActorPool = null;
|
||||
this._workerTargetActorPool = null;
|
||||
this._onWorkerListChanged = this._onWorkerListChanged.bind(this);
|
||||
|
||||
// Try to destroy the Content Process Target when the content process shuts down.
|
||||
|
@ -155,7 +155,7 @@ const ContentProcessTargetActor = ActorClassWithSpec(contentProcessTargetSpec, {
|
|||
|
||||
ensureWorkerList() {
|
||||
if (!this._workerList) {
|
||||
this._workerList = new WorkerDescriptorActorList(this.conn, {});
|
||||
this._workerList = new WorkerTargetActorList(this.conn, {});
|
||||
}
|
||||
return this._workerList;
|
||||
},
|
||||
|
@ -171,11 +171,11 @@ const ContentProcessTargetActor = ActorClassWithSpec(contentProcessTargetSpec, {
|
|||
|
||||
// Do not destroy the pool before transfering ownership to the newly created
|
||||
// pool, so that we do not accidentally destroy actors that are still in use.
|
||||
if (this._workerDescriptorActorPool) {
|
||||
this._workerDescriptorActorPool.destroy();
|
||||
if (this._workerTargetActorPool) {
|
||||
this._workerTargetActorPool.destroy();
|
||||
}
|
||||
|
||||
this._workerDescriptorActorPool = pool;
|
||||
this._workerTargetActorPool = pool;
|
||||
this._workerList.onListChanged = this._onWorkerListChanged;
|
||||
|
||||
return {
|
||||
|
|
|
@ -4,77 +4,237 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { ActorClassWithSpec, Actor } = require("devtools/shared/protocol");
|
||||
/*
|
||||
* Target actor for any of the various kinds of workers.
|
||||
*
|
||||
* See devtools/docs/backend/actor-hierarchy.md for more details.
|
||||
*/
|
||||
|
||||
const { Ci } = require("chrome");
|
||||
const ChromeUtils = require("ChromeUtils");
|
||||
const { DevToolsServer } = require("devtools/server/devtools-server");
|
||||
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
const { workerTargetSpec } = require("devtools/shared/specs/targets/worker");
|
||||
|
||||
const { ThreadActor } = require("devtools/server/actors/thread");
|
||||
const { WebConsoleActor } = require("devtools/server/actors/webconsole");
|
||||
const Targets = require("devtools/server/actors/targets/index");
|
||||
loader.lazyRequireGetter(this, "ChromeUtils");
|
||||
|
||||
const makeDebuggerUtil = require("devtools/server/actors/utils/make-debugger");
|
||||
const { TabSources } = require("devtools/server/actors/utils/TabSources");
|
||||
loader.lazyRequireGetter(
|
||||
this,
|
||||
"connectToWorker",
|
||||
"devtools/server/connectors/worker-connector",
|
||||
true
|
||||
);
|
||||
|
||||
exports.WorkerTargetActor = ActorClassWithSpec(workerTargetSpec, {
|
||||
targetType: Targets.TYPES.WORKER,
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
this,
|
||||
"swm",
|
||||
"@mozilla.org/serviceworkers/manager;1",
|
||||
"nsIServiceWorkerManager"
|
||||
);
|
||||
|
||||
/**
|
||||
* Target actor for a worker in the content process.
|
||||
*
|
||||
* @param {DevToolsServerConnection} connection: The connection to the client.
|
||||
* @param {WorkerGlobalScope} workerGlobal: The worker global.
|
||||
*/
|
||||
initialize: function(connection, workerGlobal) {
|
||||
Actor.prototype.initialize.call(this, connection);
|
||||
const WorkerTargetActor = protocol.ActorClassWithSpec(workerTargetSpec, {
|
||||
initialize(conn, dbg) {
|
||||
protocol.Actor.prototype.initialize.call(this, conn);
|
||||
this._dbg = dbg;
|
||||
this._attached = false;
|
||||
this._threadActor = null;
|
||||
this._transport = null;
|
||||
|
||||
// workerGlobal is needed by the console actor for evaluations.
|
||||
this.workerGlobal = workerGlobal;
|
||||
this._sources = null;
|
||||
|
||||
this.makeDebugger = makeDebuggerUtil.bind(null, {
|
||||
findDebuggees: () => {
|
||||
return [workerGlobal];
|
||||
},
|
||||
shouldAddNewGlobalAsDebuggee: () => true,
|
||||
});
|
||||
},
|
||||
|
||||
form() {
|
||||
return {
|
||||
actor: this.actorID,
|
||||
threadActor: this.threadActor?.actorID,
|
||||
consoleActor: this._consoleActor?.actorID,
|
||||
this._dbgListener = {
|
||||
onClose: this._onWorkerClose.bind(this),
|
||||
onError: this._onWorkerError.bind(this),
|
||||
};
|
||||
},
|
||||
|
||||
form() {
|
||||
const form = {
|
||||
actor: this.actorID,
|
||||
consoleActor: this._consoleActor,
|
||||
threadActor: this._threadActor,
|
||||
id: this._dbg.id,
|
||||
url: this._dbg.url,
|
||||
traits: {},
|
||||
type: this._dbg.type,
|
||||
};
|
||||
if (this._dbg.type === Ci.nsIWorkerDebugger.TYPE_SERVICE) {
|
||||
/**
|
||||
* With parent-intercept mode, the ServiceWorkerManager in content
|
||||
* processes don't maintain ServiceWorkerRegistrations; record the
|
||||
* ServiceWorker's ID, and this data will be merged with the
|
||||
* corresponding registration in the parent process.
|
||||
*/
|
||||
if (!swm.isParentInterceptEnabled() || !DevToolsServer.isInChildProcess) {
|
||||
const registration = this._getServiceWorkerRegistrationInfo();
|
||||
form.scope = registration.scope;
|
||||
const newestWorker =
|
||||
registration.activeWorker ||
|
||||
registration.waitingWorker ||
|
||||
registration.installingWorker;
|
||||
form.fetch = newestWorker?.handlesFetchEvents;
|
||||
}
|
||||
}
|
||||
return form;
|
||||
},
|
||||
|
||||
attach() {
|
||||
// needed by the console actor
|
||||
this.threadActor = new ThreadActor(this, this.workerGlobal);
|
||||
|
||||
// needed by the thread actor to communicate with the console when evaluating logpoints.
|
||||
this._consoleActor = new WebConsoleActor(this.conn, this);
|
||||
|
||||
this.manage(this.threadActor);
|
||||
this.manage(this._consoleActor);
|
||||
},
|
||||
|
||||
get dbg() {
|
||||
if (!this._dbg) {
|
||||
this._dbg = this.makeDebugger();
|
||||
}
|
||||
return this._dbg;
|
||||
},
|
||||
|
||||
get sources() {
|
||||
if (this._sources === null) {
|
||||
this._sources = new TabSources(this.threadActor);
|
||||
if (this._dbg.isClosed) {
|
||||
return { error: "closed" };
|
||||
}
|
||||
|
||||
return this._sources;
|
||||
if (!this._attached) {
|
||||
const isServiceWorker =
|
||||
this._dbg.type == Ci.nsIWorkerDebugger.TYPE_SERVICE;
|
||||
if (isServiceWorker) {
|
||||
this._preventServiceWorkerShutdown();
|
||||
}
|
||||
this._dbg.addListener(this._dbgListener);
|
||||
this._attached = true;
|
||||
}
|
||||
|
||||
return {
|
||||
type: "attached",
|
||||
url: this._dbg.url,
|
||||
};
|
||||
},
|
||||
|
||||
// This is called from the ThreadActor#onAttach method
|
||||
onThreadAttached() {
|
||||
// This isn't an RDP event and is only listened to from startup/worker.js.
|
||||
this.emit("worker-thread-attached");
|
||||
detach() {
|
||||
if (!this._attached) {
|
||||
return { error: "wrongState" };
|
||||
}
|
||||
|
||||
this._detach();
|
||||
|
||||
return { type: "detached" };
|
||||
},
|
||||
|
||||
destroy() {
|
||||
if (this._attached) {
|
||||
this._detach();
|
||||
}
|
||||
protocol.Actor.prototype.destroy.call(this);
|
||||
},
|
||||
|
||||
connect(options) {
|
||||
if (!this._attached) {
|
||||
return { error: "wrongState" };
|
||||
}
|
||||
|
||||
if (this._threadActor !== null) {
|
||||
return {
|
||||
type: "connected",
|
||||
threadActor: this._threadActor,
|
||||
};
|
||||
}
|
||||
|
||||
return connectToWorker(this.conn, this._dbg, this.actorID, options).then(
|
||||
({ threadActor, transport, consoleActor }) => {
|
||||
this._threadActor = threadActor;
|
||||
this._transport = transport;
|
||||
this._consoleActor = consoleActor;
|
||||
|
||||
return {
|
||||
type: "connected",
|
||||
threadActor: this._threadActor,
|
||||
consoleActor: this._consoleActor,
|
||||
};
|
||||
},
|
||||
error => {
|
||||
return { error: error.toString() };
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
push() {
|
||||
if (this._dbg.type !== Ci.nsIWorkerDebugger.TYPE_SERVICE) {
|
||||
return { error: "wrongType" };
|
||||
}
|
||||
const registration = this._getServiceWorkerRegistrationInfo();
|
||||
const originAttributes = ChromeUtils.originAttributesToSuffix(
|
||||
this._dbg.principal.originAttributes
|
||||
);
|
||||
swm.sendPushEvent(originAttributes, registration.scope);
|
||||
return { type: "pushed" };
|
||||
},
|
||||
|
||||
_onWorkerClose() {
|
||||
if (this._attached) {
|
||||
this._detach();
|
||||
}
|
||||
|
||||
this.conn.sendActorEvent(this.actorID, "close");
|
||||
},
|
||||
|
||||
_onWorkerError(filename, lineno, message) {
|
||||
reportError("ERROR:" + filename + ":" + lineno + ":" + message + "\n");
|
||||
},
|
||||
|
||||
_getServiceWorkerRegistrationInfo() {
|
||||
return swm.getRegistrationByPrincipal(this._dbg.principal, this._dbg.url);
|
||||
},
|
||||
|
||||
_getServiceWorkerInfo() {
|
||||
const registration = this._getServiceWorkerRegistrationInfo();
|
||||
return registration.getWorkerByID(this._dbg.serviceWorkerID);
|
||||
},
|
||||
|
||||
_detach() {
|
||||
if (this._threadActor !== null) {
|
||||
this._transport.close();
|
||||
this._transport = null;
|
||||
this._threadActor = null;
|
||||
}
|
||||
|
||||
// If the worker is already destroyed, nsIWorkerDebugger.type throws
|
||||
// (_dbg.closed appears to be false when it throws)
|
||||
let type;
|
||||
try {
|
||||
type = this._dbg.type;
|
||||
} catch (e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
const isServiceWorker = type == Ci.nsIWorkerDebugger.TYPE_SERVICE;
|
||||
if (isServiceWorker) {
|
||||
this._allowServiceWorkerShutdown();
|
||||
}
|
||||
|
||||
this._dbg.removeListener(this._dbgListener);
|
||||
this._attached = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Automatically disable the internal sw timeout that shut them down by calling
|
||||
* nsIWorkerInfo.attachDebugger().
|
||||
* This can be removed when Bug 1496997 lands.
|
||||
*/
|
||||
_preventServiceWorkerShutdown() {
|
||||
if (swm.isParentInterceptEnabled()) {
|
||||
// In parentIntercept mode, the worker target actor cannot call attachDebugger
|
||||
// because this API can only be called from the parent process. This will be
|
||||
// done by the worker target front.
|
||||
return;
|
||||
}
|
||||
|
||||
const worker = this._getServiceWorkerInfo();
|
||||
if (worker) {
|
||||
worker.attachDebugger();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Allow the service worker to time out. See _preventServiceWorkerShutdown.
|
||||
*/
|
||||
_allowServiceWorkerShutdown() {
|
||||
if (swm.isParentInterceptEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const worker = this._getServiceWorkerInfo();
|
||||
if (worker) {
|
||||
worker.detachDebugger();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
exports.WorkerTargetActor = WorkerTargetActor;
|
||||
|
|
|
@ -30,8 +30,8 @@ loader.lazyRequireGetter(
|
|||
);
|
||||
loader.lazyRequireGetter(
|
||||
this,
|
||||
"WorkerDescriptorActorList",
|
||||
"devtools/server/actors/worker/worker-descriptor-actor-list",
|
||||
"WorkerTargetActorList",
|
||||
"devtools/server/actors/worker/worker-target-actor-list",
|
||||
true
|
||||
);
|
||||
loader.lazyRequireGetter(
|
||||
|
@ -94,7 +94,7 @@ exports.createRootActor = function createRootActor(connection) {
|
|||
return new RootActor(connection, {
|
||||
tabList: new BrowserTabList(connection),
|
||||
addonList: new BrowserAddonList(connection),
|
||||
workerList: new WorkerDescriptorActorList(connection, {}),
|
||||
workerList: new WorkerTargetActorList(connection, {}),
|
||||
serviceWorkerRegistrationList: new ServiceWorkerRegistrationActorList(
|
||||
connection
|
||||
),
|
||||
|
|
|
@ -10,5 +10,5 @@ DevToolsModules(
|
|||
'service-worker-registration-list.js',
|
||||
'service-worker-registration.js',
|
||||
'service-worker.js',
|
||||
'worker-descriptor-actor-list.js',
|
||||
'worker-target-actor-list.js',
|
||||
)
|
||||
|
|
|
@ -228,7 +228,7 @@ const ServiceWorkerRegistrationActor = protocol.ActorClassWithSpec(
|
|||
*/
|
||||
preventShutdown() {
|
||||
if (!swm.isParentInterceptEnabled()) {
|
||||
// In non parent-intercept mode, this is handled by the WorkerDescriptorActor attach().
|
||||
// In non parent-intercept mode, this is handled by the WorkerTargetActor attach().
|
||||
throw new Error(
|
||||
"ServiceWorkerRegistrationActor.preventShutdown can only be used " +
|
||||
"in parent-intercept mode"
|
||||
|
@ -252,7 +252,7 @@ const ServiceWorkerRegistrationActor = protocol.ActorClassWithSpec(
|
|||
*/
|
||||
allowShutdown() {
|
||||
if (!swm.isParentInterceptEnabled()) {
|
||||
// In non parent-intercept mode, this is handled by the WorkerDescriptorActor detach().
|
||||
// In non parent-intercept mode, this is handled by the WorkerTargetActor detach().
|
||||
throw new Error(
|
||||
"ServiceWorkerRegistrationActor.allowShutdown can only be used " +
|
||||
"in parent-intercept mode"
|
||||
|
|
|
@ -8,8 +8,8 @@ const { Ci } = require("chrome");
|
|||
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||
loader.lazyRequireGetter(
|
||||
this,
|
||||
"WorkerDescriptorActor",
|
||||
"devtools/server/actors/descriptors/worker",
|
||||
"WorkerTargetActor",
|
||||
"devtools/server/actors/targets/worker",
|
||||
true
|
||||
);
|
||||
|
||||
|
@ -48,7 +48,7 @@ function matchServiceWorker(dbg, origin) {
|
|||
// When a new worker appears, in some cases (i.e. the debugger is running) we
|
||||
// want it to pause during registration until a later time (i.e. the debugger
|
||||
// finishes attaching to the worker). This is an optional WorkderDebuggerManager
|
||||
// listener that can be installed in addition to the WorkerDescriptorActorList
|
||||
// listener that can be installed in addition to the WorkerTargetActorList
|
||||
// listener. It always listens to new workers and pauses any matching filters
|
||||
// which have been set on it.
|
||||
//
|
||||
|
@ -60,7 +60,7 @@ function matchServiceWorker(dbg, origin) {
|
|||
// setPauseServiceWorkers(origin) will pause all service workers which have the
|
||||
// specified origin.
|
||||
//
|
||||
// FIXME Bug 1601279 separate WorkerPauser from WorkerDescriptorActorList and give
|
||||
// FIXME Bug 1601279 separate WorkerPauser from WorkerTargetActorList and give
|
||||
// it a more consistent interface.
|
||||
function WorkerPauser(options) {
|
||||
this._options = options;
|
||||
|
@ -99,7 +99,7 @@ WorkerPauser.prototype = {
|
|||
},
|
||||
};
|
||||
|
||||
function WorkerDescriptorActorList(conn, options) {
|
||||
function WorkerTargetActorList(conn, options) {
|
||||
this._conn = conn;
|
||||
this._options = options;
|
||||
this._actors = new Map();
|
||||
|
@ -110,7 +110,7 @@ function WorkerDescriptorActorList(conn, options) {
|
|||
this.onUnregister = this.onUnregister.bind(this);
|
||||
}
|
||||
|
||||
WorkerDescriptorActorList.prototype = {
|
||||
WorkerTargetActorList.prototype = {
|
||||
destroy() {
|
||||
this.onListChanged = null;
|
||||
if (this._workerPauser) {
|
||||
|
@ -138,7 +138,7 @@ WorkerDescriptorActorList.prototype = {
|
|||
// Create an actor for each debugger for which we don't have one.
|
||||
for (const dbg of dbgs) {
|
||||
if (!this._actors.has(dbg)) {
|
||||
this._actors.set(dbg, new WorkerDescriptorActor(this._conn, dbg));
|
||||
this._actors.set(dbg, new WorkerTargetActor(this._conn, dbg));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,4 +209,4 @@ WorkerDescriptorActorList.prototype = {
|
|||
},
|
||||
};
|
||||
|
||||
exports.WorkerDescriptorActorList = WorkerDescriptorActorList;
|
||||
exports.WorkerTargetActorList = WorkerTargetActorList;
|
|
@ -38,7 +38,7 @@ function connectToWorker(connection, dbg, id, options) {
|
|||
onMessage: message => {
|
||||
message = JSON.parse(message);
|
||||
if (message.type !== "rpc") {
|
||||
if (message.type == "worker-thread-attached") {
|
||||
if (message.type == "attached") {
|
||||
// The thread actor has finished attaching and can hit installed
|
||||
// breakpoints. Allow content to begin executing in the worker.
|
||||
dbg.setDebuggerReady(true);
|
||||
|
@ -164,7 +164,8 @@ function connectToWorker(connection, dbg, id, options) {
|
|||
connection.setForwarding(id, transport);
|
||||
|
||||
resolve({
|
||||
workerTargetForm: message.workerTargetForm,
|
||||
threadActor: message.threadActor,
|
||||
consoleActor: message.consoleActor,
|
||||
transport: transport,
|
||||
});
|
||||
},
|
||||
|
|
|
@ -37,10 +37,13 @@ this.rpc = function(method, ...params) {
|
|||
loadSubScript("resource://devtools/shared/worker/loader.js");
|
||||
|
||||
var defer = worker.require("devtools/shared/defer");
|
||||
const { WorkerTargetActor } = worker.require(
|
||||
"devtools/server/actors/targets/worker"
|
||||
);
|
||||
const { Actor } = worker.require("devtools/shared/protocol/Actor");
|
||||
var { ThreadActor } = worker.require("devtools/server/actors/thread");
|
||||
var { WebConsoleActor } = worker.require("devtools/server/actors/webconsole");
|
||||
var { TabSources } = worker.require("devtools/server/actors/utils/TabSources");
|
||||
var makeDebugger = worker.require("devtools/server/actors/utils/make-debugger");
|
||||
var { DevToolsServer } = worker.require("devtools/server/devtools-server");
|
||||
var Targets = worker.require("devtools/server/actors/targets/index");
|
||||
|
||||
DevToolsServer.init();
|
||||
DevToolsServer.createRootActor = function() {
|
||||
|
@ -58,16 +61,59 @@ this.addEventListener("message", function(event) {
|
|||
// Step 3: Create a connection to the parent.
|
||||
const connection = DevToolsServer.connectToParent(packet.id, this);
|
||||
|
||||
// Step 4: Create a WorkerTarget actor.
|
||||
const workerTargetActor = new WorkerTargetActor(connection, global);
|
||||
// Step 4: Create a thread actor for the connection to the parent.
|
||||
let sources = null;
|
||||
|
||||
workerTargetActor.on(
|
||||
"worker-thread-attached",
|
||||
function onThreadAttached() {
|
||||
postMessage(JSON.stringify({ type: "worker-thread-attached" }));
|
||||
}
|
||||
);
|
||||
workerTargetActor.attach();
|
||||
const makeWorkerDebugger = makeDebugger.bind(null, {
|
||||
findDebuggees: () => {
|
||||
return [this.global];
|
||||
},
|
||||
|
||||
shouldAddNewGlobalAsDebuggee: () => {
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
||||
const targetActorMock = new Actor();
|
||||
targetActorMock.initialize(connection);
|
||||
|
||||
const threadActor = new ThreadActor(targetActorMock, global);
|
||||
targetActorMock.manage(threadActor);
|
||||
|
||||
Object.assign(targetActorMock, {
|
||||
actorID: packet.id,
|
||||
targetType: Targets.TYPES.FRAME,
|
||||
|
||||
// threadActor is needed from the webconsole for grip previewing
|
||||
threadActor,
|
||||
workerGlobal: global,
|
||||
|
||||
onThreadAttached() {
|
||||
postMessage(JSON.stringify({ type: "attached" }));
|
||||
},
|
||||
|
||||
get dbg() {
|
||||
if (!this._dbg) {
|
||||
this._dbg = makeWorkerDebugger();
|
||||
}
|
||||
return this._dbg;
|
||||
},
|
||||
makeDebugger: makeWorkerDebugger,
|
||||
|
||||
get sources() {
|
||||
if (sources === null) {
|
||||
sources = new TabSources(threadActor);
|
||||
}
|
||||
return sources;
|
||||
},
|
||||
});
|
||||
|
||||
const consoleActor = new WebConsoleActor(connection, targetActorMock);
|
||||
targetActorMock.manage(consoleActor);
|
||||
|
||||
// needed so the thread actor can communicate with the console
|
||||
// when evaluating logpoints.
|
||||
targetActorMock._consoleActor = consoleActor;
|
||||
|
||||
// Step 5: Send a response packet to the parent to notify
|
||||
// it that a connection has been established.
|
||||
|
@ -80,10 +126,10 @@ this.addEventListener("message", function(event) {
|
|||
JSON.stringify({
|
||||
type: "connected",
|
||||
id: packet.id,
|
||||
workerTargetForm: workerTargetActor.form(),
|
||||
threadActor: threadActor.actorID,
|
||||
consoleActor: consoleActor.actorID,
|
||||
})
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case "disconnect":
|
||||
|
|
|
@ -363,7 +363,7 @@ class TargetList extends EventEmitter {
|
|||
return TargetList.TYPES.PROCESS;
|
||||
}
|
||||
|
||||
if (typeName == "workerDescriptor") {
|
||||
if (typeName == "workerTarget") {
|
||||
if (target.isSharedWorker) {
|
||||
return TargetList.TYPES.SHARED_WORKER;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,5 @@ DevToolsModules(
|
|||
'process.js',
|
||||
'tab.js',
|
||||
'webextension.js',
|
||||
'worker.js',
|
||||
)
|
||||
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const { Arg, RetVal, generateActorSpec } = require("devtools/shared/protocol");
|
||||
|
||||
const workerDescriptorSpec = generateActorSpec({
|
||||
typeName: "workerDescriptor",
|
||||
|
||||
methods: {
|
||||
attach: {
|
||||
request: {},
|
||||
response: RetVal("json"),
|
||||
},
|
||||
detach: {
|
||||
request: {},
|
||||
response: RetVal("json"),
|
||||
},
|
||||
// Backwards compatibility for FF82 servers and below.
|
||||
// Can be deleted once FF83 is merged into release.
|
||||
connect: {
|
||||
request: {
|
||||
options: Arg(0, "json"),
|
||||
},
|
||||
response: RetVal("json"),
|
||||
},
|
||||
getTarget: {
|
||||
request: {},
|
||||
response: RetVal("json"),
|
||||
},
|
||||
push: {
|
||||
request: {},
|
||||
response: RetVal("json"),
|
||||
},
|
||||
},
|
||||
|
||||
events: {
|
||||
// WorkerDescriptorActor still uses old sendActorEvent function,
|
||||
// but it should use emit instead.
|
||||
// Do not emit a `close` event as Target class emit this event on destroy
|
||||
"worker-close": {
|
||||
type: "close",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
exports.workerDescriptorSpec = workerDescriptorSpec;
|
|
@ -77,11 +77,6 @@ const Types = (exports.__TypesForTests = [
|
|||
spec: "devtools/shared/specs/descriptors/webextension",
|
||||
front: "devtools/client/fronts/descriptors/webextension",
|
||||
},
|
||||
{
|
||||
types: ["workerDescriptor"],
|
||||
spec: "devtools/shared/specs/descriptors/worker",
|
||||
front: "devtools/client/fronts/descriptors/worker",
|
||||
},
|
||||
{
|
||||
types: ["device"],
|
||||
spec: "devtools/shared/specs/device",
|
||||
|
@ -285,7 +280,7 @@ const Types = (exports.__TypesForTests = [
|
|||
{
|
||||
types: ["workerTarget"],
|
||||
spec: "devtools/shared/specs/targets/worker",
|
||||
front: null,
|
||||
front: "devtools/client/fronts/targets/worker",
|
||||
},
|
||||
{
|
||||
types: ["thread"],
|
||||
|
|
|
@ -12,7 +12,7 @@ const {
|
|||
} = require("devtools/shared/protocol");
|
||||
|
||||
types.addDictType("root.listWorkers", {
|
||||
workers: "array:workerDescriptor",
|
||||
workers: "array:workerTarget",
|
||||
});
|
||||
types.addDictType("root.listServiceWorkerRegistrations", {
|
||||
registrations: "array:serviceWorkerRegistration",
|
||||
|
|
|
@ -35,7 +35,7 @@ types.addDictType("browsingContextTarget.window", {
|
|||
});
|
||||
|
||||
types.addDictType("browsingContextTarget.workers", {
|
||||
workers: "array:workerDescriptor",
|
||||
workers: "array:workerTarget",
|
||||
});
|
||||
|
||||
types.addDictType("browsingContextTarget.reload", {
|
||||
|
|
|
@ -12,7 +12,7 @@ const {
|
|||
|
||||
types.addDictType("contentProcessTarget.workers", {
|
||||
error: "nullable:string",
|
||||
workers: "nullable:array:workerDescriptor",
|
||||
workers: "nullable:array:workerTarget",
|
||||
});
|
||||
|
||||
const contentProcessTargetSpec = generateActorSpec({
|
||||
|
|
|
@ -3,15 +3,40 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const { generateActorSpec } = require("devtools/shared/protocol");
|
||||
|
||||
// XXX: This actor doesn't expose any methods and events yet, but will in the future
|
||||
// (e.g. resource-available-form and resource-destroyed-form).
|
||||
const { Arg, RetVal, generateActorSpec } = require("devtools/shared/protocol");
|
||||
|
||||
const workerTargetSpec = generateActorSpec({
|
||||
typeName: "workerTarget",
|
||||
methods: {},
|
||||
events: {},
|
||||
|
||||
methods: {
|
||||
attach: {
|
||||
request: {},
|
||||
response: RetVal("json"),
|
||||
},
|
||||
detach: {
|
||||
request: {},
|
||||
response: RetVal("json"),
|
||||
},
|
||||
connect: {
|
||||
request: {
|
||||
options: Arg(0, "json"),
|
||||
},
|
||||
response: RetVal("json"),
|
||||
},
|
||||
push: {
|
||||
request: {},
|
||||
response: RetVal("json"),
|
||||
},
|
||||
},
|
||||
|
||||
events: {
|
||||
// WorkerTargetActor still uses old sendActorEvent function,
|
||||
// but it should use emit instead.
|
||||
// Do not emit a `close` event as Target class emit this event on destroy
|
||||
"worker-close": {
|
||||
type: "close",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
exports.workerTargetSpec = workerTargetSpec;
|
||||
|
|
|
@ -23,7 +23,7 @@ const {
|
|||
ServiceWorkerRegistrationActorList,
|
||||
} = require("devtools/server/actors/worker/service-worker-registration-list");
|
||||
const {
|
||||
WorkerDescriptorActorList,
|
||||
WorkerTargetActorList,
|
||||
} = require("devtools/server/actors/worker/worker-target-actor-list");
|
||||
|
||||
const { ProcessActorList } = require("devtools/server/actors/process");
|
||||
|
@ -43,7 +43,7 @@ exports.createRootActor = function createRootActor(aConnection) {
|
|||
const parameters = {
|
||||
tabList: new MobileTabList(aConnection),
|
||||
addonList: new BrowserAddonList(aConnection),
|
||||
workerList: new WorkerDescriptorActorList(aConnection, {}),
|
||||
workerList: new WorkerTargetActorList(aConnection, {}),
|
||||
serviceWorkerRegistrationList: new ServiceWorkerRegistrationActorList(
|
||||
aConnection
|
||||
),
|
||||
|
|
Загрузка…
Ссылка в новой задаче