1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:17:35 +00:00

Tests/LibWeb: Add TransformStream start callback test

This test proves the ability of TransformStream to execute
caller supplied code in the start callback, and have access to
TransformStreamDefaultController.
This commit is contained in:
Kenneth Myhra 2023-07-13 23:43:20 +02:00 committed by Andreas Kling
parent 74fdf59941
commit 5c6125c92b
2 changed files with 23 additions and 0 deletions

View file

@ -0,0 +1,3 @@
In start
Done: false
Hello, world!

View file

@ -0,0 +1,20 @@
<script src="../include.js"></script>
<script>
test(() => {
const {readable} = new TransformStream({
start(controller) {
println("In start");
controller.enqueue("Hello, world!");
}
});
const reader = readable.getReader();
reader.read().then(function processText({done, value}) {
println(`Done: ${done}`);
if (done)
return;
println(value);
reader.read().then(processText);
});
});
</script>