diff options
Diffstat (limited to 'testing/web-platform/tests/wasm/jsapi/global/valueOf.any.js')
-rw-r--r-- | testing/web-platform/tests/wasm/jsapi/global/valueOf.any.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/testing/web-platform/tests/wasm/jsapi/global/valueOf.any.js b/testing/web-platform/tests/wasm/jsapi/global/valueOf.any.js new file mode 100644 index 0000000000..0695a5a61f --- /dev/null +++ b/testing/web-platform/tests/wasm/jsapi/global/valueOf.any.js @@ -0,0 +1,28 @@ +// META: global=window,dedicatedworker,jsshell + +test(() => { + const argument = { "value": "i32" }; + const thisValues = [ + undefined, + null, + true, + "", + Symbol(), + 1, + {}, + WebAssembly.Global, + WebAssembly.Global.prototype, + ]; + + const fn = WebAssembly.Global.prototype.valueOf; + + for (const thisValue of thisValues) { + assert_throws_js(TypeError, () => fn.call(thisValue), `this=${format_value(thisValue)}`); + } +}, "Branding"); + +test(() => { + const argument = { "value": "i32" }; + const global = new WebAssembly.Global(argument, 0); + assert_equals(global.valueOf({}), 0); +}, "Stray argument"); |