diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/wasm/jsapi/table | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/wasm/jsapi/table')
8 files changed, 744 insertions, 0 deletions
diff --git a/testing/web-platform/tests/wasm/jsapi/table/assertions.js b/testing/web-platform/tests/wasm/jsapi/table/assertions.js new file mode 100644 index 0000000000..19cc5c3b92 --- /dev/null +++ b/testing/web-platform/tests/wasm/jsapi/table/assertions.js @@ -0,0 +1,24 @@ +function assert_equal_to_array(table, expected, message) { + assert_equals(table.length, expected.length, `${message}: length`); + // The argument check in get() happens before the range check, and negative numbers + // are illegal, hence will throw TypeError per spec. + assert_throws_js(TypeError, () => table.get(-1), `${message}: table.get(-1)`); + for (let i = 0; i < expected.length; ++i) { + assert_equals(table.get(i), expected[i], `${message}: table.get(${i} of ${expected.length})`); + } + assert_throws_js(RangeError, () => table.get(expected.length), + `${message}: table.get(${expected.length} of ${expected.length})`); + assert_throws_js(RangeError, () => table.get(expected.length + 1), + `${message}: table.get(${expected.length + 1} of ${expected.length})`); +} + +function assert_Table(actual, expected) { + assert_equals(Object.getPrototypeOf(actual), WebAssembly.Table.prototype, + "prototype"); + assert_true(Object.isExtensible(actual), "extensible"); + + assert_equals(actual.length, expected.length, "length"); + for (let i = 0; i < expected.length; ++i) { + assert_equals(actual.get(i), null, `actual.get(${i})`); + } +} diff --git a/testing/web-platform/tests/wasm/jsapi/table/constructor-types.tentative.any.js b/testing/web-platform/tests/wasm/jsapi/table/constructor-types.tentative.any.js new file mode 100644 index 0000000000..99ca41b55a --- /dev/null +++ b/testing/web-platform/tests/wasm/jsapi/table/constructor-types.tentative.any.js @@ -0,0 +1,20 @@ +// META: global=window,dedicatedworker,jsshell +// META: script=/wasm/jsapi/assertions.js +// META: script=/wasm/jsapi/table/assertions.js + +test(() => { + const argument = { "element": "anyfunc", "initial": 0, "minimum": 0 }; + assert_throws_js(TypeError, () => new WebAssembly.Table(argument)); +}, "Initializing with both initial and minimum"); + +test(() => { + const argument = { "element": "anyfunc", "minimum": 0 }; + const table = new WebAssembly.Table(argument); + assert_Table(table, { "length": 0 }); +}, "Zero minimum"); + +test(() => { + const argument = { "element": "anyfunc", "minimum": 5 }; + const table = new WebAssembly.Table(argument); + assert_Table(table, { "length": 5 }); +}, "Non-zero minimum");
\ No newline at end of file diff --git a/testing/web-platform/tests/wasm/jsapi/table/constructor.any.js b/testing/web-platform/tests/wasm/jsapi/table/constructor.any.js new file mode 100644 index 0000000000..6d38d04e4f --- /dev/null +++ b/testing/web-platform/tests/wasm/jsapi/table/constructor.any.js @@ -0,0 +1,208 @@ +// META: global=window,dedicatedworker,jsshell +// META: script=/wasm/jsapi/wasm-module-builder.js +// META: script=/wasm/jsapi/assertions.js +// META: script=/wasm/jsapi/table/assertions.js + +test(() => { + assert_function_name(WebAssembly.Table, "Table", "WebAssembly.Table"); +}, "name"); + +test(() => { + assert_function_length(WebAssembly.Table, 1, "WebAssembly.Table"); +}, "length"); + +test(() => { + assert_throws_js(TypeError, () => new WebAssembly.Table()); +}, "No arguments"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 0 }; + assert_throws_js(TypeError, () => WebAssembly.Table(argument)); +}, "Calling"); + +test(() => { + assert_throws_js(TypeError, () => new WebAssembly.Table({})); +}, "Empty descriptor"); + +test(() => { + const invalidArguments = [ + undefined, + null, + false, + true, + "", + "test", + Symbol(), + 1, + NaN, + {}, + ]; + for (const invalidArgument of invalidArguments) { + assert_throws_js(TypeError, + () => new WebAssembly.Table(invalidArgument), + `new Table(${format_value(invalidArgument)})`); + } +}, "Invalid descriptor argument"); + +test(() => { + assert_throws_js(TypeError, () => new WebAssembly.Table({ "element": "anyfunc", "initial": undefined })); +}, "Undefined initial value in descriptor"); + +test(() => { + assert_throws_js(TypeError, () => new WebAssembly.Table({ "element": undefined, "initial": 0 })); +}, "Undefined element value in descriptor"); + +const outOfRangeValues = [ + NaN, + Infinity, + -Infinity, + -1, + 0x100000000, + 0x1000000000, +]; + +for (const value of outOfRangeValues) { + test(() => { + assert_throws_js(TypeError, () => new WebAssembly.Table({ "element": "anyfunc", "initial": value })); + }, `Out-of-range initial value in descriptor: ${format_value(value)}`); + + test(() => { + assert_throws_js(TypeError, () => new WebAssembly.Table({ "element": "anyfunc", "initial": 0, "maximum": value })); + }, `Out-of-range maximum value in descriptor: ${format_value(value)}`); +} + +test(() => { + assert_throws_js(RangeError, () => new WebAssembly.Table({ "element": "anyfunc", "initial": 10, "maximum": 9 })); +}, "Initial value exceeds maximum"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 0 }; + const table = new WebAssembly.Table(argument); + assert_Table(table, { "length": 0 }); +}, "Basic (zero)"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 5 }; + const table = new WebAssembly.Table(argument); + assert_Table(table, { "length": 5 }); +}, "Basic (non-zero)"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 0 }; + const table = new WebAssembly.Table(argument, null, {}); + assert_Table(table, { "length": 0 }); +}, "Stray argument"); + +test(() => { + const proxy = new Proxy({}, { + has(o, x) { + assert_unreached(`Should not call [[HasProperty]] with ${x}`); + }, + get(o, x) { + switch (x) { + case "element": + return "anyfunc"; + case "initial": + case "maximum": + return 0; + default: + return undefined; + } + }, + }); + const table = new WebAssembly.Table(proxy); + assert_Table(table, { "length": 0 }); +}, "Proxy descriptor"); + +test(() => { + const table = new WebAssembly.Table({ + "element": { + toString() { return "anyfunc"; }, + }, + "initial": 1, + }); + assert_Table(table, { "length": 1 }); +}, "Type conversion for descriptor.element"); + +test(() => { + const order = []; + + new WebAssembly.Table({ + get maximum() { + order.push("maximum"); + return { + valueOf() { + order.push("maximum valueOf"); + return 1; + }, + }; + }, + + get initial() { + order.push("initial"); + return { + valueOf() { + order.push("initial valueOf"); + return 1; + }, + }; + }, + + get element() { + order.push("element"); + return { + toString() { + order.push("element toString"); + return "anyfunc"; + }, + }; + }, + }); + + assert_array_equals(order, [ + "element", + "element toString", + "initial", + "initial valueOf", + "maximum", + "maximum valueOf", + ]); +}, "Order of evaluation for descriptor"); + +test(() => { + const testObject = {}; + const argument = { "element": "externref", "initial": 3 }; + const table = new WebAssembly.Table(argument, testObject); + assert_equals(table.length, 3); + assert_equals(table.get(0), testObject); + assert_equals(table.get(1), testObject); + assert_equals(table.get(2), testObject); +}, "initialize externref table with default value"); + +test(() => { + const argument = { "element": "i32", "initial": 3 }; + assert_throws_js(TypeError, () => new WebAssembly.Table(argument)); +}, "initialize table with a wrong element value"); + +test(() => { + const builder = new WasmModuleBuilder(); + builder + .addFunction("fn", kSig_v_v) + .addBody([]) + .exportFunc(); + const bin = builder.toBuffer(); + const fn = new WebAssembly.Instance(new WebAssembly.Module(bin)).exports.fn; + const argument = { "element": "anyfunc", "initial": 3 }; + const table = new WebAssembly.Table(argument, fn); + assert_equals(table.length, 3); + assert_equals(table.get(0), fn); + assert_equals(table.get(1), fn); + assert_equals(table.get(2), fn); +}, "initialize anyfunc table with default value"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 3 }; + assert_throws_js(TypeError, () => new WebAssembly.Table(argument, {})); + assert_throws_js(TypeError, () => new WebAssembly.Table(argument, "cannot be used as a wasm function")); + assert_throws_js(TypeError, () => new WebAssembly.Table(argument, 37)); +}, "initialize anyfunc table with a bad default value"); diff --git a/testing/web-platform/tests/wasm/jsapi/table/get-set.any.js b/testing/web-platform/tests/wasm/jsapi/table/get-set.any.js new file mode 100644 index 0000000000..9301057a53 --- /dev/null +++ b/testing/web-platform/tests/wasm/jsapi/table/get-set.any.js @@ -0,0 +1,263 @@ +// META: global=window,dedicatedworker,jsshell +// META: script=/wasm/jsapi/wasm-module-builder.js +// META: script=assertions.js + +let functions = {}; +setup(() => { + const builder = new WasmModuleBuilder(); + + builder + .addFunction("fn", kSig_v_d) + .addBody([]) + .exportFunc(); + builder + .addFunction("fn2", kSig_v_v) + .addBody([]) + .exportFunc(); + + const buffer = builder.toBuffer() + const module = new WebAssembly.Module(buffer); + const instance = new WebAssembly.Instance(module, {}); + functions = instance.exports; +}); + +test(() => { + const argument = { "element": "anyfunc", "initial": 5 }; + const table = new WebAssembly.Table(argument); + assert_throws_js(TypeError, () => table.get()); +}, "Missing arguments: get"); + +test(t => { + const thisValues = [ + undefined, + null, + true, + "", + Symbol(), + 1, + {}, + WebAssembly.Table, + WebAssembly.Table.prototype, + ]; + + const argument = { + valueOf: t.unreached_func("Should not touch the argument (valueOf)"), + toString: t.unreached_func("Should not touch the argument (toString)"), + }; + + const fn = WebAssembly.Table.prototype.get; + + for (const thisValue of thisValues) { + assert_throws_js(TypeError, () => fn.call(thisValue, argument), `this=${format_value(thisValue)}`); + } +}, "Branding: get"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 5 }; + const table = new WebAssembly.Table(argument); + assert_throws_js(TypeError, () => table.set()); +}, "Missing arguments: set"); + +test(t => { + const thisValues = [ + undefined, + null, + true, + "", + Symbol(), + 1, + {}, + WebAssembly.Table, + WebAssembly.Table.prototype, + ]; + + const argument = { + valueOf: t.unreached_func("Should not touch the argument (valueOf)"), + toString: t.unreached_func("Should not touch the argument (toString)"), + }; + + const fn = WebAssembly.Table.prototype.set; + + for (const thisValue of thisValues) { + assert_throws_js(TypeError, () => fn.call(thisValue, argument, null), `this=${format_value(thisValue)}`); + } +}, "Branding: set"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 5 }; + const table = new WebAssembly.Table(argument); + assert_equal_to_array(table, [null, null, null, null, null]); + + const {fn, fn2} = functions; + + assert_equals(table.set(0, fn), undefined, "set() returns undefined."); + table.set(2, fn2); + table.set(4, fn); + + assert_equal_to_array(table, [fn, null, fn2, null, fn]); + + table.set(0, null); + assert_equal_to_array(table, [null, null, fn2, null, fn]); +}, "Basic"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 5 }; + const table = new WebAssembly.Table(argument); + assert_equal_to_array(table, [null, null, null, null, null]); + + const {fn, fn2} = functions; + + table.set(0, fn); + table.set(2, fn2); + table.set(4, fn); + + assert_equal_to_array(table, [fn, null, fn2, null, fn]); + + table.grow(4); + + assert_equal_to_array(table, [fn, null, fn2, null, fn, null, null, null, null]); +}, "Growing"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 5 }; + const table = new WebAssembly.Table(argument); + assert_equal_to_array(table, [null, null, null, null, null]); + + const {fn} = functions; + + // -1 is the wrong type hence the type check on entry gets this + // before the range check does. + assert_throws_js(TypeError, () => table.set(-1, fn)); + assert_throws_js(RangeError, () => table.set(5, fn)); + assert_equal_to_array(table, [null, null, null, null, null]); +}, "Setting out-of-bounds"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 1 }; + const table = new WebAssembly.Table(argument); + assert_equal_to_array(table, [null]); + + const invalidArguments = [ + undefined, + true, + false, + "test", + Symbol(), + 7, + NaN, + {}, + ]; + for (const argument of invalidArguments) { + assert_throws_js(TypeError, () => table.set(0, argument), + `set(${format_value(argument)})`); + } + assert_equal_to_array(table, [null]); +}, "Setting non-function"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 1 }; + const table = new WebAssembly.Table(argument); + assert_equal_to_array(table, [null]); + + const fn = function() {}; + assert_throws_js(TypeError, () => table.set(0, fn)); + assert_equal_to_array(table, [null]); +}, "Setting non-wasm function"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 1 }; + const table = new WebAssembly.Table(argument); + assert_equal_to_array(table, [null]); + + const fn = () => {}; + assert_throws_js(TypeError, () => table.set(0, fn)); + assert_equal_to_array(table, [null]); +}, "Setting non-wasm arrow function"); + +const outOfRangeValues = [ + undefined, + NaN, + Infinity, + -Infinity, + -1, + 0x100000000, + 0x1000000000, + "0x100000000", + { valueOf() { return 0x100000000; } }, +]; + +for (const value of outOfRangeValues) { + test(() => { + const argument = { "element": "anyfunc", "initial": 1 }; + const table = new WebAssembly.Table(argument); + assert_throws_js(TypeError, () => table.get(value)); + }, `Getting out-of-range argument: ${format_value(value)}`); + + test(() => { + const argument = { "element": "anyfunc", "initial": 1 }; + const table = new WebAssembly.Table(argument); + assert_throws_js(TypeError, () => table.set(value, null)); + }, `Setting out-of-range argument: ${format_value(value)}`); +} + +test(() => { + const argument = { "element": "anyfunc", "initial": 1 }; + const table = new WebAssembly.Table(argument); + let called = 0; + const value = { + valueOf() { + called++; + return 0; + }, + }; + assert_throws_js(TypeError, () => table.set(value, {})); + assert_equals(called, 1); +}, "Order of argument conversion"); + +test(() => { + const {fn} = functions; + const argument = { "element": "anyfunc", "initial": 1 }; + const table = new WebAssembly.Table(argument); + + assert_equals(table.get(0, {}), null); + assert_equals(table.set(0, fn, {}), undefined); +}, "Stray argument"); + +test(() => { + const builder = new WasmModuleBuilder(); + builder + .addFunction("fn", kSig_v_v) + .addBody([]) + .exportFunc(); + const bin = builder.toBuffer(); + const fn = new WebAssembly.Instance(new WebAssembly.Module(bin)).exports.fn; + + const argument = { "element": "anyfunc", "initial": 1 }; + const table = new WebAssembly.Table(argument, fn); + + assert_equals(table.get(0), fn); + table.set(0); + assert_equals(table.get(0), null); + + table.set(0, fn); + assert_equals(table.get(0), fn); + + assert_throws_js(TypeError, () => table.set(0, {})); + assert_throws_js(TypeError, () => table.set(0, 37)); +}, "Arguments for anyfunc table set"); + +test(() => { + const testObject = {}; + const argument = { "element": "externref", "initial": 1 }; + const table = new WebAssembly.Table(argument, testObject); + + assert_equals(table.get(0), testObject); + table.set(0); + assert_equals(table.get(0), undefined); + + table.set(0, testObject); + assert_equals(table.get(0), testObject); + + table.set(0, 37); + assert_equals(table.get(0), 37); +}, "Arguments for externref table set"); diff --git a/testing/web-platform/tests/wasm/jsapi/table/grow.any.js b/testing/web-platform/tests/wasm/jsapi/table/grow.any.js new file mode 100644 index 0000000000..520d24bf4b --- /dev/null +++ b/testing/web-platform/tests/wasm/jsapi/table/grow.any.js @@ -0,0 +1,126 @@ +// META: global=window,dedicatedworker,jsshell +// META: script=/wasm/jsapi/wasm-module-builder.js +// META: script=assertions.js + +function nulls(n) { + return Array(n).fill(null); +} + +test(() => { + const argument = { "element": "anyfunc", "initial": 5 }; + const table = new WebAssembly.Table(argument); + assert_throws_js(TypeError, () => table.grow()); +}, "Missing arguments"); + +test(t => { + const thisValues = [ + undefined, + null, + true, + "", + Symbol(), + 1, + {}, + WebAssembly.Table, + WebAssembly.Table.prototype, + ]; + + const argument = { + valueOf: t.unreached_func("Should not touch the argument (valueOf)"), + toString: t.unreached_func("Should not touch the argument (toString)"), + }; + + const fn = WebAssembly.Table.prototype.grow; + + for (const thisValue of thisValues) { + assert_throws_js(TypeError, () => fn.call(thisValue, argument), `this=${format_value(thisValue)}`); + } +}, "Branding"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 5 }; + const table = new WebAssembly.Table(argument); + assert_equal_to_array(table, nulls(5), "before"); + + const result = table.grow(3); + assert_equals(result, 5); + assert_equal_to_array(table, nulls(8), "after"); +}, "Basic"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 3, "maximum": 5 }; + const table = new WebAssembly.Table(argument); + assert_equal_to_array(table, nulls(3), "before"); + + const result = table.grow(2); + assert_equals(result, 3); + assert_equal_to_array(table, nulls(5), "after"); +}, "Reached maximum"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 2, "maximum": 5 }; + const table = new WebAssembly.Table(argument); + assert_equal_to_array(table, nulls(2), "before"); + + assert_throws_js(RangeError, () => table.grow(4)); + assert_equal_to_array(table, nulls(2), "after"); +}, "Exceeded maximum"); + +const outOfRangeValues = [ + undefined, + NaN, + Infinity, + -Infinity, + -1, + 0x100000000, + 0x1000000000, + "0x100000000", + { valueOf() { return 0x100000000; } }, +]; + +for (const value of outOfRangeValues) { + test(() => { + const argument = { "element": "anyfunc", "initial": 1 }; + const table = new WebAssembly.Table(argument); + assert_throws_js(TypeError, () => table.grow(value)); + }, `Out-of-range argument: ${format_value(value)}`); +} + +test(() => { + const argument = { "element": "anyfunc", "initial": 5 }; + const table = new WebAssembly.Table(argument); + assert_equal_to_array(table, nulls(5), "before"); + + const result = table.grow(3, null, {}); + assert_equals(result, 5); + assert_equal_to_array(table, nulls(8), "after"); +}, "Stray argument"); + +test(() => { + const builder = new WasmModuleBuilder(); + builder + .addFunction("fn", kSig_v_v) + .addBody([]) + .exportFunc(); + const bin = builder.toBuffer() + const argument = { "element": "anyfunc", "initial": 1 }; + const table = new WebAssembly.Table(argument); + const fn = new WebAssembly.Instance(new WebAssembly.Module(bin)).exports.fn; + const result = table.grow(2, fn); + assert_equals(result, 1); + assert_equals(table.get(0), null); + assert_equals(table.get(1), fn); + assert_equals(table.get(2), fn); +}, "Grow with exported-function argument"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 1 }; + const table = new WebAssembly.Table(argument); + assert_throws_js(TypeError, () => table.grow(2, {})); +}, "Grow with non-function argument"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 1 }; + const table = new WebAssembly.Table(argument); + assert_throws_js(TypeError, () => table.grow(2, () => true)); +}, "Grow with JS-function argument"); diff --git a/testing/web-platform/tests/wasm/jsapi/table/length.any.js b/testing/web-platform/tests/wasm/jsapi/table/length.any.js new file mode 100644 index 0000000000..a9ef095ded --- /dev/null +++ b/testing/web-platform/tests/wasm/jsapi/table/length.any.js @@ -0,0 +1,60 @@ +// META: global=window,dedicatedworker,jsshell + +test(() => { + const thisValues = [ + undefined, + null, + true, + "", + Symbol(), + 1, + {}, + WebAssembly.Table, + WebAssembly.Table.prototype, + ]; + + const desc = Object.getOwnPropertyDescriptor(WebAssembly.Table.prototype, "length"); + assert_equals(typeof desc, "object"); + + const getter = desc.get; + assert_equals(typeof getter, "function"); + + assert_equals(typeof desc.set, "undefined"); + + for (const thisValue of thisValues) { + assert_throws_js(TypeError, () => getter.call(thisValue), `this=${format_value(thisValue)}`); + } +}, "Branding"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 2 }; + const table = new WebAssembly.Table(argument); + assert_equals(table.length, 2, "Initial length"); + + const desc = Object.getOwnPropertyDescriptor(WebAssembly.Table.prototype, "length"); + assert_equals(typeof desc, "object"); + + const getter = desc.get; + assert_equals(typeof getter, "function"); + + assert_equals(getter.call(table, {}), 2); +}, "Stray argument"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 2 }; + const table = new WebAssembly.Table(argument); + assert_equals(table.length, 2, "Initial length"); + table.length = 4; + assert_equals(table.length, 2, "Should not change the length"); +}, "Setting (sloppy mode)"); + +test(() => { + const argument = { "element": "anyfunc", "initial": 2 }; + const table = new WebAssembly.Table(argument); + assert_equals(table.length, 2, "Initial length"); + assert_throws_js(TypeError, () => { + "use strict"; + table.length = 4; + }); + assert_equals(table.length, 2, "Should not change the length"); +}, "Setting (strict mode)"); diff --git a/testing/web-platform/tests/wasm/jsapi/table/toString.any.js b/testing/web-platform/tests/wasm/jsapi/table/toString.any.js new file mode 100644 index 0000000000..8a09f2832c --- /dev/null +++ b/testing/web-platform/tests/wasm/jsapi/table/toString.any.js @@ -0,0 +1,17 @@ +// META: global=window,dedicatedworker,jsshell + +test(() => { + const argument = { "element": "anyfunc", "initial": 0 }; + const table = new WebAssembly.Table(argument); + assert_class_string(table, "WebAssembly.Table"); +}, "Object.prototype.toString on an Table"); + +test(() => { + assert_own_property(WebAssembly.Table.prototype, Symbol.toStringTag); + + const propDesc = Object.getOwnPropertyDescriptor(WebAssembly.Table.prototype, Symbol.toStringTag); + assert_equals(propDesc.value, "WebAssembly.Table", "value"); + assert_equals(propDesc.configurable, true, "configurable"); + assert_equals(propDesc.enumerable, false, "enumerable"); + assert_equals(propDesc.writable, false, "writable"); +}, "@@toStringTag exists on the prototype with the appropriate descriptor"); diff --git a/testing/web-platform/tests/wasm/jsapi/table/type.tentative.any.js b/testing/web-platform/tests/wasm/jsapi/table/type.tentative.any.js new file mode 100644 index 0000000000..ef1ceecb17 --- /dev/null +++ b/testing/web-platform/tests/wasm/jsapi/table/type.tentative.any.js @@ -0,0 +1,26 @@ +// META: global=window,dedicatedworker,jsshell +// META: script=/wasm/jsapi/assertions.js + +function assert_type(argument) { + const mytable = new WebAssembly.Table(argument); + const tabletype = mytable.type() + assert_equals(tabletype.minimum, argument.minimum); + assert_equals(tabletype.maximum, argument.maximum); + assert_equals(tabletype.element, argument.element); +} + +test(() => { + assert_type({ "minimum": 0, "element": "funcref"}); +}, "Zero initial, no maximum"); + +test(() => { + assert_type({ "minimum": 5, "element": "funcref" }); +}, "Non-zero initial, no maximum"); + +test(() => { + assert_type({ "minimum": 0, "maximum": 0, "element": "funcref" }); +}, "Zero maximum"); + +test(() => { + assert_type({ "minimum": 0, "maximum": 5, "element": "funcref" }); +}, "Non-zero maximum"); |