|
25 | 25 | companyURL: "https://www.mozilla.org/",
|
26 | 26 | w3cid: "68503"
|
27 | 27 | },
|
| 28 | + { |
| 29 | + name: "Marcos Caceres", |
| 30 | + company: "Apple Inc.", |
| 31 | + companyURL: "https://www.apple.com/", |
| 32 | + w3cid: "39125" |
| 33 | + }, |
28 | 34 | {
|
29 | 35 | name: "Bryan Sullivan",
|
30 | 36 | company: "AT&T",
|
|
195 | 201 | subscriptiona> having the new keys as |newSubscription|.
|
196 | 202 | p>
|
197 | 203 | <p>
|
198 |
| - To <dfn>create a push subscriptiondfn>, given an <a>PushSubscriptionOptionsa> object |
199 |
| - of |options|, the <a>user agenta> must run the following steps: |
| 204 | + To <dfn>create a push subscriptiondfn>, given an {{PushSubscriptionOptionsInit}} |
| 205 | + |optionsDictionary:PushSubscriptionOptionsInit|: |
200 | 206 | p>
|
201 |
| - <ol> |
202 |
| - <li>Let |subscription| be a new <a>push subscriptiona>. |
| 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|. |
203 | 213 | 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|. |
205 | 215 | li>
|
206 | 216 | <li>Generate a new P-256 <a>ECDHa> key pair [[ANSI-X9-62]]. Store the private key in an
|
207 | 217 | internal slot on |subscription|; this value MUST NOT be made available to applications.
|
|
214 | 224 | key can be retrieved by calling the {{PushSubscription/getKey()}} method of the
|
215 | 225 | {{PushSubscription}} with an argument of {{PushEncryptionKeyName/"auth"}}.
|
216 | 226 | li>
|
217 |
| - <li>Make a request to the <a>push servicea> to create a new <a>push subscriptiona>. |
218 |
| - Include the {{PushSubscriptionOptions/applicationServerKey}} attribute of |options| when |
219 |
| - it has been set. |
| 227 | + <li>Request a new <a>push subscriptiona>. Include the |
| 228 | + {{PushSubscriptionOptions/applicationServerKey}} attribute of |options| when it has been |
| 229 | + set. Rethrow any [=exceptions=]. |
220 | 230 | li>
|
221 |
| - <li>When the request has completed, return |subscription|. |
| 231 | + <li>When the <a>push subscriptiona> request has completed successfully: |
| 232 | + <ol> |
| 233 | + <li>Set |subscription|'s {{PushSubscription/endpoint}} attribute to the [=URL=] |
| 234 | + provided by the <a>push subscriptiona>. |
| 235 | + li> |
| 236 | + <li>If provided by the <a>push subscriptiona>, set |subscription|'s |
| 237 | + {{PushSubscription/expirationTime}}. |
| 238 | + li> |
| 239 | + ol> |
| 240 | + li> |
| 241 | + <li>Return |subscription|. |
222 | 242 | li>
|
223 | 243 | ol>
|
224 | 244 | <section>
|
|
548 | 568 | MAY support content codings defined in previous versions of the draft for compatibility
|
549 | 569 | reasons.
|
550 | 570 | p>
|
| 571 | + <h3> |
| 572 | + `subscribe()` method |
| 573 | + h3> |
551 | 574 | <p>
|
552 |
| - The <dfn>subscribedfn> method when invoked MUST run the following steps: |
| 575 | + The <dfn>subscribe()dfn> method when invoked MUST run the following steps: |
553 | 576 | p>
|
554 |
| - <ol> |
| 577 | + <ol class="algorithm"> |
555 | 578 | <li>If the [=relevant global object=] of [=this=] does not have [=transient activation=],
|
556 | 579 | return [=a promise rejected with=] with a {{"NotAllowedError"}} {{DOMException}}.
|
557 | 580 | li>
|
558 | 581 | <li>[=Consume user activation=] of [=this=]'s [=relevant global object=].
|
559 | 582 | li>
|
560 | 583 | <li>Let |promise| be <a>a new promisea>.
|
561 | 584 | li>
|
562 |
| - <li>Return |promise| and continue the following steps asynchronously. |
| 585 | + <li>Let |global| be [=this=]' [=relevant global object=]. |
563 | 586 | li>
|
564 |
| - <li>If the <a>current settings objecta> 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 servicea> |
| 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}}. |
566 | 607 | li>
|
567 | 608 | <li>If the |options| argument includes a non-null value for the
|
568 | 609 | {{PushSubscriptionOptions/applicationServerKey}} attribute, run the following sub-steps:
|
569 | 610 | <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. |
575 | 620 | 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. |
579 | 625 | li>
|
580 | 626 | ol>
|
581 | 627 | li>
|
582 |
| - <li>If the |options| argument does not include a non-null value for the |
583 |
| - {{PushSubscriptionOptions/applicationServerKey}} attribute, and the <a>push servicea> |
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 |
588 | 629 | registrationa>.
|
589 | 630 | 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=]. |
593 | 636 | li>
|
594 | 637 | <li>Let |permission| be [=request permission to use=] "push".
|
595 | 638 | 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. |
598 | 642 | li>
|
599 |
| - <li>If the <a>Service Workera> is already subscribed, run the following substeps: |
| 643 | + <li>If |sw| is already subscribed, run the following sub-steps: |
600 | 644 | <ol>
|
601 |
| - <li>Retrieve the <a>push subscriptiona> associated with the <a>Service Workera>. |
| 645 | + <li>Try to retrieve the <a>push subscriptiona> 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. |
602 | 649 | 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 subscriptiona> associated with |sw|. |
605 | 651 | 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=]. |
607 | 655 | 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">referencesa>. |
| 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. |
614 | 660 | 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. |
616 | 664 | li>
|
617 | 665 | ol>
|
618 | 666 | li>
|
619 |
| - <li>Let |subscription| be the result of running the <a>create a push subscriptiona> 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. |
624 | 671 | 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 |
626 | 674 | |subscription|.
|
627 | 675 | li>
|
628 | 676 | ol>
|
|
939 | 987 | };
|
940 | 988 | pre>
|
941 | 989 | <p>
|
942 |
| - <a>PushMessageDataa> objects have an associated <dfn>bytesdfn> (a byte sequence) set on |
943 |
| - creation, which is `null` if there was no data in the <a>push messagea>. |
| 990 | + <a>PushMessageDataa> objects have an associated [=byte sequence=] set on creation, which |
| 991 | + is `null` if there was no data in the <a>push messagea>. |
944 | 992 | p>
|
945 | 993 | <p>
|
946 | 994 | The <dfn>arrayBuffer()dfn> method, when invoked, MUST return an {{ArrayBuffer}} whose
|
|
0 commit comments