summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/wasm/webapi
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/wasm/webapi')
-rw-r--r--testing/web-platform/tests/wasm/webapi/META.yml1
-rw-r--r--testing/web-platform/tests/wasm/webapi/abort.any.js37
-rw-r--r--testing/web-platform/tests/wasm/webapi/body.any.js19
-rw-r--r--testing/web-platform/tests/wasm/webapi/contenttype.any.js64
-rw-r--r--testing/web-platform/tests/wasm/webapi/empty-body.any.js20
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/execute-start.tentative.html23
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/exported-names.tentative.html17
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/invalid-bytecode.tentative.html24
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/js-wasm-cycle-errors.tentative.html38
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/js-wasm-cycle.tentative.html11
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/module-parse-error.tentative.html24
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resolve-export.js1
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resolve-export.tentative.html25
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/execute-start.wasmbin0 -> 51 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/exported-names.wasmbin0 -> 73 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/invalid-bytecode.wasmbin0 -> 14 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/invalid-module.wasmbin0 -> 27 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-function-error.js2
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-function-error.wasmbin0 -> 75 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-global.js2
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-global.wasmbin0 -> 68 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-memory.js2
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-memory.wasmbin0 -> 67 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-table.js2
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-table.wasmbin0 -> 67 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-value.js2
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-value.wasmbin0 -> 66 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle.js13
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle.wasmbin0 -> 101 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/log.js1
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/resolve-export.wasmbin0 -> 8 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-export-i64-global.wasmbin0 -> 23 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-export-to-wasm.wasmbin0 -> 45 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-error-from-wasm.wasmbin0 -> 46 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-from-wasm.wasmbin0 -> 75 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-func.js1
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-func.wasmbin0 -> 45 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-global.js1
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-global.wasmbin0 -> 40 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-memory.js1
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-memory.wasmbin0 -> 41 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-table.js1
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-table.wasmbin0 -> 40 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-js-cycle.js15
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-js-cycle.wasmbin0 -> 294 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker-helper.js1
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker.js1
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker.wasmbin0 -> 62 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/wasm-import-wasm-export.tentative.html14
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/wasm-import.tentative.html34
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/wasm-js-cycle.tentative.html32
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/wasm-to-wasm-link-error.tentative.html26
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/worker-import.tentative.html13
-rw-r--r--testing/web-platform/tests/wasm/webapi/esm-integration/worker.tentative.html13
-rw-r--r--testing/web-platform/tests/wasm/webapi/historical.any.js29
-rw-r--r--testing/web-platform/tests/wasm/webapi/idlharness.any.js10
-rw-r--r--testing/web-platform/tests/wasm/webapi/instantiateStreaming-bad-imports.any.js13
-rw-r--r--testing/web-platform/tests/wasm/webapi/instantiateStreaming.any.js49
-rw-r--r--testing/web-platform/tests/wasm/webapi/invalid-args.any.js28
-rw-r--r--testing/web-platform/tests/wasm/webapi/invalid-code.any.js21
-rw-r--r--testing/web-platform/tests/wasm/webapi/modified-contenttype.any.js24
-rw-r--r--testing/web-platform/tests/wasm/webapi/origin.sub.any.js15
-rw-r--r--testing/web-platform/tests/wasm/webapi/rejected-arg.any.js9
-rw-r--r--testing/web-platform/tests/wasm/webapi/resources/incrementer.no_mime_type.wasmbin0 -> 46 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/resources/incrementer.wasmbin0 -> 46 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/resources/incrementer.wasm.headers2
-rw-r--r--testing/web-platform/tests/wasm/webapi/resources/incrementer.wrong_mime_type.wasmbin0 -> 46 bytes
-rw-r--r--testing/web-platform/tests/wasm/webapi/resources/incrementer.wrong_mime_type.wasm.headers2
-rw-r--r--testing/web-platform/tests/wasm/webapi/status.any.js21
-rw-r--r--testing/web-platform/tests/wasm/webapi/status.py4
-rw-r--r--testing/web-platform/tests/wasm/webapi/wasm_stream_compile_test.html115
-rw-r--r--testing/web-platform/tests/wasm/webapi/wasm_stream_instantiate_test.html115
72 files changed, 938 insertions, 0 deletions
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 @@
+<!DOCTYPE html>
+<title>Check execution of WebAssembly start function</title>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+ setup({allow_uncaught_exception: true});
+
+ const test_load = async_test(
+ "Importing a WebAssembly module should execute the start function.");
+
+ window.log = [];
+ window.addEventListener("error", ev => {
+ log.push(ev.message);
+ });
+
+ window.addEventListener("load", test_load.step_func_done(ev => {
+ assert_array_equals(log, ["executed"]);
+ }));
+
+ function unreachable() { log.push("unexpected"); }
+</script>
+<script type="module" src="./resources/execute-start.wasm" onerror="unreachable()""></script>
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 @@
+<!doctype html>
+<title>Exported names from a WebAssembly module</title>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script type=module>
+setup({ single_test: true });
+import * as mod from "./resources/exported-names.wasm";
+assert_array_equals(Object.getOwnPropertyNames(mod).sort(),
+ ["func", "glob", "mem", "tab"]);
+assert_true(mod.func instanceof Function);
+assert_true(mod.mem instanceof WebAssembly.Memory);
+assert_true(mod.glob instanceof WebAssembly.Global);
+assert_true(mod.tab instanceof WebAssembly.Table);
+assert_throws_js(TypeError, () => { mod.func = 2; });
+done();
+</script>
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 @@
+<!DOCTYPE html>
+<title>Handling of importing invalid WebAssembly modules</title>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+ setup({allow_uncaught_exception: true});
+
+ window.log = [];
+
+ window.addEventListener("error", ev => log.push(ev.error));
+
+ const test_load = async_test(
+ "Test that imports of invalid WebAssembly modules leads to WebAssembly.CompileError on window.");
+ window.addEventListener("load", test_load.step_func_done(ev => {
+ assert_equals(log.length, 2);
+ assert_equals(log[0].constructor, WebAssembly.CompileError);
+ assert_equals(log[1].constructor, WebAssembly.CompileError);
+ }));
+
+ function unreachable() { log.push("unexpected"); }
+</script>
+<script type="module" src="./resources/invalid-bytecode.wasm" onerror="unreachable()"></script>
+<script type="module" src="./resources/invalid-module.wasm" onerror="unreachable()"></script>
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 @@
+<!doctype html>
+<title>Cyclic linking between JavaScript and WebAssembly (JS higher)</title>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+ setup({allow_uncaught_exception: true});
+
+ const test_load = async_test(
+ "Check cyclic linking between JavaScript and WebAssembly where JavaScript is higher in the module graph.");
+
+ window.log = [];
+ window.addEventListener("error", ev => {
+ test_load.step(() => assert_equals(ev.error.constructor, WebAssembly.LinkError));
+ log.push(ev.message);
+ });
+
+ window.addEventListener("load", test_load.step_func_done(ev => {
+ assert_equals(log.length, 10);
+ assert_equals(log[1], 1);
+ assert_equals(log[3], 2);
+ assert_equals(log[5], 3);
+ assert_equals(log[7], 4);
+ assert_equals(log[9], 5);
+ }));
+
+ function unreachable() { log.push("unexpected"); }
+</script>
+<script type="module" src="./resources/js-wasm-cycle-value.js"
+ onerror="unreachable()" onload="log.push(1)"></script>
+<script type="module" src="./resources/js-wasm-cycle-global.js"
+ onerror="unreachable()" onload="log.push(2)"></script>
+<script type="module" src="./resources/js-wasm-cycle-memory.js"
+ onerror="unreachable()" onload="log.push(3)"></script>
+<script type="module" src="./resources/js-wasm-cycle-table.js"
+ onerror="unreachable()" onload="log.push(4)"></script>
+<script type="module" src="./resources/js-wasm-cycle-function-error.js"
+ onerror="unreachable()" onload="log.push(5)"></script>
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 @@
+<!doctype html>
+<title>Check bindings in JavaScript and WebAssembly cycle (JS higher)</title>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script type=module>
+setup({ single_test: true });
+import { f } from "./resources/js-wasm-cycle.js";
+assert_equals(f(), 24);
+done();
+</script>
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 @@
+<!DOCTYPE html>
+<title>Handling of importing invalid WebAssembly modules</title>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+ setup({allow_uncaught_exception: true});
+
+ window.log = [];
+
+ window.addEventListener("error", ev => log.push(ev.error));
+
+ const test_load = async_test(
+ "Test that imports of invalid WebAssembly modules leads to WebAssembly.CompileError on window.");
+ window.addEventListener("load", test_load.step_func_done(ev => {
+ assert_equals(log.length, 2);
+ assert_equals(log[0].constructor, WebAssembly.CompileError);
+ assert_equals(log[1].constructor, WebAssembly.CompileError);
+ }));
+
+ function unreachable() { log.push("unexpected"); }
+</script>
+<script type="module" src="./resources/invalid-bytecode.wasm" onerror="unreachable()"></script>
+<script type="module" src="./resources/invalid-module.wasm" onerror="unreachable()"></script>
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 @@
+<!DOCTYPE html>
+<title>Check ResolveExport on invalid re-export from WebAssembly</title>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+ setup({allow_uncaught_exception: true});
+
+ const test_load = async_test(
+ "Re-export of missing Wasm export should result in SyntaxError.");
+
+ window.log = [];
+ window.addEventListener("error", ev => {
+ test_load.step(() => assert_equals(ev.error.constructor, SyntaxError));
+ log.push(ev.message);
+ });
+
+ window.addEventListener("load", test_load.step_func_done(ev => {
+ assert_equals(log[1], 1);
+ }));
+
+ function unreachable() { log.push("unexpected"); }
+</script>
+<script type="module" src="./resolve-export.js"
+ onerror="unreachable()" onload="log.push(1)"></script>
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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/execute-start.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/exported-names.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/invalid-bytecode.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/invalid-module.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-function-error.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-global.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-memory.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-table.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle-value.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/js-wasm-cycle.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/resolve-export.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-export-i64-global.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-export-to-wasm.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-error-from-wasm.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-from-wasm.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-func.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-global.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-memory.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-import-table.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/wasm-js-cycle.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker.wasm
Binary files 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 @@
+<!doctype html>
+<title>Check import and export between WebAssembly modules</title>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script type=module>
+setup({ single_test: true });
+window.log = [];
+import { logExec } from "./resources/wasm-import-from-wasm.wasm";
+logExec();
+assert_equals(log.length, 1);
+assert_equals(log[0], "executed");
+done();
+</script>
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 @@
+<!doctype html>
+<title>Errors for imports of WebAssembly modules</title>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+ setup({allow_uncaught_exception: true});
+
+ const test_load = async_test(
+ "Invalid imports for WebAssembly modules should error.");
+
+ window.log = [];
+ window.addEventListener("error", ev => {
+ test_load.step(() => assert_equals(ev.error.constructor, WebAssembly.LinkError));
+ log.push(ev.message);
+ });
+
+ window.addEventListener("load", test_load.step_func_done(ev => {
+ assert_equals(log[1], 1);
+ assert_equals(log[3], 2);
+ assert_equals(log[5], 3);
+ assert_equals(log[7], 4);
+ }));
+
+ function unreachable() { log.push("unexpected"); }
+</script>
+<script type="module" src="./resources/wasm-import-func.wasm"
+ onerror="unreachable()" onload="log.push(1)"></script>
+<script type="module" src="./resources/wasm-import-memory.wasm"
+ onerror="unreachable()" onload="log.push(2)"></script>
+<script type="module" src="./resources/wasm-import-table.wasm"
+ onerror="unreachable()" onload="log.push(3)"></script>
+<script type="module" src="./resources/wasm-import-global.wasm"
+ onerror="unreachable()" onload="log.push(4)"></script>
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 @@
+<!doctype html>
+<title>Check bindings in JavaScript and WebAssembly cycle (Wasm higher)</title>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script type=module>
+setup({ single_test: true });
+import * as wasm from "./resources/wasm-js-cycle.wasm";
+import * as js from "./resources/wasm-js-cycle.js";
+
+js.mutateBindings();
+
+assert_true(wasm.wasmGlob instanceof WebAssembly.Global);
+assert_equals(wasm.wasmGlob.valueOf(), 24);
+
+assert_true(wasm.wasmFunc instanceof Function);
+assert_equals(wasm.wasmFunc(), 43);
+
+assert_equals(wasm.incrementGlob(), 43);
+
+const buf = new Int32Array(wasm.wasmMem.buffer);
+assert_equals(buf[0], 0);
+assert_equals(wasm.mutateMem(), 42);
+assert_equals(buf[0], 42);
+
+assert_equals(wasm.wasmTab.get(0), null);
+const ref = wasm.mutateTab();
+assert_true(ref instanceof Function);
+assert_equals(wasm.wasmTab.get(0), ref);
+
+done();
+</script>
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 @@
+<!doctype html>
+<title>Errors for linking WebAssembly module scripts</title>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+ setup({allow_uncaught_exception: true});
+
+ const test_load = async_test(
+ "Link errors for imports between WebAssembly modules should be reported.");
+
+ window.log = [];
+ window.addEventListener("error", ev => {
+ test_load.step(() => assert_equals(ev.error.constructor, WebAssembly.LinkError));
+ log.push(ev.message);
+ });
+
+ window.addEventListener("load", test_load.step_func_done(ev => {
+ assert_equals(log.length, 2);
+ assert_equals(log[1], 1);
+ }));
+
+ function unreachable() { log.push("unexpected"); }
+</script>
+<script type="module" src="./resources/wasm-import-error-from-wasm.wasm"
+ onerror="unreachable()" onload="log.push(1)"></script>
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 @@
+<!DOCTYPE html>
+<title>Testing import of WebAssembly from JavaScript worker</title>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script type=module>
+setup({ single_test: true });
+const worker = new Worker("resources/worker.js", { type: "module" });
+worker.onmessage = (msg) => {
+ assert_equals(msg.data, 42);
+ done();
+}
+</script>
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 @@
+<!DOCTYPE html>
+<title>Testing WebAssembly worker</title>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script type=module>
+setup({ single_test: true });
+const worker = new Worker("resources/worker.wasm", { type: "module" });
+worker.onmessage = (msg) => {
+ assert_equals(msg, 42);
+ done();
+}
+</script>
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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/resources/incrementer.no_mime_type.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/resources/incrementer.wasm
Binary files 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
--- /dev/null
+++ b/testing/web-platform/tests/wasm/webapi/resources/incrementer.wrong_mime_type.wasm
Binary files 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 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>WebAssembly.compileStreaming</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<script>
+ promise_test(async function() {
+ const response = await fetch('resources/incrementer.wasm');
+ const module = await WebAssembly.compileStreaming(response);
+ assert_true(module instanceof WebAssembly.Module);
+ }, "compileStreaming using resolved response");
+
+ promise_test(async function() {
+ const response = await fetch('resources/incrementer.wasm');
+ const module = await WebAssembly.compileStreaming(response);
+ const instance = new WebAssembly.Instance(module);
+ assert_true(instance instanceof WebAssembly.Instance);
+ }, "compileStreaming using resolved response and check instantiate");
+
+ promise_test(async function() {
+ const result = fetch('resources/incrementer.wasm');
+ const module = await WebAssembly.compileStreaming(result);
+ const instance = new WebAssembly.Instance(module);
+ assert_true(instance instanceof WebAssembly.Instance);
+ }, "compileStreaming using promise response from fetch and check instantiate");
+
+ promise_test(async function(t) {
+ const result = fetch('resources/incrementer.wrong_mime_type.wasm');
+ await promise_rejects_js(t, TypeError, WebAssembly.compileStreaming(result));
+ }, "compileStreaming raise error if wrong mime type");
+
+ promise_test(async function(t) {
+ const result = fetch('resources/incrementer.no_mime_type.wasm?pipe=header(Content-Type,)');
+ await promise_rejects_js(t, TypeError, WebAssembly.compileStreaming(result));
+ }, "compileStreaming raise error if no mime type");
+
+ promise_test(async function(t) {
+ const result = fetch('webapi/status.py?status=404');
+ await promise_rejects_js(t, TypeError, WebAssembly.compileStreaming(result));
+ }, "compileStreaming raise error if 404 status");
+
+ const getWasmUrl = fileName => {
+ const host_info = get_host_info();
+ const url = host_info.HTTP_ORIGIN_WITH_DIFFERENT_PORT + '/wasm/webapi/';
+ return url + fileName + "?pipe=header(Access-Control-Allow-Origin,*)";
+ };
+
+ promise_test(async function() {
+ const result = fetch(getWasmUrl('resources/incrementer.wasm'), {"mode": "cors"} );
+ const module = await WebAssembly.compileStreaming(result);
+ assert_true(module instanceof WebAssembly.Module);
+ }, "compileStreaming check CORS");
+
+ promise_test(async function(t) {
+ const result = fetch(getWasmUrl('resources/incrementer.wasm'), {"mode": "no-cors"} );
+ await promise_rejects_js(t, TypeError, WebAssembly.compileStreaming(result));
+ }, "compileStreaming raise error if no-cors");
+
+ promise_test(async function() {
+ const v = await fetch('resources/incrementer.wasm');
+ const buffer = await v.arrayBuffer();
+ const response = new Response(buffer, { headers: { "Content-Type" : "application/wasm" }});
+ const module = await WebAssembly.compileStreaming(response);
+ assert_true(module instanceof WebAssembly.Module);
+ }, "compileStreaming receive promise with response created from ArrayBuffer");
+
+ promise_test(async function() {
+ const v = await fetch('resources/incrementer.wasm');
+ const buffer = await v.arrayBuffer();
+ const stream = new ReadableStream({
+ start(controller) {
+ (async () => {
+ await Promise.resolve().then(() => controller.enqueue(new Uint8Array(buffer.slice(0, 20))));
+ await Promise.resolve().then(() => controller.enqueue(new Uint8Array(buffer.slice(20, buffer.byteLength))));
+ await Promise.resolve().then(() => controller.close());
+ })();
+ }
+ });
+ const response = new Response(stream, { headers: { "Content-Type" : "application/wasm" }});
+ const module = await WebAssembly.compileStreaming(response);
+ assert_true(module instanceof WebAssembly.Module);
+ }, "compileStreaming using ReadableStream with Uint8Array chunks");
+
+ promise_test(async function(t) {
+ const v = await fetch('resources/incrementer.wasm');
+ const buffer = await v.arrayBuffer();
+ const stream = new ReadableStream({
+ start(controller) {
+ // Enqueuing an ArrayBuffer rather a Uint8Array per
+ // https://streams.spec.whatwg.org/#read-loop
+ controller.enqueue(buffer);
+ controller.close();
+ }
+ });
+ const response = new Response(stream, { headers: { "Content-Type" : "application/wasm" }});
+ await promise_rejects_js(t, TypeError, WebAssembly.compileStreaming(response));
+ }, "compileStreaming using ReadableStream with ArrayBuffer chunk");
+
+ promise_test(async function() {
+ const response = await fetch('resources/incrementer.wasm');
+ const blob = await response.blob();
+ const module = await WebAssembly.compileStreaming(new Response(blob, { headers: { "Content-Type" : "application/wasm" }}));
+ assert_true(module instanceof WebAssembly.Module);
+ }, "compileStreaming using blob");
+
+ promise_test(async function(t) {
+ const response = await fetch('resources/incrementer.wasm');
+ const blob = await response.blob();
+ const formData = new FormData;
+ formData.append('blob', blob);
+ formData.append('blob2', "Hello");
+ await promise_rejects_js(t, WebAssembly.CompileError, WebAssembly.compileStreaming(new Response(formData, { headers: { "Content-Type" : "application/wasm" }})));
+ }, "compileStreaming using FormData");
+</script>
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 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>WebAssembly.instantiateStreaming</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<script>
+ promise_test(async function() {
+ const response = await fetch('resources/incrementer.wasm');
+ const { instance, module } = await WebAssembly.instantiateStreaming(response);
+ assert_true(instance instanceof WebAssembly.Instance);
+ assert_true(module instanceof WebAssembly.Module);
+ }, "instantiateStreaming using resolved response");
+
+ promise_test(async function() {
+ const response = await fetch('resources/incrementer.wasm');
+ const { instance } = await WebAssembly.instantiateStreaming(response);
+ assert_true(instance instanceof WebAssembly.Instance);
+ }, "instantiateStreaming using resolved response and check instantiate");
+
+ promise_test(async function() {
+ const result = fetch('resources/incrementer.wasm');
+ const { instance } = await WebAssembly.instantiateStreaming(result);
+ assert_true(instance instanceof WebAssembly.Instance);
+ }, "instantiateStreaming using promise response from fetch and check instantiate");
+
+ promise_test(async function(t) {
+ const result = fetch('resources/incrementer.wrong_mime_type.wasm');
+ await promise_rejects_js(t, TypeError, WebAssembly.instantiateStreaming(result));
+ }, "instantiateStreaming raise error if wrong mime type");
+
+ promise_test(async function(t) {
+ const result = fetch('resources/incrementer.no_mime_type.wasm?pipe=header(Content-Type,)');
+ await promise_rejects_js(t, TypeError, WebAssembly.instantiateStreaming(result));
+ }, "instantiateStreaming raise error if no mime type");
+
+ promise_test(async function(t) {
+ const result = fetch('webapi/status.py?status=404');
+ await promise_rejects_js(t, TypeError, WebAssembly.instantiateStreaming(result));
+ }, "instantiateStreaming raise error if 404 status");
+
+ const getWasmUrl = fileName => {
+ const host_info = get_host_info();
+ const url = host_info.HTTP_ORIGIN_WITH_DIFFERENT_PORT + '/wasm/webapi/';
+ return url + fileName + "?pipe=header(Access-Control-Allow-Origin,*)";
+ };
+
+ promise_test(async function() {
+ const result = fetch(getWasmUrl('resources/incrementer.wasm'), {"mode": "cors"} );
+ const { instance } = await WebAssembly.instantiateStreaming(result);
+ assert_true(instance instanceof WebAssembly.Instance);
+ }, "instantiateStreaming check CORS");
+
+ promise_test(async function(t) {
+ const result = fetch(getWasmUrl('resources/incrementer.wasm'), {"mode": "no-cors"} );
+ await promise_rejects_js(t, TypeError, WebAssembly.instantiateStreaming(result));
+ }, "instantiateStreaming raise error if no-cors");
+
+ promise_test(async function() {
+ const v = await fetch('resources/incrementer.wasm');
+ const buffer = await v.arrayBuffer();
+ const response = new Response(buffer, { headers: { "Content-Type" : "application/wasm" }});
+ const { instance } = await WebAssembly.instantiateStreaming(response);
+ assert_true(instance instanceof WebAssembly.Instance);
+ }, "instantiateStreaming receive promise with response created from ArrayBuffer");
+
+ promise_test(async function() {
+ const v = await fetch('resources/incrementer.wasm');
+ const buffer = await v.arrayBuffer();
+ const stream = new ReadableStream({
+ start(controller) {
+ (async () => {
+ await Promise.resolve().then(() => controller.enqueue(new Uint8Array(buffer.slice(0, 20))));
+ await Promise.resolve().then(() => controller.enqueue(new Uint8Array(buffer.slice(20, buffer.byteLength))));
+ await Promise.resolve().then(() => controller.close());
+ })();
+ }
+ });
+ const response = new Response(stream, { headers: { "Content-Type" : "application/wasm" }});
+ const { instance } = await WebAssembly.instantiateStreaming(response);
+ assert_true(instance instanceof WebAssembly.Instance);
+ }, "instantiateStreaming using ReadableStream with Uint8Array chunks");
+
+ promise_test(async function(t) {
+ const v = await fetch('resources/incrementer.wasm');
+ const buffer = await v.arrayBuffer();
+ const stream = new ReadableStream({
+ start(controller) {
+ // Enqueuing an ArrayBuffer rather a Uint8Array per
+ // https://streams.spec.whatwg.org/#read-loop
+ controller.enqueue(buffer);
+ controller.close();
+ }
+ });
+ const response = new Response(stream, { headers: { "Content-Type" : "application/wasm" }});
+ await promise_rejects_js(t, TypeError, WebAssembly.instantiateStreaming(response));
+ }, "instantiateStreaming using ReadableStream with ArrayBuffer chunk");
+
+ promise_test(async function() {
+ const response = await fetch('resources/incrementer.wasm');
+ const blob = await response.blob();
+ const { instance, module } = await WebAssembly.instantiateStreaming(new Response(blob, { headers: { "Content-Type" : "application/wasm" }}));
+ assert_true(instance instanceof WebAssembly.Instance);
+ assert_true(module instanceof WebAssembly.Module);
+ }, "instantiateStreaming using blob");
+
+ promise_test(async function(t) {
+ const response = await fetch('resources/incrementer.wasm');
+ const blob = await response.blob();
+ const formData = new FormData;
+ formData.append('blob', blob);
+ formData.append('blob2', "Hello");
+ await promise_rejects_js(t, WebAssembly.CompileError, WebAssembly.instantiateStreaming(new Response(formData, { headers: { "Content-Type" : "application/wasm" }})));
+ }, "instantiateStreaming using FormData");
+</script>