From 318f48f9adc486e95dcc5f86fd0a1848c6df51f6 Mon Sep 17 00:00:00 2001 From: Andreu Botella Date: Wed, 8 Dec 2021 23:31:22 +0100 Subject: [PATCH] feat(streams): support abort reasons in streams (#12991) --- ext/web/06_streams.js | 5 ++--- tools/wpt/expectation.json | 32 ++++---------------------------- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js index 15f51ca7a4..ed77dde667 100644 --- a/ext/web/06_streams.js +++ b/ext/web/06_streams.js @@ -55,7 +55,6 @@ WeakMapPrototypeSet, } = globalThis.__bootstrap.primordials; const consoleInternal = window.__bootstrap.console; - const { DOMException } = window.__bootstrap.domException; class AssertionError extends Error { constructor(msg) { @@ -1872,7 +1871,7 @@ let abortAlgorithm; if (signal) { abortAlgorithm = () => { - const error = new DOMException("Aborted", "AbortError"); + const error = signal.reason; /** @type {Array<() => Promise>} */ const actions = []; if (preventAbort === false) { @@ -3343,7 +3342,7 @@ if (state === "closed" || state === "errored") { return resolvePromiseWith(undefined); } - stream[_controller][_signal][signalAbort](); + stream[_controller][_signal][signalAbort](reason); if (state === "closed" || state === "errored") { return resolvePromiseWith(undefined); } diff --git a/tools/wpt/expectation.json b/tools/wpt/expectation.json index b203269393..4ec7cea21e 100644 --- a/tools/wpt/expectation.json +++ b/tools/wpt/expectation.json @@ -5787,28 +5787,8 @@ "idlharness.any.html": true, "idlharness.any.worker.html": true, "piping": { - "abort.any.html": [ - "(reason: 'null') all the error objects should be the same object", - "(reason: 'undefined') all the error objects should be the same object", - "(reason: 'error1: error1') all the error objects should be the same object", - "(reason: 'null') abort should prevent further reads", - "(reason: 'undefined') abort should prevent further reads", - "(reason: 'error1: error1') abort should prevent further reads", - "(reason: 'null') all pending writes should complete on abort", - "(reason: 'undefined') all pending writes should complete on abort", - "(reason: 'error1: error1') all pending writes should complete on abort" - ], - "abort.any.worker.html": [ - "(reason: 'null') all the error objects should be the same object", - "(reason: 'undefined') all the error objects should be the same object", - "(reason: 'error1: error1') all the error objects should be the same object", - "(reason: 'null') abort should prevent further reads", - "(reason: 'undefined') abort should prevent further reads", - "(reason: 'error1: error1') abort should prevent further reads", - "(reason: 'null') all pending writes should complete on abort", - "(reason: 'undefined') all pending writes should complete on abort", - "(reason: 'error1: error1') all pending writes should complete on abort" - ], + "abort.any.html": true, + "abort.any.worker.html": true, "close-propagation-backward.any.html": true, "close-propagation-backward.any.worker.html": true, "close-propagation-forward.any.html": true, @@ -5907,12 +5887,8 @@ "terminate.any.worker.html": true }, "writable-streams": { - "aborting.any.html": [ - "WritableStreamDefaultController.signal" - ], - "aborting.any.worker.html": [ - "WritableStreamDefaultController.signal" - ], + "aborting.any.html": true, + "aborting.any.worker.html": true, "bad-strategies.any.html": true, "bad-strategies.any.worker.html": true, "bad-underlying-sinks.any.html": true,