fedcm-accounts-push-basic.tentative.https.html (2120B)
1 <!DOCTYPE html> 2 <title>Federated Credential Management API Accounts Push 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 <body> 10 11 <script type="module"> 12 import {fedcm_test, 13 request_options_with_mediation_required, 14 fedcm_select_account_promise, 15 fedcm_get_dialog_type_promise, 16 select_manifest, 17 setup_accounts_push, mark_signed_out} from '../support/fedcm-helper.sub.js'; 18 19 fedcm_test(async t => { 20 // Opens a window that then invokes navigator.login.setStatus with two pushed 21 // accounts with different picture URLs; one successful picture response, and 22 // one uncacheable response. Register the cleanup handler, which uses the 23 // setStatus API to set the state to 'logged-out' 24 t.add_cleanup(() => { 25 mark_signed_out(); 26 }); 27 await setup_accounts_push(); 28 29 const test_options = request_options_with_mediation_required("manifest_accounts_push.json"); 30 await select_manifest(t, test_options); 31 32 const cred_promise = navigator.credentials.get(test_options); 33 const type = await fedcm_get_dialog_type_promise(t); 34 assert_equals(type, "AccountChooser"); 35 36 const accounts = await window.test_driver.get_fedcm_account_list(); 37 assert_equals(accounts.length, 2); 38 39 assert_equals(accounts[0].accountId , "john_doe"); 40 assert_equals(accounts[0].givenName, "John"); 41 assert_equals(accounts[0].name, "John Doe"); 42 assert_equals(accounts[0].email, "john_doe@idp.example"); 43 44 assert_equals(accounts[1].accountId , "jane_doe"); 45 assert_equals(accounts[1].givenName, "Jane"); 46 assert_equals(accounts[1].name, "Jane Doe"); 47 assert_equals(accounts[1].email, "jane_doe@idp.example"); 48 49 50 await fedcm_select_account_promise(t, 0); 51 52 const cred = await cred_promise; 53 assert_equals(cred.token, "account_id=john_doe"); 54 assert_equals(cred.isAutoSelected, false); 55 }, "Successfully obtaining token should resolve the promise."); 56 57 </script>