Skip to content

Commit 74fdf59

Browse files
kennethmyhraawesomekling
authored andcommitted
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.
1 parent 1faca5e commit 74fdf59

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Done: false
2+
HELLO, WORLD!
3+
Done: true
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script src="../include.js"></script>
2+
<script>
3+
test(() => {
4+
const {writable, readable} = new TransformStream({
5+
transform(chunk, controller) {
6+
controller.enqueue(chunk.toUpperCase());
7+
}
8+
});
9+
const writer = writable.getWriter();
10+
writer.write("Hello, world!");
11+
writer.close();
12+
const reader = readable.getReader();
13+
reader.read().then(function processText({done, value}) {
14+
println(`Done: ${done}`);
15+
if (done)
16+
return;
17+
18+
println(value);
19+
reader.read().then(processText);
20+
});
21+
});
22+
</script>

0 commit comments

Comments
 (0)