Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/fixtures/wpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Last update:
- url: https://github.com/web-platform-tests/wpt/tree/258f285de0/url
- urlpattern: https://github.com/web-platform-tests/wpt/tree/f07c03cbed/urlpattern
- user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/65a2134d50/wasm/jsapi
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/288c467d35/wasm/jsapi
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
- web-locks: https://github.com/web-platform-tests/wpt/tree/10a122a6bc/web-locks
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/2cb332d710/WebCryptoAPI
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/wpt/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"path": "user-timing"
},
"wasm/jsapi": {
"commit": "65a2134d50",
"commit": "288c467d350ec4b8e4fbc7f2ccb6119293186611",
"path": "wasm/jsapi"
},
"wasm/webapi": {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(module
(import "wasm:js/string-constants" "" (global $empty externref))
(import "wasm:js/string-constants" "\00" (global $null_byte externref))
(import "wasm:js/string-constants" "hello" (global $hello externref))
(import "wasm:js/string-constants" "\f0\9f\98\80" (global $emoji externref))

(export "empty" (global $empty))
(export "nullByte" (global $null_byte))
(export "hello" (global $hello))
(export "emoji" (global $emoji))
)
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ promise_test(async () => {

assert_equals(imports.length, 0);
}, "Source phase import should handle string builtin import reflection correctly");

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// META: global=window,dedicatedworker,jsshell,shadowrealm

promise_test(async () => {
const wasmModuleSource = await import.source("./resources/js-string-constants.wasm");

const instance = new WebAssembly.Instance(wasmModuleSource, {});

assert_equals(instance.exports.empty.value, "");
assert_equals(instance.exports.nullByte.value, "\0");
assert_equals(instance.exports.hello.value, "hello");
assert_equals(instance.exports.emoji.value, "\u{1F600}");
}, "String constants from wasm:js/string-constants should be supported in source phase imports");

promise_test(async () => {
const wasmModuleSource = await import.source("./resources/js-string-constants.wasm");

const exports = WebAssembly.Module.exports(wasmModuleSource);
const exportNames = exports.map((exp) => exp.name);

assert_true(exportNames.includes("empty"));
assert_true(exportNames.includes("nullByte"));
assert_true(exportNames.includes("hello"));
assert_true(exportNames.includes("emoji"));
}, "Source phase import should properly expose string constants exports");

promise_test(async () => {
const wasmModuleSource = await import.source("./resources/js-string-constants.wasm");

const imports = WebAssembly.Module.imports(wasmModuleSource);

assert_equals(imports.length, 0);
}, "Source phase import should handle string constants import reflection correctly");
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ promise_test(async () => {
assert_equals(wasmModule.testString("hello"), 1);
assert_equals(wasmModule.testString(42), 0);
}, "String builtins should be supported in imports in ESM integration");

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// META: global=window,dedicatedworker,jsshell,shadowrealm

promise_test(async () => {
const wasmModule = await import("./resources/js-string-constants.wasm");

assert_equals(wasmModule.empty, "");
assert_equals(wasmModule.nullByte, "\0");
assert_equals(wasmModule.hello, "hello");
assert_equals(wasmModule.emoji, "\u{1F600}");
}, "String constants from wasm:js/string-constants should be supported in ESM integration");
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
function assert_throws_wasm(fn, message) {
try {
fn();
assert_not_reached(`expected to throw with ${message}`);
assert_unreached(`expected to throw with ${message}`);
} catch (e) {
assert_true(e instanceof WebAssembly.Exception, `Error should be a WebAssembly.Exception with ${message}`);
// According to the spec discussion, the current `WebAssembly.Exception` does not have `[[ErrorData]]` semantically.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test(() => {
}, "name");

test(() => {
assert_function_length(WebAssembly.Exception, 1, "WebAssembly.Exception");
assert_function_length(WebAssembly.Exception, 2, "WebAssembly.Exception");
}, "length");

test(() => {
Expand Down
13 changes: 13 additions & 0 deletions test/fixtures/wpt/wasm/jsapi/js-string/basic.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,19 @@ test(() => {
a, a
), a !== null && !isString, WebAssembly.RuntimeError);

if (a !== null && !isString) {
assert_throws_if(() => assert_same_behavior(
builtinExports['equals'],
polyfillExports['equals'],
null, a
), true, WebAssembly.RuntimeError);
assert_throws_if(() => assert_same_behavior(
builtinExports['equals'],
polyfillExports['equals'],
a, null
), true, WebAssembly.RuntimeError);
}

assert_throws_if(() => assert_same_behavior(
builtinExports['compare'],
polyfillExports['compare'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ test(() => {
const toStringTag = Object.getOwnPropertyDescriptor(AbstractModuleSource.prototype, Symbol.toStringTag).get;

assert_equals(toStringTag.call(module), "WebAssembly.Module");
assert_throws_js(TypeError, () => toStringTag.call({}));
assert_equals(toStringTag.call({}), undefined);
}, "AbstractModuleSourceProto toStringTag brand check");
Loading