Skip to content

Commit

Permalink
Add .type property to WASM Memory, Table & Global
Browse files Browse the repository at this point in the history
This is part of adding type reflections to the WebAssembly JS-API. This
adds a new property on the WebAssembly.Memory, WebAssembly.Table &
WebAssembly.Global objects. It exposes the current type or the object in
a format which is compatible with the constructor for type's
constructor.

Differential Revision: https://phabricator.services.mozilla.com/D90702

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1651725
gecko-commit: dff33d0b33c8fb168966504f5562572ddec72a8e
gecko-reviewers: lth
  • Loading branch information
Jessica Tallon authored and jgraham committed Feb 4, 2021
1 parent 827142d commit d8dfec8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions wasm/jsapi/table/type.tentative.any.js
Original file line number Diff line number Diff line change
@@ -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);

assert_equals(mytable.type.minimum, argument.minimum);
assert_equals(mytable.type.maximum, argument.maximum);
assert_equals(mytable.type.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" });
}, "None-zero maximum");

0 comments on commit d8dfec8

Please sign in to comment.