LibWeb: Use the proper in-flight request to check if a stream is closing

This commit is contained in:
Timothy Flynn
2024-04-01 09:52:27 -04:00
committed by Alexander Kalenik
parent 59cd086199
commit b6501adef8
Notes: sideshowbarker 2024-07-17 01:11:48 +09:00
3 changed files with 48 additions and 1 deletions

View 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>