Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /wasm/jsapi/esm-integration/source-phase.tentative.any.js - WPT Dashboard Interop Dashboard
- /wasm/jsapi/esm-integration/source-phase.tentative.any.html - WPT Dashboard Interop Dashboard
- /wasm/jsapi/esm-integration/source-phase.tentative.any.shadowrealm-in-dedicatedworker.html - WPT Dashboard Interop Dashboard
- /wasm/jsapi/esm-integration/source-phase.tentative.any.shadowrealm-in-shadowrealm.html - WPT Dashboard Interop Dashboard
- /wasm/jsapi/esm-integration/source-phase.tentative.any.shadowrealm-in-sharedworker.html - WPT Dashboard Interop Dashboard
- /wasm/jsapi/esm-integration/source-phase.tentative.any.shadowrealm-in-window.html - WPT Dashboard Interop Dashboard
- /wasm/jsapi/esm-integration/source-phase.tentative.any.worker.html - WPT Dashboard Interop Dashboard
- /wasm/jsapi/esm-integration/source-phase.tentative.https.any.shadowrealm-in-audioworklet.html - WPT Dashboard Interop Dashboard
- /wasm/jsapi/esm-integration/source-phase.tentative.https.any.shadowrealm-in-serviceworker.html - WPT Dashboard Interop Dashboard
// META: global=window,dedicatedworker,jsshell,shadowrealm
promise_test(async () => {
const exportedNamesSource = await import.source("./resources/exports.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(),
[
"a\u200Bb\u0300c",
"func",
"glob",
"mem",
"tab",
"value with spaces",
"🎯test-func!",
]
);
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, "WebAssembly instance should execute imported function");
}, "Source phase imports");
promise_test(async () => {
const { mod1, mod2, mod3, mod4 } = await import('./resources/source-phase-identity.js');
assert_equals(mod1, mod2);
assert_equals(mod3, mod4);
}, "Source phase identities");