Ensure push subscriptions are associated with an active service worker

NEW
Unassigned

Status

()

3 years ago
4 months ago

People

(Reporter: lina, Unassigned)

Tracking

(Blocks: 1 bug)

Trunk
Points:
---

Firefox Tracking Flags

(firefox47 affected)

Details

(Whiteboard: dom-triaged)

https://w3c.github.io/push-api/#pushmanager-interface says we should wait until the service worker registration has an active worker before creating a subscription, but we don't actually enforce that. It's possible to register a worker, capture its `PushManager`, unregister, and create subscriptions like so:

    let pushManager;
    navigator.serviceWorker.register("./sw.js").then(registration => {
      pushManager = registration.pushManager;
      return registration.unregister();
    }).then(_ => {
      return pushManager.subscribe();
    }).then(subscription => {
      // Created subscription without active worker.
    });

We should wait until the worker is active, and, once the registration is removed, `pushManager.subscribe()` should reject with an InvalidStateError.
Whiteboard: dom-triaged
(Reporter)

Comment 1

2 years ago
Another issue is that a push subscription can be created by a non-active worker. See https://github.com/w3c/push-api/issues/221.
(Reporter)

Updated

4 months ago
Blocks: 1497427
You need to log in before you can comment on or make changes to this bug.