summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/wasm/webapi/instantiateStreaming.any.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/wasm/webapi/instantiateStreaming.any.js')
-rw-r--r--testing/web-platform/tests/wasm/webapi/instantiateStreaming.any.js49
1 files changed, 49 insertions, 0 deletions
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");