tor-browser

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

wasm-js-cycle.tentative.html (925B)


      1 <!doctype html>
      2 <title>Check bindings in JavaScript and WebAssembly cycle (Wasm higher)</title>
      3 
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script type=module>
      7 setup({ single_test: true });
      8 import * as wasm from "./resources/wasm-js-cycle.wasm";
      9 import * as js from "./resources/wasm-js-cycle.js";
     10 
     11 js.mutateBindings();
     12 
     13 assert_true(wasm.wasmGlob instanceof WebAssembly.Global);
     14 assert_equals(wasm.wasmGlob.valueOf(), 24);
     15 
     16 assert_true(wasm.wasmFunc instanceof Function);
     17 assert_equals(wasm.wasmFunc(), 43);
     18 
     19 assert_equals(wasm.incrementGlob(), 43);
     20 
     21 const buf = new Int32Array(wasm.wasmMem.buffer);
     22 assert_equals(buf[0], 0);
     23 assert_equals(wasm.mutateMem(), 42);
     24 assert_equals(buf[0], 42);
     25 
     26 assert_equals(wasm.wasmTab.get(0), null);
     27 const ref = wasm.mutateTab();
     28 assert_true(ref instanceof Function);
     29 assert_equals(wasm.wasmTab.get(0), ref);
     30 
     31 done();
     32 </script>