3 <title>FederatedCredential.revoke() promise resolution
</title>
4 <link rel=
"author" title=
"Christian Biesinger" href=
"mailto:cbiesinger@chromium.org">
5 <link rel=
"help" href=
"https://fedidcg.github.io/FedCM/#browser-api-revocation">
6 <script src=
"/resources/testharness.js"></script>
7 <script src=
"/resources/testharnessreport.js"></script>
10 import {set_fedcm_cookie} from './support/fedcm-helper.js';
11 const url_prefix = 'https://{{host}}:{{ports[https][
0]}}/credential-management/support/';
13 async function getCredential(provider_url) {
15 url: provider_url || url_prefix,
18 return await navigator.credentials.get({
20 providers: [provider],
25 promise_test(async t =
> {
26 await set_fedcm_cookie();
27 await (await getCredential()).login({nonce: '
1'});
28 await (await getCredential()).revoke(
"1234");
30 // Second revoke should now fail since the first revoke should revoke
32 const result = (await getCredential()).revoke(
"1234");
33 return promise_rejects_dom(t,
"NetworkError", result);
34 },
"Successfully revoking a token should resolve the promise.");
36 promise_test(async t =
> {
37 // Have to first login or the request will be rejected before it reaches
39 await set_fedcm_cookie();
40 await (await getCredential()).login({nonce: '
1'});
41 await (await getCredential()).revoke(
"1234");
43 const result = (await getCredential()).revoke(
"fail");
44 return promise_rejects_dom(t,
"NetworkError", result);
45 },
"Error should reject the promise.");
47 promise_test(async t =
> {
48 const result = (await getCredential()).revoke(
"");
49 return promise_rejects_dom(t,
"InvalidStateError", result);
50 },
"Empty hint should reject the promise.");
52 promise_test(async t =
> {
53 const result = getCredential(
"https://other-idp.example/").then((c) =
> c.revoke(
"foo@bar.com"));
54 return promise_rejects_dom(t,
"NetworkError", result);
55 },
"Provider URL should honor Content-Security-Policy.");