зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1552945 - Send push events to ServiceWorkerRegistrationActor's active Service Worker r=jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D31906 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
cbf68e6857
Коммит
7753ae42bf
|
@ -140,13 +140,32 @@ function installTemporaryExtension() {
|
|||
};
|
||||
}
|
||||
|
||||
function pushServiceWorker(id) {
|
||||
function pushServiceWorker(id, registrationFront) {
|
||||
return async (_, getState) => {
|
||||
const clientWrapper = getCurrentClient(getState().runtimes);
|
||||
|
||||
try {
|
||||
const workerActor = await clientWrapper.getServiceWorkerFront({ id });
|
||||
await workerActor.push();
|
||||
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
|
||||
* underlying ServiceWorkerRegistration is "connected" to the
|
||||
* corresponding running Service Worker - this is only guaranteed with
|
||||
* parent-intercept mode. The `else` statement is for backward
|
||||
* compatibility and can be removed when the release channel is >= FF69
|
||||
* _and_ parent-intercept is stable (which definitely won't happen when
|
||||
* the release channel is < FF69).
|
||||
*/
|
||||
if (registrationFront.push && isParentInterceptEnabled) {
|
||||
await registrationFront.push();
|
||||
} else {
|
||||
const workerActor = await clientWrapper.getServiceWorkerFront({ id });
|
||||
await workerActor.push();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
|
|
@ -70,7 +70,9 @@ class ServiceWorkerAdditionalActions extends PureComponent {
|
|||
|
||||
push() {
|
||||
const { dispatch, target } = this.props;
|
||||
dispatch(Actions.pushServiceWorker(target.id));
|
||||
dispatch(
|
||||
Actions.pushServiceWorker(target.id, target.details.registrationFront)
|
||||
);
|
||||
}
|
||||
|
||||
start() {
|
||||
|
|
|
@ -108,7 +108,6 @@ skip-if = fission || debug
|
|||
skip-if = debug || asan || serviceworker_e10s # Frequent intermittent failures, Bug 1527224
|
||||
[browser_aboutdebugging_serviceworker_not_compatible.js]
|
||||
[browser_aboutdebugging_serviceworker_push.js]
|
||||
skip-if = serviceworker_e10s
|
||||
[browser_aboutdebugging_serviceworker_pushservice_url.js]
|
||||
[browser_aboutdebugging_serviceworker_runtime-page.js]
|
||||
[browser_aboutdebugging_serviceworker_start.js]
|
||||
|
|
|
@ -44471,4 +44471,4 @@ Object.keys(PLACEHOLDERS_ALIAS).forEach(type => {
|
|||
|
||||
/***/ })
|
||||
/******/ ]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -11,6 +11,7 @@ const { LongStringActor } = require("devtools/server/actors/string");
|
|||
const {
|
||||
addDebugServiceWorkersListener,
|
||||
canDebugServiceWorkers,
|
||||
isParentInterceptEnabled,
|
||||
removeDebugServiceWorkersListener,
|
||||
} = require("devtools/shared/service-workers-debug-helper");
|
||||
|
||||
|
@ -52,6 +53,7 @@ exports.DeviceActor = protocol.ActorClassWithSpec(deviceSpec, {
|
|||
getDescription: function() {
|
||||
return Object.assign({}, getSystemInfo(), {
|
||||
canDebugServiceWorkers: canDebugServiceWorkers(),
|
||||
isParentInterceptEnabled: isParentInterceptEnabled(),
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -171,6 +171,21 @@ const ServiceWorkerRegistrationActor = protocol.ActorClassWithSpec(
|
|||
return { type: "unregistered" };
|
||||
},
|
||||
|
||||
push() {
|
||||
if (!swm.isParentInterceptEnabled()) {
|
||||
throw new Error(
|
||||
"ServiceWorkerRegistrationActor.push can only be used " +
|
||||
"in parent-intercept mode"
|
||||
);
|
||||
}
|
||||
|
||||
const { principal, scope } = this._registration;
|
||||
const originAttributes = ChromeUtils.originAttributesToSuffix(
|
||||
principal.originAttributes
|
||||
);
|
||||
swm.sendPushEvent(originAttributes, scope);
|
||||
},
|
||||
|
||||
getPushSubscription() {
|
||||
const registration = this._registration;
|
||||
let pushSubscriptionActor = this._pushSubscriptionActor;
|
||||
|
|
|
@ -60,8 +60,13 @@ function canDebugServiceWorkers() {
|
|||
return isNewSWImplementation || !multiE10s;
|
||||
}
|
||||
|
||||
function isParentInterceptEnabled() {
|
||||
return swm.isParentInterceptEnabled();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
addDebugServiceWorkersListener,
|
||||
canDebugServiceWorkers,
|
||||
isParentInterceptEnabled,
|
||||
removeDebugServiceWorkersListener,
|
||||
};
|
||||
|
|
|
@ -18,6 +18,9 @@ const serviceWorkerRegistrationSpec = generateActorSpec({
|
|||
},
|
||||
|
||||
methods: {
|
||||
push: {
|
||||
request: {},
|
||||
},
|
||||
start: {
|
||||
request: {},
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче