mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-22 09:18:55 +00:00
LibWeb: Use the proper in-flight request to check if a stream is closing
This commit is contained in:
parent
59cd086199
commit
b6501adef8
Notes:
sideshowbarker
2024-07-17 01:11:48 +09:00
Author: https://github.com/trflynn89
Commit: b6501adef8
Pull-request: https://github.com/SerenityOS/serenity/pull/23795
Reviewed-by: https://github.com/kalenikaliaksandr
Reviewed-by: https://github.com/kennethmyhra ✅
3 changed files with 48 additions and 1 deletions
19
Tests/LibWeb/Text/expected/Streams/WritableStream-write.txt
Normal file
19
Tests/LibWeb/Text/expected/Streams/WritableStream-write.txt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
W
|
||||||
|
e
|
||||||
|
l
|
||||||
|
l
|
||||||
|
-
|
||||||
|
h
|
||||||
|
e
|
||||||
|
l
|
||||||
|
l
|
||||||
|
o
|
||||||
|
-
|
||||||
|
f
|
||||||
|
r
|
||||||
|
i
|
||||||
|
e
|
||||||
|
n
|
||||||
|
d
|
||||||
|
s
|
||||||
|
!
|
28
Tests/LibWeb/Text/input/Streams/WritableStream-write.html
Normal file
28
Tests/LibWeb/Text/input/Streams/WritableStream-write.html
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
asyncTest(done => {
|
||||||
|
const stream = new WritableStream({
|
||||||
|
write(chunk) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
println(chunk);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
function sendMessage(message) {
|
||||||
|
const writer = stream.getWriter();
|
||||||
|
|
||||||
|
for (const chunk of message) {
|
||||||
|
writer.ready.then(() => writer.write(chunk));
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.ready.then(() => {
|
||||||
|
writer.close();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
sendMessage("Well-hello-friends!");
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -3492,7 +3492,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> writable_stream_add_write
|
||||||
bool writable_stream_close_queued_or_in_flight(WritableStream const& stream)
|
bool writable_stream_close_queued_or_in_flight(WritableStream const& stream)
|
||||||
{
|
{
|
||||||
// 1. If stream.[[closeRequest]] is undefined and stream.[[inFlightCloseRequest]] is undefined, return false.
|
// 1. If stream.[[closeRequest]] is undefined and stream.[[inFlightCloseRequest]] is undefined, return false.
|
||||||
if (!stream.close_request() && !stream.in_flight_write_request())
|
if (!stream.close_request() && !stream.in_flight_close_request())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// 2. Return true.
|
// 2. Return true.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue