tor-browser

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

credentialless-cross-origin-isolated.tentative.window.js (1340B)


      1 // META: script=/common/get-host-info.sub.js
      2 // META: script=/common/utils.js
      3 // META: script=/common/dispatcher/dispatcher.js
      4 // META: script=./resources/common.js
      5 
      6 const http  = get_host_info().HTTP_ORIGIN;
      7 const https = get_host_info().HTTPS_ORIGIN;
      8 
      9 let crossOriginIsolatedTest = (
     10    description,
     11    origin ,
     12    headers,
     13    expect_crossOriginIsolated) => {
     14  promise_test_parallel(async test => {
     15    const w_token = token();
     16    const w_url = origin + executor_path + headers + `&uuid=${w_token}`;
     17    const w = window.open(w_url)
     18    add_completion_callback(() => w.close());
     19 
     20    const this_token = token();
     21    send(w_token, `
     22      if (window.crossOriginIsolated)
     23        send("${this_token}", "crossOriginIsolated");
     24      else
     25        send("${this_token}", "not isolated")
     26    `);
     27    assert_equals(await receive(this_token), expect_crossOriginIsolated);
     28  }, description);
     29 }
     30 
     31 crossOriginIsolatedTest("Main crossOriginIsolated case:",
     32  https,  dip_credentialless, "crossOriginIsolated");
     33 
     34 crossOriginIsolatedTest("Missing HTTPS:",
     35  http,  dip_credentialless, "not isolated");
     36 
     37 crossOriginIsolatedTest("Report-only:",
     38  https, dip_report_only_credentialless, "not isolated");
     39 
     40 crossOriginIsolatedTest("Report-only + enforced:",
     41  https, dip_credentialless +
     42         dip_report_only_credentialless, "crossOriginIsolated");