Skip to content

Only allows instrument.set() in active service worker #224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2018
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
16 changes: 13 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,14 @@ <h2>
When called, this method executes the following steps:
</p>
<ol>
<li>Let <var>registration</var> be the <a>PaymentInstrument</a>'s
associated <a>service worker registration</a>.
</li>
<li>If <var>registration</var> has no <a>active worker</a>, then
reject a <a>Promise</a> with an
"<code><a>InvalidStateError</a></code>" DOMException and terminate
these steps.
</li>
<li>Upon user agent discretion and depending on user consent,
optionally return a <a>Promise</a> rejected with a
<a>NotAllowedError</a>.
Expand Down Expand Up @@ -716,7 +724,8 @@ <h2>
&lt;script&gt;

const instrumentKey = "c8126178-3bba-4d09-8f00-0771bcfd3b11";
const registration = await navigator.serviceWorker.register("/register/sw.js");
navigator.serviceWorker.register("/register/sw.js");
const registration = await navigator.serviceWorker.ready;
await registration.paymentManager.paymentInstruments.set({
instrumentKey,
{
Expand Down Expand Up @@ -773,8 +782,8 @@ <h2>
return; // not supported, so bail out.
}

const registration =
await navigator.serviceWorker.register("/sw.js");
navigator.serviceWorker.register("/sw.js");
const registration = await navigator.serviceWorker.ready;

// Excellent, we got it! Let's now set up the user's cards.
await addInstruments(registration);
Expand Down Expand Up @@ -2396,6 +2405,7 @@ <h2>
<dd>
The terms <dfn data-cite=
"!SERVICE-WORKERS#service-worker-concept">service worker</dfn>,
<dfn>service worker registration</dfn>, <dfn>active worker</dfn>,
<dfn data-cite="!SERVICE-WORKERS#dfn-service-worker-client">service
worker client</dfn>, <code><dfn data-cite=
"!SERVICE-WORKERS#service-worker-registration-concept">ServiceWorkerRegistration</dfn></code>,
Expand Down