Bug 1557170 - Add isParentInterceptEnabled trait to ServiceWorkerRegistration actor r=daisuke

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Julian Descottes 2019-08-28 06:38:47 +00:00
Родитель 451bc0629c
Коммит 8a65fc4677
4 изменённых файлов: 11 добавлений и 27 удалений

Просмотреть файл

@ -143,13 +143,6 @@ function installTemporaryExtension() {
function pushServiceWorker(id, registrationFront) {
return async (_, getState) => {
try {
const clientWrapper = getCurrentClient(getState().runtimes);
const deviceFront = await clientWrapper.getFront("device");
// TODO: device description should already have been received, so this
// call should be able to be avoided (bug 1557250).
const { isParentInterceptEnabled } = await deviceFront.getDescription();
/**
* Older servers will not define `ServiceWorkerRegistrationFront.push`,
* and `ServiceWorkerRegistrationFront.push` will only work if the
@ -160,9 +153,11 @@ function pushServiceWorker(id, registrationFront) {
* _and_ parent-intercept is stable (which definitely won't happen when
* the release channel is < FF69).
*/
const { isParentInterceptEnabled } = registrationFront.traits;
if (registrationFront.push && isParentInterceptEnabled) {
await registrationFront.push();
} else {
const clientWrapper = getCurrentClient(getState().runtimes);
const workerActor = await clientWrapper.getServiceWorkerFront({ id });
await workerActor.push();
}

Просмотреть файл

@ -72,9 +72,10 @@ const ServiceWorkerRegistrationActor = protocol.ActorClassWithSpec(
const newestWorker = activeWorker || waitingWorker || installingWorker;
const isNewE10sImplementation = swm.isParentInterceptEnabled();
const isParentInterceptEnabled = swm.isParentInterceptEnabled();
const isMultiE10sWithOldImplementation =
Services.appinfo.browserTabsRemoteAutostart && !isNewE10sImplementation;
Services.appinfo.browserTabsRemoteAutostart &&
!isParentInterceptEnabled;
return {
actor: this.actorID,
scope: registration.scope,
@ -87,6 +88,9 @@ const ServiceWorkerRegistrationActor = protocol.ActorClassWithSpec(
// - In non-e10s or new implementaion: check if we have an active worker
active: isMultiE10sWithOldImplementation ? true : !!activeWorker,
lastUpdateTime: registration.lastUpdateTime,
traits: {
isParentInterceptEnabled,
},
};
},

Просмотреть файл

@ -9,7 +9,6 @@ const {
FrontClassWithSpec,
registerFront,
} = require("devtools/shared/protocol");
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
loader.lazyRequireGetter(this, "getFront", "devtools/shared/protocol", true);
loader.lazyRequireGetter(
@ -31,13 +30,6 @@ loader.lazyRequireGetter(
true
);
XPCOMUtils.defineLazyServiceGetter(
this,
"swm",
"@mozilla.org/serviceworkers/manager;1",
"nsIServiceWorkerManager"
);
class RootFront extends FrontClassWithSpec(rootSpec) {
constructor(client, form) {
super(client);
@ -135,16 +127,6 @@ class RootFront extends FrontClassWithSpec(rootSpec) {
});
});
/**
* FIXME (bug 1557170): Make this compatible with remote debugging.
*
* Getting the value from `ServiceWorkerManager.isParentInterceptEnabled`
* may not return the same value as what exists on a remote server.
* Unfortunately, calling `DeviceFront.getDescription()` here to read the
* dom.serviceWorkers.parent_intercept pref causes test failures.
*/
const isParentInterceptEnabled = swm.isParentInterceptEnabled();
workers.forEach(front => {
const worker = {
id: front.id,
@ -165,6 +147,7 @@ class RootFront extends FrontClassWithSpec(rootSpec) {
* >= FF69 _and_ parent-intercept is stable (which definitely won't
* happen when the release channel is < FF69).
*/
const { isParentInterceptEnabled } = r.registrationFront.traits;
if (!r.newestWorkerId || !isParentInterceptEnabled) {
return r.scope === front.scope;
}

Просмотреть файл

@ -66,6 +66,8 @@ class ServiceWorkerRegistrationFront extends FrontClassWithSpec(
form(form) {
this.actorID = form.actor;
this._form = form;
// FF70+ ServiceWorkerRegistration actor starts exposing traits object
this.traits = form.traits || {};
}
}