tor-browser

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

preflight-cache-partitioning.sub.window.js (1194B)


      1 // META: script=/common/utils.js
      2 
      3 const TEST_PAGE =
      4  "http://{{host}}:{{ports[http][0]}}/cors/resources/preflight-cache-partitioning.sub.html";
      5 const TEST_ANOTHER_PAGE =
      6  "http://{{hosts[alt][]}}:{{ports[http][0]}}/cors/resources/preflight-cache-partitioning.sub.html";
      7 
      8 promise_test(async t => {
      9  let uuid_token = token();
     10 
     11  const TEST_PAGES = [TEST_PAGE, TEST_ANOTHER_PAGE];
     12 
     13  // We will load the same page with different top-level origins to check if the
     14  // CORS preflight cache is partitioned. The page will load the iframe with one
     15  // origin and trigger the CORS preflight through fetching a cross-origin
     16  // resources in the iframe.
     17 
     18  for (let test_page of TEST_PAGES) {
     19    let win;
     20 
     21    await new Promise(resolve => {
     22      window.onmessage = (e) => {
     23        if (e.data.type === "loaded") {
     24          resolve();
     25        }
     26      };
     27 
     28      win = window.open(test_page);
     29    });
     30 
     31    await new Promise(resolve => {
     32      win.postMessage({ type: "run", token: uuid_token }, "*");
     33 
     34      window.onmessage = (e) => {
     35        assert_equals(e.data.type, "pass", e.data.msg);
     36        resolve();
     37      };
     38    });
     39 
     40    win.close();
     41  }
     42 }, "The preflight cache should be partitioned");