fedcm-use-other-account.tentative.https.html (1972B)
1 <!DOCTYPE html> 2 <title>Federated Credential Management API Use Another Account API tests.</title> 3 <link rel="help" href="https://fedidcg.github.io/FedCM"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/resources/testdriver.js"></script> 7 <script src="/resources/testdriver-vendor.js"></script> 8 9 <script type="module"> 10 import {request_options_with_mediation_required, 11 fedcm_test, 12 fedcm_get_dialog_type_promise, 13 fedcm_settles_without_dialog, 14 manifest_origin, 15 open_and_wait_for_popup, 16 select_manifest} from '../support/fedcm-helper.sub.js'; 17 18 const url_path = '/fedcm/support/' 19 const url_prefix = manifest_origin + url_path; 20 21 async function set_accounts_cookie(value) { 22 await open_and_wait_for_popup(manifest_origin, url_path + 'set_accounts_cookie.py?' + value); 23 } 24 25 fedcm_test(async t => { 26 await set_accounts_cookie("1"); 27 28 let test_options = 29 request_options_with_mediation_required("manifest_with_variable_accounts.json"); 30 await select_manifest(t, test_options); 31 32 // Trigger FedCM and wait for the initial dialog. 33 const cred_promise = navigator.credentials.get(test_options); 34 let type = await fedcm_get_dialog_type_promise(t); 35 assert_equals(type, "AccountChooser"); 36 37 // Tell the account endpoint to now return 2 accounts and click use other account. 38 await set_accounts_cookie("2"); 39 await window.test_driver.click_fedcm_dialog_button("ConfirmIdpLoginContinue"); 40 41 // Wait for the account chooser to appear again. 42 type = await fedcm_get_dialog_type_promise(t); 43 assert_equals(type, "AccountChooser"); 44 45 // Select the first account, which is the most recently signed in account. 46 await window.test_driver.select_fedcm_account(0); 47 const cred = await fedcm_settles_without_dialog(t, cred_promise); 48 assert_equals(cred.token, "account_id=jane_doe"); 49 }, 'Test that the "Use Other Account" button works correctly.'); 50 51 </script>