-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[js-api] Add tests for WebAssembly.JSTag #319
Conversation
This adds tests for `WebAssembly.JSTag`. The tests are adapted from https://github.com/v8/v8/blob/main/test/mjsunit/wasm/exnref-api.js. Confirmed that they run successfully with web test infrastructure in Chrome with `--js-flags=--experimental-wasm-exnref` command line argument. The only thing failing there was the shadowrealm test, which I think we should add a separate expectation files like the existing `***.tentative.any.shadowrealm-expected.txt` in https://github.com/chromium/chromium/tree/main/third_party/blink/web_tests/external/wpt/wasm/jsapi/exception. But given that we don't host these files in this EH repo, I'll just upload the js files.
|
||
test(() => { | ||
assert_throws_js(TypeError, () => new WebAssembly.Exception(WebAssembly.JSTag, [{}])) | ||
}, "Creating a WebAssembly.Exception with JSTag explicitly is not allowed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I'm showing my lack of knowledge about the details of the test infra, but does this assertion check the exact text of the error message? The spec mandates what kind of exception should be thrown (TypeError), but not the text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this string is checked against anything else. So I just used it to describe what the tests were about. Maybe I'm abusing it? 🤷🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think it's fine as long as the test won't fail because of different error messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is just the name of the subtest.
} | ||
const buffer = builder.toBuffer(); | ||
const {instance} = await WebAssembly.instantiate(buffer, { | ||
module: { throw_ref, JSTag: WebAssembly.JSTag } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be throw_ref: throw_ref,
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works, but it looks in case the imported name and the external name are the same, just writing it once seems to have the same effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is the shorthand syntax in JS object initializers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
|
||
test(() => { | ||
assert_throws_js(TypeError, () => new WebAssembly.Exception(WebAssembly.JSTag, [{}])) | ||
}, "Creating a WebAssembly.Exception with JSTag explicitly is not allowed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is just the name of the subtest.
} | ||
const buffer = builder.toBuffer(); | ||
const {instance} = await WebAssembly.instantiate(buffer, { | ||
module: { throw_ref, JSTag: WebAssembly.JSTag } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is the shorthand syntax in JS object initializers.
}); | ||
|
||
const obj = {}; | ||
const wasmTag = new WebAssembly.Tag({parameters:['externref']}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears unused in this subtest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
This adds tests for
WebAssembly.JSTag
. The tests are adapted from https://github.com/v8/v8/blob/main/test/mjsunit/wasm/exnref-api.js.Confirmed that they run successfully with web test infrastructure in Chrome with
--js-flags=--experimental-wasm-exnref
command line argument. The only thing failing there was the shadowrealm test, which I think we should add a separate expectation files like the existing***.tentative.any.shadowrealm-expected.txt
inhttps://github.com/chromium/chromium/tree/main/third_party/blink/web_tests/external/wpt/wasm/jsapi/exception. But given that we don't host these files in this EH repo, I'll just upload the js files.