Files
sousa-gecko/testing/web-platform/mozilla/tests/push-api/push-sw.js
T
Kagami Sascha Rosylight 54e123f5c4 Bug 1969357 - Add telemetry for DWP payloads r=asuth,dom-worker-reviewers
Also extend the data clear telemetry, which is also relevant for DWP as one of the arguments was that DWP subscription should not be cleared with other data as long as the permission exists.

Differential Revision: https://phabricator.services.mozilla.com/D274428
2025-12-04 13:28:26 +00:00

21 lines
465 B
JavaScript

async function postAll(data) {
const clients = await self.clients.matchAll({ includeUncontrolled: true });
for (const client of clients) {
client.postMessage(data);
}
}
onpush = ev => postAll({
type: ev.type,
data: ev.data.text(),
});
onpushsubscriptionchange = ev => {
postAll({
type: ev.type,
constructor: ev.constructor.name,
oldSubscription: ev.oldSubscription?.toJSON(),
newSubscription: ev.newSubscription?.toJSON(),
});
}