Title: [188684] trunk/LayoutTests
Revision
188684
Author
[email protected]
Date
2015-08-20 01:00:43 -0700 (Thu, 20 Aug 2015)

Log Message

[Streams API] Sync tests with upstream reference
https://bugs.webkit.org/show_bug.cgi?id=148078

Synced with the upstream reference tests. This means that we moved
some of ours to the reference and brought some new ones. Of course
expectations were updated accordingly.

Reviewed by Darin Adler.

* streams/readable-stream-controller-error-expected.txt: Expectations.
* streams/readable-stream-controller-error.html: Changed test descriptions and moved one test to the reference.
* streams/readable-stream-gc-expected.txt: Removed.
* streams/readable-stream-gc.html: Moved to the reference.
* streams/readable-stream-reader-read-expected.txt: Expectations.
* streams/readable-stream-reader-read.html: Moved a test to the reference.
* streams/reference-implementation/readable-stream-expected.txt:
* streams/reference-implementation/readable-stream-reader-expected.txt: Expectations.
* streams/reference-implementation/readable-stream-reader.html: Brought changes from upstream reference and
uncomented async pull source test (which had been commented since a long time ago and is working now).
* streams/reference-implementation/readable-stream-tee.html: Brought changes from upstream reference.
* streams/reference-implementation/readable-stream-templated-expected.txt: Expectations.
* streams/reference-implementation/readable-stream-templated.html:
* streams/reference-implementation/readable-stream.html: Brought changes from upstream reference.

Modified Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (188683 => 188684)


--- trunk/LayoutTests/ChangeLog	2015-08-20 07:41:11 UTC (rev 188683)
+++ trunk/LayoutTests/ChangeLog	2015-08-20 08:00:43 UTC (rev 188684)
@@ -1,3 +1,29 @@
+2015-08-20  Xabier Rodriguez Calvar  <[email protected]>
+
+        [Streams API] Sync tests with upstream reference
+        https://bugs.webkit.org/show_bug.cgi?id=148078
+
+        Synced with the upstream reference tests. This means that we moved
+        some of ours to the reference and brought some new ones. Of course
+        expectations were updated accordingly.
+
+        Reviewed by Darin Adler.
+
+        * streams/readable-stream-controller-error-expected.txt: Expectations.
+        * streams/readable-stream-controller-error.html: Changed test descriptions and moved one test to the reference.
+        * streams/readable-stream-gc-expected.txt: Removed.
+        * streams/readable-stream-gc.html: Moved to the reference.
+        * streams/readable-stream-reader-read-expected.txt: Expectations.
+        * streams/readable-stream-reader-read.html: Moved a test to the reference.
+        * streams/reference-implementation/readable-stream-expected.txt:
+        * streams/reference-implementation/readable-stream-reader-expected.txt: Expectations.
+        * streams/reference-implementation/readable-stream-reader.html: Brought changes from upstream reference and
+        uncomented async pull source test (which had been commented since a long time ago and is working now).
+        * streams/reference-implementation/readable-stream-tee.html: Brought changes from upstream reference.
+        * streams/reference-implementation/readable-stream-templated-expected.txt: Expectations.
+        * streams/reference-implementation/readable-stream-templated.html:
+        * streams/reference-implementation/readable-stream.html: Brought changes from upstream reference.
+
 2015-08-19  Wenson Hsieh  <[email protected]>
 
         Select validation does not correctly work when handling change event

Modified: trunk/LayoutTests/streams/readable-stream-controller-error-expected.txt (188683 => 188684)


--- trunk/LayoutTests/streams/readable-stream-controller-error-expected.txt	2015-08-20 07:41:11 UTC (rev 188683)
+++ trunk/LayoutTests/streams/readable-stream-controller-error-expected.txt	2015-08-20 08:00:43 UTC (rev 188684)
@@ -1,5 +1,4 @@
 
-PASS Erroring a ReadableStream should reject ReadableStreamReader close promise 
-PASS Erroring a ReadableStream should reject ReadableStreamReader close promise 
-PASS Erroring a ReadableStream without any value 
+PASS Erroring a ReadableStream after checking closed should reject ReadableStreamReader closed promise 
+PASS Erroring a ReadableStream before checking closed should reject ReadableStreamReader closed promise 
 

Modified: trunk/LayoutTests/streams/readable-stream-controller-error.html (188683 => 188684)


--- trunk/LayoutTests/streams/readable-stream-controller-error.html	2015-08-20 07:41:11 UTC (rev 188683)
+++ trunk/LayoutTests/streams/readable-stream-controller-error.html	2015-08-20 08:00:43 UTC (rev 188684)
@@ -2,7 +2,7 @@
 <script src=''></script>
 <script src=''></script>
 <script>
-var test1 = async_test('Erroring a ReadableStream should reject ReadableStreamReader close promise');
+var test1 = async_test('Erroring a ReadableStream after checking closed should reject ReadableStreamReader closed promise');
 test1.step(function() {
     var controller;
     var rs = new ReadableStream({
@@ -22,7 +22,7 @@
     controller.error(rsError);
 });
 
-var test2 = async_test('Erroring a ReadableStream should reject ReadableStreamReader close promise');
+var test2 = async_test('Erroring a ReadableStream before checking closed should reject ReadableStreamReader closed promise');
 test2.step(function() {
     var controller;
     var rs = new ReadableStream({
@@ -43,23 +43,4 @@
         test2.done();
     }));
 });
-
-var test3 = async_test('Erroring a ReadableStream without any value');
-test3.step(function() {
-    var controller;
-    var rs = new ReadableStream({
-        start: function(c) {
-            controller = c;
-        }
-    });
-
-    rs.getReader().closed.then(test3.step_func(function() {
-        assert_unreached("closed promise should not be resolved when stream is errored");
-    }), test3.step_func(function(err) {
-        assert_equals(err, undefined);
-        test3.done();
-    }));
-
-    controller.error();
-});
 </script>

Deleted: trunk/LayoutTests/streams/readable-stream-gc-expected.txt (188683 => 188684)


--- trunk/LayoutTests/streams/readable-stream-gc-expected.txt	2015-08-20 07:41:11 UTC (rev 188683)
+++ trunk/LayoutTests/streams/readable-stream-gc-expected.txt	2015-08-20 08:00:43 UTC (rev 188684)
@@ -1,5 +0,0 @@
-
-PASS Readable stream controller methods should continue working properly when scripts are loosing reference to the readable stream 
-PASS Readable stream closed promise should resolve even if stream and reader JS references are lost 
-PASS Readable stream closed promise should reject even if stream and reader JS references are lost 
-

Deleted: trunk/LayoutTests/streams/readable-stream-gc.html (188683 => 188684)


--- trunk/LayoutTests/streams/readable-stream-gc.html	2015-08-20 07:41:11 UTC (rev 188683)
+++ trunk/LayoutTests/streams/readable-stream-gc.html	2015-08-20 08:00:43 UTC (rev 188684)
@@ -1,66 +0,0 @@
-<!DOCTYPE html>
-<script src=''></script>
-<script src=''></script>
-<script src=''></script>
-<script>
-function garbageCollectAndDo(task)
-{
-    var timeout = 50;
-    if (window.GCController)
-        window.GCController.collect();
-    else if (window.gc)
-        window.gc();
-    else
-        timeout = 400;
-    setTimeout(task, timeout);
-}
-
-var test1 = async_test('Readable stream controller methods should continue working properly when scripts are loosing reference to the readable stream');
-test1.step(function() {
-    var controller;
-    new ReadableStream({
-        start: function(c) {
-            controller = c;
-        }
-    });
-
-    garbageCollectAndDo(test1.step_func(function() {
-        controller.close();
-        assert_throws(new TypeError(), function() { controller.close(); });
-        assert_throws(new TypeError(), function() { controller.error(); });
-        test1.done();
-    }));
-});
-
-var test2 = async_test('Readable stream closed promise should resolve even if stream and reader JS references are lost');
-test2.step(function() {
-    var controller;
-    new ReadableStream({
-        start: function(c) {
-            controller = c;
-        }
-    }).getReader().closed.then(test2.step_func(function() {
-        test2.done();
-    }));
-
-    garbageCollectAndDo(test2.step_func(function() {
-        controller.close();
-    }));
-});
-
-var test3 = async_test('Readable stream closed promise should reject even if stream and reader JS references are lost');
-test3.step(function() {
-    var controller;
-    new ReadableStream({
-        start: function(c) {
-            controller = c;
-        }
-    }).getReader().closed.catch(test3.step_func(function() {
-        test3.done();
-    }));
-
-    garbageCollectAndDo(test3.step_func(function() {
-        controller.error();
-    }));
-});
-</script>

Modified: trunk/LayoutTests/streams/readable-stream-reader-read-expected.txt (188683 => 188684)


--- trunk/LayoutTests/streams/readable-stream-reader-read-expected.txt	2015-08-20 07:41:11 UTC (rev 188683)
+++ trunk/LayoutTests/streams/readable-stream-reader-read-expected.txt	2015-08-20 08:00:43 UTC (rev 188684)
@@ -3,6 +3,5 @@
 PASS Reading twice on a closed stream 
 PASS Reading twice on an errored stream 
 PASS Reading twice on a stream that gets errored 
-PASS Reading within a read promise resolve callback on a stream that gets closed 
 PASS ReadableStream: if start rejects with no parameter, it should error the stream with an undefined error 
 

Modified: trunk/LayoutTests/streams/readable-stream-reader-read.html (188683 => 188684)


--- trunk/LayoutTests/streams/readable-stream-reader-read.html	2015-08-20 07:41:11 UTC (rev 188683)
+++ trunk/LayoutTests/streams/readable-stream-reader-read.html	2015-08-20 08:00:43 UTC (rev 188684)
@@ -135,36 +135,17 @@
     controller.error(myError);
  });
 
-var test5 = async_test('Reading within a read promise resolve callback on a stream that gets closed');
+var test5 = async_test('ReadableStream: if start rejects with no parameter, it should error the stream with an undefined error');
 test5.step(function() {
-    var controller;
     var rs = new ReadableStream({
         start: function(c) {
-            controller = c;
-        }
-    });
-
-    var reader = rs.getReader();
-
-    reader.read().then(test5.step_func(function() {
-        reader.read().then(test5.step_func(function() {
-            test5.done();
-        }));
-    }));
-    controller.close();
-});
-
-var test6 = async_test('ReadableStream: if start rejects with no parameter, it should error the stream with an undefined error');
-test6.step(function() {
-    var rs = new ReadableStream({
-        start: function(c) {
             return Promise.reject();
         }
     });
 
-    rs.getReader().read().catch(test6.step_func(function(e) {
+    rs.getReader().read().catch(test5.step_func(function(e) {
         assert_equals(typeof e, "undefined");
-        test6.done();
+        test5.done();
     }));
 });
 

Modified: trunk/LayoutTests/streams/reference-implementation/readable-stream-expected.txt (188683 => 188684)


--- trunk/LayoutTests/streams/reference-implementation/readable-stream-expected.txt	2015-08-20 07:41:11 UTC (rev 188683)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-expected.txt	2015-08-20 08:00:43 UTC (rev 188684)
@@ -30,4 +30,8 @@
 PASS ReadableStream strategies: the default strategy should continue giving desiredSize of 1 if the chunks are read immediately 
 PASS ReadableStream integration test: adapting a random push source 
 PASS ReadableStream integration test: adapting a sync pull source 
+PASS ReadableStream integration test: adapting an async pull source 
+PASS ReadableStreamController methods should continue working properly when scripts lose their reference to the readable stream 
+PASS ReadableStream closed promise should fulfill even if the stream and reader JS references are lost 
+PASS ReadableStream closed promise should reject even if stream and reader JS references are lost 
 

Modified: trunk/LayoutTests/streams/reference-implementation/readable-stream-reader-expected.txt (188683 => 188684)


--- trunk/LayoutTests/streams/reference-implementation/readable-stream-reader-expected.txt	2015-08-20 07:41:11 UTC (rev 188683)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-reader-expected.txt	2015-08-20 08:00:43 UTC (rev 188684)
@@ -18,4 +18,5 @@
 PASS cancel() on a released reader is a no-op and does not pass through 
 PASS Getting a second reader after erroring the stream should succeed 
 PASS Garbage-collecting a ReadableStreamReader should not unlock its stream 
+PASS ReadableStreamReader closed promise should be rejected with undefined if that is the error 
 

Modified: trunk/LayoutTests/streams/reference-implementation/readable-stream-reader.html (188683 => 188684)


--- trunk/LayoutTests/streams/reference-implementation/readable-stream-reader.html	2015-08-20 07:41:11 UTC (rev 188683)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-reader.html	2015-08-20 08:00:43 UTC (rev 188684)
@@ -312,4 +312,23 @@
 
     assert_throws(new TypeError(), function() { rs.getReader(); }, 'old reader should still be locking the stream even after garbage collection');
 }, 'Garbage-collecting a ReadableStreamReader should not unlock its stream');
+
+var test9 = async_test('ReadableStreamReader closed promise should be rejected with undefined if that is the error');
+test9.step(function() {
+    var controller;
+    var rs = new ReadableStream({
+        start: function(c) {
+            controller = c;
+        }
+    });
+
+    rs.getReader().closed.then(test9.step_func(function() {
+        assert_unreached("closed promise should not be resolved when stream is errored");
+    }), test9.step_func(function(err) {
+        assert_equals(err, undefined, 'passed error should be undefined as it was');
+        test9.done();
+    }));
+
+    controller.error();
+});
 </script>

Modified: trunk/LayoutTests/streams/reference-implementation/readable-stream-tee.html (188683 => 188684)


--- trunk/LayoutTests/streams/reference-implementation/readable-stream-tee.html	2015-08-20 07:41:11 UTC (rev 188683)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-tee.html	2015-08-20 08:00:43 UTC (rev 188684)
@@ -201,10 +201,10 @@
     var reason2 = new Error('I have the death sentence on twelve systems.');
 
     var rs = new ReadableStream({
-        cancel: test6.step_func(function(reason) {
+        cancel: function(reason) {
             assert_array_equals(reason, [reason1, reason2], 'the cancel reason should be an array containing those from the branches');
             test6.done();
-        })
+        }
     });
 
     var branch = rs.tee();
@@ -230,7 +230,6 @@
     branch1.cancel().catch(test7.step_func(function(e) {
         assert_equals(e, theError, 'branch1.cancel() should reject with the error');
         cancelRejected = true;
-        test7.done();
     }));
     branch2.cancel().catch(test7.step_func(function(e) {
         assert_equals(e, theError, 'branch2.cancel() should reject with the error');

Modified: trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt (188683 => 188684)


--- trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt	2015-08-20 07:41:11 UTC (rev 188683)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt	2015-08-20 08:00:43 UTC (rev 188684)
@@ -19,32 +19,51 @@
 PASS locked should be false 
 PASS getReader() should be OK 
 PASS should be able to acquire multiple readers, since they are all auto-released 
-PASS Running templatedRSClosedReader with ReadableStream (closed via call in start) reader 
+PASS Running templatedRSClosedReader with ReadableStream reader (closed before getting reader) 
 PASS read() should fulfill with { value: undefined, done: true } 
+PASS read() multiple times should fulfill with { value: undefined, done: true } 
+PASS read() should work when used within another read() fulfill callback 
 PASS closed should fulfill with undefined 
 PASS cancel() should return a distinct fulfilled promise each time 
+PASS Running templatedRSClosedReader with ReadableStream reader (closed after getting reader) 
+PASS read() should fulfill with { value: undefined, done: true } 
+PASS read() multiple times should fulfill with { value: undefined, done: true } 
+PASS read() should work when used within another read() fulfill callback 
+PASS closed should fulfill with undefined 
+PASS cancel() should return a distinct fulfilled promise each time 
 PASS Running templatedRSClosed with ReadableStream (closed via cancel) 
 PASS cancel() should return a distinct fulfilled promise each time 
 PASS locked should be false 
 PASS getReader() should be OK 
 PASS should be able to acquire multiple readers, since they are all auto-released 
-PASS Running templatedRSClosedReader with ReadableStream (closed via cancel) reader 
+PASS Running templatedRSClosedReader with ReadableStream reader (closed via cancel after getting reader) 
 PASS read() should fulfill with { value: undefined, done: true } 
+PASS read() multiple times should fulfill with { value: undefined, done: true } 
+PASS read() should work when used within another read() fulfill callback 
 PASS closed should fulfill with undefined 
 PASS cancel() should return a distinct fulfilled promise each time 
 PASS Running templatedRSErrored with ReadableStream (errored via call in start) 
 PASS getReader() should return a reader that acts errored 
+PASS read() twice should give the error each time 
 PASS locked should be false 
 PASS Running templatedRSErroredSyncOnly with ReadableStream (errored via call in start) 
+PASS should be able to obtain a second reader, with the correct closed promise 
 PASS cancel() should return a distinct rejected promise each time 
 PASS reader cancel() should return a distinct rejected promise each time 
 PASS should be able to acquire multiple readers, since they are all auto-released 
 PASS Running templatedRSErrored with ReadableStream (errored via returning a rejected promise in start) 
 PASS getReader() should return a reader that acts errored 
+PASS read() twice should give the error each time 
 PASS locked should be false 
 PASS Running templatedRSErroredReader with ReadableStream (errored via returning a rejected promise in start) reader 
 PASS closed should reject with the error 
 PASS read() should reject with the error 
+PASS Running templatedRSErroredReader with ReadableStream reader (errored before getting reader) 
+PASS closed should reject with the error 
+PASS read() should reject with the error 
+PASS Running templatedRSErroredReader with ReadableStream reader (errored after getting reader) 
+PASS closed should reject with the error 
+PASS read() should reject with the error 
 PASS Running templatedRSTwoChunksOpenReader with ReadableStream (two chunks enqueued, still open) reader 
 PASS calling read() twice without waiting will eventually give both chunks 
 PASS calling read() twice with waiting will eventually give both chunks 

Modified: trunk/LayoutTests/streams/reference-implementation/readable-stream-templated.html (188683 => 188684)


--- trunk/LayoutTests/streams/reference-implementation/readable-stream-templated.html	2015-08-20 07:41:11 UTC (rev 188683)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-templated.html	2015-08-20 08:00:43 UTC (rev 188684)
@@ -91,6 +91,28 @@
         }));
     });
 
+    var test2 = async_test('read() twice should give the error each time');
+    test2.step(function() {
+        var rs = factory();
+        var promiseCount = 0;
+
+        var reader = rs.getReader();
+
+        reader.read().catch(test2.step_func(function(e) {
+            assert_equals(e, error, 'reader.read() should reject with the error');
+            assert_equals(++promiseCount, 1);
+        }));
+        reader.read().catch(test2.step_func(function(e) {
+            assert_equals(e, error, 'reader.read() should reject with the error');
+            assert_equals(++promiseCount, 2);
+        }));
+        reader.closed.catch(test2.step_func(function(e) {
+            assert_equals(e, error, 'reader.closed should reject with the error');
+            assert_equals(++promiseCount, 3);
+            test2.done();
+        }));
+   });
+
     test(function() {
         var rs = factory();
 
@@ -102,31 +124,48 @@
     test(function() {
     }, 'Running templatedRSErroredSyncOnly with ' + label);
 
-    var test1 = async_test('cancel() should return a distinct rejected promise each time');
+    var test1 = async_test('should be able to obtain a second reader, with the correct closed promise');
     test1.step(function() {
         var rs = factory();
+
+        rs.getReader();
+
+        var reader = rs.getReader(); // Calling getReader() twice does not throw (the stream is not locked).
+
+        reader.closed.then(
+            test1.step_func(function() { assert_unreached('closed promise should not be fulfilled when stream is errored'); }),
+            test1.step_func(function(err) {
+                assert_equals(err, error);
+                test1.done();
+            })
+        );
+    });
+
+    var test2 = async_test('cancel() should return a distinct rejected promise each time');
+    test2.step(function() {
+        var rs = factory();
         var promisesCount = 0;
         var allChecked = false;
 
         var cancelPromise1 = rs.cancel();
         var cancelPromise2 = rs.cancel();
 
-        cancelPromise1.catch(test1.step_func(function(e) {
+        cancelPromise1.catch(test2.step_func(function(e) {
             assert_equals(e, error, 'first cancel() call should reject with the error');
             ++promisesCount;
         }));
-        cancelPromise2.catch(test1.step_func(function(e) {
+        cancelPromise2.catch(test2.step_func(function(e) {
             assert_equals(e, error, 'second cancel() call should reject with the error');
             assert_equals(++promisesCount, 2);
             assert_true(allChecked);
-            test1.done();
+            test2.done();
         }));
         assert_not_equals(cancelPromise1, cancelPromise2, 'cancel() calls should return distinct promises');
         allChecked = true;
     });
 
-    var test2 = async_test('reader cancel() should return a distinct rejected promise each time');
-    test2.step(function() {
+    var test3 = async_test('reader cancel() should return a distinct rejected promise each time');
+    test3.step(function() {
         var rs = factory();
         var reader = rs.getReader();
         var promisesCount = 0;
@@ -135,15 +174,15 @@
         var cancelPromise1 = reader.cancel();
         var cancelPromise2 = reader.cancel();
 
-        cancelPromise1.catch(test2.step_func(function(e) {
+        cancelPromise1.catch(test3.step_func(function(e) {
             assert_equals(e, error, 'first cancel() call should reject with the error');
             ++promisesCount;
         }));
-        cancelPromise2.catch(test2.step_func(function(e) {
+        cancelPromise2.catch(test3.step_func(function(e) {
             assert_equals(e, error, 'second cancel() call should reject with the error');
             assert_equals(++promisesCount, 2);
             assert_true(allChecked);
-            test2.done();
+            test3.done();
         }));
         assert_not_equals(cancelPromise1, cancelPromise2, 'cancel() calls should return distinct promises');
         allChecked = true;
@@ -328,22 +367,51 @@
         );
     });
 
-    var test2 = async_test('closed should fulfill with undefined');
+    var test2 = async_test('read() multiple times should fulfill with { value: undefined, done: true }');
     test2.step(function() {
         var { reader } = factory();
+        var readCount = 0;
 
-        reader.closed.then(
+        reader.read().then(
             test2.step_func(function(v) {
-                assert_equals(v, undefined, 'reader closed should fulfill with undefined');
+                assert_object_equals(v, { value: undefined, done: true }, 'read() should fulfill correctly');
+                ++readCount;
+            }),
+            test2.step_func(function() { assert_unreached('read() should not return a rejected promise'); })
+        );
+        reader.read().then(
+            test2.step_func(function(v) {
+                assert_object_equals(v, { value: undefined, done: true }, 'read() should fulfill correctly');
+                assert_equals(++readCount, 2);
                 test2.done();
             }),
-            test2.step_func(function() { assert_unreached('reader closed should not reject'); })
+            test2.step_func(function() { assert_unreached('read() should not return a rejected promise'); })
         );
     });
 
-    var test3 = async_test('cancel() should return a distinct fulfilled promise each time');
+    var test3 = async_test('read() should work when used within another read() fulfill callback');
     test3.step(function() {
         var { reader } = factory();
+
+        reader.read().then(test3.step_func(function() { reader.read().then(test3.step_func(function() { test3.done('read() should fulfill'); })); }));
+    });
+
+    var test4 = async_test('closed should fulfill with undefined');
+    test4.step(function() {
+        var { reader } = factory();
+
+        reader.closed.then(
+            test4.step_func(function(v) {
+                assert_equals(v, undefined, 'reader closed should fulfill with undefined');
+                test4.done();
+            }),
+            test4.step_func(function() { assert_unreached('reader closed should not reject'); })
+        );
+    });
+
+    var test5 = async_test('cancel() should return a distinct fulfilled promise each time');
+    test5.step(function() {
+        var { reader } = factory();
         var promiseCount = 0;
         var allChecked = false;
 
@@ -351,15 +419,15 @@
         var cancelPromise2 = reader.cancel();
         var closedReaderPromise = reader.closed;
 
-        cancelPromise1.then(test3.step_func(function(v) {
+        cancelPromise1.then(test5.step_func(function(v) {
             assert_equals(v, undefined, 'first cancel() call should fulfill with undefined');
             ++promiseCount;
         }));
-        cancelPromise2.then(test3.step_func(function(v) {
+        cancelPromise2.then(test5.step_func(function(v) {
             assert_equals(v, undefined, 'second cancel() call should fulfill with undefined');
             assert_equals(++promiseCount, 2);
             assert_true(allChecked);
-            test3.done();
+            test5.done();
         }));
         assert_not_equals(cancelPromise1, cancelPromise2, 'cancel() calls should return distinct promises');
         assert_not_equals(cancelPromise1, closedReaderPromise, 'cancel() promise 1 should be distinct from reader.closed');
@@ -607,14 +675,26 @@
     });
 });
 
-templatedRSClosedReader('ReadableStream (closed via call in start) reader', function() {
+templatedRSClosedReader('ReadableStream reader (closed before getting reader)', function() {
     var controller;
     var stream = new ReadableStream({
         start: function(c) {
             controller = c;
         }
     });
+    controller.close();
     var result = streamAndDefaultReader(stream);
+    return result;
+});
+
+templatedRSClosedReader('ReadableStream reader (closed after getting reader)', function() {
+    var controller;
+    var stream = new ReadableStream({
+        start: function(c) {
+            controller = c;
+        }
+    });
+    var result = streamAndDefaultReader(stream);
     controller.close();
     return result;
 });
@@ -625,7 +705,7 @@
     return stream;
 });
 
-templatedRSClosedReader('ReadableStream (closed via cancel) reader', function() {
+templatedRSClosedReader('ReadableStream reader (closed via cancel after getting reader)', function() {
     var stream = new ReadableStream();
     var result = streamAndDefaultReader(stream);
     result.reader.cancel();
@@ -670,6 +750,28 @@
     theError
 );
 
+templatedRSErroredReader('ReadableStream reader (errored before getting reader)', function() {
+    var controller;
+    var stream = new ReadableStream({
+        start: function(c) {
+            controller = c;
+        }
+    });
+    controller.error(theError);
+    return streamAndDefaultReader(stream);
+}, theError);
+
+templatedRSErroredReader('ReadableStream reader (errored after getting reader)', function() {
+    var controller;
+    var result = streamAndDefaultReader(new ReadableStream({
+        start: function(c) {
+            controller = c;
+        }
+    }));
+    controller.error(theError);
+    return result;
+}, theError);
+
 var chunks = ['a', 'b'];
 
 templatedRSTwoChunksOpenReader('ReadableStream (two chunks enqueued, still open) reader', function() {

Modified: trunk/LayoutTests/streams/reference-implementation/readable-stream.html (188683 => 188684)


--- trunk/LayoutTests/streams/reference-implementation/readable-stream.html	2015-08-20 07:41:11 UTC (rev 188683)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream.html	2015-08-20 08:00:43 UTC (rev 188684)
@@ -2,6 +2,7 @@
 <script src=''></script>
 <script src=''></script>
 <script src=''></script>
+<script src=''></script>
 <script>
 test(function() {
     new ReadableStream(); // ReadableStream constructed with no parameters.
@@ -765,15 +766,76 @@
     }));
 });
 
-// var test20 = async_test('ReadableStream integration test: adapting an async pull source');
-// test20.step(function() {
-//     var rs = sequentialReadableStream(10, { async: true });
+var test20 = async_test('ReadableStream integration test: adapting an async pull source');
+test20.step(function() {
+    var rs = sequentialReadableStream(10, { async: true });
 
-//     readableStreamToArray(rs).then(test20.step_func(function(chunks) {
-//         assert_true(rs.source.closed, 'source should be closed after all chunks are read');
-//         assert_array_equals(chunks, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 'the expected 10 chunks should be read');
+    readableStreamToArray(rs).then(test20.step_func(function(chunks) {
+        assert_true(rs.source.closed, 'source should be closed after all chunks are read');
+        assert_array_equals(chunks, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 'the expected 10 chunks should be read');
 
-//         test20.done();
-//     }));
-// });
+        test20.done();
+    }));
+});
+
+function garbageCollectAndDo(task)
+{
+    var timeout = 50;
+    if (window.GCController)
+        window.GCController.collect();
+    else if (window.gc)
+        window.gc();
+    else
+        timeout = 400;
+    setTimeout(task, timeout);
+}
+
+var test21 = async_test('ReadableStreamController methods should continue working properly when scripts lose their reference to the readable stream');
+test21.step(function() {
+    var controller;
+    new ReadableStream({
+        start: function(c) {
+            controller = c;
+        }
+    });
+
+    garbageCollectAndDo(test21.step_func(function() {
+        controller.close();
+        assert_throws(new TypeError(), function() { controller.close(); }, 'close should throw a TypeError the second time');
+        assert_throws(new TypeError(), function() { controller.error(); }), 'error should throw a TypeError on a closed stream';
+        test21.done();
+    }));
+});
+
+var test22 = async_test('ReadableStream closed promise should fulfill even if the stream and reader JS references are lost');
+test22.step(function() {
+    var controller;
+    new ReadableStream({
+        start: function(c) {
+            controller = c;
+        }
+    }).getReader().closed.then(test22.step_func(function() {
+        test22.done('closed promise should be fulfilled');
+    }));
+
+    garbageCollectAndDo(test22.step_func(function() {
+        controller.close();
+    }));
+});
+
+var test23 = async_test('ReadableStream closed promise should reject even if stream and reader JS references are lost');
+test23.step(function() {
+    var controller;
+    new ReadableStream({
+        start: function(c) {
+            controller = c;
+        }
+    }).getReader().closed.catch(test23.step_func(function() {
+        test23.done('closed promise should be rejected');
+    }));
+
+    garbageCollectAndDo(test23.step_func(function() {
+        controller.error();
+    }));
+});
 </script>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to