Bug 1595964 Part 2 - Expose evaluating worker in service worker registration front, r=jdescottes.

Depends on D54286

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brian Hackett 2019-12-07 16:13:07 +00:00
parent 2f8d4e8dd9
commit 8f4a55899e
4 changed files with 36 additions and 6 deletions

View File

@ -71,11 +71,13 @@ const ServiceWorkerRegistrationActor = protocol.ActorClassWithSpec(
form() {
const registration = this._registration;
const evaluatingWorker = this._evaluatingWorker.form();
const installingWorker = this._installingWorker.form();
const waitingWorker = this._waitingWorker.form();
const activeWorker = this._activeWorker.form();
const newestWorker = activeWorker || waitingWorker || installingWorker;
const newestWorker =
activeWorker || waitingWorker || installingWorker || evaluatingWorker;
const isParentInterceptEnabled = swm.isParentInterceptEnabled();
const isMultiE10sWithOldImplementation =
@ -85,6 +87,7 @@ const ServiceWorkerRegistrationActor = protocol.ActorClassWithSpec(
actor: this.actorID,
scope: registration.scope,
url: registration.scriptSpec,
evaluatingWorker,
installingWorker,
waitingWorker,
activeWorker,
@ -121,6 +124,7 @@ const ServiceWorkerRegistrationActor = protocol.ActorClassWithSpec(
this._destroyServiceWorkerActors();
this._evaluatingWorker = null;
this._installingWorker = null;
this._waitingWorker = null;
this._activeWorker = null;
@ -297,6 +301,7 @@ const ServiceWorkerRegistrationActor = protocol.ActorClassWithSpec(
},
_destroyServiceWorkerActors() {
this._evaluatingWorker.destroy();
this._installingWorker.destroy();
this._waitingWorker.destroy();
this._activeWorker.destroy();
@ -304,11 +309,16 @@ const ServiceWorkerRegistrationActor = protocol.ActorClassWithSpec(
_createServiceWorkerActors() {
const {
evaluatingWorker,
installingWorker,
waitingWorker,
activeWorker,
} = this._registration;
this._evaluatingWorker = new ServiceWorkerActor(
this._conn,
evaluatingWorker
);
this._installingWorker = new ServiceWorkerActor(
this._conn,
installingWorker
@ -318,6 +328,7 @@ const ServiceWorkerRegistrationActor = protocol.ActorClassWithSpec(
// Add the ServiceWorker actors as children of this ServiceWorkerRegistration actor,
// assigning them valid actorIDs.
this.manage(this._evaluatingWorker);
this.manage(this._installingWorker);
this.manage(this._waitingWorker);
this.manage(this._activeWorker);

View File

@ -4,6 +4,7 @@
"use strict";
const { Ci } = require("chrome");
const protocol = require("devtools/shared/protocol");
const {
serviceWorkerSpec,
@ -20,11 +21,17 @@ const ServiceWorkerActor = protocol.ActorClassWithSpec(serviceWorkerSpec, {
return null;
}
// handlesFetchEvents is not available if the worker's main script is in the
// evaluating state.
const isEvaluating =
this._worker.state == Ci.nsIServiceWorkerInfo.STATE_PARSED;
const fetch = isEvaluating ? undefined : this._worker.handlesFetchEvents;
return {
actor: this.actorID,
url: this._worker.scriptSpec,
state: this._worker.state,
fetch: this._worker.handlesFetchEvents,
fetch,
id: this._worker.id,
};
},

View File

@ -106,8 +106,14 @@ class RootFront extends FrontClassWithSpec(rootSpec) {
};
registrations.forEach(front => {
const { activeWorker, waitingWorker, installingWorker } = front;
const newestWorker = activeWorker || waitingWorker || installingWorker;
const {
activeWorker,
waitingWorker,
installingWorker,
evaluatingWorker,
} = front;
const newestWorker =
activeWorker || waitingWorker || installingWorker || evaluatingWorker;
// All the information is simply mirrored from the registration front.
// However since registering workers will fetch similar information from the worker
@ -165,8 +171,10 @@ class RootFront extends FrontClassWithSpec(rootSpec) {
});
if (registration) {
// XXX: Race, sometimes a ServiceWorkerRegistrationInfo doesn't
// have a scriptSpec, but its associated WorkerDebugger does.
// Before bug 1595964, URLs were not available for registrations
// whose worker's main script is being evaluated. Now, URLs are
// always available, and this test deals with older servers.
// @backward-compatibility: remove in Firefox 75
if (!registration.url) {
registration.name = registration.url = front.url;
}

View File

@ -43,6 +43,10 @@ class ServiceWorkerRegistrationFront extends FrontClassWithSpec(
return this._form.url;
}
get evaluatingWorker() {
return this._getServiceWorker("evaluatingWorker");
}
get activeWorker() {
return this._getServiceWorker("activeWorker");
}