|
| 1 | +// META: global=window,dedicatedworker,jsshell,shadowrealm |
| 2 | + |
| 3 | +promise_test(async () => { |
| 4 | + const wasmModuleSource = await import.source("./resources/js-string-constants.wasm"); |
| 5 | + |
| 6 | + const instance = new WebAssembly.Instance(wasmModuleSource, {}); |
| 7 | + |
| 8 | + assert_equals(instance.exports.empty.value, ""); |
| 9 | + assert_equals(instance.exports.nullByte.value, "\0"); |
| 10 | + assert_equals(instance.exports.hello.value, "hello"); |
| 11 | + assert_equals(instance.exports.emoji.value, "\u{1F600}"); |
| 12 | +}, "String constants from wasm:js/string-constants should be supported in source phase imports"); |
| 13 | + |
| 14 | +promise_test(async () => { |
| 15 | + const wasmModuleSource = await import.source("./resources/js-string-constants.wasm"); |
| 16 | + |
| 17 | + const exports = WebAssembly.Module.exports(wasmModuleSource); |
| 18 | + const exportNames = exports.map((exp) => exp.name); |
| 19 | + |
| 20 | + assert_true(exportNames.includes("empty")); |
| 21 | + assert_true(exportNames.includes("nullByte")); |
| 22 | + assert_true(exportNames.includes("hello")); |
| 23 | + assert_true(exportNames.includes("emoji")); |
| 24 | +}, "Source phase import should properly expose string constants exports"); |
| 25 | + |
| 26 | +promise_test(async () => { |
| 27 | + const wasmModuleSource = await import.source("./resources/js-string-constants.wasm"); |
| 28 | + |
| 29 | + const imports = WebAssembly.Module.imports(wasmModuleSource); |
| 30 | + |
| 31 | + assert_equals(imports.length, 0); |
| 32 | +}, "Source phase import should handle string constants import reflection correctly"); |
0 commit comments