- 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 @@
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:
Let |promise| be [=a new promise=].
-
Let |global| be [=this=]' [=relevant global object=].
+
Let |global| be [=this=]'s [=relevant global object=].
-
Return |promise| and continue [=in parallel=].
+
Run these steps [=in parallel=]:
-
-
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}}
-
-
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}}.
-
-
If the |options| argument includes a non-null value for the
- {{PushSubscriptionOptions/applicationServerKey}} attribute, run the following sub-steps:
-
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]].
+
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}}
-
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.
+
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}}.
-
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.
+
If the |options| argument includes a non-null value for the
+ {{PushSubscriptionOptions/applicationServerKey}} attribute:
+
+
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]].
+
+
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.
+
+
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.
+
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.
-
-
Let |permission| be [=request permission to use=] "push".
-
-
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.
-
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.
+
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.
+
+
Let |permission| be [=request permission to use=] "push".
+
+
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.
-
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=].
+
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.
+
+
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=].
+
+
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.
+
+
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.
+
+
-
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.
+
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.
-
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.
+
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|.
-
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.
-
-
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|.
+
Return |promise|.
- The getSubscription method when invoked MUST run the
- following steps:
+ The getSubscription() method steps are: