summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/credential-management/fedcm-login-status/confirm-idp-login.https.html
blob: 0f8df72b615b5fadb9e17decd69c670652d06d21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE html>
<meta charset="utf-8">
<title>FedCM IDP log-in status API tests</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>

<script type="module">
import {request_options_with_mediation_required,
        fedcm_test,
        fedcm_get_dialog_type_promise,
        select_manifest,
        mark_signed_in} from '../support/fedcm-helper.sub.js';

fedcm_test(async t => {
  await mark_signed_in();

  let test_options = request_options_with_mediation_required("manifest_with_variable_accounts.json");
  await select_manifest(t, test_options);

  let cred_promise = navigator.credentials.get(test_options);
  let type = await fedcm_get_dialog_type_promise(t);
  assert_equals(type, "ConfirmIdpLogin");

  // Manifest selection only persists for a single fetch, so we need to set it
  // again because Chrome's implementation re-fetches the manifest as well, not
  // just the accounts endpoint.
  // (This is not technically spec-compliant)
  await select_manifest(t, test_options);
  await window.test_driver.click_fedcm_dialog_button("ConfirmIdpLoginContinue");

  // Now wait for the account chooser.
  type = await fedcm_get_dialog_type_promise(t);
  assert_equals(type, "AccountChooser");
  window.test_driver.select_fedcm_account(0);

  let cred = await cred_promise;
  assert_equals(cred.token, "account_id=1234");
}, 'Tests the IDP login dialog and subsequent account chooser.');
</script>