Selaa lähdekoodia

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.
Kenneth Myhra 2 vuotta sitten
vanhempi
commit
5c6125c92b

+ 3 - 0
Tests/LibWeb/Text/expected/Streams/TransformStream-start-callback.txt

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

+ 20 - 0
Tests/LibWeb/Text/input/Streams/TransformStream-start-callback.html

@@ -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>