Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 91 additions & 87 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -721,12 +721,8 @@ <h2>
creating the <a>push subscription</a>.
</p>
<p>
If the <a>user agent</a> has to change the keys for any reason, it MUST <a>fire the
"`pushsubscriptionchange`" event</a> with the <a>service worker registration</a>
associated with the <a>push subscription</a> as |registration|, a {{PushSubscription}}
instance representing the <a>push subscription</a> having the old keys as
|oldSubscription| and a {{PushSubscription}} instance representing the <a>push
subscription</a> having the new keys as |newSubscription|.
If the [=user agent=] has to change the keys for any reason, it MUST [=refresh=] the
[=push subscription=].
</p>
<p>
To <dfn>create a push subscription</dfn>, given an {{PushSubscriptionOptionsInit}}
Expand Down Expand Up @@ -771,7 +767,7 @@ <h2>
</ol>
<section>
<h2>
Subscription Refreshes
Subscription refreshes
</h2>
<p>
A <a>user agent</a> or <a>push service</a> MAY choose to <dfn>refresh</dfn> a <a>push
Expand Down Expand Up @@ -808,7 +804,7 @@ <h2>
</section>
<section>
<h2>
Subscription Deactivation
Subscription deactivation
</h2>
<p>
When a <a>push subscription</a> is <dfn data-lt="deactivate">deactivated</dfn>, both
Expand Down Expand Up @@ -1100,14 +1096,14 @@ <h3>
`subscribe()` method
</h3>
<p>
The <dfn>subscribe()</dfn> method when invoked MUST run the following steps:
The <dfn>subscribe()</dfn> method steps are:
</p>
<ol class="algorithm">
<li>Let |promise| be [=a new promise=].
</li>
<li>Let |global| be [=this=]' [=relevant global object=].
<li>Let |global| be [=this=]'s [=relevant global object=].
</li>
<li>Return |promise| and continue [=in parallel=].
<li>Run these steps [=in parallel=]:
<aside class="note" title="Validation order can vary across user agents">
<p>
Because of implementation-specific reasons, user agents are known to do some of the
Expand All @@ -1117,100 +1113,108 @@ <h3>
don't believe this affects interoperability of implementations or web applications.
</p>
</aside>
</li>
<li>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}}
</li>
<li>If the |options| argument does not include a non-null value for the
{{PushSubscriptionOptionsInit/applicationServerKey}} member, and the <a>push service</a>
requires one to be given, [=queue a global task=] on the [=networking task source=] using
|global| to [=reject=] |promise| with a {{"NotSupportedError"}} {{DOMException}}.
</li>
<li>If the |options| argument includes a non-null value for the
{{PushSubscriptionOptions/applicationServerKey}} attribute, run the following sub-steps:
<ol>
<li>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]].
<li>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}}
</li>
<li>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.
<li>If the |options| argument does not include a non-null value for the
{{PushSubscriptionOptionsInit/applicationServerKey}} member, and the <a>push service</a>
requires one to be given, [=queue a global task=] on the [=networking task source=]
using |global| to [=reject=] |promise| with a {{"NotSupportedError"}} {{DOMException}}.
</li>
<li>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.
<li>If the |options| argument includes a non-null value for the
{{PushSubscriptionOptions/applicationServerKey}} attribute:
<ol>
<li>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]].
</li>
<li>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.
</li>
<li>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.
</li>
</ol>
</li>
</ol>
</li>
<li>Let |registration:ServiceWorkerRegistration| be [=this=]'s associated <a>service worker
registration</a>.
</li>
<li>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.
</li>
<li>Let |permission| be [=request permission to use=] "push".
</li>
<li>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.
</li>
<li>If |registration| has a <a>push subscription</a>:
<ol>
<li>Let |subscription| be the result of obtaining |registration|'s <a>push
subscription</a>. 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.
<li>Let |registration:ServiceWorkerRegistration| be [=this=]'s associated <a>service
worker registration</a>.
</li>
<li>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.
</li>
<li>Let |permission| be [=request permission to use=] "push".
</li>
<li>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.
</li>
<li>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=].
<li>If |registration| has a <a>push subscription</a>:
<ol>
<li>Let |subscription| be the result of obtaining |registration|'s <a>push
subscription</a>. 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.
</li>
<li>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=].
</li>
<li>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.
</li>
<li>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.
</li>
</ol>
</li>
<li>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.
<li>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.
</li>
<li>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.
<li>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|.
</li>
</ol>
</li>
<li>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.
</li>
<li>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|.
<li>Return |promise|.
</li>
</ol>
<p>
The <dfn data-dfn-for="PushManager">getSubscription</dfn> method when invoked MUST run the
following steps:
The <dfn data-dfn-for="PushManager">getSubscription()</dfn> method steps are:
</p>
<ol>
<li>Let |promise| be <a>a new promise</a>.
</li>
<li>Return |promise| and continue the following steps asynchronously.
</li>
<li>If the <a>Service Worker</a> is not subscribed, resolve |promise| with null.
</li>
<li>Retrieve the <a>push subscription</a> associated with the <a>Service Worker</a>.
</li>
<li>If there is an error, reject |promise| with a {{DOMException}} whose name is
{{"AbortError"}} and terminate these steps.
<li>Run these steps [=in parallel=]:
<ol>
<li>If the <a>Service Worker</a> is not subscribed, resolve |promise| with null.
</li>
<li>Retrieve the <a>push subscription</a> associated with the <a>Service Worker</a>.
</li>
<li>If there is an error, reject |promise| with a {{DOMException}} whose name is
{{"AbortError"}} and terminate these steps.
</li>
<li>When the request has been completed, resolve |promise| with a {{PushSubscription}}
providing the details of the retrieved <a>push subscription</a>.
</li>
</ol>
</li>
<li>When the request has been completed, resolve |promise| with a {{PushSubscription}}
providing the details of the retrieved <a>push subscription</a>.
<li>Return |promise|.
</li>
</ol>
<p>
Expand Down