зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1459962 - Part 1: return all service workers for a given registration r=jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D70365
This commit is contained in:
Родитель
725728fc20
Коммит
e5cbda98ef
|
@ -107,7 +107,6 @@ class Worker extends PureComponent {
|
|||
} else if (this.isActive()) {
|
||||
return l10n.getString("serviceworker-worker-status-stopped");
|
||||
}
|
||||
|
||||
// NOTE: this is already localized by the service worker front
|
||||
// (strings are in debugger.properties)
|
||||
return this.props.worker.stateText;
|
||||
|
|
|
@ -55,7 +55,7 @@ class WorkerList extends PureComponent {
|
|||
{},
|
||||
workers.map(worker =>
|
||||
Worker({
|
||||
key: worker.id,
|
||||
key: `${worker.id}-${worker.state}`,
|
||||
isDebugEnabled: canDebugWorkers,
|
||||
worker,
|
||||
})
|
||||
|
|
|
@ -16,12 +16,15 @@ Array [
|
|||
<ul>
|
||||
<Worker
|
||||
isDebugEnabled={true}
|
||||
key="id-worker-1-example-0"
|
||||
worker={
|
||||
Object {
|
||||
"active": true,
|
||||
"id": "id-worker-1-example",
|
||||
"name": "worker1",
|
||||
"registrationFront": "",
|
||||
"scope": "SCOPE 123",
|
||||
"state": 0,
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerTargetFront": "",
|
||||
}
|
||||
|
@ -62,12 +65,15 @@ Array [
|
|||
<ul>
|
||||
<Worker
|
||||
isDebugEnabled={true}
|
||||
key="id-worker-1-example-0"
|
||||
worker={
|
||||
Object {
|
||||
"active": true,
|
||||
"id": "id-worker-1-example",
|
||||
"name": "worker1",
|
||||
"registrationFront": "",
|
||||
"scope": "SCOPE 123",
|
||||
"state": 0,
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerTargetFront": "",
|
||||
}
|
||||
|
@ -75,12 +81,15 @@ Array [
|
|||
/>
|
||||
<Worker
|
||||
isDebugEnabled={true}
|
||||
key="id-worker-2-example-0"
|
||||
worker={
|
||||
Object {
|
||||
"active": false,
|
||||
"id": "id-worker-2-example",
|
||||
"name": "worker2",
|
||||
"registrationFront": "",
|
||||
"scope": "SCOPE 456",
|
||||
"state": 0,
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerTargetFront": "",
|
||||
}
|
||||
|
@ -88,12 +97,15 @@ Array [
|
|||
/>
|
||||
<Worker
|
||||
isDebugEnabled={true}
|
||||
key="id-worker-3-example-0"
|
||||
worker={
|
||||
Object {
|
||||
"active": true,
|
||||
"id": "id-worker-3-example",
|
||||
"name": "worker3",
|
||||
"registrationFront": "",
|
||||
"scope": "SCOPE 789",
|
||||
"state": 0,
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerTargetFront": "",
|
||||
}
|
||||
|
|
|
@ -10,17 +10,21 @@ exports[`WorkersPage filters out workers from diferent domains 1`] = `
|
|||
Array [
|
||||
Object {
|
||||
"active": true,
|
||||
"id": "id-worker-1-example",
|
||||
"name": "worker1",
|
||||
"registrationFront": "",
|
||||
"scope": "SCOPE 123",
|
||||
"state": 0,
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerTargetFront": "",
|
||||
},
|
||||
Object {
|
||||
"active": false,
|
||||
"id": "id-worker-2-example",
|
||||
"name": "worker2",
|
||||
"registrationFront": "",
|
||||
"scope": "SCOPE 456",
|
||||
"state": 0,
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerTargetFront": "",
|
||||
},
|
||||
|
@ -48,9 +52,11 @@ exports[`WorkersPage it renders a list with a single element if there's just 1 w
|
|||
Array [
|
||||
Object {
|
||||
"active": true,
|
||||
"id": "id-worker-1-example",
|
||||
"name": "worker1",
|
||||
"registrationFront": "",
|
||||
"scope": "SCOPE 123",
|
||||
"state": 0,
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerTargetFront": "",
|
||||
},
|
||||
|
@ -70,25 +76,31 @@ exports[`WorkersPage renders a list with multiple elements when there are multip
|
|||
Array [
|
||||
Object {
|
||||
"active": true,
|
||||
"id": "id-worker-1-example",
|
||||
"name": "worker1",
|
||||
"registrationFront": "",
|
||||
"scope": "SCOPE 123",
|
||||
"state": 0,
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerTargetFront": "",
|
||||
},
|
||||
Object {
|
||||
"active": false,
|
||||
"id": "id-worker-2-example",
|
||||
"name": "worker2",
|
||||
"registrationFront": "",
|
||||
"scope": "SCOPE 456",
|
||||
"state": 0,
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerTargetFront": "",
|
||||
},
|
||||
Object {
|
||||
"active": true,
|
||||
"id": "id-worker-3-example",
|
||||
"name": "worker3",
|
||||
"registrationFront": "",
|
||||
"scope": "SCOPE 789",
|
||||
"state": 0,
|
||||
"url": "http://example.com/worker.js",
|
||||
"workerTargetFront": "",
|
||||
},
|
||||
|
|
|
@ -14,6 +14,8 @@ const SINGLE_WORKER_DEFAULT_DOMAIN_LIST = [
|
|||
registrationFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://example.com/worker.js",
|
||||
id: "id-worker-1-example",
|
||||
state: 0,
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -25,6 +27,8 @@ const SINGLE_WORKER_DIFFERENT_DOMAIN_LIST = [
|
|||
registrationFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://different-example.com/worker.js",
|
||||
id: "id-worker-1-different-example",
|
||||
state: 0,
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -36,6 +40,8 @@ const MULTIPLE_WORKER_LIST = [
|
|||
registrationFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://example.com/worker.js",
|
||||
id: "id-worker-1-example",
|
||||
state: 0,
|
||||
},
|
||||
{
|
||||
active: false,
|
||||
|
@ -44,6 +50,8 @@ const MULTIPLE_WORKER_LIST = [
|
|||
registrationFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://example.com/worker.js",
|
||||
id: "id-worker-2-example",
|
||||
state: 0,
|
||||
},
|
||||
{
|
||||
active: true,
|
||||
|
@ -52,6 +60,8 @@ const MULTIPLE_WORKER_LIST = [
|
|||
registrationFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://example.com/worker.js",
|
||||
id: "id-worker-3-example",
|
||||
state: 0,
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -63,6 +73,8 @@ const MULTIPLE_WORKER_MIXED_DOMAINS_LIST = [
|
|||
registrationFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://example.com/worker.js",
|
||||
id: "id-worker-1-example",
|
||||
state: 0,
|
||||
},
|
||||
{
|
||||
active: false,
|
||||
|
@ -71,6 +83,8 @@ const MULTIPLE_WORKER_MIXED_DOMAINS_LIST = [
|
|||
registrationFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://example.com/worker.js",
|
||||
id: "id-worker-2-example",
|
||||
state: 0,
|
||||
},
|
||||
{
|
||||
active: true,
|
||||
|
@ -79,6 +93,8 @@ const MULTIPLE_WORKER_MIXED_DOMAINS_LIST = [
|
|||
registrationFront: "",
|
||||
workerTargetFront: "",
|
||||
url: "http://different-example.com/worker.js",
|
||||
id: "id-worker-3-different-example",
|
||||
state: 0,
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
@ -59,36 +59,36 @@ class RootFront extends FrontClassWithSpec(rootSpec) {
|
|||
: await this.listAllWorkerTargets();
|
||||
|
||||
for (const registrationFront of registrations) {
|
||||
// TODO: add all workers to the result. See Bug 1612897
|
||||
const latestWorker =
|
||||
registrationFront.activeWorker ||
|
||||
registrationFront.waitingWorker ||
|
||||
registrationFront.installingWorker ||
|
||||
registrationFront.evaluatingWorker;
|
||||
|
||||
if (latestWorker !== null) {
|
||||
const latestWorkerFront = allWorkers.find(
|
||||
workerFront => workerFront.id === latestWorker.id
|
||||
// workers from the registration, ordered from most recent to older
|
||||
const workers = [
|
||||
registrationFront.activeWorker,
|
||||
registrationFront.waitingWorker,
|
||||
registrationFront.installingWorker,
|
||||
registrationFront.evaluatingWorker,
|
||||
]
|
||||
.filter(w => !!w) // filter out non-existing workers
|
||||
// build a worker object with its WorkerTargetFront
|
||||
.map(workerFront => {
|
||||
const workerTargetFront = allWorkers.find(
|
||||
targetFront => targetFront.id === workerFront.id
|
||||
);
|
||||
if (latestWorkerFront) {
|
||||
registrationFront.workerTargetFront = latestWorkerFront;
|
||||
}
|
||||
|
||||
return {
|
||||
id: registrationFront.id,
|
||||
name: workerFront.url,
|
||||
state: workerFront.state,
|
||||
stateText: workerFront.stateText,
|
||||
url: workerFront.url,
|
||||
workerTargetFront,
|
||||
};
|
||||
});
|
||||
|
||||
// TODO: return only the worker targets. See Bug 1620605
|
||||
result.push({
|
||||
registration: registrationFront,
|
||||
workers: [
|
||||
{
|
||||
id: registrationFront.id,
|
||||
name: latestWorker.url,
|
||||
state: latestWorker.state,
|
||||
stateText: latestWorker.stateText,
|
||||
url: latestWorker.url,
|
||||
workerTargetFront: latestWorkerFront,
|
||||
},
|
||||
],
|
||||
workers,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -112,10 +112,14 @@ class RootFront extends FrontClassWithSpec(rootSpec) {
|
|||
const allWorkers = await this.listAllWorkerTargets();
|
||||
const serviceWorkers = await this.listAllServiceWorkers(allWorkers);
|
||||
|
||||
// NOTE: listAllServiceWorkers() now returns all the workers belonging to
|
||||
// a registration. To preserve the usual behavior at about:debugging,
|
||||
// in which we show only the most recent one, we grab the first
|
||||
// worker in the array only.
|
||||
const result = {
|
||||
service: serviceWorkers
|
||||
.map(({ registration, workers }) => {
|
||||
return workers.map(worker => {
|
||||
return workers.slice(0, 1).map(worker => {
|
||||
return Object.assign(worker, {
|
||||
registrationFront: registration,
|
||||
fetch: registration.fetch,
|
||||
|
|
Загрузка…
Ссылка в новой задаче