mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-22 09:18:55 +00:00
LibWeb: Implement operation to error a ReadableStream
This commit is contained in:
parent
2a2c59e74b
commit
88d46b51ed
Notes:
sideshowbarker
2024-07-17 02:38:39 +09:00
Author: https://github.com/trflynn89
Commit: 88d46b51ed
Pull-request: https://github.com/SerenityOS/serenity/pull/24452
Issue: https://github.com/SerenityOS/serenity/issues/23847
2 changed files with 17 additions and 0 deletions
|
@ -186,6 +186,22 @@ void ReadableStream::close()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://streams.spec.whatwg.org/#readablestream-error
|
||||||
|
void ReadableStream::error(JS::Value error)
|
||||||
|
{
|
||||||
|
controller()->visit(
|
||||||
|
// 1. If stream.[[controller]] implements ReadableByteStreamController, then perform
|
||||||
|
// ! ReadableByteStreamControllerError(stream.[[controller]], e).
|
||||||
|
[&](JS::NonnullGCPtr<ReadableByteStreamController> controller) {
|
||||||
|
readable_byte_stream_controller_error(controller, error);
|
||||||
|
},
|
||||||
|
|
||||||
|
// 2. Otherwise, perform ! ReadableStreamDefaultControllerError(stream.[[controller]], e).
|
||||||
|
[&](JS::NonnullGCPtr<ReadableStreamDefaultController> controller) {
|
||||||
|
readable_stream_default_controller_error(controller, error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void ReadableStream::initialize(JS::Realm& realm)
|
void ReadableStream::initialize(JS::Realm& realm)
|
||||||
{
|
{
|
||||||
Base::initialize(realm);
|
Base::initialize(realm);
|
||||||
|
|
|
@ -80,6 +80,7 @@ public:
|
||||||
WebIDL::ExceptionOr<ReadableStreamPair> tee();
|
WebIDL::ExceptionOr<ReadableStreamPair> tee();
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
|
void error(JS::Value);
|
||||||
|
|
||||||
Optional<ReadableStreamController>& controller() { return m_controller; }
|
Optional<ReadableStreamController>& controller() { return m_controller; }
|
||||||
void set_controller(Optional<ReadableStreamController> value) { m_controller = move(value); }
|
void set_controller(Optional<ReadableStreamController> value) { m_controller = move(value); }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue