Title: [189689] trunk/LayoutTests
Revision
189689
Author
calva...@igalia.com
Date
2015-09-14 00:59:48 -0700 (Mon, 14 Sep 2015)

Log Message

[Streams API] Add pipe-to-options writable stream tests
https://bugs.webkit.org/show_bug.cgi?id=148297

Reviewed by Darin Adler.

* streams/reference-implementation/pipe-to-options-expected.txt: Added.
* streams/reference-implementation/pipe-to-options.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (189688 => 189689)


--- trunk/LayoutTests/ChangeLog	2015-09-14 07:56:27 UTC (rev 189688)
+++ trunk/LayoutTests/ChangeLog	2015-09-14 07:59:48 UTC (rev 189689)
@@ -1,5 +1,15 @@
 2015-09-14  Xabier Rodriguez Calvar  <calva...@igalia.com>
 
+        [Streams API] Add pipe-to-options writable stream tests
+        https://bugs.webkit.org/show_bug.cgi?id=148297
+
+        Reviewed by Darin Adler.
+
+        * streams/reference-implementation/pipe-to-options-expected.txt: Added.
+        * streams/reference-implementation/pipe-to-options.html: Added.
+
+2015-09-14  Xabier Rodriguez Calvar  <calva...@igalia.com>
+
         [Streams API] Add tests about abort on writable streams
         https://bugs.webkit.org/show_bug.cgi?id=148298
 

Added: trunk/LayoutTests/streams/reference-implementation/pipe-to-options-expected.txt (0 => 189689)


--- trunk/LayoutTests/streams/reference-implementation/pipe-to-options-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/streams/reference-implementation/pipe-to-options-expected.txt	2015-09-14 07:59:48 UTC (rev 189689)
@@ -0,0 +1,5 @@
+
+FAIL Piping with no options and a destination error Can't find variable: WritableStream
+FAIL Piping with { preventCancel: false } and a destination error Can't find variable: WritableStream
+FAIL Piping with { preventCancel: true } and a destination error Can't find variable: WritableStream
+

Added: trunk/LayoutTests/streams/reference-implementation/pipe-to-options.html (0 => 189689)


--- trunk/LayoutTests/streams/reference-implementation/pipe-to-options.html	                        (rev 0)
+++ trunk/LayoutTests/streams/reference-implementation/pipe-to-options.html	2015-09-14 07:59:48 UTC (rev 189689)
@@ -0,0 +1,105 @@
+<!DOCTYPE html>
+<script src=''></script>
+<script src=''></script>
+<script src=''></script>
+<script>
+var test1 = async_test('Piping with no options and a destination error');
+test1.step(function() {
+    var cancelCalled = false;
+    var theError = new Error('destination error');
+    var rs = new ReadableStream({
+        start: function(c) {
+            c.enqueue('a');
+            setTimeout(test1.step_func(function() { c.enqueue('b'); }), 200);
+            setTimeout(test1.step_func(function() {
+                c.enqueue('c'); // Enqueue after cancel should not throw.
+                assert_true(cancelCalled);
+                test1.done();
+            }), 500);
+        },
+        cancel: function(r) {
+            assert_equals(r, theError, 'reason passed to cancel equals the source error');
+            cancelCalled = true;
+        }
+    });
+
+    var ws = new WritableStream({
+        write: function(chunk) {
+            if (chunk === 'b') {
+                throw theError;
+            }
+        }
+    });
+
+    rs.pipeTo(ws);
+});
+
+var test2 = async_test('Piping with { preventCancel: false } and a destination error');
+test2.step(function() {
+    var cancelCalled = false;
+    var theError = new Error('destination error');
+    var rs = new ReadableStream({
+        start: function(c) {
+            c.enqueue('a');
+            setTimeout(test2.step_func(function() { c.enqueue('b'); }), 200);
+            setTimeout(test2.step_func(function() {
+                c.enqueue('c'); // Enqueue after cancel should not throw.
+                assert_true(cancelCalled);
+                test2.done();
+            }), 500);
+        },
+        cancel: function(r) {
+            assert_equals(r, theError, 'reason passed to cancel equals the source error');
+            cancelCalled = true;
+        }
+    });
+
+    var ws = new WritableStream({
+        write: function(chunk) {
+            if (chunk === 'b') {
+                throw theError;
+            }
+        }
+    });
+
+    rs.pipeTo(ws, { preventCancel: false });
+});
+
+var test3 = async_test('Piping with { preventCancel: true } and a destination error');
+test3.step(function() {
+    var theError = new Error('destination error');
+    var rs = new ReadableStream({
+        start: function(c) {
+            c.enqueue('a');
+            setTimeout(test3.step_func(function() { c.enqueue('b'); }), 200);
+            setTimeout(test3.step_func(function() { c.enqueue('c'); }), 400);
+            setTimeout(test3.step_func(function() { c.enqueue('d'); }), 600);
+        },
+        cancel: function(r) {
+            assert_unreached('unexpected call to cancel');
+        }
+    });
+
+    var ws = new WritableStream({
+        write: function(chunk) {
+            if (chunk === 'b') {
+                throw theError;
+            }
+        }
+    });
+
+    rs.pipeTo(ws, { preventCancel: true }).catch(test3.step_func(function(e) {
+        assert_equals(e, theError, 'rejection reason of pipeTo promise is the sink error');
+
+        var reader;
+        reader = rs.getReader(); // Should be able to get a stream reader after pipeTo completes.
+
+        // { value: 'c', done: false } gets consumed before we know that ws has errored, and so is lost.
+
+        return reader.read().then(test3.step_func(function(result) {
+            assert_object_equals(result, { value: 'd', done: false }, 'should be able to read the remaining chunk from the reader');
+            test3.done();
+        }));
+    })).catch(test3.step_func(function(e) { assert_unreached(e); }));
+});
+</script>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to