tor-browser

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

cross-origin-isolated.window.js (1560B)


      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,  coop_same_origin +
     33          coep_credentialless, "crossOriginIsolated");
     34 
     35 crossOriginIsolatedTest("Missing HTTPS:",
     36  http,  coop_same_origin +
     37         coep_credentialless, "not isolated");
     38 
     39 crossOriginIsolatedTest("Missing COOP:same-origin:",
     40  https,  coep_credentialless, "not isolated");
     41 
     42 crossOriginIsolatedTest("Report-only:",
     43  https, coop_same_origin +
     44         coep_report_only_credentialless, "not isolated");
     45 
     46 crossOriginIsolatedTest("Report-only + enforced:",
     47  https, coop_same_origin +
     48         coep_credentialless +
     49         coep_report_only_credentialless, "crossOriginIsolated");