mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-14 23:22:52 +00:00
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.
30 lines
710 B
HTML
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>
|