Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e2b5d96

Browse filesBrowse files
targosdanielleadams
authored andcommitted
test: update wasm/jsapi WPT
PR-URL: #47210 Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 5d46c59 commit e2b5d96
Copy full SHA for e2b5d96

File tree

Expand file treeCollapse file tree

8 files changed

+101
-40
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

8 files changed

+101
-40
lines changed
Open diff view settings
Collapse file

‎test/fixtures/wpt/README.md‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/README.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Last update:
2929
- streams: https://github.com/web-platform-tests/wpt/tree/9e5ef42bd3/streams
3030
- url: https://github.com/web-platform-tests/wpt/tree/84caeb6fbd/url
3131
- user-timing: https://github.com/web-platform-tests/wpt/tree/df24fb604e/user-timing
32-
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/d8dbe6990b/wasm/jsapi
32+
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi
3333
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
3434
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/188993d46b/WebCryptoAPI
3535
- webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/a370aad338/webidl/ecmascript-binding/es-exceptions
Collapse file

‎test/fixtures/wpt/versions.json‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/versions.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"path": "user-timing"
7777
},
7878
"wasm/jsapi": {
79-
"commit": "d8dbe6990bed03ec03beee25069a9347d4c3d6d5",
79+
"commit": "cde25e7e3c3b9d2280eb088a3fb9da988793d255",
8080
"path": "wasm/jsapi"
8181
},
8282
"wasm/webapi": {
Collapse file

‎test/fixtures/wpt/wasm/jsapi/exception/basic.tentative.any.js‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/wasm/jsapi/exception/basic.tentative.any.js
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ promise_test(async () => {
1414
const kWasmAnyRef = 0x6f;
1515
const kSig_v_r = makeSig([kWasmAnyRef], []);
1616
const builder = new WasmModuleBuilder();
17-
const except = builder.addException(kSig_v_r);
17+
const tagIndex = builder.addTag(kSig_v_r);
1818
builder.addFunction("throw_param", kSig_v_r)
1919
.addBody([
2020
kExprLocalGet, 0,
21-
kExprThrow, except,
21+
kExprThrow, tagIndex,
2222
])
2323
.exportFunc();
2424
const buffer = builder.toBuffer();
@@ -45,11 +45,11 @@ promise_test(async () => {
4545

4646
promise_test(async () => {
4747
const builder = new WasmModuleBuilder();
48-
const except = builder.addException(kSig_v_a);
48+
const tagIndex = builder.addTag(kSig_v_a);
4949
builder.addFunction("throw_null", kSig_v_v)
5050
.addBody([
5151
kExprRefNull, kWasmAnyFunc,
52-
kExprThrow, except,
52+
kExprThrow, tagIndex,
5353
])
5454
.exportFunc();
5555
const buffer = builder.toBuffer();
@@ -59,11 +59,11 @@ promise_test(async () => {
5959

6060
promise_test(async () => {
6161
const builder = new WasmModuleBuilder();
62-
const except = builder.addException(kSig_v_i);
62+
const tagIndex = builder.addTag(kSig_v_i);
6363
builder.addFunction("throw_int", kSig_v_v)
6464
.addBody([
6565
...wasmI32Const(7),
66-
kExprThrow, except,
66+
kExprThrow, tagIndex,
6767
])
6868
.exportFunc();
6969
const buffer = builder.toBuffer();
@@ -74,12 +74,12 @@ promise_test(async () => {
7474
promise_test(async () => {
7575
const builder = new WasmModuleBuilder();
7676
const fnIndex = builder.addImport("module", "fn", kSig_v_v);
77-
const except = builder.addException(kSig_v_r);
77+
const tagIndex= builder.addTag(kSig_v_r);
7878
builder.addFunction("catch_exception", kSig_r_v)
7979
.addBody([
8080
kExprTry, kWasmStmt,
8181
kExprCallFunction, fnIndex,
82-
kExprCatch, except,
82+
kExprCatch, tagIndex,
8383
kExprReturn,
8484
kExprEnd,
8585
kExprRefNull, kWasmAnyRef,
Collapse file

‎test/fixtures/wpt/wasm/jsapi/exception/constructor.tentative.any.js‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/wasm/jsapi/exception/constructor.tentative.any.js
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ test(() => {
1818
}, "No arguments");
1919

2020
test(() => {
21-
const argument = new WebAssembly.Tag({ parameters: [] });
22-
assert_throws_js(TypeError, () => WebAssembly.Exception(argument));
21+
const tag = new WebAssembly.Tag({ parameters: [] });
22+
assert_throws_js(TypeError, () => WebAssembly.Exception(tag));
2323
}, "Calling");
2424

2525
test(() => {
@@ -53,10 +53,10 @@ test(() => {
5353
["i64", undefined],
5454
];
5555
for (const typeAndArg of typesAndArgs) {
56-
const exn = new WebAssembly.Tag({ parameters: [typeAndArg[0]] });
56+
const tag = new WebAssembly.Tag({ parameters: [typeAndArg[0]] });
5757
assert_throws_js(
5858
TypeError,
59-
() => new WebAssembly.Exception(exn, typeAndArg[1])
59+
() => new WebAssembly.Exception(tag, typeAndArg[1])
6060
);
6161
}
6262
}, "Invalid exception argument");
Collapse file

‎test/fixtures/wpt/wasm/jsapi/exception/getArg.tentative.any.js‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/wasm/jsapi/exception/getArg.tentative.any.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test(() => {
2020
test(() => {
2121
const tag = new WebAssembly.Tag({ parameters: [] });
2222
const exn = new WebAssembly.Exception(tag, []);
23-
assert_throws_js(TypeError, () => exn.getArg(tag, 1));
23+
assert_throws_js(RangeError, () => exn.getArg(tag, 1));
2424
}, "Index out of bounds");
2525

2626
test(() => {
@@ -43,7 +43,7 @@ test(() => {
4343
const tag = new WebAssembly.Tag({ parameters: [] });
4444
const exn = new WebAssembly.Exception(tag, []);
4545
for (const value of outOfRangeValues) {
46-
assert_throws_js(TypeError, () => exn.getArg(tag, value));
46+
assert_throws_js(RangeError, () => exn.getArg(tag, value));
4747
}
4848
}, "Getting out-of-range argument");
4949

Collapse file
+61Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// META: global=window,dedicatedworker,jsshell
2+
// META: script=/wasm/jsapi/assertions.js
3+
// META: script=/wasm/jsapi/wasm-module-builder.js
4+
5+
test(() => {
6+
const tag = new WebAssembly.Tag({ parameters: ["i32"] });
7+
const exn = new WebAssembly.Exception(tag, [42]);
8+
const exn_same_payload = new WebAssembly.Exception(tag, [42]);
9+
const exn_diff_payload = new WebAssembly.Exception(tag, [53]);
10+
11+
const builder = new WasmModuleBuilder();
12+
const jsfuncIndex = builder.addImport("module", "jsfunc", kSig_v_v);
13+
const tagIndex = builder.addImportedTag("module", "tag", kSig_v_i);
14+
const imports = {
15+
module: {
16+
jsfunc: function() { throw exn; },
17+
tag: tag
18+
}
19+
};
20+
21+
builder
22+
.addFunction("catch_rethrow", kSig_v_v)
23+
.addBody([
24+
kExprTry, kWasmStmt,
25+
kExprCallFunction, jsfuncIndex,
26+
kExprCatch, tagIndex,
27+
kExprDrop,
28+
kExprRethrow, 0x00,
29+
kExprEnd
30+
])
31+
.exportFunc();
32+
33+
builder
34+
.addFunction("catch_all_rethrow", kSig_v_v)
35+
.addBody([
36+
kExprTry, kWasmStmt,
37+
kExprCallFunction, jsfuncIndex,
38+
kExprCatchAll,
39+
kExprRethrow, 0x00,
40+
kExprEnd
41+
])
42+
.exportFunc();
43+
44+
const buffer = builder.toBuffer();
45+
WebAssembly.instantiate(buffer, imports).then(result => {
46+
try {
47+
result.instance.exports.catch_rethrow();
48+
} catch (e) {
49+
assert_equals(e, exn);
50+
assert_not_equals(e, exn_same_payload);
51+
assert_not_equals(e, exn_diff_payload);
52+
}
53+
try {
54+
result.instance.exports.catch_all_rethrow();
55+
} catch (e) {
56+
assert_equals(e, exn);
57+
assert_not_equals(e, exn_same_payload);
58+
assert_not_equals(e, exn_diff_payload);
59+
}
60+
});
61+
}, "Identity check");
Collapse file

‎test/fixtures/wpt/wasm/jsapi/exception/toString.tentative.any.js‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/wasm/jsapi/exception/toString.tentative.any.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
test(() => {
44
const argument = { parameters: [] };
55
const tag = new WebAssembly.Tag(argument);
6-
const exception = new WebAssembly.Exception(tag, []);
7-
assert_class_string(exception, "WebAssembly.Exception");
6+
const exn = new WebAssembly.Exception(tag, []);
7+
assert_class_string(exn, "WebAssembly.Exception");
88
}, "Object.prototype.toString on an Exception");
99

1010
test(() => {
Collapse file

‎test/fixtures/wpt/wasm/jsapi/wasm-module-builder.js‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/wasm/jsapi/wasm-module-builder.js
+22-22Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ let kElementSectionCode = 9; // Elements section
6565
let kCodeSectionCode = 10; // Function code
6666
let kDataSectionCode = 11; // Data segments
6767
let kDataCountSectionCode = 12; // Data segment count (between Element & Code)
68-
let kExceptionSectionCode = 13; // Exception section (between Global & Export)
68+
let kTagSectionCode = 13; // Tag section (between Memory & Global)
6969

7070
// Name section types
7171
let kModuleNameCode = 0;
@@ -104,13 +104,13 @@ let kExternalFunction = 0;
104104
let kExternalTable = 1;
105105
let kExternalMemory = 2;
106106
let kExternalGlobal = 3;
107-
let kExternalException = 4;
107+
let kExternalTag = 4;
108108

109109
let kTableZero = 0;
110110
let kMemoryZero = 0;
111111
let kSegmentZero = 0;
112112

113-
let kExceptionAttribute = 0;
113+
let kTagAttribute = 0;
114114

115115
// Useful signatures
116116
let kSig_i_i = makeSig([kWasmI32], [kWasmI32]);
@@ -681,15 +681,15 @@ class WasmModuleBuilder {
681681
this.exports = [];
682682
this.globals = [];
683683
this.tables = [];
684-
this.exceptions = [];
684+
this.tags = [];
685685
this.functions = [];
686686
this.element_segments = [];
687687
this.data_segments = [];
688688
this.explicit = [];
689689
this.num_imported_funcs = 0;
690690
this.num_imported_globals = 0;
691691
this.num_imported_tables = 0;
692-
this.num_imported_exceptions = 0;
692+
this.num_imported_tags = 0;
693693
return this;
694694
}
695695

@@ -752,10 +752,10 @@ class WasmModuleBuilder {
752752
return table;
753753
}
754754

755-
addException(type) {
755+
addTag(type) {
756756
let type_index = (typeof type) == "number" ? type : this.addType(type);
757-
let except_index = this.exceptions.length + this.num_imported_exceptions;
758-
this.exceptions.push(type_index);
757+
let except_index = this.tags.length + this.num_imported_tags;
758+
this.tags.push(type_index);
759759
return except_index;
760760
}
761761

@@ -804,14 +804,14 @@ class WasmModuleBuilder {
804804
return this.num_imported_tables++;
805805
}
806806

807-
addImportedException(module, name, type) {
808-
if (this.exceptions.length != 0) {
809-
throw new Error('Imported exceptions must be declared before local ones');
807+
addImportedTag(module, name, type) {
808+
if (this.tags.length != 0) {
809+
throw new Error('Imported tags must be declared before local ones');
810810
}
811811
let type_index = (typeof type) == "number" ? type : this.addType(type);
812-
let o = {module: module, name: name, kind: kExternalException, type: type_index};
812+
let o = {module: module, name: name, kind: kExternalTag, type: type_index};
813813
this.imports.push(o);
814-
return this.num_imported_exceptions++;
814+
return this.num_imported_tags++;
815815
}
816816

817817
addExport(name, index) {
@@ -938,8 +938,8 @@ class WasmModuleBuilder {
938938
section.emit_u8(has_max ? 1 : 0); // flags
939939
section.emit_u32v(imp.initial); // initial
940940
if (has_max) section.emit_u32v(imp.maximum); // maximum
941-
} else if (imp.kind == kExternalException) {
942-
section.emit_u32v(kExceptionAttribute);
941+
} else if (imp.kind == kExternalTag) {
942+
section.emit_u32v(kTagAttribute);
943943
section.emit_u32v(imp.type);
944944
} else {
945945
throw new Error("unknown/unsupported import kind " + imp.kind);
@@ -1036,13 +1036,13 @@ class WasmModuleBuilder {
10361036
});
10371037
}
10381038

1039-
// Add exceptions.
1040-
if (wasm.exceptions.length > 0) {
1041-
if (debug) print("emitting exceptions @ " + binary.length);
1042-
binary.emit_section(kExceptionSectionCode, section => {
1043-
section.emit_u32v(wasm.exceptions.length);
1044-
for (let type of wasm.exceptions) {
1045-
section.emit_u32v(kExceptionAttribute);
1039+
// Add tags.
1040+
if (wasm.tags.length > 0) {
1041+
if (debug) print("emitting tags @ " + binary.length);
1042+
binary.emit_section(kTagSectionCode, section => {
1043+
section.emit_u32v(wasm.tags.length);
1044+
for (let type of wasm.tags) {
1045+
section.emit_u32v(kTagAttribute);
10461046
section.emit_u32v(type);
10471047
}
10481048
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.