Преглед изворни кода

LibWeb: Wait for the correct condition in Stream tests

We were signaling that the test is complete too early in some Stream
tests.
Timothy Flynn пре 10 месеци
родитељ
комит
f3f7f77dbc

+ 5 - 7
Tests/LibWeb/Text/input/Streams/ReadableStream-pipeThrough.html

@@ -39,19 +39,17 @@
             cancel() {},
         });
 
-
         const reader = transformStream.readable.getReader();
-        reader.read().then(function processText({done, value}) {
-            if (done)
+        reader.read().then(function processText(result) {
+            if (result.done) {
+                done();
                 return;
+            }
 
-            println(value);
+            println(result.value);
             reader.read().then(processText);
-        }).then(() => {
-            done();
         });
 
         stream.pipeThrough(transformStream);
-
     });
 </script>

+ 6 - 3
Tests/LibWeb/Text/input/Streams/ReadableStream-pipeTo.html

@@ -11,8 +11,13 @@
                     return new Promise((resolve) => {
                         const textDecoder = new TextDecoder("utf-8");
                         println(textDecoder.decode(new Uint8Array(chunk)));
+
                         resolve();
                     });
+                },
+
+                close() {
+                    done();
                 }
             }
         );
@@ -40,8 +45,6 @@
             cancel() {},
         });
 
-        stream.pipeTo(writableStream).then(() => {
-            done();
-        });
+        stream.pipeTo(writableStream);
     });
 </script>

+ 4 - 1
Tests/LibWeb/Text/input/Streams/WritableStream-write.html

@@ -8,6 +8,10 @@
                     resolve();
                 });
             },
+
+            close() {
+                done();
+            }
         });
 
         function sendMessage(message) {
@@ -19,7 +23,6 @@
 
             writer.ready.then(() => {
                 writer.close();
-                done();
             });
         }