2525 companyURL : "https://www.mozilla.org/" ,
2626 w3cid : "68503"
2727 } ,
28+ {
29+ name : "Marcos Caceres" ,
30+ company : "Apple Inc." ,
31+ companyURL : "https://www.apple.com/" ,
32+ w3cid : "39125"
33+ } ,
2834 {
2935 name : "Bryan Sullivan" ,
3036 company : "AT&T" ,
@@ -195,13 +201,17 @@ <h2>
195201 subscription</ a > having the new keys as |newSubscription|.
196202 </ p >
197203 < p >
198- To < dfn > create a push subscription</ dfn > , given an < a > PushSubscriptionOptions </ a > object
199- of |options|, the < a > user agent </ a > must run the following steps :
204+ To < dfn > create a push subscription</ dfn > , given an {{PushSubscriptionOptionsInit}}
205+ |optionsDictionary:PushSubscriptionOptionsInit| :
200206 </ p >
201- < ol >
202- < li > Let |subscription| be a new < a > push subscription</ a > .
207+ < ol class ="algorithm ">
208+ < li > Let |subscription:PushSubscription| be a new {{PushSubscription}}.
209+ </ li >
210+ < li > Let |options:PushSubscriptionOptions| be a newly created {{PushSubscriptionOptions}}
211+ object, initializing its attributes with the corresponding members and values of
212+ |optionsDictionary|.
203213 </ li >
204- < li > Set the `options` attribute of |subscription| to be a copy of |options|.
214+ < li > Set |subscription|'s {{PushSubscription/options}} attribute to |options|.
205215 </ li >
206216 < li > Generate a new P-256 < a > ECDH</ a > key pair [[ANSI-X9-62]]. Store the private key in an
207217 internal slot on |subscription|; this value MUST NOT be made available to applications.
@@ -214,11 +224,21 @@ <h2>
214224 key can be retrieved by calling the {{PushSubscription/getKey()}} method of the
215225 {{PushSubscription}} with an argument of {{PushEncryptionKeyName/"auth"}}.
216226 </ li >
217- < li > Make a request to the < a > push service </ a > to create a new < a > push subscription</ a > .
218- Include the {{PushSubscriptionOptions/applicationServerKey}} attribute of |options| when
219- it has been set .
227+ < li > Request a new < a > push subscription</ a > . Include the
228+ {{PushSubscriptionOptions/applicationServerKey}} attribute of |options| when it has been
229+ set. Rethrow any [=exceptions=] .
220230 </ li >
221- < li > When the request has completed, return |subscription|.
231+ < li > When the < a > push subscription</ a > request has completed successfully:
232+ < ol >
233+ < li > Set |subscription|'s {{PushSubscription/endpoint}} attribute to the [=URL=]
234+ provided by the < a > push subscription</ a > .
235+ </ li >
236+ < li > If provided by the < a > push subscription</ a > , set |subscription|'s
237+ {{PushSubscription/expirationTime}}.
238+ </ li >
239+ </ ol >
240+ </ li >
241+ < li > Return |subscription|.
222242 </ li >
223243 </ ol >
224244 < section >
@@ -548,81 +568,109 @@ <h2>
548568 MAY support content codings defined in previous versions of the draft for compatibility
549569 reasons.
550570 </ p >
571+ < h3 >
572+ `subscribe()` method
573+ </ h3 >
551574 < p >
552- The < dfn > subscribe</ dfn > method when invoked MUST run the following steps:
575+ The < dfn > subscribe() </ dfn > method when invoked MUST run the following steps:
553576 </ p >
554- < ol >
577+ < ol class =" algorithm " >
555578 < li > If the [=relevant global object=] of [=this=] does not have [=transient activation=],
556579 return [=a promise rejected with=] with a {{"NotAllowedError"}} {{DOMException}}.
557580 </ li >
558581 < li > [=Consume user activation=] of [=this=]'s [=relevant global object=].
559582 </ li >
560583 < li > Let |promise| be < a > a new promise</ a > .
561584 </ li >
562- < li > Return |promise| and continue the following steps asynchronously .
585+ < li > Let |global| be [=this=]' [=relevant global object=] .
563586 </ li >
564- < li > If the < a > current settings object</ a > is not a [=secure context=], reject |promise|
565- with a {{DOMException}} whose name is {{"SecurityError"}} and terminate these steps.
587+ < li > Return |promise| and continue [=in parallel=].
588+ < aside class ="note " title ="Validation order can vary across user agents ">
589+ < p >
590+ Because of implementation-specific reasons, user agents are known to do some of the
591+ following checks in different order (e.g., some check if
592+ {{PushSubscriptionOptionsInit/userVisibleOnly}} is allowed after validating the
593+ {{PushSubscriptionOptionsInit/applicationServerKey}}, and vice versa). However, we
594+ don't believe this affects interoperability of implementations or web applications.
595+ </ p >
596+ </ aside >
597+ </ li >
598+ < li > If the |options| argument has a {{PushSubscriptionOptionsInit/userVisibleOnly}} value
599+ set to `false` and the user agent requires it to be `true`, [=queue a global task=] on the
600+ [=networking task source=] using |global| to [=reject=] |promise| {{"NotAllowedError"}}
601+ {{DOMException}}
602+ </ li >
603+ < li > If the |options| argument does not include a non-null value for the
604+ {{PushSubscriptionOptionsInit/applicationServerKey}} member, and the < a > push service</ a >
605+ requires one to be given, [=queue a global task=] on the [=networking task source=] using
606+ |global| to [=reject=] |promise| with a {{"NotSupportedError"}} {{DOMException}}.
566607 </ li >
567608 < li > If the |options| argument includes a non-null value for the
568609 {{PushSubscriptionOptions/applicationServerKey}} attribute, run the following sub-steps:
569610 < ol >
570- < li > If the |applicationServerKey| is provided as a {{DOMString}}, set its value to an
571- {{ArrayBuffer}} containing the sequence of octets that result from decoding
572- |applicationServerKey| using the base64url encoding [[RFC7515]]. If decoding fails,
573- reject promise with a {{DOMException}} whose name is {{"InvalidCharacterError"}} and
574- terminate these steps.
611+ < li > If |options|'s {{PushSubscriptionOptionsInit/applicationServerKey}} is a
612+ {{DOMString}}, set its value to an {{ArrayBuffer}} containing the sequence of octets
613+ that result from decoding |options|'s
614+ {{PushSubscriptionOptionsInit/applicationServerKey}} using the base64url encoding
615+ [[RFC7515]].
616+ </ li >
617+ < li > If decoding fails, [=queue a global task=] on the [=networking task source=] using
618+ |global| to [=reject=] |promise| with an {{"InvalidCharacterError"}} {{DOMException}}
619+ and terminate these steps.
575620 </ li >
576- < li > Ensure that |applicationServerKey| describes a valid point on the P-256 curve. If
577- the |applicationServerKey| value is invalid, reject |promise| with a {{DOMException}}
578- whose name is {{"InvalidAccessError"}} and terminate these steps.
621+ < li > Ensure that |options|'s {{PushSubscriptionOptionsInit/applicationServerKey}}
622+ describes a valid point on the P-256 curve. If its value is invalid, [=queue a global
623+ task=] on the [=networking task source=] using |global| to [=reject=] |promise| with an
624+ {{"InvalidAccessError"}} {{DOMException}} and terminate these steps.
579625 </ li >
580626 </ ol >
581627 </ li >
582- < li > If the |options| argument does not include a non-null value for the
583- {{PushSubscriptionOptions/applicationServerKey}} attribute, and the < a > push service</ a >
584- requires one to be given, reject |promise| with a {{DOMException}} whose name is
585- {{"NotSupportedError"}} and terminate these steps.
586- </ li >
587- < li > Let |registration| be the {{PushManager}}'s associated < a > service worker
628+ < li > Let |registration:ServiceWorkerRegistration| be [=this=]'s associated < a > service worker
588629 registration</ a > .
589630 </ li >
590- < li > If |registration|'s [=service worker registration/active worker=] is null, reject
591- |promise| with a {{DOMException}} whose name is {{"InvalidStateError"}} and terminate these
592- steps.
631+ < li > If |registration|'s [=service worker registration/active worker=] is null, [=queue a
632+ global task=] on the [=networking task source=] using |global| to [=reject=] |promise| with
633+ an {{"InvalidStateError"}} {{DOMException}} and terminate these steps.
634+ </ li >
635+ < li > Let |sw| be |registration|'s [=service worker registration/active worker=].
593636 </ li >
594637 < li > Let |permission| be [=request permission to use=] "push".
595638 </ li >
596- < li > If |permission| is "denied", reject |promise| with a {{DOMException}} whose name is
597- {{"NotAllowedError"}} and terminate these steps.
639+ < li > If |permission| is {{PermissionState/"denied"}}, [=queue a global task=] on the [=user
640+ interaction task source=] using |global| to [=reject=] |promise| with a
641+ {{"NotAllowedError"}} {{DOMException}} and terminate these steps.
598642 </ li >
599- < li > If the < a > Service Worker </ a > is already subscribed, run the following substeps :
643+ < li > If |sw| is already subscribed, run the following sub-steps :
600644 < ol >
601- < li > Retrieve the < a > push subscription</ a > associated with the < a > Service Worker</ a > .
645+ < li > Try to retrieve the < a > push subscription</ a > associated with the |sw|. If there is
646+ an error, [=queue a global task=] on the [=networking task source=] using |global| to
647+ [=reject=] |promise| with an {{"AbortError"}} {{DOMException}} and terminate these
648+ steps.
602649 </ li >
603- < li > If there is an error, reject |promise| with a {{DOMException}} whose name is
604- {{"AbortError"}} and terminate these steps.
650+ < li > Let |subscription| be the < a > push subscription</ a > associated with |sw|.
605651 </ li >
606- < li > Let |subscription| be the retrieved subscription.
652+ < li > Compare the |options| argument with the `options` attribute of |subscription|. The
653+ contents of {{BufferSource}} values are compared for equality rather than
654+ [=ECMAScript/reference record|reference=].
607655 </ li >
608- < li > Compare the |options| argument with the `options` attribute of |subscription|. If
609- any attribute on |options| contains a different value to that stored for
610- |subscription|, then reject |promise| with an {{InvalidStateError}} and terminate these
611- steps. The contents of {{BufferSource}} values are compared for equality rather than
612- < a href =
613- "https://tc39.github.io/ecma262/#sec-reference-specification-type "> references</ a > .
656+ < li > If any attribute on |options| contains a different value to that stored for
657+ |subscription|, then [=queue a global task=] on the [=networking task source=] using
658+ |global| to [=reject=] |promise| with an {{"InvalidStateError"}} {{DOMException}} and
659+ terminate these steps.
614660 </ li >
615- < li > When the request has been completed, resolve |promise| with |subscription|.
661+ < li > When the request has been completed, [=queue a global task=] on the [=networking
662+ task source=] using |global| to [=resolve=] |promise| with |subscription| and terminate
663+ these steps.
616664 </ li >
617665 </ ol >
618666 </ li >
619- < li > Let |subscription| be the result of running the < a > create a push subscription</ a > steps
620- given |options|.
621- </ li >
622- < li > If there is an error, reject |promise| with a {{DOMException}} whose name is
623- {{"AbortError"}} and terminate these steps.
667+ < li > Let |subscription| be the result of trying to [=create a push subscription=] with
668+ |options|. If creating the subscription [=exception/throws=] an [=exception=], [=queue a
669+ global task=] on the [=networking task source=] using |global| to [=reject=] |promise| with
670+ a that [=exception=] and terminate these these steps.
624671 </ li >
625- < li > Resolve |promise| with a {{PushSubscription}} providing the details of the new
672+ < li > Otherwise, [=queue a global task=] on the [=networking task source=] using |global| to
673+ [=resolve=] |promise| with a {{PushSubscription}} providing the details of the new
626674 |subscription|.
627675 </ li >
628676 </ ol >
939987 };
940988 </ pre >
941989 < p >
942- < a > PushMessageData</ a > objects have an associated < dfn > bytes </ dfn > (a byte sequence) set on
943- creation, which is `null` if there was no data in the < a > push message</ a > .
990+ < a > PushMessageData</ a > objects have an associated [= byte sequence=] set on creation, which
991+ is `null` if there was no data in the < a > push message</ a > .
944992 </ p >
945993 < p >
946994 The < dfn > arrayBuffer()</ dfn > method, when invoked, MUST return an {{ArrayBuffer}} whose
0 commit comments