1<!DOCTYPE html>
2<title>Handling of importing invalid WebAssembly modules</title>
3
4<script src="/resources/testharness.js"></script>
5<script src="/resources/testharnessreport.js"></script>
6<script>
7    setup({allow_uncaught_exception: true});
8
9    window.log = [];
10
11    window.addEventListener("error", ev => log.push(ev.error));
12
13    const test_load = async_test(
14        "Test that imports of invalid WebAssembly modules leads to WebAssembly.CompileError on window.");
15    window.addEventListener("load", test_load.step_func_done(ev => {
16      assert_equals(log.length, 2);
17      assert_equals(log[0].constructor, WebAssembly.CompileError);
18      assert_equals(log[1].constructor, WebAssembly.CompileError);
19    }));
20
21    function unreachable() { log.push("unexpected"); }
22</script>
23<script type="module" src="./resources/invalid-bytecode.wasm" onerror="unreachable()"></script>
24<script type="module" src="./resources/invalid-module.wasm" onerror="unreachable()"></script>
25