summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/wasm/webapi/esm-integration/source-phase.tentative.html
blob: 870b16bd0a0ce8db80d403fc12aeecaf5e6ccedb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!doctype html>
<title>Source phase imports</title>

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script type=module>
setup({ single_test: true });

import source exportedNamesSource from "./resources/exported-names.wasm";

assert_true(exportedNamesSource instanceof WebAssembly.Module);
const AbstractModuleSource = Object.getPrototypeOf(WebAssembly.Module);
assert_equals(AbstractModuleSource.name, "AbstractModuleSource");
assert_true(exportedNamesSource instanceof AbstractModuleSource);

assert_array_equals(WebAssembly.Module.exports(exportedNamesSource).map(({ name }) => name).sort(),
                    ["func", "glob", "mem", "tab"]);

const wasmImportFromWasmSource = await import.source("./resources/wasm-import-from-wasm.wasm");

assert_true(wasmImportFromWasmSource instanceof WebAssembly.Module);

let logged = false;
const instance = await WebAssembly.instantiate(wasmImportFromWasmSource, {
  "./wasm-export-to-wasm.wasm": {
    log () {
      logged = true;
    }
  }
});
instance.exports.logExec();
assert_true(logged);

done();
</script>