tor-browser

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

test_responseReadyForWasm.html (1572B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Test for Response ready to be used by wasm</title>
      6  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      7  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
      8 </head>
      9 <body>
     10  <script type="application/javascript">
     11 
     12 const isCachingEnabled = SpecialPowers.getBoolPref("javascript.options.wasm_caching");
     13 
     14 async function runTests() {
     15  let response = await fetch("/tests/dom/promise/tests/test_webassembly_compile_sample.wasm");
     16  ok(!!response, "Fetch a wasm module produces a Response object");
     17  is(response.headers.get("content-type"), "application/wasm", "Correct content-type");
     18  if (!isCachingEnabled) {
     19    ok(!SpecialPowers.wrap(response).hasCacheInfoChannel, "nsICacheInfoChannel not available");
     20    SimpleTest.finish();
     21    return;
     22  }
     23 
     24  ok(SpecialPowers.wrap(response).hasCacheInfoChannel, "nsICacheInfoChannel available");
     25 
     26  let clonedResponse = response.clone();
     27  ok(!!clonedResponse, "Cloned response");
     28  is(clonedResponse.headers.get("content-type"), "application/wasm", "Correct content-type");
     29  ok(SpecialPowers.wrap(clonedResponse).hasCacheInfoChannel, "nsICacheInfoChannel available");
     30 
     31  response = await fetch(location.href);
     32  ok(!!response, "Fetch another resource");
     33  ok(response.headers.get("content-type") != "application/wasm", "Correct content-type");
     34  ok(!SpecialPowers.wrap(response).hasCacheInfoChannel, "nsICacheInfoChannel available");
     35 
     36  SimpleTest.finish();
     37 }
     38 
     39 SimpleTest.waitForExplicitFinish();
     40 runTests();
     41 
     42  </script>
     43 </body>
     44 </html>