From 8a65fc4677e4123122e36879be6e05b408e13333 Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Wed, 28 Aug 2019 06:38:47 +0000 Subject: [PATCH] Bug 1557170 - Add isParentInterceptEnabled trait to ServiceWorkerRegistration actor r=daisuke Differential Revision: https://phabricator.services.mozilla.com/D43598 --HG-- extra : moz-landing-system : lando --- .../src/actions/debug-targets.js | 9 ++------- .../worker/service-worker-registration.js | 8 ++++++-- devtools/shared/fronts/root.js | 19 +------------------ .../worker/service-worker-registration.js | 2 ++ 4 files changed, 11 insertions(+), 27 deletions(-) diff --git a/devtools/client/aboutdebugging/src/actions/debug-targets.js b/devtools/client/aboutdebugging/src/actions/debug-targets.js index b2586e490dd7..6844839427a6 100644 --- a/devtools/client/aboutdebugging/src/actions/debug-targets.js +++ b/devtools/client/aboutdebugging/src/actions/debug-targets.js @@ -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(); } diff --git a/devtools/server/actors/worker/service-worker-registration.js b/devtools/server/actors/worker/service-worker-registration.js index 922ade1d2cdc..7d5d4f122ea0 100644 --- a/devtools/server/actors/worker/service-worker-registration.js +++ b/devtools/server/actors/worker/service-worker-registration.js @@ -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, + }, }; }, diff --git a/devtools/shared/fronts/root.js b/devtools/shared/fronts/root.js index a0c18c31e54e..175e41f057ae 100644 --- a/devtools/shared/fronts/root.js +++ b/devtools/shared/fronts/root.js @@ -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; } diff --git a/devtools/shared/fronts/worker/service-worker-registration.js b/devtools/shared/fronts/worker/service-worker-registration.js index af6291d6e58e..0c55910487b9 100644 --- a/devtools/shared/fronts/worker/service-worker-registration.js +++ b/devtools/shared/fronts/worker/service-worker-registration.js @@ -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 || {}; } }