1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:17:45 +00:00

LibWeb: Add AO transform_stream_default_controller_terminate()

This commit is contained in:
Kenneth Myhra 2023-07-07 19:44:46 +02:00 committed by Andreas Kling
parent 4ae82983a4
commit e1740938fc
2 changed files with 25 additions and 0 deletions

View file

@ -2799,6 +2799,30 @@ WebIDL::ExceptionOr<void> transform_stream_default_controller_error(TransformStr
return {};
}
// https://streams.spec.whatwg.org/#transform-stream-default-controller-terminate
WebIDL::ExceptionOr<void> transform_stream_default_controller_terminate(TransformStreamDefaultController& controller)
{
auto& realm = controller.realm();
// 1. Let stream be controller.[[stream]].
auto stream = controller.stream();
// 2. Let readableController be stream.[[readable]].[[controller]].
VERIFY(stream->readable()->controller().has_value() && stream->readable()->controller()->has<JS::NonnullGCPtr<ReadableStreamDefaultController>>());
auto readable_controller = stream->readable()->controller()->get<JS::NonnullGCPtr<ReadableStreamDefaultController>>();
// 3. Perform ! ReadableStreamDefaultControllerClose(readableController).
readable_stream_default_controller_close(readable_controller);
// 4. Let error be a TypeError exception indicating that the stream has been terminated.
auto error = MUST_OR_THROW_OOM(JS::TypeError::create(realm, "Stream has been terminated."sv));
// 5. Perform ! TransformStreamErrorWritableAndUnblockWrite(stream, error).
TRY(transform_stream_error_writable_and_unblock_write(*stream, error));
return {};
}
// https://streams.spec.whatwg.org/#transform-stream-error
WebIDL::ExceptionOr<void> transform_stream_error(TransformStream& stream, JS::Value error)
{

View file

@ -136,6 +136,7 @@ WebIDL::ExceptionOr<void> writable_stream_default_controller_write(WritableStrea
void transform_stream_default_controller_clear_algorithms(TransformStreamDefaultController&);
WebIDL::ExceptionOr<void> transform_stream_default_controller_enqueue(TransformStreamDefaultController&, JS::Value chunk);
WebIDL::ExceptionOr<void> transform_stream_default_controller_error(TransformStreamDefaultController&, JS::Value error);
WebIDL::ExceptionOr<void> transform_stream_default_controller_terminate(TransformStreamDefaultController&);
WebIDL::ExceptionOr<void> transform_stream_error(TransformStream&, JS::Value error);
WebIDL::ExceptionOr<void> transform_stream_error_writable_and_unblock_write(TransformStream&, JS::Value error);
WebIDL::ExceptionOr<void> transform_stream_set_backpressure(TransformStream&, bool backpressure);