11cb0ef41Sopenharmony_ciconst methods = [ 21cb0ef41Sopenharmony_ci "compileStreaming", 31cb0ef41Sopenharmony_ci "instantiateStreaming", 41cb0ef41Sopenharmony_ci]; 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_cifor (const method of methods) { 71cb0ef41Sopenharmony_ci promise_test(async t => { 81cb0ef41Sopenharmony_ci const controller = new AbortController(); 91cb0ef41Sopenharmony_ci const signal = controller.signal; 101cb0ef41Sopenharmony_ci controller.abort(); 111cb0ef41Sopenharmony_ci const request = fetch('../incrementer.wasm', { signal }); 121cb0ef41Sopenharmony_ci return promise_rejects_dom(t, 'AbortError', WebAssembly[method](request), 131cb0ef41Sopenharmony_ci `${method} should reject`); 141cb0ef41Sopenharmony_ci }, `${method}() on an already-aborted request should reject with AbortError`); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci promise_test(async t => { 171cb0ef41Sopenharmony_ci const controller = new AbortController(); 181cb0ef41Sopenharmony_ci const signal = controller.signal; 191cb0ef41Sopenharmony_ci const request = fetch('../incrementer.wasm', { signal }); 201cb0ef41Sopenharmony_ci const promise = WebAssembly[method](request); 211cb0ef41Sopenharmony_ci controller.abort(); 221cb0ef41Sopenharmony_ci return promise_rejects_dom(t, 'AbortError', promise, `${method} should reject`); 231cb0ef41Sopenharmony_ci }, `${method}() synchronously followed by abort should reject with AbortError`); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci promise_test(async t => { 261cb0ef41Sopenharmony_ci const controller = new AbortController(); 271cb0ef41Sopenharmony_ci const signal = controller.signal; 281cb0ef41Sopenharmony_ci return fetch('../incrementer.wasm', { signal }) 291cb0ef41Sopenharmony_ci .then(response => { 301cb0ef41Sopenharmony_ci Promise.resolve().then(() => controller.abort()); 311cb0ef41Sopenharmony_ci return WebAssembly[method](response); 321cb0ef41Sopenharmony_ci }) 331cb0ef41Sopenharmony_ci .catch(err => { 341cb0ef41Sopenharmony_ci assert_equals(err.name, "AbortError"); 351cb0ef41Sopenharmony_ci }); 361cb0ef41Sopenharmony_ci }, `${method}() asynchronously racing with abort should succeed or reject with AbortError`); 371cb0ef41Sopenharmony_ci} 38