Title: [191293] trunk/LayoutTests
Revision
191293
Author
calva...@igalia.com
Date
2015-10-19 09:36:44 -0700 (Mon, 19 Oct 2015)

Log Message

[Streams API] Update readable-stream-reader tests to latest spec
https://bugs.webkit.org/show_bug.cgi?id=149699

Reviewed by Darin Adler.

* streams/reference-implementation/readable-stream-reader-expected.txt: Updated expectations.
* streams/reference-implementation/readable-stream-reader.html: Updated tests.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (191292 => 191293)


--- trunk/LayoutTests/ChangeLog	2015-10-19 16:34:44 UTC (rev 191292)
+++ trunk/LayoutTests/ChangeLog	2015-10-19 16:36:44 UTC (rev 191293)
@@ -1,5 +1,15 @@
 2015-10-19  Xabier Rodriguez Calvar  <calva...@igalia.com>
 
+        [Streams API] Update readable-stream-reader tests to latest spec
+        https://bugs.webkit.org/show_bug.cgi?id=149699
+
+        Reviewed by Darin Adler.
+
+        * streams/reference-implementation/readable-stream-reader-expected.txt: Updated expectations.
+        * streams/reference-implementation/readable-stream-reader.html: Updated tests.
+
+2015-10-19  Xabier Rodriguez Calvar  <calva...@igalia.com>
+
         [Streams API] Update readable-stream-controller-error tests against latest reference
         https://bugs.webkit.org/show_bug.cgi?id=149700
 

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


--- trunk/LayoutTests/streams/reference-implementation/readable-stream-reader-expected.txt	2015-10-19 16:34:44 UTC (rev 191292)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-reader-expected.txt	2015-10-19 16:36:44 UTC (rev 191293)
@@ -10,12 +10,12 @@
 PASS Constructing a ReadableStreamReader directly should be OK if the stream is closed 
 PASS Constructing a ReadableStreamReader directly should be OK if the stream is errored 
 PASS Reading from a reader for an empty stream will wait until a chunk is available 
-PASS cancel() on a reader releases the reader before calling through 
+FAIL cancel() on a reader does not release the reader assert_unreached: reader.cancel() should not reject Reached unreachable code
 PASS closed should be fulfilled after stream is closed (.closed access before acquiring) 
-PASS closed should be fulfilled after reader releases its lock (multiple stream locks) 
+FAIL closed should be rejected after reader releases its lock (multiple stream locks) assert_equals: expected 2 but got 1
 PASS Multiple readers can access the stream in sequence 
 PASS Cannot use an already-released reader to unlock a stream again 
-PASS cancel() on a released reader is a no-op and does not pass through 
+FAIL cancel() on a released reader is a no-op and does not pass through assert_unreached: cancel promise should not fulfill Reached unreachable code
 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 (191292 => 191293)


--- trunk/LayoutTests/streams/reference-implementation/readable-stream-reader.html	2015-10-19 16:34:44 UTC (rev 191292)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-reader.html	2015-10-19 16:36:44 UTC (rev 191293)
@@ -4,6 +4,8 @@
 <script src=''></script>
 <script src=''></script>
 <script>
+// This is updated till https://github.com/whatwg/streams/commit/ec5ffa036308d9f6350d2946560d48cdbf090939
+
 var ReadableStreamReader;
 
 test(function() {
@@ -65,8 +67,8 @@
 
 test(function() {
     var rs = new ReadableStream();
-    new ReadableStreamReader(rs); // Constructing directly should be fine.
-    assert_throws(new TypeError(), function() { new ReadableStreamReader(rs); }, 'constructing directly should fail');
+    new ReadableStreamReader(rs); // Constructing directly the first time should be fine.
+    assert_throws(new TypeError(), function() { new ReadableStreamReader(rs); }, 'constructing directly the second time should fail');
 }, 'Constructing a ReadableStreamReader directly should fail if the stream is already locked (via direct construction)');
 
 test(function() {
@@ -126,15 +128,16 @@
     controller.enqueue('a');
 });
 
-var test2 = async_test('cancel() on a reader releases the reader before calling through');
+var test2 = async_test('cancel() on a reader does not release the reader');
 test2.step(function() {
     var cancelCalled = false;
     var passedReason = new Error('it wasn\'t the right time, sorry');
     var rs = new ReadableStream({
         cancel: function(reason) {
+            assert_true(rs.locked, 'the stream should still be locked');
+            assert_throws(new TypeError(), function() { rs.getReader(); }, 'should not be able to get another reader');
+            assert_equals(reason, passedReason, 'the cancellation reason is passed through to the underlying source');
             cancelCalled = true;
-            rs.getReader(); // Should be able to get another reader without error.
-            assert_equals(reason, passedReason, 'the cancellation reason is passed through to the underlying source');
         }
     });
 
@@ -144,7 +147,8 @@
             assert_true(cancelCalled);
             test2.done('reader.cancel() should fulfill');
         }),
-        test2.step_func(function(e) { assert_unreached('reader.cancel() should not reject'); }));
+        test2.step_func(function(e) { assert_unreached('reader.cancel() should not reject'); })
+    );
 });
 
 var test3 = async_test('closed should be fulfilled after stream is closed (.closed access before acquiring)');
@@ -164,10 +168,10 @@
     controller.close();
 });
 
-var test4 = async_test('closed should be fulfilled after reader releases its lock (multiple stream locks)');
+var test4 = async_test('closed should be rejected after reader releases its lock (multiple stream locks)');
 test4.step(function() {
+    var promiseCalls = 0;
     var controller;
-    var reader1Closed = false;
     var rs = new ReadableStream({
         start: function(c) {
             controller = c;
@@ -181,12 +185,13 @@
     var reader2 = rs.getReader();
     controller.close();
 
-    reader1.closed.then(test4.step_func(function() {
-        reader1Closed = true;
+    reader1.closed.catch(test4.step_func(function(e) {
+        assert_throws(new TypeError(), function() { throw e; }, 'reader1 closed should be rejected with a TypeError');
+        assert_equals(++promiseCalls, 1);
     }));
 
     reader2.closed.then(test4.step_func(function() {
-        assert_true(reader1Closed);
+        assert_equals(++promiseCalls, 2);
         test4.done('reader2 closed should be fulfilled');
     }));
 });
@@ -240,7 +245,7 @@
 
 var test7 = async_test('cancel() on a released reader is a no-op and does not pass through');
 test7.step(function() {
-    var cancelled = false;
+    var promiseCalls = 0;
     var rs = new ReadableStream({
         start: function(c) {
             c.enqueue('a');
@@ -253,15 +258,16 @@
     var reader = rs.getReader();
     reader.releaseLock();
     reader.cancel().then(test7.step_func(function(v) {
-        assert_equals(v, undefined, 'cancel() on the reader should fulfill with undefined')
-        cancelled = true;
+        assert_unreached('cancel promise should not fulfill');
+    })).catch(test7.step_func(function(e) {
+        assert_equals(++promiseCalls, 2);
+        test7.done();
     }));
 
     var reader2 = rs.getReader();
     reader2.read().then(test7.step_func(function(r) {
         assert_object_equals(r, { value: 'a', done: false }, 'a new reader should be able to read a chunk');
-        assert_true(cancelled);
-        test7.done();
+        assert_equals(++promiseCalls, 1);
     }));
 });
 
@@ -292,12 +298,16 @@
 
     controller.error(theError);
 
-    rs.getReader().closed.catch(test8.step_func(function(e) {
+    reader1.releaseLock();
+
+    var reader2 = rs.getReader();
+
+    reader2.closed.catch(test8.step_func(function(e) {
         assert_equals(e, theError, 'the second reader closed getter should be rejected with the error');
         ++receivedErrors;
     }));
 
-    rs.getReader().read().catch(test8.step_func(function(e) {
+    reader2.read().catch(test8.step_func(function(e) {
         assert_equals(e, theError, 'the third reader read() should be rejected with the error');
         assert_equals(++receivedErrors, 4);
         test8.done();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to