tor-browser

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

fedcm-client-metadata-not-cached.https.html (1930B)


      1 <!DOCTYPE html>
      2 <title>Federated Credential Management API network request 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 <script type="module">
     10 import {request_options_with_mediation_required,
     11        fedcm_test,
     12        fedcm_get_and_select_first_account} from './support/fedcm-helper.sub.js';
     13 
     14 fedcm_test(async t => {
     15  // Reset the client_metadata fetch count.
     16  const clear_metadata_count_path = `/fedcm/support/client_metadata_clear_count.py`;
     17  await fetch(clear_metadata_count_path);
     18 
     19  // FedCM flow causes the counter of client metadata to increase by 1.
     20  const cred = await fedcm_get_and_select_first_account(t, request_options_with_mediation_required());
     21  assert_equals(cred.token, "token");
     22 
     23  await new Promise(resolve => {
     24    // Fetch the client metadata from a popup window.
     25    let popup_window = window.open('/fedcm/support/client_metadata.py?skip_checks=1');
     26    const popup_window_load_handler = (event) => {
     27      popup_window.removeEventListener('load', popup_window_load_handler);
     28      popup_window.close();
     29      resolve();
     30    };
     31    popup_window.addEventListener('load', popup_window_load_handler);
     32  });
     33 
     34  const client_metadata_counter = await fetch(clear_metadata_count_path);
     35  const client_metadata_counter_text = await client_metadata_counter.text();
     36  // Check that the client metadata response is not cached. If the client metadata response was
     37  // cached, when the user visits the IDP as a first party, the IDP would be able to determine the
     38  // last RP the user visited regardless of whether the user granted consent via the FedCM prompt.
     39  assert_equals(client_metadata_counter_text, "2");
     40 }, 'Test client_metadata request is not cached');
     41 </script>