Bug 1771985 [wpt PR 34266] - [FedCM] Move set_cookie into the helper file to share...
[gecko.git] / testing / web-platform / tests / credential-management / fedcm-logout.sub.https.html
blobad775d8bd21107ab0e79194536e95667ddcec43c
1 <!DOCTYPE html>
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>
6 <body>
7 <script type="module">
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 = {
12 federated: {
13 providers: [{
14 url: url_prefix,
15 clientId: '1',
16 // hint has to match the account id in support/accounts.json
17 hint: '1234',
21 const test_options_no_hint = {
22 federated: {
23 providers: [{
24 url: url_prefix,
25 clientId: '1',
29 const login_options = {
30 nonce: '2',
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");
39 await cred.logout();
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.");
56 </script>