Skip to content

Commit

Permalink
Add some tests for instantiateStreaming().
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger committed Oct 22, 2018
1 parent 21b45a4 commit 6ac2a03
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
14 changes: 14 additions & 0 deletions wasm/webapi/instantiateStreaming-bad-imports.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// META: global=window,worker
// META: script=/wasm/jsapi/wasm-constants.js
// 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(t, error, WebAssembly.instantiateStreaming(response, ...args));
}, name);
});
20 changes: 20 additions & 0 deletions wasm/webapi/instantiateStreaming.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// META: global=window,worker
// META: script=/wasm/jsapi/wasm-constants.js
// 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);
}

0 comments on commit 6ac2a03

Please sign in to comment.