fedcm-userinfo-after-resolve.https.html (2059B)
1 <!DOCTYPE html> 2 <title>Federated Credential Management API authz getUserInfo() 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 {alt_manifest_origin, 13 alt_request_options_with_mediation_required, 14 select_manifest, 15 fedcm_test, 16 fedcm_get_and_select_first_account} from '../support/fedcm-helper.sub.js'; 17 18 async function createIframeWithPermissionPolicyAndWaitForMessage(test, iframeUrl) { 19 const messageWatcher = new EventWatcher(test, window, "message"); 20 let iframe = document.createElement("iframe"); 21 iframe.src = iframeUrl; 22 iframe.allow = "identity-credentials-get"; 23 document.body.appendChild(iframe); 24 let message = null; 25 // Ignore internal "testdriver-complete" messages. 26 do { 27 message = await messageWatcher.wait_for("message"); 28 } while (!("result" in message.data)); 29 return message.data; 30 } 31 32 fedcm_test(async t => { 33 const options = alt_request_options_with_mediation_required('manifest_with_continue_on.json'); 34 await select_manifest(t, options); 35 const cred = await fedcm_get_and_select_first_account(t, options); 36 assert_equals(cred.token, "account=1234"); 37 38 const iframe_in_idp_scope = `${alt_manifest_origin}/\ 39 fedcm/support/fedcm/userinfo-iframe.html`; 40 const message = await createIframeWithPermissionPolicyAndWaitForMessage(t, iframe_in_idp_scope); 41 assert_equals(message.result, "Pass"); 42 assert_equals(message.numAccounts, 1); 43 assert_equals(message.firstAccountEmail, "john_doe@idp.example"); 44 assert_equals(message.firstAccountName, "John Doe"); 45 assert_equals(message.firstAccountGivenName, "John"); 46 assert_equals(message.firstAccountPicture, "https://localhost/profile/123"); 47 }, 'Test getUserInfo() after resolve() to verify that resolve stores the RP/IDP connection'); 48 49 </script>