ladybird/Tests/LibWeb/Text/input/Streams/ReadableStream-from-asyncIterator.html
Timothy Flynn c9cbaeb59d LibWeb: Convert some sync tests to be async
The events tested here are decidedly async. We also can't really write
sync tests of the form "test(async () => {})". Nothing will await the
async callback.
2024-10-03 07:07:28 -04:00

30 lines
710 B
HTML

<script src="../include.js"></script>
<script>
async function* asyncGenerator() {
yield "Well";
yield "Hello";
yield "Friends";
yield "!";
yield "🦬";
}
async function readStream(stream) {
const reader = stream.getReader();
while (true) {
const { done, value } = await reader.read();
if (done)
break;
println(value);
}
}
asyncTest(done => {
const asyncIterable = {
[Symbol.asyncIterator]: asyncGenerator,
};
const readableStream = ReadableStream.from(asyncIterable);
readStream(readableStream).then(done);
});
</script>