tor-browser

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

utils.js (1046B)


      1 function testFetchNoCors(file, options, ...pipe) {
      2  return fetch(`${file}${pipe.length ? `?pipe=${pipe.join("|")}` : ""}`, {
      3    ...(options || {}),
      4    mode: "no-cors",
      5  });
      6 }
      7 
      8 function promise_internal_response_is_filtered(fetchPromise, message) {
      9  return promise_test(async () => {
     10    const response = await fetchPromise;
     11 
     12    // A parent filtered opaque response is defined here as a response that isn't just an
     13    // opaque response, but also where the internal response has been made unavailable.
     14    // `Response.cloneUnfiltered` is used to inspect the state of the internal response,
     15    // which is exactly what we want to be missing in this case.
     16    const unfiltered = SpecialPowers.wrap(response).cloneUnfiltered();
     17    assert_equals(
     18      await SpecialPowers.unwrap(unfiltered).text(),
     19      "",
     20      "The internal response should be empty"
     21    );
     22    assert_equals(
     23      Array.from(await SpecialPowers.unwrap(unfiltered).headers).length,
     24      0,
     25      "The internal response should have no headers"
     26    );
     27  }, message);
     28 }