mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 17:28:11 +00:00
LibWeb: Add AO transform_stream_default_controller_terminate()
This commit is contained in:
parent
4ae82983a4
commit
e1740938fc
2 changed files with 25 additions and 0 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue