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>
7setup({ single_test: true });
8import * as wasm from "./resources/wasm-js-cycle.wasm";
9import * as js from "./resources/wasm-js-cycle.js";
10
11js.mutateBindings();
12
13assert_true(wasm.wasmGlob instanceof WebAssembly.Global);
14assert_equals(wasm.wasmGlob.valueOf(), 24);
15
16assert_true(wasm.wasmFunc instanceof Function);
17assert_equals(wasm.wasmFunc(), 43);
18
19assert_equals(wasm.incrementGlob(), 43);
20
21const buf = new Int32Array(wasm.wasmMem.buffer);
22assert_equals(buf[0], 0);
23assert_equals(wasm.mutateMem(), 42);
24assert_equals(buf[0], 42);
25
26assert_equals(wasm.wasmTab.get(0), null);
27const ref = wasm.mutateTab();
28assert_true(ref instanceof Function);
29assert_equals(wasm.wasmTab.get(0), ref);
30
31done();
32</script>
33