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 --- .../web-platform/tests/wasm/webapi/abort.any.js | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 testing/web-platform/tests/wasm/webapi/abort.any.js (limited to 'testing/web-platform/tests/wasm/webapi/abort.any.js') 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`); +} -- cgit v1.2.3