From 6fa97eceeb204de1dcc0df84dad0868291ae2796 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 22 Oct 2018 14:07:10 +0200 Subject: [PATCH] WebAssembly: Test aborted responses. --- wasm/webapi/abort.any.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 wasm/webapi/abort.any.js diff --git a/wasm/webapi/abort.any.js b/wasm/webapi/abort.any.js new file mode 100644 index 00000000000000..cc0f5d9f34ff0c --- /dev/null +++ b/wasm/webapi/abort.any.js @@ -0,0 +1,24 @@ +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(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(t, 'AbortError', promise, `${method} should reject`); + }, `${method}() synchronously followed by abort should reject with AbortError`); +}