2 <title>Federated Credential Management logout() API.
</title>
3 <link rel=
"help" href=
"https://wicg.github.io/FedCM">
4 <script src=
"/resources/testharness.js"></script>
5 <script src=
"/resources/testharnessreport.js"></script>
8 import {set_fedcm_cookie} from './support/fedcm-helper.js';
10 const url_prefix = 'https://{{host}}:{{ports[https][
0]}}/credential-management/support/';
11 const test_options = {
16 // hint has to match the account id in support/accounts.json
21 const test_options_no_hint = {
29 const login_options = {
33 promise_test(async t =
> {
34 await set_fedcm_cookie();
35 const cred = await navigator.credentials.get(test_options);
36 const token = await cred.login(login_options);
37 assert_equals(token.idToken,
"token");
40 },
"logout should not throw an exception.");
42 promise_test(async t =
> {
43 const cred = await navigator.credentials.get(test_options);
45 return promise_rejects_dom(t,
"InvalidStateError", cred.logout());
46 },
"logout should throw an exception when not logged in.");
48 promise_test(async t =
> {
49 await set_fedcm_cookie();
50 const cred = await navigator.credentials.get(test_options_no_hint);
51 const token = await cred.login(login_options);
52 assert_equals(token.idToken,
"token");
54 return promise_rejects_dom(t,
"InvalidStateError", cred.logout());
55 },
"logout should require a hint.");