Created
May 27, 2019 16:11
-
-
Save juliandescottes/7f51cb771418a2aa537d4c57a34e11a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/devtools/client/aboutdebugging-new/src/actions/debug-targets.js b/devtools/client/aboutdebugging-new/src/actions/debug-targets.js | |
--- a/devtools/client/aboutdebugging-new/src/actions/debug-targets.js | |
+++ b/devtools/client/aboutdebugging-new/src/actions/debug-targets.js | |
@@ -124,28 +124,25 @@ function installTemporaryExtension() { | |
await AddonManager.installTemporaryAddon(file); | |
dispatch({ type: TEMPORARY_EXTENSION_INSTALL_SUCCESS }); | |
} catch (e) { | |
dispatch({ type: TEMPORARY_EXTENSION_INSTALL_FAILURE, error: e }); | |
} | |
}; | |
} | |
-function pushServiceWorker(id) { | |
+function pushServiceWorker(id, registrationFront) { | |
return async (_, getState) => { | |
- const clientWrapper = getCurrentClient(getState().runtimes); | |
- | |
try { | |
- const workerActor = await clientWrapper.getServiceWorkerFront({ id }); | |
- | |
- if (swm.isParentInterceptEnabled()) { | |
- const { originAttributes, scope } = | |
- workerActor.serviceWorkerRegistration; | |
- swm.sendPushEvent(originAttributes, scope); | |
+ if (registrationFront.push) { | |
+ await registrationFront.push(); | |
} else { | |
+ // Backward compatibility. Remove when FF69 is on release channel. | |
+ const clientWrapper = getCurrentClient(getState().runtimes); | |
+ const workerActor = await clientWrapper.getServiceWorkerFront({ id }); | |
await workerActor.push(); | |
} | |
} catch (e) { | |
console.error(e); | |
} | |
}; | |
} | |
diff --git a/devtools/client/aboutdebugging-new/src/components/debugtarget/ServiceWorkerAdditionalActions.js b/devtools/client/aboutdebugging-new/src/components/debugtarget/ServiceWorkerAdditionalActions.js | |
--- a/devtools/client/aboutdebugging-new/src/components/debugtarget/ServiceWorkerAdditionalActions.js | |
+++ b/devtools/client/aboutdebugging-new/src/components/debugtarget/ServiceWorkerAdditionalActions.js | |
@@ -30,17 +30,17 @@ class ServiceWorkerAdditionalActions ext | |
// Provided by redux state | |
runtimeDetails: Types.runtimeDetails.isRequired, | |
target: Types.debugTarget.isRequired, | |
}; | |
} | |
push() { | |
const { dispatch, target } = this.props; | |
- dispatch(Actions.pushServiceWorker(target.id)); | |
+ dispatch(Actions.pushServiceWorker(target.id, target.details.registrationFront)); | |
} | |
start() { | |
const { dispatch, target } = this.props; | |
dispatch(Actions.startServiceWorker(target.details.registrationFront)); | |
} | |
unregister() { | |
diff --git a/devtools/server/actors/worker/service-worker-registration.js b/devtools/server/actors/worker/service-worker-registration.js | |
--- a/devtools/server/actors/worker/service-worker-registration.js | |
+++ b/devtools/server/actors/worker/service-worker-registration.js | |
@@ -157,16 +157,23 @@ protocol.ActorClassWithSpec(serviceWorke | |
QueryInterface: ChromeUtils.generateQI( | |
[Ci.nsIServiceWorkerUnregisterCallback]), | |
}; | |
swm.propagateUnregister(principal, unregisterCallback, scope); | |
return { type: "unregistered" }; | |
}, | |
+ push() { | |
+ const { principal, scope } = this._registration; | |
+ const originAttributes = | |
+ ChromeUtils.originAttributesToSuffix(principal.originAttributes); | |
+ swm.sendPushEvent(originAttributes, scope); | |
+ }, | |
+ | |
getPushSubscription() { | |
const registration = this._registration; | |
let pushSubscriptionActor = this._pushSubscriptionActor; | |
if (pushSubscriptionActor) { | |
return Promise.resolve(pushSubscriptionActor); | |
} | |
return new Promise((resolve, reject) => { | |
PushService.getSubscription( | |
diff --git a/devtools/shared/specs/worker/service-worker-registration.js b/devtools/shared/specs/worker/service-worker-registration.js | |
--- a/devtools/shared/specs/worker/service-worker-registration.js | |
+++ b/devtools/shared/specs/worker/service-worker-registration.js | |
@@ -13,16 +13,19 @@ const serviceWorkerRegistrationSpec = ge | |
type: "push-subscription-modified", | |
}, | |
"registration-changed": { | |
type: "registration-changed", | |
}, | |
}, | |
methods: { | |
+ push: { | |
+ request: {}, | |
+ }, | |
start: { | |
request: {}, | |
}, | |
unregister: { | |
request: {}, | |
}, | |
getPushSubscription: { | |
request: {}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment