tor-browser

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

multiple-origins.https.window.js (1572B)


      1 // META: script=/common/get-host-info.sub.js
      2 // META: script=/common/utils.js
      3 // META: script=/fetch/fetch-later/resources/fetch-later-helper.js
      4 // META: script=/fetch/fetch-later/quota/resources/helper.js
      5 'use strict';
      6 
      7 const {HTTPS_ORIGIN, HTTPS_NOTSAMESITE_ORIGIN} = get_host_info();
      8 
      9 for (const dataType in BeaconDataType) {
     10  // Tests multiple request reporting origins within same document.
     11  test(
     12      () => {
     13        const controller = new AbortController();
     14 
     15        // Makes the 1st call (POST) that sends max/2+1 quota to `HTTPS_ORIGIN`.
     16        fetchLater(`${HTTPS_ORIGIN}/`, {
     17          method: 'POST',
     18          signal: controller.signal,
     19          body: makeBeaconData(
     20              generatePayload(QUOTA_PER_REPORTING_ORIGIN / 2 + 1), dataType)
     21        });
     22 
     23        // Makes the 2nd call (POST) that sends max/2+1 of allowed quota, but to
     24        // a different reporting origin `HTTPS_NOTSAMESITE_ORIGIN`.
     25        fetchLater(`${HTTPS_NOTSAMESITE_ORIGIN}/`, {
     26          method: 'POST',
     27          signal: controller.signal,
     28          body: makeBeaconData(
     29              generatePayload(QUOTA_PER_REPORTING_ORIGIN / 2 + 1), dataType)
     30        });
     31 
     32        // Makes the 3rd call (GET) to `HTTPS_NOTSAMESITE_ORIGIN`.
     33        fetchLater(`${HTTPS_NOTSAMESITE_ORIGIN}/`, {
     34          method: 'GET',
     35          signal: controller.signal,
     36        });
     37 
     38        // Release quota taken by the pending requests for subsequent tests.
     39        controller.abort();
     40      },
     41      `fetchLater() has per-request-origin quota for its POST body of ${
     42          dataType}.`);
     43 }