зеркало из 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) => {
|
return async (_, getState) => {
|
||||||
const clientWrapper = getCurrentClient(getState().runtimes);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const workerActor = await clientWrapper.getServiceWorkerFront({ id });
|
const clientWrapper = getCurrentClient(getState().runtimes);
|
||||||
await workerActor.push();
|
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) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,9 @@ class ServiceWorkerAdditionalActions extends PureComponent {
|
||||||
|
|
||||||
push() {
|
push() {
|
||||||
const { dispatch, target } = this.props;
|
const { dispatch, target } = this.props;
|
||||||
dispatch(Actions.pushServiceWorker(target.id));
|
dispatch(
|
||||||
|
Actions.pushServiceWorker(target.id, target.details.registrationFront)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
|
|
|
@ -108,7 +108,6 @@ skip-if = fission || debug
|
||||||
skip-if = debug || asan || serviceworker_e10s # Frequent intermittent failures, Bug 1527224
|
skip-if = debug || asan || serviceworker_e10s # Frequent intermittent failures, Bug 1527224
|
||||||
[browser_aboutdebugging_serviceworker_not_compatible.js]
|
[browser_aboutdebugging_serviceworker_not_compatible.js]
|
||||||
[browser_aboutdebugging_serviceworker_push.js]
|
[browser_aboutdebugging_serviceworker_push.js]
|
||||||
skip-if = serviceworker_e10s
|
|
||||||
[browser_aboutdebugging_serviceworker_pushservice_url.js]
|
[browser_aboutdebugging_serviceworker_pushservice_url.js]
|
||||||
[browser_aboutdebugging_serviceworker_runtime-page.js]
|
[browser_aboutdebugging_serviceworker_runtime-page.js]
|
||||||
[browser_aboutdebugging_serviceworker_start.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 {
|
const {
|
||||||
addDebugServiceWorkersListener,
|
addDebugServiceWorkersListener,
|
||||||
canDebugServiceWorkers,
|
canDebugServiceWorkers,
|
||||||
|
isParentInterceptEnabled,
|
||||||
removeDebugServiceWorkersListener,
|
removeDebugServiceWorkersListener,
|
||||||
} = require("devtools/shared/service-workers-debug-helper");
|
} = require("devtools/shared/service-workers-debug-helper");
|
||||||
|
|
||||||
|
@ -52,6 +53,7 @@ exports.DeviceActor = protocol.ActorClassWithSpec(deviceSpec, {
|
||||||
getDescription: function() {
|
getDescription: function() {
|
||||||
return Object.assign({}, getSystemInfo(), {
|
return Object.assign({}, getSystemInfo(), {
|
||||||
canDebugServiceWorkers: canDebugServiceWorkers(),
|
canDebugServiceWorkers: canDebugServiceWorkers(),
|
||||||
|
isParentInterceptEnabled: isParentInterceptEnabled(),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -171,6 +171,21 @@ const ServiceWorkerRegistrationActor = protocol.ActorClassWithSpec(
|
||||||
return { type: "unregistered" };
|
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() {
|
getPushSubscription() {
|
||||||
const registration = this._registration;
|
const registration = this._registration;
|
||||||
let pushSubscriptionActor = this._pushSubscriptionActor;
|
let pushSubscriptionActor = this._pushSubscriptionActor;
|
||||||
|
|
|
@ -60,8 +60,13 @@ function canDebugServiceWorkers() {
|
||||||
return isNewSWImplementation || !multiE10s;
|
return isNewSWImplementation || !multiE10s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isParentInterceptEnabled() {
|
||||||
|
return swm.isParentInterceptEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
addDebugServiceWorkersListener,
|
addDebugServiceWorkersListener,
|
||||||
canDebugServiceWorkers,
|
canDebugServiceWorkers,
|
||||||
|
isParentInterceptEnabled,
|
||||||
removeDebugServiceWorkersListener,
|
removeDebugServiceWorkersListener,
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,6 +18,9 @@ const serviceWorkerRegistrationSpec = generateActorSpec({
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
push: {
|
||||||
|
request: {},
|
||||||
|
},
|
||||||
start: {
|
start: {
|
||||||
request: {},
|
request: {},
|
||||||
},
|
},
|
||||||
|
|
Загрузка…
Ссылка в новой задаче