From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- testing/web-platform/tests/wasm/webapi/META.yml | 1 + .../web-platform/tests/wasm/webapi/abort.any.js | 37 +++++++ testing/web-platform/tests/wasm/webapi/body.any.js | 19 ++++ .../tests/wasm/webapi/contenttype.any.js | 64 ++++++++++++ .../tests/wasm/webapi/empty-body.any.js | 20 ++++ .../esm-integration/execute-start.tentative.html | 23 +++++ .../esm-integration/exported-names.tentative.html | 17 +++ .../invalid-bytecode.tentative.html | 24 +++++ .../js-wasm-cycle-errors.tentative.html | 38 +++++++ .../esm-integration/js-wasm-cycle.tentative.html | 11 ++ .../module-parse-error.tentative.html | 24 +++++ .../wasm/webapi/esm-integration/resolve-export.js | 1 + .../esm-integration/resolve-export.tentative.html | 25 +++++ .../esm-integration/resources/execute-start.wasm | Bin 0 -> 51 bytes .../esm-integration/resources/exported-names.wasm | Bin 0 -> 73 bytes .../resources/invalid-bytecode.wasm | Bin 0 -> 14 bytes .../esm-integration/resources/invalid-module.wasm | Bin 0 -> 27 bytes .../resources/js-wasm-cycle-function-error.js | 2 + .../resources/js-wasm-cycle-function-error.wasm | Bin 0 -> 75 bytes .../resources/js-wasm-cycle-global.js | 2 + .../resources/js-wasm-cycle-global.wasm | Bin 0 -> 68 bytes .../resources/js-wasm-cycle-memory.js | 2 + .../resources/js-wasm-cycle-memory.wasm | Bin 0 -> 67 bytes .../resources/js-wasm-cycle-table.js | 2 + .../resources/js-wasm-cycle-table.wasm | Bin 0 -> 67 bytes .../resources/js-wasm-cycle-value.js | 2 + .../resources/js-wasm-cycle-value.wasm | Bin 0 -> 66 bytes .../esm-integration/resources/js-wasm-cycle.js | 13 +++ .../esm-integration/resources/js-wasm-cycle.wasm | Bin 0 -> 101 bytes .../wasm/webapi/esm-integration/resources/log.js | 1 + .../esm-integration/resources/resolve-export.wasm | Bin 0 -> 8 bytes .../resources/wasm-export-i64-global.wasm | Bin 0 -> 23 bytes .../resources/wasm-export-to-wasm.wasm | Bin 0 -> 45 bytes .../resources/wasm-import-error-from-wasm.wasm | Bin 0 -> 46 bytes .../resources/wasm-import-from-wasm.wasm | Bin 0 -> 75 bytes .../esm-integration/resources/wasm-import-func.js | 1 + .../resources/wasm-import-func.wasm | Bin 0 -> 45 bytes .../resources/wasm-import-global.js | 1 + .../resources/wasm-import-global.wasm | Bin 0 -> 40 bytes .../resources/wasm-import-memory.js | 1 + .../resources/wasm-import-memory.wasm | Bin 0 -> 41 bytes .../esm-integration/resources/wasm-import-table.js | 1 + .../resources/wasm-import-table.wasm | Bin 0 -> 40 bytes .../esm-integration/resources/wasm-js-cycle.js | 15 +++ .../esm-integration/resources/wasm-js-cycle.wasm | Bin 0 -> 294 bytes .../esm-integration/resources/worker-helper.js | 1 + .../webapi/esm-integration/resources/worker.js | 1 + .../webapi/esm-integration/resources/worker.wasm | Bin 0 -> 62 bytes .../wasm-import-wasm-export.tentative.html | 14 +++ .../esm-integration/wasm-import.tentative.html | 34 ++++++ .../esm-integration/wasm-js-cycle.tentative.html | 32 ++++++ .../wasm-to-wasm-link-error.tentative.html | 26 +++++ .../esm-integration/worker-import.tentative.html | 13 +++ .../webapi/esm-integration/worker.tentative.html | 13 +++ .../tests/wasm/webapi/historical.any.js | 29 ++++++ .../tests/wasm/webapi/idlharness.any.js | 10 ++ .../webapi/instantiateStreaming-bad-imports.any.js | 13 +++ .../tests/wasm/webapi/instantiateStreaming.any.js | 49 +++++++++ .../tests/wasm/webapi/invalid-args.any.js | 28 +++++ .../tests/wasm/webapi/invalid-code.any.js | 21 ++++ .../tests/wasm/webapi/modified-contenttype.any.js | 24 +++++ .../tests/wasm/webapi/origin.sub.any.js | 15 +++ .../tests/wasm/webapi/rejected-arg.any.js | 9 ++ .../webapi/resources/incrementer.no_mime_type.wasm | Bin 0 -> 46 bytes .../tests/wasm/webapi/resources/incrementer.wasm | Bin 0 -> 46 bytes .../wasm/webapi/resources/incrementer.wasm.headers | 2 + .../resources/incrementer.wrong_mime_type.wasm | Bin 0 -> 46 bytes .../incrementer.wrong_mime_type.wasm.headers | 2 + .../web-platform/tests/wasm/webapi/status.any.js | 21 ++++ testing/web-platform/tests/wasm/webapi/status.py | 4 + .../wasm/webapi/wasm_stream_compile_test.html | 115 +++++++++++++++++++++ .../wasm/webapi/wasm_stream_instantiate_test.html | 115 +++++++++++++++++++++ 72 files changed, 938 insertions(+) create mode 100644 testing/web-platform/tests/wasm/webapi/META.yml create mode 100644 testing/web-platform/tests/wasm/webapi/abort.any.js create mode 100644 testing/web-platform/tests/wasm/webapi/body.any.js create mode 100644 testing/web-platform/tests/wasm/webapi/contenttype.any.js create mode 100644 testing/web-platform/tests/wasm/webapi/empty-body.any.js create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/execute-start.tentative.html create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/exported-names.tentative.html create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/invalid-bytecode.tentative.html create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/js-wasm-cycle-errors.tentative.html create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/js-wasm-cycle.tentative.html create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/module-parse-error.tentative.html create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resolve-export.js create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resolve-export.tentative.html create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/execute-start.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/exported-names.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/invalid-bytecode.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/invalid-module.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-function-error.js create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-function-error.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-global.js create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-global.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-memory.js create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-memory.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-table.js create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-table.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-value.js create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-value.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle.js create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/log.js create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/resolve-export.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-export-i64-global.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-export-to-wasm.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-error-from-wasm.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-from-wasm.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-func.js create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-func.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-global.js create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-global.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-memory.js create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-memory.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-table.js create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-table.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-js-cycle.js create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-js-cycle.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker-helper.js create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker.js create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/wasm-import-wasm-export.tentative.html create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/wasm-import.tentative.html create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/wasm-js-cycle.tentative.html create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/wasm-to-wasm-link-error.tentative.html create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/worker-import.tentative.html create mode 100644 testing/web-platform/tests/wasm/webapi/esm-integration/worker.tentative.html create mode 100644 testing/web-platform/tests/wasm/webapi/historical.any.js create mode 100644 testing/web-platform/tests/wasm/webapi/idlharness.any.js create mode 100644 testing/web-platform/tests/wasm/webapi/instantiateStreaming-bad-imports.any.js create mode 100644 testing/web-platform/tests/wasm/webapi/instantiateStreaming.any.js create mode 100644 testing/web-platform/tests/wasm/webapi/invalid-args.any.js create mode 100644 testing/web-platform/tests/wasm/webapi/invalid-code.any.js create mode 100644 testing/web-platform/tests/wasm/webapi/modified-contenttype.any.js create mode 100644 testing/web-platform/tests/wasm/webapi/origin.sub.any.js create mode 100644 testing/web-platform/tests/wasm/webapi/rejected-arg.any.js create mode 100644 testing/web-platform/tests/wasm/webapi/resources/incrementer.no_mime_type.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/resources/incrementer.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/resources/incrementer.wasm.headers create mode 100644 testing/web-platform/tests/wasm/webapi/resources/incrementer.wrong_mime_type.wasm create mode 100644 testing/web-platform/tests/wasm/webapi/resources/incrementer.wrong_mime_type.wasm.headers create mode 100644 testing/web-platform/tests/wasm/webapi/status.any.js create mode 100644 testing/web-platform/tests/wasm/webapi/status.py create mode 100644 testing/web-platform/tests/wasm/webapi/wasm_stream_compile_test.html create mode 100644 testing/web-platform/tests/wasm/webapi/wasm_stream_instantiate_test.html (limited to 'testing/web-platform/tests/wasm/webapi') diff --git a/testing/web-platform/tests/wasm/webapi/META.yml b/testing/web-platform/tests/wasm/webapi/META.yml new file mode 100644 index 0000000000..69715cd7c8 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/META.yml @@ -0,0 +1 @@ +spec: https://webassembly.github.io/spec/web-api/ diff --git a/testing/web-platform/tests/wasm/webapi/abort.any.js b/testing/web-platform/tests/wasm/webapi/abort.any.js new file mode 100644 index 0000000000..f5ddd353aa --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/abort.any.js @@ -0,0 +1,37 @@ +const methods = [ + "compileStreaming", + "instantiateStreaming", +]; + +for (const method of methods) { + promise_test(async t => { + const controller = new AbortController(); + const signal = controller.signal; + controller.abort(); + const request = fetch('../incrementer.wasm', { signal }); + return promise_rejects_dom(t, 'AbortError', WebAssembly[method](request), + `${method} should reject`); + }, `${method}() on an already-aborted request should reject with AbortError`); + + promise_test(async t => { + const controller = new AbortController(); + const signal = controller.signal; + const request = fetch('../incrementer.wasm', { signal }); + const promise = WebAssembly[method](request); + controller.abort(); + return promise_rejects_dom(t, 'AbortError', promise, `${method} should reject`); + }, `${method}() synchronously followed by abort should reject with AbortError`); + + promise_test(async t => { + const controller = new AbortController(); + const signal = controller.signal; + return fetch('../incrementer.wasm', { signal }) + .then(response => { + Promise.resolve().then(() => controller.abort()); + return WebAssembly[method](response); + }) + .catch(err => { + assert_equals(err.name, "AbortError"); + }); + }, `${method}() asynchronously racing with abort should succeed or reject with AbortError`); +} diff --git a/testing/web-platform/tests/wasm/webapi/body.any.js b/testing/web-platform/tests/wasm/webapi/body.any.js new file mode 100644 index 0000000000..4db7e8d123 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/body.any.js @@ -0,0 +1,19 @@ +// META: global=window,worker +// META: script=/wasm/jsapi/wasm-module-builder.js + +for (const method of ["compileStreaming", "instantiateStreaming"]) { + promise_test(t => { + const buffer = new WasmModuleBuilder().toBuffer(); + const argument = new Response(buffer, { headers: { "Content-Type": "application/wasm" } }); + argument.arrayBuffer(); + return promise_rejects_js(t, TypeError, WebAssembly[method](argument)); + }, `${method} after consumption`); + + promise_test(t => { + const buffer = new WasmModuleBuilder().toBuffer(); + const argument = new Response(buffer, { headers: { "Content-Type": "application/wasm" } }); + const promise = WebAssembly[method](argument); + argument.arrayBuffer(); + return promise_rejects_js(t, TypeError, promise); + }, `${method} before consumption`); +} diff --git a/testing/web-platform/tests/wasm/webapi/contenttype.any.js b/testing/web-platform/tests/wasm/webapi/contenttype.any.js new file mode 100644 index 0000000000..0a2f5f1122 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/contenttype.any.js @@ -0,0 +1,64 @@ +// META: global=window,worker +// META: script=/wasm/jsapi/assertions.js + +promise_test(t => { + const response = fetch("/wasm/incrementer.wasm").then(res => new Response(res.body)); + return promise_rejects_js(t, TypeError, WebAssembly.compileStreaming(response)); +}, "Response with no Content-Type: compileStreaming"); + +promise_test(t => { + const response = fetch("/wasm/incrementer.wasm").then(res => new Response(res.body)); + return promise_rejects_js(t, TypeError, WebAssembly.instantiateStreaming(response)); +}, "Response with no Content-Type: instantiateStreaming"); + +const invalidContentTypes = [ + "", + "application/javascript", + "application/octet-stream", + "text/wasm", + "application/wasm;", + "application/wasm;x", + "application/wasm;charset=UTF-8", +]; + +for (const contenttype of invalidContentTypes) { + promise_test(t => { + const response = fetch(`/wasm/incrementer.wasm?pipe=header(Content-Type,${encodeURIComponent(contenttype)})`); + return promise_rejects_js(t, TypeError, WebAssembly.compileStreaming(response)); + }, `Response with Content-Type ${format_value(contenttype)}: compileStreaming`); + + promise_test(t => { + const response = fetch(`/wasm/incrementer.wasm?pipe=header(Content-Type,${encodeURIComponent(contenttype)})`); + return promise_rejects_js(t, TypeError, WebAssembly.instantiateStreaming(response)); + }, `Response with Content-Type ${format_value(contenttype)}: instantiateStreaming`); +} + +const validContentTypes = [ + "application/wasm", + "APPLICATION/wasm", + "APPLICATION/WASM", +]; + +for (const contenttype of validContentTypes) { + promise_test(async t => { + const response = fetch(`/wasm/incrementer.wasm?pipe=header(Content-Type,${encodeURIComponent(contenttype)})`); + const module = await WebAssembly.compileStreaming(response); + assert_equals(Object.getPrototypeOf(module), WebAssembly.Module.prototype, + "prototype"); + }, `Response with Content-Type ${format_value(contenttype)}: compileStreaming`); + + promise_test(async t => { + const response = fetch(`/wasm/incrementer.wasm?pipe=header(Content-Type,${encodeURIComponent(contenttype)})`); + const result = await WebAssembly.instantiateStreaming(response); + assert_WebAssemblyInstantiatedSource( + result, + { + "increment": { + "kind": "function", + "name": "0", + "length": 1 + } + } + ); + }, `Response with Content-Type ${format_value(contenttype)}: instantiateStreaming`); +} diff --git a/testing/web-platform/tests/wasm/webapi/empty-body.any.js b/testing/web-platform/tests/wasm/webapi/empty-body.any.js new file mode 100644 index 0000000000..0771647b70 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/empty-body.any.js @@ -0,0 +1,20 @@ +// META: global=window,worker + +const invalidArguments = [ + [() => new Response(undefined, { headers: { "Content-Type": "application/wasm" } }), "no body"], + [() => new Response("", { headers: { "Content-Type": "application/wasm" } }), "empty body"], +]; + +for (const method of ["compileStreaming", "instantiateStreaming"]) { + for (const [argumentFactory, name] of invalidArguments) { + promise_test(t => { + const argument = argumentFactory(); + return promise_rejects_js(t, WebAssembly.CompileError, WebAssembly[method](argument)); + }, `${method}: ${name}`); + + promise_test(t => { + const argument = Promise.resolve(argumentFactory()); + return promise_rejects_js(t, WebAssembly.CompileError, WebAssembly[method](argument)); + }, `${method}: ${name} in a promise`); + } +} diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/execute-start.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/execute-start.tentative.html new file mode 100644 index 0000000000..a35adbe8eb --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/execute-start.tentative.html @@ -0,0 +1,23 @@ + +Check execution of WebAssembly start function + + + + + diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/exported-names.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/exported-names.tentative.html new file mode 100644 index 0000000000..16a9c59787 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/exported-names.tentative.html @@ -0,0 +1,17 @@ + +Exported names from a WebAssembly module + + + + diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/invalid-bytecode.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/invalid-bytecode.tentative.html new file mode 100644 index 0000000000..0e447dbee5 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/invalid-bytecode.tentative.html @@ -0,0 +1,24 @@ + +Handling of importing invalid WebAssembly modules + + + + + + diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/js-wasm-cycle-errors.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/js-wasm-cycle-errors.tentative.html new file mode 100644 index 0000000000..f45e06ece5 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/js-wasm-cycle-errors.tentative.html @@ -0,0 +1,38 @@ + +Cyclic linking between JavaScript and WebAssembly (JS higher) + + + + + + + + + diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/js-wasm-cycle.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/js-wasm-cycle.tentative.html new file mode 100644 index 0000000000..38b0d3203c --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/js-wasm-cycle.tentative.html @@ -0,0 +1,11 @@ + +Check bindings in JavaScript and WebAssembly cycle (JS higher) + + + + diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/module-parse-error.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/module-parse-error.tentative.html new file mode 100644 index 0000000000..0e447dbee5 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/module-parse-error.tentative.html @@ -0,0 +1,24 @@ + +Handling of importing invalid WebAssembly modules + + + + + + diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resolve-export.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resolve-export.js new file mode 100644 index 0000000000..e0dcf493f8 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resolve-export.js @@ -0,0 +1 @@ +export { f } from "./resources/resolve-export.wasm"; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resolve-export.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/resolve-export.tentative.html new file mode 100644 index 0000000000..1468822102 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resolve-export.tentative.html @@ -0,0 +1,25 @@ + +Check ResolveExport on invalid re-export from WebAssembly + + + + + diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/execute-start.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/execute-start.wasm new file mode 100644 index 0000000000..ecfdda1f9a Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/execute-start.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/exported-names.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/exported-names.wasm new file mode 100644 index 0000000000..ebffad193c Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/exported-names.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/invalid-bytecode.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/invalid-bytecode.wasm new file mode 100644 index 0000000000..1ae8b721f3 Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/invalid-bytecode.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/invalid-module.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/invalid-module.wasm new file mode 100644 index 0000000000..dd711f0953 Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/invalid-module.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-function-error.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-function-error.js new file mode 100644 index 0000000000..06cb8a0ad9 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-function-error.js @@ -0,0 +1,2 @@ +export const func = 42; +import { f } from "./js-wasm-cycle-function-error.wasm"; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-function-error.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-function-error.wasm new file mode 100644 index 0000000000..b89d94dde7 Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-function-error.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-global.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-global.js new file mode 100644 index 0000000000..1f375b8ce1 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-global.js @@ -0,0 +1,2 @@ +export const glob = new WebAssembly.Global({ value: "i32" }, 42); +import { f } from "./js-wasm-cycle-global.wasm"; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-global.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-global.wasm new file mode 100644 index 0000000000..2a9017f87b Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-global.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-memory.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-memory.js new file mode 100644 index 0000000000..92e37a86ac --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-memory.js @@ -0,0 +1,2 @@ +export const mem = new WebAssembly.Memory({ initial: 10 }); +import { f } from "./js-wasm-cycle-memory.wasm"; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-memory.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-memory.wasm new file mode 100644 index 0000000000..e699a9b3c4 Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-memory.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-table.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-table.js new file mode 100644 index 0000000000..5d6794489f --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-table.js @@ -0,0 +1,2 @@ +export const tab = new WebAssembly.Table({ element: "anyfunc" }); +import { f } from "./js-wasm-cycle-table.wasm"; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-table.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-table.wasm new file mode 100644 index 0000000000..ec4883e652 Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-table.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-value.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-value.js new file mode 100644 index 0000000000..f7b0d62080 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-value.js @@ -0,0 +1,2 @@ +export const val = 42; +import { f } from "./js-wasm-cycle-value.wasm"; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-value.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-value.wasm new file mode 100644 index 0000000000..083409e260 Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-value.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle.js new file mode 100644 index 0000000000..8ee579e2ad --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle.js @@ -0,0 +1,13 @@ +function f() { return 42; } +export { f }; + +import { mem, tab, glob, func } from "./js-wasm-cycle.wasm"; +assert_true(glob instanceof WebAssembly.Global); +assert_equals(glob.valueOf(), 1); +assert_true(mem instanceof WebAssembly.Memory); +assert_true(tab instanceof WebAssembly.Table); +assert_true(func instanceof Function); + +f = () => { return 24 }; + +assert_equals(func(), 42); diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle.wasm new file mode 100644 index 0000000000..77a3b86ab6 Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/log.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/log.js new file mode 100644 index 0000000000..0c4f5ed519 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/log.js @@ -0,0 +1 @@ +export function logExec() { log.push("executed"); } diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/resolve-export.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/resolve-export.wasm new file mode 100644 index 0000000000..d8fc92d022 Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/resolve-export.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-export-i64-global.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-export-i64-global.wasm new file mode 100644 index 0000000000..f9f0cf2799 Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-export-i64-global.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-export-to-wasm.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-export-to-wasm.wasm new file mode 100644 index 0000000000..0ee948f96f Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-export-to-wasm.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-error-from-wasm.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-error-from-wasm.wasm new file mode 100644 index 0000000000..c27bcb068d Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-error-from-wasm.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-from-wasm.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-from-wasm.wasm new file mode 100644 index 0000000000..652ff14310 Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-from-wasm.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-func.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-func.js new file mode 100644 index 0000000000..78982c32dc --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-func.js @@ -0,0 +1 @@ +export let f = 5; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-func.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-func.wasm new file mode 100644 index 0000000000..2f23c58520 Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-func.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-global.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-global.js new file mode 100644 index 0000000000..4258cd2d7d --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-global.js @@ -0,0 +1 @@ +export let g = 5; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-global.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-global.wasm new file mode 100644 index 0000000000..2f8bd77940 Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-global.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-memory.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-memory.js new file mode 100644 index 0000000000..4cee889838 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-memory.js @@ -0,0 +1 @@ +export let m = 5; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-memory.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-memory.wasm new file mode 100644 index 0000000000..d9474047cd Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-memory.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-table.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-table.js new file mode 100644 index 0000000000..ca823646cb --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-table.js @@ -0,0 +1 @@ +export let t = 5; diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-table.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-table.wasm new file mode 100644 index 0000000000..8ccc8be7f2 Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-table.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-js-cycle.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-js-cycle.js new file mode 100644 index 0000000000..161edab4f6 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-js-cycle.js @@ -0,0 +1,15 @@ +import * as mod from "./wasm-js-cycle.wasm"; + +let jsGlob = new WebAssembly.Global({ value: "i32", mutable: true }, 42); +let jsMem = new WebAssembly.Memory({ initial: 10 }); +let jsTab = new WebAssembly.Table({ initial: 10, element: "anyfunc" }); +let jsFunc = () => { return 42; }; + +export { jsGlob, jsMem, jsTab, jsFunc }; + +export function mutateBindings() { + jsGlob = 0; + jsMem = 0; + jsTab = 0; + jsFunc = 0; +} diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-js-cycle.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-js-cycle.wasm new file mode 100644 index 0000000000..b700377b27 Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-js-cycle.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker-helper.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker-helper.js new file mode 100644 index 0000000000..277bb4c1ea --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker-helper.js @@ -0,0 +1 @@ +export function pm(x) { postMessage(x); } diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker.js b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker.js new file mode 100644 index 0000000000..c72464f71a --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker.js @@ -0,0 +1 @@ +import * as mod from "./worker.wasm" diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker.wasm b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker.wasm new file mode 100644 index 0000000000..e942dc54ac Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-import-wasm-export.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-import-wasm-export.tentative.html new file mode 100644 index 0000000000..3761a22f21 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-import-wasm-export.tentative.html @@ -0,0 +1,14 @@ + +Check import and export between WebAssembly modules + + + + diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-import.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-import.tentative.html new file mode 100644 index 0000000000..243cfd46e4 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-import.tentative.html @@ -0,0 +1,34 @@ + +Errors for imports of WebAssembly modules + + + + + + + + diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-js-cycle.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-js-cycle.tentative.html new file mode 100644 index 0000000000..298d4d40b0 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-js-cycle.tentative.html @@ -0,0 +1,32 @@ + +Check bindings in JavaScript and WebAssembly cycle (Wasm higher) + + + + diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-to-wasm-link-error.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-to-wasm-link-error.tentative.html new file mode 100644 index 0000000000..6c43e72b09 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/wasm-to-wasm-link-error.tentative.html @@ -0,0 +1,26 @@ + +Errors for linking WebAssembly module scripts + + + + + diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/worker-import.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/worker-import.tentative.html new file mode 100644 index 0000000000..739f2d3f28 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/worker-import.tentative.html @@ -0,0 +1,13 @@ + +Testing import of WebAssembly from JavaScript worker + + + + diff --git a/testing/web-platform/tests/wasm/webapi/esm-integration/worker.tentative.html b/testing/web-platform/tests/wasm/webapi/esm-integration/worker.tentative.html new file mode 100644 index 0000000000..8002e07ce7 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/esm-integration/worker.tentative.html @@ -0,0 +1,13 @@ + +Testing WebAssembly worker + + + + diff --git a/testing/web-platform/tests/wasm/webapi/historical.any.js b/testing/web-platform/tests/wasm/webapi/historical.any.js new file mode 100644 index 0000000000..257112c416 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/historical.any.js @@ -0,0 +1,29 @@ +// META: global=window,worker + +promise_test(async t => { + const db_name = "WebAssembly"; + const obj_store = "store"; + const module_key = "module"; + + await new Promise((resolve, reject) => { + const delete_request = indexedDB.deleteDatabase(db_name); + delete_request.onsuccess = resolve; + delete_request.onerror = reject; + }); + + const db = await new Promise((resolve, reject) => { + const open_request = indexedDB.open(db_name); + open_request.onupgradeneeded = function() { + open_request.result.createObjectStore(obj_store); + }; + open_request.onsuccess = function() { + resolve(open_request.result); + }; + open_request.onerror = reject; + }); + + const mod = await WebAssembly.compileStreaming(fetch('../incrementer.wasm')); + const tx = db.transaction(obj_store, 'readwrite'); + const store = tx.objectStore(obj_store); + assert_throws_dom("DataCloneError", () => store.put(mod, module_key)); +}); diff --git a/testing/web-platform/tests/wasm/webapi/idlharness.any.js b/testing/web-platform/tests/wasm/webapi/idlharness.any.js new file mode 100644 index 0000000000..0c4669e6ca --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/idlharness.any.js @@ -0,0 +1,10 @@ +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js + +"use strict"; + +idl_test( + ["wasm-web-api"], + ["wasm-js-api"], + idl_array => {} +); diff --git a/testing/web-platform/tests/wasm/webapi/instantiateStreaming-bad-imports.any.js b/testing/web-platform/tests/wasm/webapi/instantiateStreaming-bad-imports.any.js new file mode 100644 index 0000000000..38ecc40252 --- /dev/null +++ b/testing/web-platform/tests/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/testing/web-platform/tests/wasm/webapi/instantiateStreaming.any.js b/testing/web-platform/tests/wasm/webapi/instantiateStreaming.any.js new file mode 100644 index 0000000000..cf3a5e7331 --- /dev/null +++ b/testing/web-platform/tests/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/testing/web-platform/tests/wasm/webapi/invalid-args.any.js b/testing/web-platform/tests/wasm/webapi/invalid-args.any.js new file mode 100644 index 0000000000..b27e018a98 --- /dev/null +++ b/testing/web-platform/tests/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/testing/web-platform/tests/wasm/webapi/invalid-code.any.js b/testing/web-platform/tests/wasm/webapi/invalid-code.any.js new file mode 100644 index 0000000000..37373d4997 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/invalid-code.any.js @@ -0,0 +1,21 @@ +// META: global=window,worker +// META: script=/wasm/jsapi/wasm-module-builder.js + +let emptyModuleBinary; +setup(() => { + emptyModuleBinary = new WasmModuleBuilder().toBuffer(); +}); + +for (const method of ["compileStreaming", "instantiateStreaming"]) { + promise_test(t => { + const buffer = new Uint8Array(Array.from(emptyModuleBinary).concat([0, 0])); + const response = new Response(buffer, { headers: { "Content-Type": "application/wasm" } }); + return promise_rejects_js(t, WebAssembly.CompileError, WebAssembly[method](response)); + }, `Invalid code (0x0000): ${method}`); + + promise_test(t => { + const buffer = new Uint8Array(Array.from(emptyModuleBinary).concat([0xCA, 0xFE])); + const response = new Response(buffer, { headers: { "Content-Type": "application/wasm" } }); + return promise_rejects_js(t, WebAssembly.CompileError, WebAssembly[method](response)); + }, `Invalid code (0xCAFE): ${method}`); +} diff --git a/testing/web-platform/tests/wasm/webapi/modified-contenttype.any.js b/testing/web-platform/tests/wasm/webapi/modified-contenttype.any.js new file mode 100644 index 0000000000..354930517c --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/modified-contenttype.any.js @@ -0,0 +1,24 @@ +// META: global=window,worker +// META: script=/wasm/jsapi/wasm-module-builder.js + +["compileStreaming", "instantiateStreaming"].forEach(method => { + promise_test(async t => { + const buffer = new WasmModuleBuilder().toBuffer(); + const argument = new Response(buffer, { headers: { "Content-Type": "test/test" } }); + argument.headers.set("Content-Type", "application/wasm"); + // This should resolve successfully + await WebAssembly[method](argument); + // Ensure body can only be read once + return promise_rejects_js(t, TypeError, argument.blob()); + }, `${method} with Content-Type set late`); + + promise_test(async t => { + const buffer = new WasmModuleBuilder().toBuffer(); + const argument = new Response(buffer, { headers: { "Content-Type": "application/wasm" } }); + argument.headers.delete("Content-Type"); + // Ensure Wasm cannot be created + await promise_rejects_js(t, TypeError, WebAssembly[method](argument)); + // This should resolve successfully + await argument.arrayBuffer(); + }, `${method} with Content-Type removed late`); +}); diff --git a/testing/web-platform/tests/wasm/webapi/origin.sub.any.js b/testing/web-platform/tests/wasm/webapi/origin.sub.any.js new file mode 100644 index 0000000000..bf7901eedd --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/origin.sub.any.js @@ -0,0 +1,15 @@ +// META: global=window,worker + +for (const method of ["compileStreaming", "instantiateStreaming"]) { + promise_test(t => { + const url = "http://{{domains[www]}}:{{ports[http][0]}}/wasm/incrementer.wasm"; + const response = fetch(url, { "mode": "no-cors" }); + return promise_rejects_js(t, TypeError, WebAssembly[method](response)); + }, `Opaque response: ${method}`); + + promise_test(t => { + const url = "/fetch/api/resources/redirect.py?redirect_status=301&location=/wasm/incrementer.wasm"; + const response = fetch(url, { "mode": "no-cors", "redirect": "manual" }); + return promise_rejects_js(t, TypeError, WebAssembly[method](response)); + }, `Opaque redirect response: ${method}`); +} diff --git a/testing/web-platform/tests/wasm/webapi/rejected-arg.any.js b/testing/web-platform/tests/wasm/webapi/rejected-arg.any.js new file mode 100644 index 0000000000..49018db5e8 --- /dev/null +++ b/testing/web-platform/tests/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/testing/web-platform/tests/wasm/webapi/resources/incrementer.no_mime_type.wasm b/testing/web-platform/tests/wasm/webapi/resources/incrementer.no_mime_type.wasm new file mode 100644 index 0000000000..47afcdef2a Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/resources/incrementer.no_mime_type.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/resources/incrementer.wasm b/testing/web-platform/tests/wasm/webapi/resources/incrementer.wasm new file mode 100644 index 0000000000..47afcdef2a Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/resources/incrementer.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/resources/incrementer.wasm.headers b/testing/web-platform/tests/wasm/webapi/resources/incrementer.wasm.headers new file mode 100644 index 0000000000..76b9c163b6 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/resources/incrementer.wasm.headers @@ -0,0 +1,2 @@ +Content-Type: application/wasm +Cache-Control: max-age=3600 diff --git a/testing/web-platform/tests/wasm/webapi/resources/incrementer.wrong_mime_type.wasm b/testing/web-platform/tests/wasm/webapi/resources/incrementer.wrong_mime_type.wasm new file mode 100644 index 0000000000..47afcdef2a Binary files /dev/null and b/testing/web-platform/tests/wasm/webapi/resources/incrementer.wrong_mime_type.wasm differ diff --git a/testing/web-platform/tests/wasm/webapi/resources/incrementer.wrong_mime_type.wasm.headers b/testing/web-platform/tests/wasm/webapi/resources/incrementer.wrong_mime_type.wasm.headers new file mode 100644 index 0000000000..833ee71634 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/resources/incrementer.wrong_mime_type.wasm.headers @@ -0,0 +1,2 @@ +Content-Type: text/css +Cache-Control: max-age=3600 diff --git a/testing/web-platform/tests/wasm/webapi/status.any.js b/testing/web-platform/tests/wasm/webapi/status.any.js new file mode 100644 index 0000000000..f3859646cc --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/status.any.js @@ -0,0 +1,21 @@ +// META: global=window,worker + +const statuses = [ + 0, + 300, + 400, + 404, + 500, + 600, + 700, + 999, +]; + +for (const method of ["compileStreaming", "instantiateStreaming"]) { + for (const status of statuses) { + promise_test(t => { + const response = fetch(`status.py?status=${status}`); + return promise_rejects_js(t, TypeError, WebAssembly[method](response)); + }, `Response with status ${status}: ${method}`); + } +} diff --git a/testing/web-platform/tests/wasm/webapi/status.py b/testing/web-platform/tests/wasm/webapi/status.py new file mode 100644 index 0000000000..9f056678c1 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/status.py @@ -0,0 +1,4 @@ +def main(request, response): + status = int(request.GET[b"status"]) + module = b"\0asm\1\0\0\0" + return status, [(b"Content-Type", b"application/wasm")], module diff --git a/testing/web-platform/tests/wasm/webapi/wasm_stream_compile_test.html b/testing/web-platform/tests/wasm/webapi/wasm_stream_compile_test.html new file mode 100644 index 0000000000..790410e425 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/wasm_stream_compile_test.html @@ -0,0 +1,115 @@ + + +WebAssembly.compileStreaming + + + + diff --git a/testing/web-platform/tests/wasm/webapi/wasm_stream_instantiate_test.html b/testing/web-platform/tests/wasm/webapi/wasm_stream_instantiate_test.html new file mode 100644 index 0000000000..f39f650495 --- /dev/null +++ b/testing/web-platform/tests/wasm/webapi/wasm_stream_instantiate_test.html @@ -0,0 +1,115 @@ + + +WebAssembly.instantiateStreaming + + + + -- cgit v1.2.3