Truly independent web browser
Tests/LibWeb: Import WebAssembly instantiation and string builtin tests
Andreas Kling71ecfe2d2162
diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.iniindex ca7a5a07d88..c79543d5a9b 100644--- a/Tests/LibWeb/TestConfig.ini+++ b/Tests/LibWeb/TestConfig.ini@@ -470,6 +470,14 @@ Text/input/wpt-import/workers/nested_worker_sync_xhr.worker.htmlText/input/wpt-import/workers/nested_worker_terminate_from_document.htmlText/input/wpt-import/encoding/legacy-mb-schinese/gb18030/gb18030-decoder.any.worker.htmlText/input/wpt-import/encoding/api-basics.any.worker.html+Text/input/wpt-import/wasm/jsapi/constructor/instantiate.any.worker.html+Text/input/wpt-import/wasm/jsapi/js-string/basic.any.worker.html+Text/input/wpt-import/wasm/jsapi/js-string/constants.any.worker.html+Text/input/wpt-import/wasm/jsapi/js-string/imports.any.worker.html+Text/input/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.worker.html+Text/input/wpt-import/wasm/webapi/instantiateStreaming.any.worker.html+Text/input/wpt-import/wasm/webapi/invalid-args.any.worker.html+Text/input/wpt-import/wasm/webapi/rejected-arg.any.worker.htmlText/input/wpt-import/encoding/encodeInto.any.worker.htmlText/input/wpt-import/WebCryptoAPI/historical.any.worker.htmlText/input/Worker/Worker-close-after-postMessage.htmldiff --git a/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/constructor/instantiate.any.txt b/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/constructor/instantiate.any.txtnew file mode 100644index 00000000000..45f8256d950--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/constructor/instantiate.any.txt@@ -0,0 +1,63 @@+Harness status: OK++Found 57 tests++29 Pass+28 Fail+Pass Missing arguments+Fail Branding+Pass Invalid arguments+Pass Promise type+Fail Empty module without imports argument: BufferSource argument+Pass Empty module without imports argument: Module argument+Fail Empty module with undefined imports argument: BufferSource argument+Pass Empty module with undefined imports argument: Module argument+Fail Empty module with empty imports argument: BufferSource argument+Pass Empty module with empty imports argument: Module argument+Fail getter order for imports object: BufferSource argument+Pass getter order for imports object: Module argument+Fail imports: BufferSource argument+Pass imports: Module argument+Fail imports with empty module names: BufferSource argument+Pass imports with empty module names: Module argument+Fail imports with empty names: BufferSource argument+Pass imports with empty names: Module argument+Fail exports with empty name: function: BufferSource argument+Pass exports with empty name: function: Module argument+Fail exports with empty name: table: BufferSource argument+Pass exports with empty name: table: Module argument+Fail exports with empty name: global: BufferSource argument+Pass exports with empty name: global: Module argument+Fail No imports: BufferSource argument+Pass No imports: Module argument+Fail exports and imports: BufferSource argument+Pass exports and imports: Module argument+Fail i64 exports and imports: BufferSource argument+Pass i64 exports and imports: Module argument+Fail import with i32-returning function: BufferSource argument+Pass import with i32-returning function: Module argument+Fail import with function that takes and returns i32: BufferSource argument+Pass import with function that takes and returns i32: Module argument+Fail import with i64-returning function: BufferSource argument+Pass import with i64-returning function: Module argument+Fail import with function that takes and returns i64: BufferSource argument+Pass import with function that takes and returns i64: Module argument+Fail import with i32-taking function: BufferSource argument+Pass import with i32-taking function: Module argument+Fail import with i64-taking function: BufferSource argument+Pass import with i64-taking function: Module argument+Fail export i64-returning function: BufferSource argument+Pass export i64-returning function: Module argument+Fail i32 mutable WebAssembly.Global import: BufferSource argument+Pass i32 mutable WebAssembly.Global import: Module argument+Fail i64 mutable WebAssembly.Global import: BufferSource argument+Pass i64 mutable WebAssembly.Global import: Module argument+Fail Multiple i64 arguments: BufferSource argument+Pass Multiple i64 arguments: Module argument+Fail stray argument: BufferSource argument+Pass stray argument: Module argument+Fail Synchronous options handling: Buffer argument+Fail Synchronous options handling: Module argument+Pass Empty buffer+Pass Invalid code+Fail Changing the buffer\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/constructor/instantiate.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/constructor/instantiate.any.worker.txtnew file mode 100644index 00000000000..45f8256d950--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/constructor/instantiate.any.worker.txt@@ -0,0 +1,63 @@+Harness status: OK++Found 57 tests++29 Pass+28 Fail+Pass Missing arguments+Fail Branding+Pass Invalid arguments+Pass Promise type+Fail Empty module without imports argument: BufferSource argument+Pass Empty module without imports argument: Module argument+Fail Empty module with undefined imports argument: BufferSource argument+Pass Empty module with undefined imports argument: Module argument+Fail Empty module with empty imports argument: BufferSource argument+Pass Empty module with empty imports argument: Module argument+Fail getter order for imports object: BufferSource argument+Pass getter order for imports object: Module argument+Fail imports: BufferSource argument+Pass imports: Module argument+Fail imports with empty module names: BufferSource argument+Pass imports with empty module names: Module argument+Fail imports with empty names: BufferSource argument+Pass imports with empty names: Module argument+Fail exports with empty name: function: BufferSource argument+Pass exports with empty name: function: Module argument+Fail exports with empty name: table: BufferSource argument+Pass exports with empty name: table: Module argument+Fail exports with empty name: global: BufferSource argument+Pass exports with empty name: global: Module argument+Fail No imports: BufferSource argument+Pass No imports: Module argument+Fail exports and imports: BufferSource argument+Pass exports and imports: Module argument+Fail i64 exports and imports: BufferSource argument+Pass i64 exports and imports: Module argument+Fail import with i32-returning function: BufferSource argument+Pass import with i32-returning function: Module argument+Fail import with function that takes and returns i32: BufferSource argument+Pass import with function that takes and returns i32: Module argument+Fail import with i64-returning function: BufferSource argument+Pass import with i64-returning function: Module argument+Fail import with function that takes and returns i64: BufferSource argument+Pass import with function that takes and returns i64: Module argument+Fail import with i32-taking function: BufferSource argument+Pass import with i32-taking function: Module argument+Fail import with i64-taking function: BufferSource argument+Pass import with i64-taking function: Module argument+Fail export i64-returning function: BufferSource argument+Pass export i64-returning function: Module argument+Fail i32 mutable WebAssembly.Global import: BufferSource argument+Pass i32 mutable WebAssembly.Global import: Module argument+Fail i64 mutable WebAssembly.Global import: BufferSource argument+Pass i64 mutable WebAssembly.Global import: Module argument+Fail Multiple i64 arguments: BufferSource argument+Pass Multiple i64 arguments: Module argument+Fail stray argument: BufferSource argument+Pass stray argument: Module argument+Fail Synchronous options handling: Buffer argument+Fail Synchronous options handling: Module argument+Pass Empty buffer+Pass Invalid code+Fail Changing the buffer\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/js-string/basic.any.txt b/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/js-string/basic.any.txtnew file mode 100644index 00000000000..6055c864758--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/js-string/basic.any.txt@@ -0,0 +1,3 @@+Harness status: Error++Found 0 testsdiff --git a/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/js-string/basic.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/js-string/basic.any.worker.txtnew file mode 100644index 00000000000..6055c864758--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/js-string/basic.any.worker.txt@@ -0,0 +1,3 @@+Harness status: Error++Found 0 testsdiff --git a/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/js-string/constants.any.txt b/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/js-string/constants.any.txtnew file mode 100644index 00000000000..eb056b1bbb0--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/js-string/constants.any.txt@@ -0,0 +1,45 @@+Harness status: OK++Found 40 tests++40 Fail+Fail constants+Fail constants 1+Fail constants 2+Fail constants 3+Fail constants 4+Fail constants 5+Fail constants 6+Fail constants 7+Fail constants 8+Fail constants 9+Fail constants 10+Fail constants 11+Fail constants 12+Fail constants 13+Fail constants 14+Fail constants 15+Fail constants 16+Fail constants 17+Fail constants 18+Fail constants 19+Fail constants 20+Fail constants 21+Fail constants 22+Fail constants 23+Fail constants 24+Fail constants 25+Fail constants 26+Fail constants 27+Fail constants 28+Fail constants 29+Fail constants 30+Fail constants 31+Fail constants 32+Fail constants 33+Fail constants 34+Fail constants 35+Fail constants 36+Fail constants 37+Fail constants 38+Fail constants 39\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/js-string/constants.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/js-string/constants.any.worker.txtnew file mode 100644index 00000000000..eb056b1bbb0--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/js-string/constants.any.worker.txt@@ -0,0 +1,45 @@+Harness status: OK++Found 40 tests++40 Fail+Fail constants+Fail constants 1+Fail constants 2+Fail constants 3+Fail constants 4+Fail constants 5+Fail constants 6+Fail constants 7+Fail constants 8+Fail constants 9+Fail constants 10+Fail constants 11+Fail constants 12+Fail constants 13+Fail constants 14+Fail constants 15+Fail constants 16+Fail constants 17+Fail constants 18+Fail constants 19+Fail constants 20+Fail constants 21+Fail constants 22+Fail constants 23+Fail constants 24+Fail constants 25+Fail constants 26+Fail constants 27+Fail constants 28+Fail constants 29+Fail constants 30+Fail constants 31+Fail constants 32+Fail constants 33+Fail constants 34+Fail constants 35+Fail constants 36+Fail constants 37+Fail constants 38+Fail constants 39\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/js-string/imports.any.txt b/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/js-string/imports.any.txtnew file mode 100644index 00000000000..2950b038f38--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/js-string/imports.any.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail imports\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/js-string/imports.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/js-string/imports.any.worker.txtnew file mode 100644index 00000000000..2950b038f38--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/wasm/jsapi/js-string/imports.any.worker.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail imports\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.txt b/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.txtnew file mode 100644index 00000000000..591d0eba570--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.txt@@ -0,0 +1,111 @@+Harness status: OK++Found 106 tests++106 Pass+Pass Non-object imports argument: null+Pass Non-object imports argument: true+Pass Non-object imports argument: ""+Pass Non-object imports argument: symbol "Symbol()"+Pass Non-object imports argument: 1+Pass Non-object imports argument: 0.1+Pass Non-object imports argument: NaN+Pass Non-object module: undefined+Pass Non-object module: null+Pass Non-object module: true+Pass Non-object module: ""+Pass Non-object module: symbol "Symbol()"+Pass Non-object module: 1+Pass Non-object module: 0.1+Pass Non-object module: NaN+Pass Missing imports argument+Pass Imports argument with missing property: undefined+Pass Imports argument with missing property: empty object+Pass Imports argument with missing property: wrong property+Pass Importing a function with an incorrectly-typed value: undefined+Pass Importing a function with an incorrectly-typed value: null+Pass Importing a function with an incorrectly-typed value: true+Pass Importing a function with an incorrectly-typed value: ""+Pass Importing a function with an incorrectly-typed value: symbol "Symbol()"+Pass Importing a function with an incorrectly-typed value: 1+Pass Importing a function with an incorrectly-typed value: 0.1+Pass Importing a function with an incorrectly-typed value: NaN+Pass Importing a function with an incorrectly-typed value: object "[object Object]"+Pass Importing an i32 global with an incorrectly-typed value: undefined+Pass Importing an i32 global with an incorrectly-typed value: null+Pass Importing an i32 global with an incorrectly-typed value: true+Pass Importing an i32 global with an incorrectly-typed value: ""+Pass Importing an i32 global with an incorrectly-typed value: symbol "Symbol()"+Pass Importing an i32 global with an incorrectly-typed value: plain object+Pass Importing an i32 global with an incorrectly-typed value: WebAssembly.Global+Pass Importing an i32 global with an incorrectly-typed value: WebAssembly.Global.prototype+Pass Importing an i32 global with an incorrectly-typed value: Object.create(WebAssembly.Global.prototype)+Pass Importing an i32 global with an incorrectly-typed value: BigInt+Pass Importing an i32 global with an incorrectly-typed value: WebAssembly.Global object (wrong value type)+Pass Importing an i64 global with an incorrectly-typed value: undefined+Pass Importing an i64 global with an incorrectly-typed value: null+Pass Importing an i64 global with an incorrectly-typed value: true+Pass Importing an i64 global with an incorrectly-typed value: ""+Pass Importing an i64 global with an incorrectly-typed value: symbol "Symbol()"+Pass Importing an i64 global with an incorrectly-typed value: plain object+Pass Importing an i64 global with an incorrectly-typed value: WebAssembly.Global+Pass Importing an i64 global with an incorrectly-typed value: WebAssembly.Global.prototype+Pass Importing an i64 global with an incorrectly-typed value: Object.create(WebAssembly.Global.prototype)+Pass Importing an i64 global with an incorrectly-typed value: Number+Pass Importing an i64 global with an incorrectly-typed value: WebAssembly.Global object (wrong value type)+Pass Importing an f32 global with an incorrectly-typed value: undefined+Pass Importing an f32 global with an incorrectly-typed value: null+Pass Importing an f32 global with an incorrectly-typed value: true+Pass Importing an f32 global with an incorrectly-typed value: ""+Pass Importing an f32 global with an incorrectly-typed value: symbol "Symbol()"+Pass Importing an f32 global with an incorrectly-typed value: plain object+Pass Importing an f32 global with an incorrectly-typed value: WebAssembly.Global+Pass Importing an f32 global with an incorrectly-typed value: WebAssembly.Global.prototype+Pass Importing an f32 global with an incorrectly-typed value: Object.create(WebAssembly.Global.prototype)+Pass Importing an f32 global with an incorrectly-typed value: BigInt+Pass Importing an f32 global with an incorrectly-typed value: WebAssembly.Global object (wrong value type)+Pass Importing an f64 global with an incorrectly-typed value: undefined+Pass Importing an f64 global with an incorrectly-typed value: null+Pass Importing an f64 global with an incorrectly-typed value: true+Pass Importing an f64 global with an incorrectly-typed value: ""+Pass Importing an f64 global with an incorrectly-typed value: symbol "Symbol()"+Pass Importing an f64 global with an incorrectly-typed value: plain object+Pass Importing an f64 global with an incorrectly-typed value: WebAssembly.Global+Pass Importing an f64 global with an incorrectly-typed value: WebAssembly.Global.prototype+Pass Importing an f64 global with an incorrectly-typed value: Object.create(WebAssembly.Global.prototype)+Pass Importing an f64 global with an incorrectly-typed value: BigInt+Pass Importing an f64 global with an incorrectly-typed value: WebAssembly.Global object (wrong value type)+Pass Importing an i32 mutable global with a primitive value+Pass Importing an i32 mutable global with an immutable Global object+Pass Importing an i64 mutable global with a primitive value+Pass Importing an i64 mutable global with an immutable Global object+Pass Importing an f32 mutable global with a primitive value+Pass Importing an f32 mutable global with an immutable Global object+Pass Importing an f64 mutable global with a primitive value+Pass Importing an f64 mutable global with an immutable Global object+Pass Importing memory with an incorrectly-typed value: undefined+Pass Importing memory with an incorrectly-typed value: null+Pass Importing memory with an incorrectly-typed value: true+Pass Importing memory with an incorrectly-typed value: ""+Pass Importing memory with an incorrectly-typed value: symbol "Symbol()"+Pass Importing memory with an incorrectly-typed value: 1+Pass Importing memory with an incorrectly-typed value: 0.1+Pass Importing memory with an incorrectly-typed value: NaN+Pass Importing memory with an incorrectly-typed value: plain object+Pass Importing memory with an incorrectly-typed value: WebAssembly.Memory+Pass Importing memory with an incorrectly-typed value: WebAssembly.Memory.prototype+Pass Importing memory with an incorrectly-typed value: Object.create(WebAssembly.Memory.prototype)+Pass Importing memory with an incorrectly-typed value: WebAssembly.Memory object (too large)+Pass Importing table with an incorrectly-typed value: undefined+Pass Importing table with an incorrectly-typed value: null+Pass Importing table with an incorrectly-typed value: true+Pass Importing table with an incorrectly-typed value: ""+Pass Importing table with an incorrectly-typed value: symbol "Symbol()"+Pass Importing table with an incorrectly-typed value: 1+Pass Importing table with an incorrectly-typed value: 0.1+Pass Importing table with an incorrectly-typed value: NaN+Pass Importing table with an incorrectly-typed value: plain object+Pass Importing table with an incorrectly-typed value: WebAssembly.Table+Pass Importing table with an incorrectly-typed value: WebAssembly.Table.prototype+Pass Importing table with an incorrectly-typed value: Object.create(WebAssembly.Table.prototype)+Pass Importing table with an incorrectly-typed value: WebAssembly.Table object (too large)\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.worker.txtnew file mode 100644index 00000000000..591d0eba570--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.worker.txt@@ -0,0 +1,111 @@+Harness status: OK++Found 106 tests++106 Pass+Pass Non-object imports argument: null+Pass Non-object imports argument: true+Pass Non-object imports argument: ""+Pass Non-object imports argument: symbol "Symbol()"+Pass Non-object imports argument: 1+Pass Non-object imports argument: 0.1+Pass Non-object imports argument: NaN+Pass Non-object module: undefined+Pass Non-object module: null+Pass Non-object module: true+Pass Non-object module: ""+Pass Non-object module: symbol "Symbol()"+Pass Non-object module: 1+Pass Non-object module: 0.1+Pass Non-object module: NaN+Pass Missing imports argument+Pass Imports argument with missing property: undefined+Pass Imports argument with missing property: empty object+Pass Imports argument with missing property: wrong property+Pass Importing a function with an incorrectly-typed value: undefined+Pass Importing a function with an incorrectly-typed value: null+Pass Importing a function with an incorrectly-typed value: true+Pass Importing a function with an incorrectly-typed value: ""+Pass Importing a function with an incorrectly-typed value: symbol "Symbol()"+Pass Importing a function with an incorrectly-typed value: 1+Pass Importing a function with an incorrectly-typed value: 0.1+Pass Importing a function with an incorrectly-typed value: NaN+Pass Importing a function with an incorrectly-typed value: object "[object Object]"+Pass Importing an i32 global with an incorrectly-typed value: undefined+Pass Importing an i32 global with an incorrectly-typed value: null+Pass Importing an i32 global with an incorrectly-typed value: true+Pass Importing an i32 global with an incorrectly-typed value: ""+Pass Importing an i32 global with an incorrectly-typed value: symbol "Symbol()"+Pass Importing an i32 global with an incorrectly-typed value: plain object+Pass Importing an i32 global with an incorrectly-typed value: WebAssembly.Global+Pass Importing an i32 global with an incorrectly-typed value: WebAssembly.Global.prototype+Pass Importing an i32 global with an incorrectly-typed value: Object.create(WebAssembly.Global.prototype)+Pass Importing an i32 global with an incorrectly-typed value: BigInt+Pass Importing an i32 global with an incorrectly-typed value: WebAssembly.Global object (wrong value type)+Pass Importing an i64 global with an incorrectly-typed value: undefined+Pass Importing an i64 global with an incorrectly-typed value: null+Pass Importing an i64 global with an incorrectly-typed value: true+Pass Importing an i64 global with an incorrectly-typed value: ""+Pass Importing an i64 global with an incorrectly-typed value: symbol "Symbol()"+Pass Importing an i64 global with an incorrectly-typed value: plain object+Pass Importing an i64 global with an incorrectly-typed value: WebAssembly.Global+Pass Importing an i64 global with an incorrectly-typed value: WebAssembly.Global.prototype+Pass Importing an i64 global with an incorrectly-typed value: Object.create(WebAssembly.Global.prototype)+Pass Importing an i64 global with an incorrectly-typed value: Number+Pass Importing an i64 global with an incorrectly-typed value: WebAssembly.Global object (wrong value type)+Pass Importing an f32 global with an incorrectly-typed value: undefined+Pass Importing an f32 global with an incorrectly-typed value: null+Pass Importing an f32 global with an incorrectly-typed value: true+Pass Importing an f32 global with an incorrectly-typed value: ""+Pass Importing an f32 global with an incorrectly-typed value: symbol "Symbol()"+Pass Importing an f32 global with an incorrectly-typed value: plain object+Pass Importing an f32 global with an incorrectly-typed value: WebAssembly.Global+Pass Importing an f32 global with an incorrectly-typed value: WebAssembly.Global.prototype+Pass Importing an f32 global with an incorrectly-typed value: Object.create(WebAssembly.Global.prototype)+Pass Importing an f32 global with an incorrectly-typed value: BigInt+Pass Importing an f32 global with an incorrectly-typed value: WebAssembly.Global object (wrong value type)+Pass Importing an f64 global with an incorrectly-typed value: undefined+Pass Importing an f64 global with an incorrectly-typed value: null+Pass Importing an f64 global with an incorrectly-typed value: true+Pass Importing an f64 global with an incorrectly-typed value: ""+Pass Importing an f64 global with an incorrectly-typed value: symbol "Symbol()"+Pass Importing an f64 global with an incorrectly-typed value: plain object+Pass Importing an f64 global with an incorrectly-typed value: WebAssembly.Global+Pass Importing an f64 global with an incorrectly-typed value: WebAssembly.Global.prototype+Pass Importing an f64 global with an incorrectly-typed value: Object.create(WebAssembly.Global.prototype)+Pass Importing an f64 global with an incorrectly-typed value: BigInt+Pass Importing an f64 global with an incorrectly-typed value: WebAssembly.Global object (wrong value type)+Pass Importing an i32 mutable global with a primitive value+Pass Importing an i32 mutable global with an immutable Global object+Pass Importing an i64 mutable global with a primitive value+Pass Importing an i64 mutable global with an immutable Global object+Pass Importing an f32 mutable global with a primitive value+Pass Importing an f32 mutable global with an immutable Global object+Pass Importing an f64 mutable global with a primitive value+Pass Importing an f64 mutable global with an immutable Global object+Pass Importing memory with an incorrectly-typed value: undefined+Pass Importing memory with an incorrectly-typed value: null+Pass Importing memory with an incorrectly-typed value: true+Pass Importing memory with an incorrectly-typed value: ""+Pass Importing memory with an incorrectly-typed value: symbol "Symbol()"+Pass Importing memory with an incorrectly-typed value: 1+Pass Importing memory with an incorrectly-typed value: 0.1+Pass Importing memory with an incorrectly-typed value: NaN+Pass Importing memory with an incorrectly-typed value: plain object+Pass Importing memory with an incorrectly-typed value: WebAssembly.Memory+Pass Importing memory with an incorrectly-typed value: WebAssembly.Memory.prototype+Pass Importing memory with an incorrectly-typed value: Object.create(WebAssembly.Memory.prototype)+Pass Importing memory with an incorrectly-typed value: WebAssembly.Memory object (too large)+Pass Importing table with an incorrectly-typed value: undefined+Pass Importing table with an incorrectly-typed value: null+Pass Importing table with an incorrectly-typed value: true+Pass Importing table with an incorrectly-typed value: ""+Pass Importing table with an incorrectly-typed value: symbol "Symbol()"+Pass Importing table with an incorrectly-typed value: 1+Pass Importing table with an incorrectly-typed value: 0.1+Pass Importing table with an incorrectly-typed value: NaN+Pass Importing table with an incorrectly-typed value: plain object+Pass Importing table with an incorrectly-typed value: WebAssembly.Table+Pass Importing table with an incorrectly-typed value: WebAssembly.Table.prototype+Pass Importing table with an incorrectly-typed value: Object.create(WebAssembly.Table.prototype)+Pass Importing table with an incorrectly-typed value: WebAssembly.Table object (too large)\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/instantiateStreaming.any.txt b/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/instantiateStreaming.any.txtnew file mode 100644index 00000000000..74e58a56a60--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/instantiateStreaming.any.txt@@ -0,0 +1,30 @@+Harness status: OK++Found 25 tests++25 Fail+Fail Empty module without imports argument+Fail Empty module with undefined imports argument+Fail Empty module with empty imports argument+Fail getter order for imports object+Fail imports+Fail imports with empty module names+Fail imports with empty names+Fail exports with empty name: function+Fail exports with empty name: table+Fail exports with empty name: global+Fail No imports+Fail exports and imports+Fail i64 exports and imports+Fail import with i32-returning function+Fail import with function that takes and returns i32+Fail import with i64-returning function+Fail import with function that takes and returns i64+Fail import with i32-taking function+Fail import with i64-taking function+Fail export i64-returning function+Fail i32 mutable WebAssembly.Global import+Fail i64 mutable WebAssembly.Global import+Fail Multiple i64 arguments+Fail stray argument+Fail Synchronous options handling\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/instantiateStreaming.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/instantiateStreaming.any.worker.txtnew file mode 100644index 00000000000..74e58a56a60--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/instantiateStreaming.any.worker.txt@@ -0,0 +1,30 @@+Harness status: OK++Found 25 tests++25 Fail+Fail Empty module without imports argument+Fail Empty module with undefined imports argument+Fail Empty module with empty imports argument+Fail getter order for imports object+Fail imports+Fail imports with empty module names+Fail imports with empty names+Fail exports with empty name: function+Fail exports with empty name: table+Fail exports with empty name: global+Fail No imports+Fail exports and imports+Fail i64 exports and imports+Fail import with i32-returning function+Fail import with function that takes and returns i32+Fail import with i64-returning function+Fail import with function that takes and returns i64+Fail import with i32-taking function+Fail import with i64-taking function+Fail export i64-returning function+Fail i32 mutable WebAssembly.Global import+Fail i64 mutable WebAssembly.Global import+Fail Multiple i64 arguments+Fail stray argument+Fail Synchronous options handling\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/invalid-args.any.txt b/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/invalid-args.any.txtnew file mode 100644index 00000000000..a98b4f4c757--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/invalid-args.any.txt@@ -0,0 +1,49 @@+Harness status: OK++Found 44 tests++44 Pass+Pass compileStreaming: undefined+Pass compileStreaming: undefined in a promise+Pass compileStreaming: null+Pass compileStreaming: null in a promise+Pass compileStreaming: true+Pass compileStreaming: true in a promise+Pass compileStreaming: "test"+Pass compileStreaming: "test" in a promise+Pass compileStreaming: symbol "Symbol()"+Pass compileStreaming: symbol "Symbol()" in a promise+Pass compileStreaming: 0+Pass compileStreaming: 0 in a promise+Pass compileStreaming: 0.1+Pass compileStreaming: 0.1 in a promise+Pass compileStreaming: NaN+Pass compileStreaming: NaN in a promise+Pass compileStreaming: Empty object+Pass compileStreaming: Empty object in a promise+Pass compileStreaming: Response interface object+Pass compileStreaming: Response interface object in a promise+Pass compileStreaming: Response interface prototype object+Pass compileStreaming: Response interface prototype object in a promise+Pass instantiateStreaming: undefined+Pass instantiateStreaming: undefined in a promise+Pass instantiateStreaming: null+Pass instantiateStreaming: null in a promise+Pass instantiateStreaming: true+Pass instantiateStreaming: true in a promise+Pass instantiateStreaming: "test"+Pass instantiateStreaming: "test" in a promise+Pass instantiateStreaming: symbol "Symbol()"+Pass instantiateStreaming: symbol "Symbol()" in a promise+Pass instantiateStreaming: 0+Pass instantiateStreaming: 0 in a promise+Pass instantiateStreaming: 0.1+Pass instantiateStreaming: 0.1 in a promise+Pass instantiateStreaming: NaN+Pass instantiateStreaming: NaN in a promise+Pass instantiateStreaming: Empty object+Pass instantiateStreaming: Empty object in a promise+Pass instantiateStreaming: Response interface object+Pass instantiateStreaming: Response interface object in a promise+Pass instantiateStreaming: Response interface prototype object+Pass instantiateStreaming: Response interface prototype object in a promise\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/invalid-args.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/invalid-args.any.worker.txtnew file mode 100644index 00000000000..a98b4f4c757--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/invalid-args.any.worker.txt@@ -0,0 +1,49 @@+Harness status: OK++Found 44 tests++44 Pass+Pass compileStreaming: undefined+Pass compileStreaming: undefined in a promise+Pass compileStreaming: null+Pass compileStreaming: null in a promise+Pass compileStreaming: true+Pass compileStreaming: true in a promise+Pass compileStreaming: "test"+Pass compileStreaming: "test" in a promise+Pass compileStreaming: symbol "Symbol()"+Pass compileStreaming: symbol "Symbol()" in a promise+Pass compileStreaming: 0+Pass compileStreaming: 0 in a promise+Pass compileStreaming: 0.1+Pass compileStreaming: 0.1 in a promise+Pass compileStreaming: NaN+Pass compileStreaming: NaN in a promise+Pass compileStreaming: Empty object+Pass compileStreaming: Empty object in a promise+Pass compileStreaming: Response interface object+Pass compileStreaming: Response interface object in a promise+Pass compileStreaming: Response interface prototype object+Pass compileStreaming: Response interface prototype object in a promise+Pass instantiateStreaming: undefined+Pass instantiateStreaming: undefined in a promise+Pass instantiateStreaming: null+Pass instantiateStreaming: null in a promise+Pass instantiateStreaming: true+Pass instantiateStreaming: true in a promise+Pass instantiateStreaming: "test"+Pass instantiateStreaming: "test" in a promise+Pass instantiateStreaming: symbol "Symbol()"+Pass instantiateStreaming: symbol "Symbol()" in a promise+Pass instantiateStreaming: 0+Pass instantiateStreaming: 0 in a promise+Pass instantiateStreaming: 0.1+Pass instantiateStreaming: 0.1 in a promise+Pass instantiateStreaming: NaN+Pass instantiateStreaming: NaN in a promise+Pass instantiateStreaming: Empty object+Pass instantiateStreaming: Empty object in a promise+Pass instantiateStreaming: Response interface object+Pass instantiateStreaming: Response interface object in a promise+Pass instantiateStreaming: Response interface prototype object+Pass instantiateStreaming: Response interface prototype object in a promise\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/rejected-arg.any.txt b/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/rejected-arg.any.txtnew file mode 100644index 00000000000..8628af0b2b1--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/rejected-arg.any.txt@@ -0,0 +1,7 @@+Harness status: OK++Found 2 tests++2 Pass+Pass compileStreaming+Pass instantiateStreaming\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/rejected-arg.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/rejected-arg.any.worker.txtnew file mode 100644index 00000000000..8628af0b2b1--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/wasm/webapi/rejected-arg.any.worker.txt@@ -0,0 +1,7 @@+Harness status: OK++Found 2 tests++2 Pass+Pass compileStreaming+Pass instantiateStreaming\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/constructor/instantiate.any.html b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/constructor/instantiate.any.htmlnew file mode 100644index 00000000000..12e6b3733c9--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/constructor/instantiate.any.html@@ -0,0 +1,17 @@+<!doctype html>+<meta charset=utf-8>++<script>+self.GLOBAL = {+ isWindow: function() { return true; },+ isWorker: function() { return false; },+ isShadowRealm: function() { return false; },+};+</script>+<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<script src="../../../wasm/jsapi/wasm-module-builder.js"></script>+<script src="../../../wasm/jsapi/assertions.js"></script>+<script src="../../../wasm/jsapi/instanceTestFactory.js"></script>+<div id=log></div>+<script src="../../../wasm/jsapi/constructor/instantiate.any.js"></script>diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/constructor/instantiate.any.js b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/constructor/instantiate.any.jsnew file mode 100644index 00000000000..8152f3a56f3--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/constructor/instantiate.any.js@@ -0,0 +1,152 @@+// META: global=window,dedicatedworker,jsshell+// META: script=/wasm/jsapi/wasm-module-builder.js+// META: script=/wasm/jsapi/assertions.js+// META: script=/wasm/jsapi/instanceTestFactory.js++let emptyModuleBinary;+setup(() => {+ emptyModuleBinary = new WasmModuleBuilder().toBuffer();+});++promise_test(t => {+ return promise_rejects_js(t, TypeError, WebAssembly.instantiate());+}, "Missing arguments");++promise_test(() => {+ const fn = WebAssembly.instantiate;+ const thisValues = [+ undefined,+ null,+ true,+ "",+ Symbol(),+ 1,+ {},+ WebAssembly,+ ];+ return Promise.all(thisValues.map(thisValue => {+ return fn.call(thisValue, emptyModuleBinary).then(assert_WebAssemblyInstantiatedSource);+ }));+}, "Branding");++promise_test(t => {+ const invalidArguments = [+ undefined,+ null,+ true,+ "",+ Symbol(),+ 1,+ {},+ WebAssembly.Module,+ WebAssembly.Module.prototype,+ ArrayBuffer,+ ArrayBuffer.prototype,+ Array.from(emptyModuleBinary),+ ];+ return Promise.all(invalidArguments.map(argument => {+ return promise_rejects_js(t, TypeError, WebAssembly.instantiate(argument),+ `instantiate(${format_value(argument)})`);+ }));+}, "Invalid arguments");++test(() => {+ const promise = WebAssembly.instantiate(emptyModuleBinary);+ assert_equals(Object.getPrototypeOf(promise), Promise.prototype, "prototype");+ assert_true(Object.isExtensible(promise), "extensibility");+}, "Promise type");++for (const [name, fn] of instanceTestFactory) {+ promise_test(() => {+ const { buffer, args, exports, verify } = fn();+ return WebAssembly.instantiate(buffer, ...args).then(result => {+ assert_WebAssemblyInstantiatedSource(result, exports);+ verify(result.instance);+ });+ }, `${name}: BufferSource argument`);++ promise_test(() => {+ const { buffer, args, exports, verify } = fn();+ const module = new WebAssembly.Module(buffer);+ return WebAssembly.instantiate(module, ...args).then(instance => {+ assert_Instance(instance, exports);+ verify(instance);+ });+ }, `${name}: Module argument`);+}++promise_test(() => {+ const builder = new WasmModuleBuilder();+ builder.addImportedGlobal("module", "global", kWasmI32);+ const buffer = builder.toBuffer();+ const order = [];++ const imports = {+ get module() {+ order.push("module getter");+ return {+ get global() {+ order.push("global getter");+ return 0;+ },+ }+ },+ };++ const expected = [+ "module getter",+ "global getter",+ ];+ const p = WebAssembly.instantiate(buffer, imports);+ assert_array_equals(order, []);+ return p.then(result => {+ assert_WebAssemblyInstantiatedSource(result);+ assert_array_equals(order, expected);+ });+}, "Synchronous options handling: Buffer argument");++promise_test(() => {+ const builder = new WasmModuleBuilder();+ builder.addImportedGlobal("module", "global", kWasmI32);+ const buffer = builder.toBuffer();+ const module = new WebAssembly.Module(buffer);+ const order = [];++ const imports = {+ get module() {+ order.push("module getter");+ return {+ get global() {+ order.push("global getter");+ return 0;+ },+ }+ },+ };++ const expected = [+ "module getter",+ "global getter",+ ];+ const p = WebAssembly.instantiate(module, imports);+ assert_array_equals(order, expected);+ return p.then(instance => assert_Instance(instance, {}));+}, "Synchronous options handling: Module argument");++promise_test(t => {+ const buffer = new Uint8Array();+ return promise_rejects_js(t, WebAssembly.CompileError, WebAssembly.instantiate(buffer));+}, "Empty buffer");++promise_test(t => {+ const buffer = new Uint8Array(Array.from(emptyModuleBinary).concat([0, 0]));+ return promise_rejects_js(t, WebAssembly.CompileError, WebAssembly.instantiate(buffer));+}, "Invalid code");++promise_test(() => {+ const buffer = new WasmModuleBuilder().toBuffer();+ assert_equals(buffer[0], 0);+ const promise = WebAssembly.instantiate(buffer);+ buffer[0] = 1;+ return promise.then(assert_WebAssemblyInstantiatedSource);+}, "Changing the buffer");diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/constructor/instantiate.any.worker.html b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/constructor/instantiate.any.worker.htmlnew file mode 100644index 00000000000..6f456195ab5--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/constructor/instantiate.any.worker.html@@ -0,0 +1,9 @@+<!doctype html>+<meta charset=utf-8>++<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<div id=log></div>+<script>+fetch_tests_from_worker(new Worker("../../../wasm/jsapi/constructor/instantiate.any.worker.js"));+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/constructor/instantiate.any.worker.js b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/constructor/instantiate.any.worker.jsnew file mode 100644index 00000000000..18b71f6977e--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/constructor/instantiate.any.worker.js@@ -0,0 +1,12 @@++self.GLOBAL = {+ isWindow: function() { return false; },+ isWorker: function() { return true; },+ isShadowRealm: function() { return false; },+};+importScripts("/resources/testharness.js");+importScripts("/wasm/jsapi/wasm-module-builder.js")+importScripts("/wasm/jsapi/assertions.js")+importScripts("/wasm/jsapi/instanceTestFactory.js")+importScripts("/wasm/jsapi/constructor/instantiate.any.js");+done();diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/instanceTestFactory.js b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/instanceTestFactory.jsnew file mode 100644index 00000000000..2e015af8198--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/instanceTestFactory.js@@ -0,0 +1,763 @@+const instanceTestFactory = [+ [+ "Empty module without imports argument",+ function() {+ return {+ buffer: emptyModuleBinary,+ args: [],+ exports: {},+ verify: () => {},+ };+ }+ ],++ [+ "Empty module with undefined imports argument",+ function() {+ return {+ buffer: emptyModuleBinary,+ args: [undefined],+ exports: {},+ verify: () => {},+ };+ }+ ],++ [+ "Empty module with empty imports argument",+ function() {+ return {+ buffer: emptyModuleBinary,+ args: [{}],+ exports: {},+ verify: () => {},+ };+ }+ ],++ [+ "getter order for imports object",+ function() {+ const builder = new WasmModuleBuilder();+ builder.addImportedGlobal("module", "global1", kWasmI32);+ builder.addImportedGlobal("module2", "global3", kWasmI32);+ builder.addImportedMemory("module", "memory", 0, 128);+ builder.addImportedGlobal("module", "global2", kWasmI32);+ const buffer = builder.toBuffer();+ const order = [];++ const imports = {+ get module() {+ order.push("module getter");+ return {+ get global1() {+ order.push("global1 getter");+ return 0;+ },+ get global2() {+ order.push("global2 getter");+ return 0;+ },+ get memory() {+ order.push("memory getter");+ return new WebAssembly.Memory({ "initial": 64, maximum: 128 });+ },+ }+ },+ get module2() {+ order.push("module2 getter");+ return {+ get global3() {+ order.push("global3 getter");+ return 0;+ },+ }+ },+ };++ const expected = [+ "module getter",+ "global1 getter",+ "module2 getter",+ "global3 getter",+ "module getter",+ "memory getter",+ "module getter",+ "global2 getter",+ ];+ return {+ buffer,+ args: [imports],+ exports: {},+ verify: () => assert_array_equals(order, expected),+ };+ }+ ],++ [+ "imports",+ function() {+ const builder = new WasmModuleBuilder();++ builder.addImport("module", "fn", kSig_v_v);+ builder.addImportedGlobal("module", "global", kWasmI32);+ builder.addImportedMemory("module", "memory", 0, 128);+ builder.addImportedTable("module", "table", 0, 128);++ const buffer = builder.toBuffer();+ const imports = {+ "module": {+ "fn": function() {},+ "global": 0,+ "memory": new WebAssembly.Memory({ "initial": 64, maximum: 128 }),+ "table": new WebAssembly.Table({ "element": "anyfunc", "initial": 64, maximum: 128 }),+ },+ get "module2"() {+ assert_unreached("Should not get modules that are not imported");+ },+ };++ return {+ buffer,+ args: [imports],+ exports: {},+ verify: () => {},+ };+ }+ ],++ [+ "imports with empty module names",+ function() {+ const builder = new WasmModuleBuilder();++ builder.addImport("", "fn", kSig_v_v);+ builder.addImportedGlobal("", "global", kWasmI32);+ builder.addImportedMemory("", "memory", 0, 128);+ builder.addImportedTable("", "table", 0, 128);++ const buffer = builder.toBuffer();+ const imports = {+ "": {+ "fn": function() {},+ "global": 0,+ "memory": new WebAssembly.Memory({ "initial": 64, maximum: 128 }),+ "table": new WebAssembly.Table({ "element": "anyfunc", "initial": 64, maximum: 128 }),+ },+ };++ return {+ buffer,+ args: [imports],+ exports: {},+ verify: () => {},+ };+ }+ ],++ [+ "imports with empty names",+ function() {+ const builder = new WasmModuleBuilder();++ builder.addImport("a", "", kSig_v_v);+ builder.addImportedGlobal("b", "", kWasmI32);+ builder.addImportedMemory("c", "", 0, 128);+ builder.addImportedTable("d", "", 0, 128);++ const buffer = builder.toBuffer();+ const imports = {+ "a": { "": function() {} },+ "b": { "": 0 },+ "c": { "": new WebAssembly.Memory({ "initial": 64, maximum: 128 }) },+ "d": { "": new WebAssembly.Table({ "element": "anyfunc", "initial": 64, maximum: 128 }) },+ };++ return {+ buffer,+ args: [imports],+ exports: {},+ verify: () => {},+ };+ }+ ],++ [+ "exports with empty name: function",+ function() {+ const builder = new WasmModuleBuilder();++ builder+ .addFunction("", kSig_v_d)+ .addBody([])+ .exportFunc();++ const buffer = builder.toBuffer();++ const exports = {+ "": { "kind": "function", "name": "0", "length": 1 },+ };++ return {+ buffer,+ args: [],+ exports,+ verify: () => {},+ };+ }+ ],++ [+ "exports with empty name: table",+ function() {+ const builder = new WasmModuleBuilder();++ builder.setTableBounds(1);+ builder.addExportOfKind("", kExternalTable, 0);++ const buffer = builder.toBuffer();++ const exports = {+ "": { "kind": "table", "length": 1 },+ };++ return {+ buffer,+ args: [],+ exports,+ verify: () => {},+ };+ }+ ],++ [+ "exports with empty name: global",+ function() {+ const builder = new WasmModuleBuilder();++ builder.addGlobal(kWasmI32, true)+ .exportAs("")+ .init = wasmI32Const(7);++ const buffer = builder.toBuffer();++ const exports = {+ "": { "kind": "global", "value": 7 },+ };++ return {+ buffer,+ args: [],+ exports,+ verify: () => {},+ };+ }+ ],++ [+ "No imports",+ function() {+ const builder = new WasmModuleBuilder();++ builder+ .addFunction("fn", kSig_v_d)+ .addBody([])+ .exportFunc();+ builder+ .addFunction("fn2", kSig_v_v)+ .addBody([])+ .exportFunc();++ builder.setTableBounds(1);+ builder.addExportOfKind("table", kExternalTable, 0);++ builder.addGlobal(kWasmI32, true)+ .exportAs("global")+ .init = wasmI32Const(7);+ builder.addGlobal(kWasmF64, true)+ .exportAs("global2")+ .init = wasmF64Const(1.2);++ builder.addMemory(4, 8, true);++ const buffer = builder.toBuffer();++ const exports = {+ "fn": { "kind": "function", "name": "0", "length": 1 },+ "fn2": { "kind": "function", "name": "1", "length": 0 },+ "table": { "kind": "table", "length": 1 },+ "global": { "kind": "global", "value": 7 },+ "global2": { "kind": "global", "value": 1.2 },+ "memory": { "kind": "memory", "size": 4 },+ };++ return {+ buffer,+ args: [],+ exports,+ verify: () => {},+ };+ }+ ],++ [+ "exports and imports",+ function() {+ const value = 102;++ const builder = new WasmModuleBuilder();++ const index = builder.addImportedGlobal("module", "global", kWasmI32);+ builder+ .addFunction("fn", kSig_i_v)+ .addBody([+ kExprGlobalGet,+ index,+ kExprReturn,+ ])+ .exportFunc();++ const buffer = builder.toBuffer();++ const imports = {+ "module": {+ "global": value,+ },+ };++ const exports = {+ "fn": { "kind": "function", "name": "0", "length": 0 },+ };++ return {+ buffer,+ args: [imports],+ exports,+ verify: instance => assert_equals(instance.exports.fn(), value)+ };+ }+ ],++ [+ "i64 exports and imports",+ function() {+ const value = 102n;++ const builder = new WasmModuleBuilder();++ const index = builder.addImportedGlobal("module", "global", kWasmI64);+ builder+ .addFunction("fn", kSig_l_v)+ .addBody([+ kExprGlobalGet,+ index,+ kExprReturn,+ ])+ .exportFunc();++ const index2 = builder.addImportedGlobal("module", "global2", kWasmI64);+ builder.addExportOfKind("global", kExternalGlobal, index2);++ const buffer = builder.toBuffer();++ const imports = {+ "module": {+ "global": value,+ "global2": 2n ** 63n,+ },+ };++ const exports = {+ "fn": { "kind": "function", "name": "0", "length": 0 },+ "global": { "kind": "global", "value": -(2n ** 63n) },+ };++ return {+ buffer,+ args: [imports],+ exports,+ verify: instance => assert_equals(instance.exports.fn(), value)+ };+ }+ ],++ [+ "import with i32-returning function",+ function() {+ const builder = new WasmModuleBuilder();++ const fnIndex = builder.addImport("module", "fn", kSig_i_v);+ const fn2 = builder+ .addFunction("fn2", kSig_v_v)+ .addBody([+ kExprCallFunction,+ fnIndex,+ kExprReturn,+ ])+ .exportFunc();++ const buffer = builder.toBuffer();++ let called = false;+ const imports = {+ "module": {+ "fn": function() {+ called = true;+ return 6n;+ },+ },+ };++ return {+ buffer,+ args: [imports],+ exports: {+ "fn2": { "kind": "function", "name": String(fn2.index), "length": 0 },+ },+ verify: instance => {+ assert_throws_js(TypeError, () => instance.exports.fn2());+ assert_true(called, "Should have called into JS");+ }+ };+ }+ ],++ [+ "import with function that takes and returns i32",+ function() {+ const builder = new WasmModuleBuilder();++ const fnIndex = builder.addImport("module", "fn", kSig_i_i);+ const fn2 = builder+ .addFunction("fn2", kSig_i_v)+ .addBody([+ kExprI32Const, 0x66,+ kExprCallFunction,+ fnIndex,+ kExprReturn,+ ])+ .exportFunc();++ const buffer = builder.toBuffer();++ let called = false;+ const imports = {+ "module": {+ "fn": function(n) {+ called = true;+ assert_equals(n, -26);+ return { valueOf() { return 6; } };+ },+ },+ };++ return {+ buffer,+ args: [imports],+ exports: {+ "fn2": { "kind": "function", "name": String(fn2.index), "length": 0 },+ },+ verify: instance => {+ assert_equals(instance.exports.fn2(), 6);+ assert_true(called, "Should have called into JS");+ }+ };+ }+ ],++ [+ "import with i64-returning function",+ function() {+ const builder = new WasmModuleBuilder();++ const fnIndex = builder.addImport("module", "fn", kSig_l_v);+ const fn2 = builder+ .addFunction("fn2", kSig_v_v)+ .addBody([+ kExprCallFunction,+ fnIndex,+ kExprReturn,+ ])+ .exportFunc();++ const buffer = builder.toBuffer();++ let called = false;+ const imports = {+ "module": {+ "fn": function() {+ called = true;+ return 6;+ },+ },+ };++ return {+ buffer,+ args: [imports],+ exports: {+ "fn2": { "kind": "function", "name": String(fn2.index), "length": 0 },+ },+ verify: instance => {+ assert_throws_js(TypeError, () => instance.exports.fn2());+ assert_true(called, "Should have called into JS");+ }+ };+ }+ ],++ [+ "import with function that takes and returns i64",+ function() {+ const builder = new WasmModuleBuilder();++ const fnIndex = builder.addImport("module", "fn", kSig_l_l);+ const fn2 = builder+ .addFunction("fn2", kSig_l_v)+ .addBody([+ kExprI64Const, 0x66,+ kExprCallFunction,+ fnIndex,+ kExprReturn,+ ])+ .exportFunc();++ const buffer = builder.toBuffer();++ let called = false;+ const imports = {+ "module": {+ "fn": function(n) {+ called = true;+ assert_equals(n, -26n);+ return { valueOf() { return 6n; } };+ },+ },+ };++ return {+ buffer,+ args: [imports],+ exports: {+ "fn2": { "kind": "function", "name": String(fn2.index), "length": 0 },+ },+ verify: instance => {+ assert_equals(instance.exports.fn2(), 6n);+ assert_true(called, "Should have called into JS");+ }+ };+ }+ ],++ [+ "import with i32-taking function",+ function() {+ const builder = new WasmModuleBuilder();++ const fn = builder+ .addFunction("fn", kSig_v_i)+ .addBody([+ kExprReturn,+ ])+ .exportFunc();++ const buffer = builder.toBuffer();++ return {+ buffer,+ args: [],+ exports: {+ "fn": { "kind": "function", "name": String(fn.index), "length": 1 },+ },+ verify: instance => assert_throws_js(TypeError, () => instance.exports.fn(6n))+ };+ }+ ],++ [+ "import with i64-taking function",+ function() {+ const builder = new WasmModuleBuilder();++ const fn = builder+ .addFunction("fn", kSig_v_l)+ .addBody([+ kExprReturn,+ ])+ .exportFunc();++ const buffer = builder.toBuffer();++ return {+ buffer,+ args: [],+ exports: {+ "fn": { "kind": "function", "name": String(fn.index), "length": 1 },+ },+ verify: instance => assert_throws_js(TypeError, () => instance.exports.fn(6))+ };+ }+ ],++ [+ "export i64-returning function",+ function() {+ const builder = new WasmModuleBuilder();++ const fn = builder+ .addFunction("fn", kSig_l_v)+ .addBody([+ kExprI64Const, 0x66,+ kExprReturn,+ ])+ .exportFunc();++ const buffer = builder.toBuffer();++ return {+ buffer,+ args: [],+ exports: {+ "fn": { "kind": "function", "name": String(fn.index), "length": 0 },+ },+ verify: instance => assert_equals(instance.exports.fn(), -26n)+ };+ }+ ],++ [+ "i32 mutable WebAssembly.Global import",+ function() {+ const initial = 102;+ const value = new WebAssembly.Global({ "value": "i32", "mutable": true }, initial);++ const builder = new WasmModuleBuilder();++ const index = builder.addImportedGlobal("module", "global", kWasmI32, true);+ const fn = builder+ .addFunction("fn", kSig_i_v)+ .addBody([+ kExprGlobalGet,+ index,+ kExprReturn,+ ])+ .exportFunc();++ const buffer = builder.toBuffer();++ const imports = {+ "module": {+ "global": value,+ },+ };++ const exports = {+ "fn": { "kind": "function", "name": String(fn.index), "length": 0 },+ };++ return {+ buffer,+ args: [imports],+ exports,+ verify: instance => {+ assert_equals(instance.exports.fn(), initial);+ const after = 201;+ value.value = after;+ assert_equals(instance.exports.fn(), after);+ }+ };+ }+ ],++ [+ "i64 mutable WebAssembly.Global import",+ function() {+ const initial = 102n;+ const value = new WebAssembly.Global({ "value": "i64", "mutable": true }, initial);++ const builder = new WasmModuleBuilder();++ const index = builder.addImportedGlobal("module", "global", kWasmI64, true);+ const fn = builder+ .addFunction("fn", kSig_l_v)+ .addBody([+ kExprGlobalGet,+ index,+ kExprReturn,+ ])+ .exportFunc();++ const buffer = builder.toBuffer();++ const imports = {+ "module": {+ "global": value,+ },+ };++ const exports = {+ "fn": { "kind": "function", "name": String(fn.index), "length": 0 },+ };++ return {+ buffer,+ args: [imports],+ exports,+ verify: instance => {+ assert_equals(instance.exports.fn(), initial);+ const after = 201n;+ value.value = after;+ assert_equals(instance.exports.fn(), after);+ }+ };+ }+ ],++ [+ "Multiple i64 arguments",+ function() {+ const builder = new WasmModuleBuilder();++ const fn = builder+ .addFunction("fn", kSig_l_ll)+ .addBody([+ kExprLocalGet, 1,+ ])+ .exportFunc();++ const buffer = builder.toBuffer();++ const exports = {+ "fn": { "kind": "function", "name": String(fn.index), "length": 2 },+ };++ return {+ buffer,+ args: [],+ exports,+ verify: instance => {+ const fn = instance.exports.fn;+ assert_equals(fn(1n, 0n), 0n);+ assert_equals(fn(1n, 123n), 123n);+ assert_equals(fn(1n, -123n), -123n);+ assert_equals(fn(1n, "5"), 5n);+ assert_throws_js(TypeError, () => fn(1n, 5));+ }+ };+ }+ ],++ [+ "stray argument",+ function() {+ return {+ buffer: emptyModuleBinary,+ args: [{}, {}],+ exports: {},+ verify: () => {}+ };+ }+ ],+];++globalThis.instanceTestFactory = instanceTestFactory;diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/basic.any.html b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/basic.any.htmlnew file mode 100644index 00000000000..29e44b01a5c--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/basic.any.html@@ -0,0 +1,17 @@+<!doctype html>+<meta charset=utf-8>++<script>+self.GLOBAL = {+ isWindow: function() { return true; },+ isWorker: function() { return false; },+ isShadowRealm: function() { return false; },+};+</script>+<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<script src="../../../wasm/jsapi/assertions.js"></script>+<script src="../../../wasm/jsapi/wasm-module-builder.js"></script>+<script src="../../../wasm/jsapi/js-string/polyfill.js"></script>+<div id=log></div>+<script src="../../../wasm/jsapi/js-string/basic.any.js"></script>diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/basic.any.js b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/basic.any.jsnew file mode 100644index 00000000000..6b6dd04e0de--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/basic.any.js@@ -0,0 +1,396 @@+// META: global=window,dedicatedworker,jsshell+// META: script=/wasm/jsapi/assertions.js+// META: script=/wasm/jsapi/wasm-module-builder.js+// META: script=/wasm/jsapi/js-string/polyfill.js++// Generate two sets of exports, one from a polyfill implementation and another+// from the builtins provided by the host.+let polyfillExports;+let builtinExports;+setup(() => {+ // Compile a module that exports a function for each builtin that will call+ // it. We could just generate a module that re-exports the builtins, but that+ // would not catch any special codegen that could happen when direct calling+ // a known builtin function from wasm.+ const builder = new WasmModuleBuilder();+ const arrayIndex = builder.addArray(kWasmI16, true, kNoSuperType, true);+ const builtins = [+ {+ name: "test",+ params: [kWasmExternRef],+ results: [kWasmI32],+ },+ {+ name: "cast",+ params: [kWasmExternRef],+ results: [wasmRefType(kWasmExternRef)],+ },+ {+ name: "fromCharCodeArray",+ params: [wasmRefNullType(arrayIndex), kWasmI32, kWasmI32],+ results: [wasmRefType(kWasmExternRef)],+ },+ {+ name: "intoCharCodeArray",+ params: [kWasmExternRef, wasmRefNullType(arrayIndex), kWasmI32],+ results: [kWasmI32],+ },+ {+ name: "fromCharCode",+ params: [kWasmI32],+ results: [wasmRefType(kWasmExternRef)],+ },+ {+ name: "fromCodePoint",+ params: [kWasmI32],+ results: [wasmRefType(kWasmExternRef)],+ },+ {+ name: "charCodeAt",+ params: [kWasmExternRef, kWasmI32],+ results: [kWasmI32],+ },+ {+ name: "codePointAt",+ params: [kWasmExternRef, kWasmI32],+ results: [kWasmI32],+ },+ {+ name: "length",+ params: [kWasmExternRef],+ results: [kWasmI32],+ },+ {+ name: "concat",+ params: [kWasmExternRef, kWasmExternRef],+ results: [wasmRefType(kWasmExternRef)],+ },+ {+ name: "substring",+ params: [kWasmExternRef, kWasmI32, kWasmI32],+ results: [wasmRefType(kWasmExternRef)],+ },+ {+ name: "equals",+ params: [kWasmExternRef, kWasmExternRef],+ results: [kWasmI32],+ },+ {+ name: "compare",+ params: [kWasmExternRef, kWasmExternRef],+ results: [kWasmI32],+ },+ ];++ // Add a function type for each builtin+ for (let builtin of builtins) {+ builtin.type = builder.addType({+ params: builtin.params,+ results: builtin.results+ });+ }++ // Add an import for each builtin+ for (let builtin of builtins) {+ builtin.importFuncIndex = builder.addImport(+ "wasm:js-string",+ builtin.name,+ builtin.type);+ }++ // Generate an exported function to call the builtin+ for (let builtin of builtins) {+ let func = builder.addFunction(builtin.name + "Imp", builtin.type);+ func.addLocals(builtin.params.length);+ let body = [];+ for (let i = 0; i < builtin.params.length; i++) {+ body.push(kExprLocalGet);+ body.push(...wasmSignedLeb(i));+ }+ body.push(kExprCallFunction);+ body.push(...wasmSignedLeb(builtin.importFuncIndex));+ func.addBody(body);+ func.exportAs(builtin.name);+ }++ const buffer = builder.toBuffer();++ // Instantiate this module using the builtins from the host+ const builtinModule = new WebAssembly.Module(buffer, {+ builtins: ["js-string"]+ });+ const builtinInstance = new WebAssembly.Instance(builtinModule, {});+ builtinExports = builtinInstance.exports;++ // Instantiate this module using the polyfill module+ const polyfillModule = new WebAssembly.Module(buffer);+ const polyfillInstance = new WebAssembly.Instance(polyfillModule, {+ "wasm:js-string": polyfillImports+ });+ polyfillExports = polyfillInstance.exports;+});++// A helper function to assert that the behavior of two functions are the+// same.+function assert_same_behavior(funcA, funcB, ...params) {+ let resultA;+ let errA = null;+ try {+ resultA = funcA(...params);+ } catch (err) {+ errA = err;+ }++ let resultB;+ let errB = null;+ try {+ resultB = funcB(...params);+ } catch (err) {+ errB = err;+ }++ if (errA || errB) {+ assert_equals(errA === null, errB === null, errA ? errA.message : errB.message);+ assert_equals(Object.getPrototypeOf(errA), Object.getPrototypeOf(errB));+ }+ assert_equals(resultA, resultB);++ if (errA) {+ throw errA;+ }+ return resultA;+}++function assert_throws_if(func, shouldThrow, constructor) {+ let error = null;+ try {+ func();+ } catch (e) {+ error = e;+ }+ assert_equals(error !== null, shouldThrow, "shouldThrow mismatch");+ if (shouldThrow && error !== null) {+ assert_true(error instanceof constructor);+ }+}++// Constant values used in the tests below+const testStrings = [+ "",+ "a",+ "1",+ "ab",+ "hello, world",+ "\n",+ "☺",+ "☺☺",+ String.fromCodePoint(0x10000, 0x10001)+];+const testCharCodes = [1, 2, 3, 10, 0x7f, 0xff, 0xfffe, 0xffff];+const testCodePoints = [1, 2, 3, 10, 0x7f, 0xff, 0xfffe, 0xffff, 0x10000, 0x10001];+const testExternRefValues = [+ null,+ undefined,+ true,+ false,+ {x:1337},+ ["abracadabra"],+ 13.37,+ -0,+ 0x7fffffff + 0.1,+ -0x7fffffff - 0.1,+ 0x80000000 + 0.1,+ -0x80000000 - 0.1,+ 0xffffffff + 0.1,+ -0xffffffff - 0.1,+ Number.EPSILON,+ Number.MAX_SAFE_INTEGER,+ Number.MIN_SAFE_INTEGER,+ Number.MIN_VALUE,+ Number.MAX_VALUE,+ Number.NaN,+ "hi",+ 37n,+ new Number(42),+ new Boolean(true),+ Symbol("status"),+ () => 1337,+];++// Test that `test` and `cast` work on various JS values. Run all the+// other builtins and assert that they also perform equivalent type+// checks.+test(() => {+ for (let a of testExternRefValues) {+ let isString = assert_same_behavior(+ builtinExports['test'],+ polyfillExports['test'],+ a+ );++ assert_throws_if(() => assert_same_behavior(+ builtinExports['cast'],+ polyfillExports['cast'],+ a+ ), !isString, WebAssembly.RuntimeError);++ let arrayMutI16 = helperExports.createArrayMutI16(10);+ assert_throws_if(() => assert_same_behavior(+ builtinExports['intoCharCodeArray'],+ polyfillExports['intoCharCodeArray'],+ a, arrayMutI16, 0+ ), !isString, WebAssembly.RuntimeError);++ assert_throws_if(() => assert_same_behavior(+ builtinExports['charCodeAt'],+ polyfillExports['charCodeAt'],+ a, 0+ ), !isString, WebAssembly.RuntimeError);++ assert_throws_if(() => assert_same_behavior(+ builtinExports['codePointAt'],+ polyfillExports['codePointAt'],+ a, 0+ ), !isString, WebAssembly.RuntimeError);++ assert_throws_if(() => assert_same_behavior(+ builtinExports['length'],+ polyfillExports['length'],+ a+ ), !isString, WebAssembly.RuntimeError);++ assert_throws_if(() => assert_same_behavior(+ builtinExports['concat'],+ polyfillExports['concat'],+ a, a+ ), !isString, WebAssembly.RuntimeError);++ assert_throws_if(() => assert_same_behavior(+ builtinExports['substring'],+ polyfillExports['substring'],+ a, 0, 0+ ), !isString, WebAssembly.RuntimeError);++ assert_throws_if(() => assert_same_behavior(+ builtinExports['equals'],+ polyfillExports['equals'],+ a, a+ ), a !== null && !isString, WebAssembly.RuntimeError);++ if (a !== null && !isString) {+ assert_throws_if(() => assert_same_behavior(+ builtinExports['equals'],+ polyfillExports['equals'],+ null, a+ ), true, WebAssembly.RuntimeError);+ assert_throws_if(() => assert_same_behavior(+ builtinExports['equals'],+ polyfillExports['equals'],+ a, null+ ), true, WebAssembly.RuntimeError);+ }++ assert_throws_if(() => assert_same_behavior(+ builtinExports['compare'],+ polyfillExports['compare'],+ a, a+ ), !isString, WebAssembly.RuntimeError);+ }+});++// Test that `fromCharCode` works on various char codes+test(() => {+ for (let a of testCharCodes) {+ assert_same_behavior(+ builtinExports['fromCharCode'],+ polyfillExports['fromCharCode'],+ a+ );+ }+});++// Test that `fromCodePoint` works on various code points+test(() => {+ for (let a of testCodePoints) {+ assert_same_behavior(+ builtinExports['fromCodePoint'],+ polyfillExports['fromCodePoint'],+ a+ );+ }+});++// Perform tests on various strings+test(() => {+ for (let a of testStrings) {+ let length = assert_same_behavior(+ builtinExports['length'],+ polyfillExports['length'],+ a+ );++ for (let i = 0; i < length; i++) {+ let charCode = assert_same_behavior(+ builtinExports['charCodeAt'],+ polyfillExports['charCodeAt'],+ a, i+ );+ }++ for (let i = 0; i < length; i++) {+ let charCode = assert_same_behavior(+ builtinExports['codePointAt'],+ polyfillExports['codePointAt'],+ a, i+ );+ }++ let arrayMutI16 = helperExports.createArrayMutI16(length);+ assert_same_behavior(+ builtinExports['intoCharCodeArray'],+ polyfillExports['intoCharCodeArray'],+ a, arrayMutI16, 0+ );++ assert_same_behavior(+ builtinExports['fromCharCodeArray'],+ polyfillExports['fromCharCodeArray'],+ arrayMutI16, 0, length+ );++ for (let i = 0; i < length; i++) {+ for (let j = 0; j < length; j++) {+ assert_same_behavior(+ builtinExports['substring'],+ polyfillExports['substring'],+ a, i, j+ );+ }+ }+ }+});++// Test various binary operations+test(() => {+ for (let a of testStrings) {+ for (let b of testStrings) {+ assert_same_behavior(+ builtinExports['concat'],+ polyfillExports['concat'],+ a, b+ );++ assert_same_behavior(+ builtinExports['equals'],+ polyfillExports['equals'],+ a, b+ );++ assert_same_behavior(+ builtinExports['compare'],+ polyfillExports['compare'],+ a, b+ );+ }+ }+});diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/basic.any.worker.html b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/basic.any.worker.htmlnew file mode 100644index 00000000000..7948f14f7c3--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/basic.any.worker.html@@ -0,0 +1,9 @@+<!doctype html>+<meta charset=utf-8>++<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<div id=log></div>+<script>+fetch_tests_from_worker(new Worker("../../../wasm/jsapi/js-string/basic.any.worker.js"));+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/basic.any.worker.js b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/basic.any.worker.jsnew file mode 100644index 00000000000..5780345af4a--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/basic.any.worker.js@@ -0,0 +1,12 @@++self.GLOBAL = {+ isWindow: function() { return false; },+ isWorker: function() { return true; },+ isShadowRealm: function() { return false; },+};+importScripts("/resources/testharness.js");+importScripts("/wasm/jsapi/assertions.js")+importScripts("/wasm/jsapi/wasm-module-builder.js")+importScripts("/wasm/jsapi/js-string/polyfill.js")+importScripts("/wasm/jsapi/js-string/basic.any.js");+done();diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/constants.any.html b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/constants.any.htmlnew file mode 100644index 00000000000..b2e808e3f76--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/constants.any.html@@ -0,0 +1,15 @@+<!doctype html>+<meta charset=utf-8>++<script>+self.GLOBAL = {+ isWindow: function() { return true; },+ isWorker: function() { return false; },+ isShadowRealm: function() { return false; },+};+</script>+<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<script src="../../../wasm/jsapi/wasm-module-builder.js"></script>+<div id=log></div>+<script src="../../../wasm/jsapi/js-string/constants.any.js"></script>diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/constants.any.js b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/constants.any.jsnew file mode 100644index 00000000000..90cf94df76e--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/constants.any.js@@ -0,0 +1,61 @@+// META: global=window,dedicatedworker,jsshell+// META: script=/wasm/jsapi/wasm-module-builder.js++// Instantiate a module with an imported global and return the global.+function instantiateImportedGlobal(module, name, type, mutable, importedStringConstants) {+ let builder = new WasmModuleBuilder();+ builder.addImportedGlobal(module, name, type, mutable);+ builder.addExportOfKind("global", kExternalGlobal, 0);+ let bytes = builder.toBuffer();+ let mod = new WebAssembly.Module(bytes, { importedStringConstants });+ let instance = new WebAssembly.Instance(mod, {});+ return instance.exports["global"];+}++const badGlobalTypes = [+ [kWasmAnyRef, false],+ [kWasmAnyRef, true],+ [wasmRefType(kWasmAnyRef), false],+ [wasmRefType(kWasmAnyRef), true],+ [kWasmFuncRef, false],+ [kWasmFuncRef, true],+ [wasmRefType(kWasmFuncRef), false],+ [wasmRefType(kWasmFuncRef), true],+ [kWasmExternRef, true],+ [wasmRefType(kWasmExternRef), true],+];+for ([type, mutable] of badGlobalTypes) {+ test(() => {+ assert_throws_js(WebAssembly.CompileError,+ () => instantiateImportedGlobal("'", "constant", type, mutable, "'"),+ "type mismatch");+ });+}++const goodGlobalTypes = [+ [kWasmExternRef, false],+ [wasmRefType(kWasmExternRef), false],+];+const constants = [+ '',+ '\0',+ '0',+ '0'.repeat(100000),+ '\uD83D\uDE00',+];+const namespaces = [+ "",+ "'",+ "strings"+];++for (let namespace of namespaces) {+ for (let constant of constants) {+ for ([type, mutable] of goodGlobalTypes) {+ test(() => {+ let result = instantiateImportedGlobal(namespace, constant, type, mutable, namespace);+ assert_equals(result.value, constant);+ });+ }+ }+}diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/constants.any.worker.html b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/constants.any.worker.htmlnew file mode 100644index 00000000000..2278c411d9d--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/constants.any.worker.html@@ -0,0 +1,9 @@+<!doctype html>+<meta charset=utf-8>++<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<div id=log></div>+<script>+fetch_tests_from_worker(new Worker("../../../wasm/jsapi/js-string/constants.any.worker.js"));+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/constants.any.worker.js b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/constants.any.worker.jsnew file mode 100644index 00000000000..f595893ebb5--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/constants.any.worker.js@@ -0,0 +1,10 @@++self.GLOBAL = {+ isWindow: function() { return false; },+ isWorker: function() { return true; },+ isShadowRealm: function() { return false; },+};+importScripts("/resources/testharness.js");+importScripts("/wasm/jsapi/wasm-module-builder.js")+importScripts("/wasm/jsapi/js-string/constants.any.js");+done();diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/imports.any.html b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/imports.any.htmlnew file mode 100644index 00000000000..4afd6dbe229--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/imports.any.html@@ -0,0 +1,15 @@+<!doctype html>+<meta charset=utf-8>++<script>+self.GLOBAL = {+ isWindow: function() { return true; },+ isWorker: function() { return false; },+ isShadowRealm: function() { return false; },+};+</script>+<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<script src="../../../wasm/jsapi/wasm-module-builder.js"></script>+<div id=log></div>+<script src="../../../wasm/jsapi/js-string/imports.any.js"></script>diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/imports.any.js b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/imports.any.jsnew file mode 100644index 00000000000..d4e16dc47d0--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/imports.any.js@@ -0,0 +1,26 @@+// META: global=window,dedicatedworker,jsshell+// META: script=/wasm/jsapi/wasm-module-builder.js++test(() => {+ let builder = new WasmModuleBuilder();++ // Import a string constant+ builder.addImportedGlobal("constants", "constant", kWasmExternRef, false);++ // Import a builtin function+ builder.addImport(+ "wasm:js-string",+ "test",+ {params: [kWasmExternRef], results: [kWasmI32]});++ let buffer = builder.toBuffer();+ let module = new WebAssembly.Module(buffer, {+ builtins: ["js-string"],+ importedStringConstants: "constants"+ });+ let imports = WebAssembly.Module.imports(module);++ // All imports that refer to a builtin module are suppressed from import+ // reflection.+ assert_equals(imports.length, 0);+});diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/imports.any.worker.html b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/imports.any.worker.htmlnew file mode 100644index 00000000000..36c75d2f7dd--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/imports.any.worker.html@@ -0,0 +1,9 @@+<!doctype html>+<meta charset=utf-8>++<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<div id=log></div>+<script>+fetch_tests_from_worker(new Worker("../../../wasm/jsapi/js-string/imports.any.worker.js"));+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/imports.any.worker.js b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/imports.any.worker.jsnew file mode 100644index 00000000000..64d357c78ac--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/imports.any.worker.js@@ -0,0 +1,10 @@++self.GLOBAL = {+ isWindow: function() { return false; },+ isWorker: function() { return true; },+ isShadowRealm: function() { return false; },+};+importScripts("/resources/testharness.js");+importScripts("/wasm/jsapi/wasm-module-builder.js")+importScripts("/wasm/jsapi/js-string/imports.any.js");+done();diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/polyfill.js b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/polyfill.jsnew file mode 100644index 00000000000..7a00d4285d7--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/jsapi/js-string/polyfill.js@@ -0,0 +1,170 @@+// Generate some helper functions for manipulating (array (mut i16)) from JS+let helperExports;+{+ const builder = new WasmModuleBuilder();+ const arrayIndex = builder.addArray(kWasmI16, true, kNoSuperType, true);++ builder+ .addFunction("createArrayMutI16", {+ params: [kWasmI32],+ results: [kWasmAnyRef]+ })+ .addBody([+ kExprLocalGet,+ ...wasmSignedLeb(0),+ ...GCInstr(kExprArrayNewDefault),+ ...wasmSignedLeb(arrayIndex)+ ])+ .exportFunc();++ builder+ .addFunction("arrayLength", {+ params: [kWasmArrayRef],+ results: [kWasmI32]+ })+ .addBody([+ kExprLocalGet,+ ...wasmSignedLeb(0),+ ...GCInstr(kExprArrayLen)+ ])+ .exportFunc();++ builder+ .addFunction("arraySet", {+ params: [wasmRefNullType(arrayIndex), kWasmI32, kWasmI32],+ results: []+ })+ .addBody([+ kExprLocalGet,+ ...wasmSignedLeb(0),+ kExprLocalGet,+ ...wasmSignedLeb(1),+ kExprLocalGet,+ ...wasmSignedLeb(2),+ ...GCInstr(kExprArraySet),+ ...wasmSignedLeb(arrayIndex)+ ])+ .exportFunc();++ builder+ .addFunction("arrayGet", {+ params: [wasmRefNullType(arrayIndex), kWasmI32],+ results: [kWasmI32]+ })+ .addBody([+ kExprLocalGet,+ ...wasmSignedLeb(0),+ kExprLocalGet,+ ...wasmSignedLeb(1),+ ...GCInstr(kExprArrayGetU),+ ...wasmSignedLeb(arrayIndex)+ ])+ .exportFunc();++ let bytes = builder.toBuffer();+ let module = new WebAssembly.Module(bytes);+ let instance = new WebAssembly.Instance(module);++ helperExports = instance.exports;+}++function throwIfNotString(a) {+ if (typeof a !== "string") {+ throw new WebAssembly.RuntimeError();+ }+}++this.polyfillImports = {+ test: (string) => {+ if (string === null ||+ typeof string !== "string") {+ return 0;+ }+ return 1;+ },+ cast: (string) => {+ throwIfNotString(string);+ return string;+ },+ fromCharCodeArray: (array, arrayStart, arrayCount) => {+ arrayStart >>>= 0;+ arrayCount >>>= 0;+ let length = helperExports.arrayLength(array);+ if (BigInt(arrayStart) + BigInt(arrayCount) > BigInt(length)) {+ throw new WebAssembly.RuntimeError();+ }+ let result = '';+ for (let i = arrayStart; i < arrayStart + arrayCount; i++) {+ result += String.fromCharCode(helperExports.arrayGet(array, i));+ }+ return result;+ },+ intoCharCodeArray: (string, arr, arrayStart) => {+ arrayStart >>>= 0;+ throwIfNotString(string);+ let arrLength = helperExports.arrayLength(arr);+ let stringLength = string.length;+ if (BigInt(arrayStart) + BigInt(stringLength) > BigInt(arrLength)) {+ throw new WebAssembly.RuntimeError();+ }+ for (let i = 0; i < stringLength; i++) {+ helperExports.arraySet(arr, arrayStart + i, string[i].charCodeAt(0));+ }+ return stringLength;+ },+ fromCharCode: (charCode) => {+ charCode >>>= 0;+ return String.fromCharCode(charCode);+ },+ fromCodePoint: (codePoint) => {+ codePoint >>>= 0;+ return String.fromCodePoint(codePoint);+ },+ charCodeAt: (string, stringIndex) => {+ stringIndex >>>= 0;+ throwIfNotString(string);+ if (stringIndex >= string.length)+ throw new WebAssembly.RuntimeError();+ return string.charCodeAt(stringIndex);+ },+ codePointAt: (string, stringIndex) => {+ stringIndex >>>= 0;+ throwIfNotString(string);+ if (stringIndex >= string.length)+ throw new WebAssembly.RuntimeError();+ return string.codePointAt(stringIndex);+ },+ length: (string) => {+ throwIfNotString(string);+ return string.length;+ },+ concat: (stringA, stringB) => {+ throwIfNotString(stringA);+ throwIfNotString(stringB);+ return stringA + stringB;+ },+ substring: (string, startIndex, endIndex) => {+ startIndex >>>= 0;+ endIndex >>>= 0;+ throwIfNotString(string);+ if (startIndex > string.length,+ endIndex > string.length,+ endIndex < startIndex) {+ return "";+ }+ return string.substring(startIndex, endIndex);+ },+ equals: (stringA, stringB) => {+ if (stringA !== null) throwIfNotString(stringA);+ if (stringB !== null) throwIfNotString(stringB);+ return stringA === stringB;+ },+ compare: (stringA, stringB) => {+ throwIfNotString(stringA);+ throwIfNotString(stringB);+ if (stringA < stringB) {+ return -1;+ }+ return stringA === stringB ? 0 : 1;+ },+};diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.html b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.htmlnew file mode 100644index 00000000000..284d81f1ff2--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.html@@ -0,0 +1,16 @@+<!doctype html>+<meta charset=utf-8>++<script>+self.GLOBAL = {+ isWindow: function() { return true; },+ isWorker: function() { return false; },+ isShadowRealm: function() { return false; },+};+</script>+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="../../wasm/jsapi/wasm-module-builder.js"></script>+<script src="../../wasm/jsapi/bad-imports.js"></script>+<div id=log></div>+<script src="../../wasm/webapi/instantiateStreaming-bad-imports.any.js"></script>diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.js b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.jsnew file mode 100644index 00000000000..38ecc40252e--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.js@@ -0,0 +1,13 @@+// META: global=window,worker+// META: script=/wasm/jsapi/wasm-module-builder.js+// META: script=/wasm/jsapi/bad-imports.js++test_bad_imports((name, error, build, ...args) => {+ promise_test(t => {+ const builder = new WasmModuleBuilder();+ build(builder);+ const buffer = builder.toBuffer();+ const response = new Response(buffer, { "headers": { "Content-Type": "application/wasm" } });+ return promise_rejects_js(t, error, WebAssembly.instantiateStreaming(response, ...args));+ }, name);+});diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.worker.html b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.worker.htmlnew file mode 100644index 00000000000..34df06b94d8--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.worker.html@@ -0,0 +1,9 @@+<!doctype html>+<meta charset=utf-8>++<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<div id=log></div>+<script>+fetch_tests_from_worker(new Worker("../../wasm/webapi/instantiateStreaming-bad-imports.any.worker.js"));+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.worker.js b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.worker.jsnew file mode 100644index 00000000000..723e15732c0--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.worker.js@@ -0,0 +1,11 @@++self.GLOBAL = {+ isWindow: function() { return false; },+ isWorker: function() { return true; },+ isShadowRealm: function() { return false; },+};+importScripts("/resources/testharness.js");+importScripts("/wasm/jsapi/wasm-module-builder.js")+importScripts("/wasm/jsapi/bad-imports.js")+importScripts("/wasm/webapi/instantiateStreaming-bad-imports.any.js");+done();diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming.any.html b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming.any.htmlnew file mode 100644index 00000000000..0e3cd112445--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming.any.html@@ -0,0 +1,17 @@+<!doctype html>+<meta charset=utf-8>++<script>+self.GLOBAL = {+ isWindow: function() { return true; },+ isWorker: function() { return false; },+ isShadowRealm: function() { return false; },+};+</script>+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="../../wasm/jsapi/wasm-module-builder.js"></script>+<script src="../../wasm/jsapi/assertions.js"></script>+<script src="../../wasm/jsapi/instanceTestFactory.js"></script>+<div id=log></div>+<script src="../../wasm/webapi/instantiateStreaming.any.js"></script>diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming.any.js b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming.any.jsnew file mode 100644index 00000000000..cf3a5e7331f--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming.any.js@@ -0,0 +1,49 @@+// META: global=window,worker+// META: script=/wasm/jsapi/wasm-module-builder.js+// META: script=/wasm/jsapi/assertions.js+// META: script=/wasm/jsapi/instanceTestFactory.js++let emptyModuleBinary;+setup(() => {+ emptyModuleBinary = new WasmModuleBuilder().toBuffer();+});++for (const [name, fn] of instanceTestFactory) {+ promise_test(async () => {+ const { buffer, args, exports, verify } = fn();+ const response = new Response(buffer, { "headers": { "Content-Type": "application/wasm" } });+ const result = await WebAssembly.instantiateStreaming(response, ...args);+ assert_WebAssemblyInstantiatedSource(result, exports);+ verify(result.instance);+ }, name);+}++promise_test(async () => {+ const builder = new WasmModuleBuilder();+ builder.addImportedGlobal("module", "global", kWasmI32);+ const buffer = builder.toBuffer();+ const response = new Response(buffer, { "headers": { "Content-Type": "application/wasm" } });+ const order = [];++ const imports = {+ get module() {+ order.push("module getter");+ return {+ get global() {+ order.push("global getter");+ return 0;+ },+ }+ },+ };++ const expected = [+ "module getter",+ "global getter",+ ];+ const p = WebAssembly.instantiateStreaming(response, imports);+ assert_array_equals(order, []);+ const result = await p;+ assert_WebAssemblyInstantiatedSource(result, {});+ assert_array_equals(order, expected);+}, "Synchronous options handling");diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming.any.worker.html b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming.any.worker.htmlnew file mode 100644index 00000000000..07d1dd14ed3--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming.any.worker.html@@ -0,0 +1,9 @@+<!doctype html>+<meta charset=utf-8>++<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<div id=log></div>+<script>+fetch_tests_from_worker(new Worker("../../wasm/webapi/instantiateStreaming.any.worker.js"));+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming.any.worker.js b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming.any.worker.jsnew file mode 100644index 00000000000..c64f29d8c73--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/instantiateStreaming.any.worker.js@@ -0,0 +1,12 @@++self.GLOBAL = {+ isWindow: function() { return false; },+ isWorker: function() { return true; },+ isShadowRealm: function() { return false; },+};+importScripts("/resources/testharness.js");+importScripts("/wasm/jsapi/wasm-module-builder.js")+importScripts("/wasm/jsapi/assertions.js")+importScripts("/wasm/jsapi/instanceTestFactory.js")+importScripts("/wasm/webapi/instantiateStreaming.any.js");+done();diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/invalid-args.any.html b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/invalid-args.any.htmlnew file mode 100644index 00000000000..53e6eafa311--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/invalid-args.any.html@@ -0,0 +1,15 @@+<!doctype html>+<meta charset=utf-8>++<script>+self.GLOBAL = {+ isWindow: function() { return true; },+ isWorker: function() { return false; },+ isShadowRealm: function() { return false; },+};+</script>+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>++<div id=log></div>+<script src="../../wasm/webapi/invalid-args.any.js"></script>diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/invalid-args.any.js b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/invalid-args.any.jsnew file mode 100644index 00000000000..b27e018a984--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/invalid-args.any.js@@ -0,0 +1,28 @@+// META: global=window,worker++const invalidArguments = [+ [undefined],+ [null],+ [true],+ ["test"],+ [Symbol()],+ [0],+ [0.1],+ [NaN],+ [{}, "Empty object"],+ [Response, "Response interface object"],+ [Response.prototype, "Response interface prototype object"],+];++for (const method of ["compileStreaming", "instantiateStreaming"]) {+ for (const [argument, name = format_value(argument)] of invalidArguments) {+ promise_test(t => {+ return promise_rejects_js(t, TypeError, WebAssembly[method](argument));+ }, `${method}: ${name}`);++ promise_test(t => {+ const promise = Promise.resolve(argument);+ return promise_rejects_js(t, TypeError, WebAssembly[method](argument));+ }, `${method}: ${name} in a promise`);+ }+}diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/invalid-args.any.worker.html b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/invalid-args.any.worker.htmlnew file mode 100644index 00000000000..c4580f18f62--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/invalid-args.any.worker.html@@ -0,0 +1,9 @@+<!doctype html>+<meta charset=utf-8>++<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<div id=log></div>+<script>+fetch_tests_from_worker(new Worker("../../wasm/webapi/invalid-args.any.worker.js"));+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/invalid-args.any.worker.js b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/invalid-args.any.worker.jsnew file mode 100644index 00000000000..1e7167ed0d8--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/invalid-args.any.worker.js@@ -0,0 +1,10 @@++self.GLOBAL = {+ isWindow: function() { return false; },+ isWorker: function() { return true; },+ isShadowRealm: function() { return false; },+};+importScripts("/resources/testharness.js");++importScripts("/wasm/webapi/invalid-args.any.js");+done();diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/rejected-arg.any.html b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/rejected-arg.any.htmlnew file mode 100644index 00000000000..c67d48c4b62--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/rejected-arg.any.html@@ -0,0 +1,15 @@+<!doctype html>+<meta charset=utf-8>++<script>+self.GLOBAL = {+ isWindow: function() { return true; },+ isWorker: function() { return false; },+ isShadowRealm: function() { return false; },+};+</script>+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>++<div id=log></div>+<script src="../../wasm/webapi/rejected-arg.any.js"></script>diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/rejected-arg.any.js b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/rejected-arg.any.jsnew file mode 100644index 00000000000..49018db5e89--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/rejected-arg.any.js@@ -0,0 +1,9 @@+// META: global=window,worker++for (const method of ["compileStreaming", "instantiateStreaming"]) {+ promise_test(t => {+ const error = { "name": "custom error" };+ const promise = Promise.reject(error);+ return promise_rejects_exactly(t, error, WebAssembly[method](promise));+ }, `${method}`);+}diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/rejected-arg.any.worker.html b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/rejected-arg.any.worker.htmlnew file mode 100644index 00000000000..04f05533157--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/rejected-arg.any.worker.html@@ -0,0 +1,9 @@+<!doctype html>+<meta charset=utf-8>++<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<div id=log></div>+<script>+fetch_tests_from_worker(new Worker("../../wasm/webapi/rejected-arg.any.worker.js"));+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/rejected-arg.any.worker.js b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/rejected-arg.any.worker.jsnew file mode 100644index 00000000000..53993194fc9--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/wasm/webapi/rejected-arg.any.worker.js@@ -0,0 +1,10 @@++self.GLOBAL = {+ isWindow: function() { return false; },+ isWorker: function() { return true; },+ isShadowRealm: function() { return false; },+};+importScripts("/resources/testharness.js");++importScripts("/wasm/webapi/rejected-arg.any.js");+done();