mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
LibWeb: Close acquired writer in AO readable_stream_pipe_to()
Also adds a test to prove that the WritableStream's close callback is called.
This commit is contained in:
parent
15b677385c
commit
e2c4019bfc
Notes:
sideshowbarker
2024-07-16 23:55:09 +09:00
Author: https://github.com/kennethmyhra Commit: https://github.com/SerenityOS/serenity/commit/e2c4019bfc Pull-request: https://github.com/SerenityOS/serenity/pull/24132 Reviewed-by: https://github.com/shannonbooth Reviewed-by: https://github.com/trflynn89
@ -0,0 +1 @@
|
||||
Writer has been closed.
|
@ -0,0 +1,20 @@
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
asyncTest(done => {
|
||||
const writableStream = new WritableStream({
|
||||
close() {
|
||||
println("Writer has been closed.");
|
||||
}
|
||||
}
|
||||
);
|
||||
const stream = new ReadableStream({
|
||||
pull(controller) {
|
||||
controller.close();
|
||||
}
|
||||
});
|
||||
|
||||
stream.pipeTo(writableStream).then(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
</script>
|
@ -314,11 +314,17 @@ JS::NonnullGCPtr<WebIDL::Promise> readable_stream_pipe_to(ReadableStream& source
|
||||
WebIDL::resolve_promise(realm, promise, JS::js_undefined());
|
||||
};
|
||||
|
||||
auto success_steps = [promise, &realm](ByteBuffer) {
|
||||
auto success_steps = [promise, &realm, writer](ByteBuffer) {
|
||||
// Make sure we close the acquired writer.
|
||||
WebIDL::resolve_promise(realm, writable_stream_default_writer_close(*writer), JS::js_undefined());
|
||||
|
||||
WebIDL::resolve_promise(realm, promise, JS::js_undefined());
|
||||
};
|
||||
|
||||
auto failure_steps = [promise, &realm](JS::Value error) {
|
||||
auto failure_steps = [promise, &realm, writer](JS::Value error) {
|
||||
// Make sure we close the acquired writer.
|
||||
WebIDL::resolve_promise(realm, writable_stream_default_writer_close(*writer), JS::js_undefined());
|
||||
|
||||
WebIDL::reject_promise(realm, promise, error);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user