From 69fb6f15f9dbb607bb8c99debf62cc5d981cb1e9 Mon Sep 17 00:00:00 2001 From: Kenneth Myhra Date: Fri, 7 Jul 2023 16:14:09 +0200 Subject: [PATCH] LibWeb: Add AO transform_stream_error() --- .../LibWeb/Streams/AbstractOperations.cpp | 16 ++++++++++++++++ .../LibWeb/Streams/AbstractOperations.h | 1 + 2 files changed, 17 insertions(+) diff --git a/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp b/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp index bf0fa166b1..a5aa69790a 100644 --- a/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp +++ b/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp @@ -2734,6 +2734,22 @@ void transform_stream_default_controller_clear_algorithms(TransformStreamDefault controller.set_flush_algorithm({}); } +// https://streams.spec.whatwg.org/#transform-stream-error +WebIDL::ExceptionOr transform_stream_error(TransformStream& stream, JS::Value error) +{ + VERIFY(stream.readable()->controller().has_value() && stream.readable()->controller()->has>()); + + auto readable_controller = stream.readable()->controller()->get>(); + + // 1. Perform ! ReadableStreamDefaultControllerError(stream.[[readable]].[[controller]], e). + readable_stream_default_controller_error(*readable_controller, error); + + // 2. Perform ! TransformStreamErrorWritableAndUnblockWrite(stream, e). + TRY(transform_stream_error_writable_and_unblock_write(stream, error)); + + return {}; +} + // https://streams.spec.whatwg.org/#transform-stream-error-writable-and-unblock-write WebIDL::ExceptionOr transform_stream_error_writable_and_unblock_write(TransformStream& stream, JS::Value error) { diff --git a/Userland/Libraries/LibWeb/Streams/AbstractOperations.h b/Userland/Libraries/LibWeb/Streams/AbstractOperations.h index 5a8913a940..6144b63107 100644 --- a/Userland/Libraries/LibWeb/Streams/AbstractOperations.h +++ b/Userland/Libraries/LibWeb/Streams/AbstractOperations.h @@ -133,6 +133,7 @@ WebIDL::ExceptionOr writable_stream_default_controller_process_write(Writa WebIDL::ExceptionOr writable_stream_default_controller_write(WritableStreamDefaultController&, JS::Value chunk, JS::Value chunk_size); void transform_stream_default_controller_clear_algorithms(TransformStreamDefaultController&); +WebIDL::ExceptionOr transform_stream_error(TransformStream&, JS::Value error); WebIDL::ExceptionOr transform_stream_error_writable_and_unblock_write(TransformStream&, JS::Value error); WebIDL::ExceptionOr transform_stream_set_backpressure(TransformStream&, bool backpressure);