test_is_auto_selected.html (3103B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>FedCM is_auto_selected Test</title> 6 <script src="/tests/SimpleTest/SimpleTest.js"></script> 7 <script src="head.js"></script> 8 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/> 9 <script> 10 SimpleTest.waitForExplicitFinish(); 11 setupTest("is_auto_selected") 12 .then(clearIdentityCredentialStorage) 13 .then( 14 function () { 15 info("Testing manual selection - is_auto_selected should be false"); 16 SpecialPowers.wrap(document).notifyUserGestureActivation(); 17 return navigator.credentials.get({ 18 identity: { 19 mode: "active", 20 providers: [{ 21 configURL: "https://example.net/tests/dom/credentialmanagement/identity/tests/mochitest/server_manifest.sjs", 22 clientId: "mochitest", 23 nonce: "nonce" 24 }] 25 } 26 }); 27 } 28 ).then((cred) => { 29 ok(true, "Successfully got a credential on first request"); 30 is(cred.token, 31 "account_id=1234&client_id=mochitest&nonce=nonce&disclosure_text_shown=false&is_auto_selected=false", 32 "is_auto_selected should be false on first request"); 33 is(cred.id, "1234", "Correct id on the credential"); 34 is(cred.type, "identity", "Correct type on the credential"); 35 is(cred.isAutoSelected, false, "Correct isAutoSelected on the credential"); 36 is(cred.configURL, "https://example.net/tests/dom/credentialmanagement/identity/tests/mochitest/server_manifest.sjs", "Correct configURL on credential"); 37 info("Testing auto-reauth - is_auto_selected should be true"); 38 return navigator.credentials.get({ 39 identity: { 40 mode: "passive", 41 providers: [{ 42 configURL: "https://example.net/tests/dom/credentialmanagement/identity/tests/mochitest/server_manifest.sjs", 43 clientId: "mochitest", 44 nonce: "nonce" 45 }] 46 }, 47 }); 48 }).then((cred) => { 49 ok(true, "Successfully got a credential on auto-reauth request"); 50 is(cred.token, 51 "account_id=1234&client_id=mochitest&nonce=nonce&disclosure_text_shown=false&is_auto_selected=true", 52 "is_auto_selected should be true on second request"); 53 is(cred.id, "1234", "Correct id on the auto-reauth credential"); 54 is(cred.type, "identity", "Correct type on the auto-reauth credential"); 55 is(cred.isAutoSelected, true, "Correct isAutoSelected on the credential"); 56 is(cred.configURL, "https://example.net/tests/dom/credentialmanagement/identity/tests/mochitest/server_manifest.sjs", "Correct configURL on the credential"); 57 }).catch((err) => { 58 info("Error: " + err); 59 ok(false, "Must not have an error: " + err.message); 60 }).finally(() => { 61 SimpleTest.finish(); 62 }); 63 </script> 64 </head> 65 <body> 66 <p id="display"></p> 67 <div id="content" style="display: none"> 68 This test verifies the is_auto_selected field behavior in FedCM: 69 1. First request - is_auto_selected=false 70 2. Second request - is_auto_selected=true 71 </div> 72 <pre id="test"></pre> 73 </body> 74 </html>