mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
Tests/LibWeb: Add TransformStream flush callback test
This test proves the ability of TransformStream to execute caller supplied code in the flush callback, and have access to TransformStreamDefaultController.
This commit is contained in:
committed by
Andreas Kling
parent
5c6125c92b
commit
221f18f72e
Notes:
sideshowbarker
2024-07-17 08:55:54 +09:00
Author: https://github.com/kennethmyhra Commit: https://github.com/SerenityOS/serenity/commit/221f18f72e Pull-request: https://github.com/SerenityOS/serenity/pull/19998 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/shannonbooth
@@ -0,0 +1,25 @@
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const {writable, readable} = new TransformStream({
|
||||
transform(chunk, controller) {
|
||||
controller.enqueue(chunk.toUpperCase());
|
||||
},
|
||||
flush(controller) {
|
||||
controller.enqueue("Enqueued in flush, this the last chunk that will be processed.");
|
||||
}
|
||||
});
|
||||
const writer = writable.getWriter();
|
||||
writer.write("Hello, world!");
|
||||
writer.close();
|
||||
const reader = readable.getReader();
|
||||
reader.read().then(function processText({done, value}) {
|
||||
println(`Done: ${done}`);
|
||||
if (done)
|
||||
return;
|
||||
|
||||
println(value);
|
||||
reader.read().then(processText);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user