source-phase.tentative.any.js (1433B)
1 // META: global=window,dedicatedworker,jsshell,shadowrealm 2 3 promise_test(async () => { 4 const exportedNamesSource = await import.source("./resources/exports.wasm"); 5 6 assert_true(exportedNamesSource instanceof WebAssembly.Module); 7 const AbstractModuleSource = Object.getPrototypeOf(WebAssembly.Module); 8 assert_equals(AbstractModuleSource.name, "AbstractModuleSource"); 9 assert_true(exportedNamesSource instanceof AbstractModuleSource); 10 11 assert_array_equals( 12 WebAssembly.Module.exports(exportedNamesSource) 13 .map(({ name }) => name) 14 .sort(), 15 [ 16 "a\u200Bb\u0300c", 17 "func", 18 "glob", 19 "mem", 20 "tab", 21 "value with spaces", 22 "🎯test-func!", 23 ] 24 ); 25 26 const wasmImportFromWasmSource = await import.source( 27 "./resources/wasm-import-from-wasm.wasm" 28 ); 29 30 assert_true(wasmImportFromWasmSource instanceof WebAssembly.Module); 31 32 let logged = false; 33 const instance = await WebAssembly.instantiate(wasmImportFromWasmSource, { 34 "./wasm-export-to-wasm.wasm": { 35 log() { 36 logged = true; 37 }, 38 }, 39 }); 40 instance.exports.logExec(); 41 assert_true(logged, "WebAssembly instance should execute imported function"); 42 }, "Source phase imports"); 43 44 promise_test(async () => { 45 const { mod1, mod2, mod3, mod4 } = await import('./resources/source-phase-identity.js'); 46 47 assert_equals(mod1, mod2); 48 assert_equals(mod3, mod4); 49 }, "Source phase identities");