mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
Tests/LibWeb: Add TransformStream transform callback test
This test proves the ability of TransformStream to execute to execute caller supplied code in the transform callback that can transform incoming chunks, and have access to TransformStreamDefaultController.
This commit is contained in:
parent
1faca5ed9f
commit
74fdf59941
Notes:
sideshowbarker
2024-07-17 06:24:08 +09:00
Author: https://github.com/kennethmyhra
Commit: 74fdf59941
Pull-request: https://github.com/SerenityOS/serenity/pull/19998
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/shannonbooth
2 changed files with 25 additions and 0 deletions
|
|
@ -0,0 +1,3 @@
|
|||
Done: false
|
||||
HELLO, WORLD!
|
||||
Done: true
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const {writable, readable} = new TransformStream({
|
||||
transform(chunk, controller) {
|
||||
controller.enqueue(chunk.toUpperCase());
|
||||
}
|
||||
});
|
||||
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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue