tor-browser

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

script-src-allows-source-phase-wasm.tentative.html (1224B)


      1 <!doctype html>
      2 <title>Source phase imports allowed by CSP</title>
      3 <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';">
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script type=module>
      7 setup({ single_test: true });
      8 
      9 import source exportedNamesSource from "./resources/exported-names.wasm";
     10 
     11 assert_true(exportedNamesSource instanceof WebAssembly.Module);
     12 const AbstractModuleSource = Object.getPrototypeOf(WebAssembly.Module);
     13 assert_equals(AbstractModuleSource.name, "AbstractModuleSource");
     14 assert_true(exportedNamesSource instanceof AbstractModuleSource);
     15 
     16 assert_array_equals(WebAssembly.Module.exports(exportedNamesSource).map(({ name }) => name).sort(),
     17                    ["func", "glob", "mem", "tab"]);
     18 
     19 const wasmImportFromWasmSource = await import.source("./resources/wasm-import-from-wasm.wasm");
     20 
     21 assert_true(wasmImportFromWasmSource instanceof WebAssembly.Module);
     22 
     23 let logged = false;
     24 const instance = await WebAssembly.instantiate(wasmImportFromWasmSource, {
     25  "./wasm-export-to-wasm.wasm": {
     26    log () {
     27      logged = true;
     28    }
     29  }
     30 });
     31 instance.exports.logExec();
     32 assert_true(logged);
     33 
     34 done();
     35 </script>