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
commit 5c6125c92b
Notes: sideshowbarker 2024-07-16 23:17:55 +09:00
2 changed files with 23 additions and 0 deletions

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>