gskachkov@gmail.com | b1d3176 | 2018-01-02 15:38:39 +0000 | [diff] [blame] | 1 | <!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> |
| 6 | description("Test that expected Wasm Module can be sent over window.postMessage."); |
| 7 | if (window.testRunner) |
| 8 | testRunner.waitUntilDone(); |
| 9 | |
| 10 | window.addEventListener("message", (answer) => finish(answer.data), false); |
| 11 | |
| 12 | function 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 | |
| 21 | var 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 | |
| 30 | setTimeout(run); |
| 31 | </script> |