diff --git a/index.html b/index.html index 603265b..9b0d7f1 100644 --- a/index.html +++ b/index.html @@ -721,12 +721,8 @@

creating the push subscription.

- If the user agent has to change the keys for any reason, it MUST fire the - "`pushsubscriptionchange`" event with the service worker registration - associated with the push subscription as |registration|, a {{PushSubscription}} - instance representing the push subscription having the old keys as - |oldSubscription| and a {{PushSubscription}} instance representing the push - subscription having the new keys as |newSubscription|. + If the [=user agent=] has to change the keys for any reason, it MUST [=refresh=] the + [=push subscription=].

To create a push subscription, given an {{PushSubscriptionOptionsInit}} @@ -771,7 +767,7 @@

- Subscription Refreshes + Subscription refreshes

A user agent or push service MAY choose to refresh a push @@ -808,7 +804,7 @@

- Subscription Deactivation + Subscription deactivation

When a push subscription is deactivated, both @@ -1100,14 +1096,14 @@

`subscribe()` method

- The subscribe() method when invoked MUST run the following steps: + The subscribe() method steps are:

  1. Let |promise| be [=a new promise=].
  2. -
  3. Let |global| be [=this=]' [=relevant global object=]. +
  4. Let |global| be [=this=]'s [=relevant global object=].
  5. -
  6. Return |promise| and continue [=in parallel=]. +
  7. Run these steps [=in parallel=]: -
  8. -
  9. If the |options| argument has a {{PushSubscriptionOptionsInit/userVisibleOnly}} value - set to `false` and the user agent requires it to be `true`, [=queue a global task=] on the - [=networking task source=] using |global| to [=reject=] |promise| {{"NotAllowedError"}} - {{DOMException}} -
  10. -
  11. If the |options| argument does not include a non-null value for the - {{PushSubscriptionOptionsInit/applicationServerKey}} member, and the push service - requires one to be given, [=queue a global task=] on the [=networking task source=] using - |global| to [=reject=] |promise| with a {{"NotSupportedError"}} {{DOMException}}. -
  12. -
  13. If the |options| argument includes a non-null value for the - {{PushSubscriptionOptions/applicationServerKey}} attribute, run the following sub-steps:
      -
    1. If |options|'s {{PushSubscriptionOptionsInit/applicationServerKey}} is a - {{DOMString}}, set its value to an {{ArrayBuffer}} containing the sequence of octets - that result from decoding |options|'s - {{PushSubscriptionOptionsInit/applicationServerKey}} using the base64url encoding - [[RFC7515]]. +
    2. If the |options| argument has a {{PushSubscriptionOptionsInit/userVisibleOnly}} + value set to `false` and the user agent requires it to be `true`, [=queue a global + task=] on the [=networking task source=] using |global| to [=reject=] |promise| + {{"NotAllowedError"}} {{DOMException}}
    3. -
    4. If decoding fails, [=queue a global task=] on the [=networking task source=] using - |global| to [=reject=] |promise| with an {{"InvalidCharacterError"}} {{DOMException}} - and terminate these steps. +
    5. If the |options| argument does not include a non-null value for the + {{PushSubscriptionOptionsInit/applicationServerKey}} member, and the push service + requires one to be given, [=queue a global task=] on the [=networking task source=] + using |global| to [=reject=] |promise| with a {{"NotSupportedError"}} {{DOMException}}.
    6. -
    7. Ensure that |options|'s {{PushSubscriptionOptionsInit/applicationServerKey}} - describes a valid point on the P-256 curve. If its value is invalid, [=queue a global - task=] on the [=networking task source=] using |global| to [=reject=] |promise| with an - {{"InvalidAccessError"}} {{DOMException}} and terminate these steps. +
    8. If the |options| argument includes a non-null value for the + {{PushSubscriptionOptions/applicationServerKey}} attribute: +
        +
      1. If |options|'s {{PushSubscriptionOptionsInit/applicationServerKey}} is a + {{DOMString}}, set its value to an {{ArrayBuffer}} containing the sequence of octets + that result from decoding |options|'s + {{PushSubscriptionOptionsInit/applicationServerKey}} using the base64url encoding + [[RFC7515]]. +
      2. +
      3. If decoding fails, [=queue a global task=] on the [=networking task source=] + using |global| to [=reject=] |promise| with an {{"InvalidCharacterError"}} + {{DOMException}} and terminate these steps. +
      4. +
      5. Ensure that |options|'s {{PushSubscriptionOptionsInit/applicationServerKey}} + describes a valid point on the P-256 curve. If its value is invalid, [=queue a + global task=] on the [=networking task source=] using |global| to [=reject=] + |promise| with an {{"InvalidAccessError"}} {{DOMException}} and terminate these + steps. +
      6. +
    9. -
    -
  14. -
  15. Let |registration:ServiceWorkerRegistration| be [=this=]'s associated service worker - registration. -
  16. -
  17. If |registration|'s [=service worker registration/active worker=] is null, [=queue a - global task=] on the [=networking task source=] using |global| to [=reject=] |promise| with - an {{"InvalidStateError"}} {{DOMException}} and terminate these steps. -
  18. -
  19. Let |permission| be [=request permission to use=] "push". -
  20. -
  21. If |permission| is {{PermissionState/"denied"}}, [=queue a global task=] on the [=user - interaction task source=] using |global| to [=reject=] |promise| with a - {{"NotAllowedError"}} {{DOMException}} and terminate these steps. -
  22. -
  23. If |registration| has a push subscription: -
      -
    1. Let |subscription| be the result of obtaining |registration|'s push - subscription. If there is an error, [=queue a global task=] on the [=networking - task source=] using |global| to [=reject=] |promise| with an {{"AbortError"}} - {{DOMException}} and terminate these steps. +
    2. Let |registration:ServiceWorkerRegistration| be [=this=]'s associated service + worker registration. +
    3. +
    4. If |registration|'s [=service worker registration/active worker=] is null, [=queue a + global task=] on the [=networking task source=] using |global| to [=reject=] |promise| + with an {{"InvalidStateError"}} {{DOMException}} and terminate these steps. +
    5. +
    6. Let |permission| be [=request permission to use=] "push". +
    7. +
    8. If |permission| is {{PermissionState/"denied"}}, [=queue a global task=] on the + [=user interaction task source=] using |global| to [=reject=] |promise| with a + {{"NotAllowedError"}} {{DOMException}} and terminate these steps.
    9. -
    10. Compare the |options| argument with the `options` attribute of |subscription|. The - contents of {{BufferSource}} values are compared for equality rather than - [=ECMAScript/reference record|reference=]. +
    11. If |registration| has a push subscription: +
        +
      1. Let |subscription| be the result of obtaining |registration|'s push + subscription. If there is an error, [=queue a global task=] on the [=networking + task source=] using |global| to [=reject=] |promise| with an {{"AbortError"}} + {{DOMException}} and terminate these steps. +
      2. +
      3. Compare the |options| argument with the `options` attribute of |subscription|. + The contents of {{BufferSource}} values are compared for equality rather than + [=ECMAScript/reference record|reference=]. +
      4. +
      5. If any attribute on |options| contains a different value to that stored for + |subscription|, then [=queue a global task=] on the [=networking task source=] using + |global| to [=reject=] |promise| with an {{"InvalidStateError"}} {{DOMException}} + and terminate these steps. +
      6. +
      7. When the request has been completed, [=queue a global task=] on the [=networking + task source=] using |global| to [=resolve=] |promise| with |subscription| and + terminate these steps. +
      8. +
    12. -
    13. If any attribute on |options| contains a different value to that stored for - |subscription|, then [=queue a global task=] on the [=networking task source=] using - |global| to [=reject=] |promise| with an {{"InvalidStateError"}} {{DOMException}} and - terminate these steps. +
    14. Let |subscription| be the result of trying to [=create a push subscription=] with + |options|. If creating the subscription [=exception/throws=] an [=exception=], [=queue a + global task=] on the [=networking task source=] using |global| to [=reject=] |promise| + with a that [=exception=] and terminate these these steps.
    15. -
    16. When the request has been completed, [=queue a global task=] on the [=networking - task source=] using |global| to [=resolve=] |promise| with |subscription| and terminate - these steps. +
    17. Otherwise, [=queue a global task=] on the [=networking task source=] using |global| + to [=resolve=] |promise| with a {{PushSubscription}} providing the details of the new + |subscription|.
  24. -
  25. Let |subscription| be the result of trying to [=create a push subscription=] with - |options|. If creating the subscription [=exception/throws=] an [=exception=], [=queue a - global task=] on the [=networking task source=] using |global| to [=reject=] |promise| with - a that [=exception=] and terminate these these steps. -
  26. -
  27. Otherwise, [=queue a global task=] on the [=networking task source=] using |global| to - [=resolve=] |promise| with a {{PushSubscription}} providing the details of the new - |subscription|. +
  28. Return |promise|.

- The getSubscription method when invoked MUST run the - following steps: + The getSubscription() method steps are:

  1. Let |promise| be a new promise.
  2. -
  3. Return |promise| and continue the following steps asynchronously. -
  4. -
  5. If the Service Worker is not subscribed, resolve |promise| with null. -
  6. -
  7. Retrieve the push subscription associated with the Service Worker. -
  8. -
  9. If there is an error, reject |promise| with a {{DOMException}} whose name is - {{"AbortError"}} and terminate these steps. +
  10. Run these steps [=in parallel=]: +
      +
    1. If the Service Worker is not subscribed, resolve |promise| with null. +
    2. +
    3. Retrieve the push subscription associated with the Service Worker. +
    4. +
    5. If there is an error, reject |promise| with a {{DOMException}} whose name is + {{"AbortError"}} and terminate these steps. +
    6. +
    7. When the request has been completed, resolve |promise| with a {{PushSubscription}} + providing the details of the retrieved push subscription. +
    8. +
  11. -
  12. When the request has been completed, resolve |promise| with a {{PushSubscription}} - providing the details of the retrieved push subscription. +
  13. Return |promise|.