fedcm-use-other-account-button-flow.tentative.https.html (3167B)
1 <!DOCTYPE html> 2 <title>Federated Credential Management API Use Another Account API tests.</title> 3 <meta name="timeout" content="long"> 4 <link rel="help" href="https://fedidcg.github.io/FedCM"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/resources/testdriver.js"></script> 8 <script src="/resources/testdriver-vendor.js"></script> 9 10 <script type="module"> 11 import {request_options_with_mediation_required, 12 fedcm_test, 13 fedcm_get_dialog_type_promise, 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 test_options.identity.mode = "active"; 31 await select_manifest(t, test_options); 32 33 // Trigger FedCM and wait for the initial dialog. 34 let cred_promise = null; 35 await test_driver.bless('initiate FedCM request', async function() { 36 cred_promise = navigator.credentials.get(test_options); 37 }); 38 39 let type = await fedcm_get_dialog_type_promise(t); 40 assert_equals(type, "AccountChooser"); 41 42 // Tell the account endpoint to now return 2 accounts and click use other account. 43 await set_accounts_cookie("2"); 44 await window.test_driver.click_fedcm_dialog_button("ConfirmIdpLoginContinue"); 45 46 // Wait for the account chooser to appear again. 47 type = await fedcm_get_dialog_type_promise(t); 48 assert_equals(type, "AccountChooser"); 49 50 // Select the first account, which is the most recently signed in account. 51 await window.test_driver.select_fedcm_account(0); 52 const cred = await cred_promise; 53 assert_equals(cred.token, "account_id=jane_doe"); 54 }, 'Test that the "Use Other Account" active works correctly.'); 55 56 57 fedcm_test(async t => { 58 await set_accounts_cookie("1"); 59 60 let test_options = 61 request_options_with_mediation_required("manifest_with_variable_accounts.json"); 62 test_options.identity.mode = "active"; 63 await select_manifest(t, test_options); 64 65 // Trigger FedCM and wait for the initial dialog. 66 let cred_promise = null; 67 await test_driver.bless('initiate FedCM request', async function() { 68 cred_promise = navigator.credentials.get(test_options); 69 }); 70 71 let type = await fedcm_get_dialog_type_promise(t); 72 assert_equals(type, "AccountChooser"); 73 74 // Click use other account but without changing the account returned. 75 await window.test_driver.click_fedcm_dialog_button("ConfirmIdpLoginContinue"); 76 77 // Wait for the account chooser to appear again. 78 type = await fedcm_get_dialog_type_promise(t); 79 assert_equals(type, "AccountChooser"); 80 81 await window.test_driver.select_fedcm_account(0); 82 const cred = await cred_promise; 83 assert_equals(cred.token, "account_id=1234"); 84 }, 'Test that the "Use Other Account" active works correctly when accounts do not change.'); 85 86 </script>