tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

resolve-after-preventsilentaccess.https.html (2177B)


      1 <!DOCTYPE html>
      2 <title>IdentityProvider.resolve after preventSilentAccess should reset user interaction</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_optional,
     11        fedcm_test,
     12        select_manifest,
     13        fedcm_get_and_select_first_account} from '../support/fedcm-helper.sub.js';
     14 
     15 fedcm_test(async t => {
     16  let test_options = request_options_with_mediation_optional("manifest_with_continue_on.json");
     17  await select_manifest(t, test_options);
     18 
     19  // Signs in account "1234" so that they will be a returning user
     20  test_options.identity.providers[0].nonce = "token";
     21  let cred = await fedcm_get_and_select_first_account(t, test_options);
     22  assert_equals(cred.token, "account=1234");
     23 
     24  try {
     25    await navigator.credentials.preventSilentAccess();
     26  } catch (ex) {
     27    // In Chrome's content_shell, the promise will be rejected
     28    // even though the part we care about succeeds.
     29  }
     30 
     31  // Ensure that mediation: silent fails as expected.
     32  await select_manifest(t, test_options);
     33  test_options.mediation = "silent";
     34  let cred_promise = navigator.credentials.get(test_options);
     35  await promise_rejects_dom(t, 'NetworkError', cred_promise);
     36 
     37  // Now trigger continue_on/IdentityProvider.resolve.
     38  await select_manifest(t, test_options);
     39  test_options.mediation = "optional";
     40  test_options.identity.providers[0].nonce = "2";
     41  cred = await fedcm_get_and_select_first_account(t, test_options);
     42  assert_equals(cred.token, "account=1234");
     43  assert_equals(cred.isAutoSelected, false);
     44 
     45  // Now silent mediation should work.
     46  await select_manifest(t, test_options);
     47  test_options.mediation = "silent";
     48  test_options.identity.providers[0].nonce = "token";
     49  cred = await navigator.credentials.get(test_options);
     50  assert_equals(cred.token, "account=1234");
     51  assert_equals(cred.isAutoSelected, true);
     52 }, "Test that resolve clears the preventSilentAccess state.");
     53 </script>