blob: 8e12ca64c2de35fcebfc135d789d7db70b88d00a [file] [log] [blame]
gskachkov@gmail.comb1d31762018-01-02 15:38:39 +00001<!DOCTYPE html>
2<script src="../resources/js-test.js"></script>
3<script src="../resources/wasm-builder.js"></script>
4<script src="./resources/load_wasm.js"></script>
5<script>
6description("Test that expected Wasm Module can be sent over window.postMessage.");
7if (window.testRunner)
8 testRunner.waitUntilDone();
9
10window.addEventListener("message", (answer) => finish(answer.data), false);
11
12function finish(module) {
13 var i = new WebAssembly.Instance(module);
14 var value = i.exports.calc(1);
15 shouldBe(() => value, () => 7002);
16
17 if (window.testRunner)
18 testRunner.notifyDone();
19}
20
21var run = async function () {
22 try {
23 var mod = await createWasmModule();
24 window.postMessage(mod, '*');
25 } catch (e) {
26 console.log('error:', e);
27 }
28};
29
30setTimeout(run);
31</script>