Title: [191337] trunk/LayoutTests
Revision
191337
Author
[email protected]
Date
2015-10-20 03:07:36 -0700 (Tue, 20 Oct 2015)

Log Message

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

Reviewed by Darin Adler.

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

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (191336 => 191337)


--- trunk/LayoutTests/ChangeLog	2015-10-20 09:57:23 UTC (rev 191336)
+++ trunk/LayoutTests/ChangeLog	2015-10-20 10:07:36 UTC (rev 191337)
@@ -1,3 +1,13 @@
+2015-10-20  Xabier Rodriguez Calvar  <[email protected]>
+
+        [Streams API] Update readable-stream-templated tests to latest spec
+        https://bugs.webkit.org/show_bug.cgi?id=149668
+
+        Reviewed by Darin Adler.
+
+        * streams/reference-implementation/readable-stream-expected.txt: Updated expectations.
+        * streams/reference-implementation/readable-stream.html: Updated tests.
+
 2015-10-13  Sergio Villar Senin  <[email protected]>
 
         ASSERTION FAILED: computeMainAxisExtentForChild(child, MainOrPreferredSize, mainSize) in WebCore::RenderFlexibleBox::adjustChildSizeForMinAndMax

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


--- trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt	2015-10-20 09:57:23 UTC (rev 191336)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt	2015-10-20 10:07:36 UTC (rev 191337)
@@ -9,8 +9,8 @@
 PASS read() should return distinct promises each time 
 PASS getReader() again on the stream should fail 
 PASS releasing the lock with pending read requests should throw but the read requests should stay pending 
-PASS releasing the lock should cause further read() calls to resolve as if the stream is closed 
-PASS releasing the lock should cause closed to fulfill 
+TIMEOUT releasing the lock should cause further read() calls to reject with a TypeError Test timed out
+TIMEOUT releasing the lock should cause closed to reject Test timed out
 PASS releasing the lock should cause locked to become false 
 PASS canceling via the reader should cause the reader to act closed 
 PASS canceling via the stream should fail 
@@ -20,18 +20,21 @@
 PASS getReader() should be OK 
 FAIL piping to a WritableStream in the writable state should close the writable stream WritableStream constructor not implemented
 FAIL piping to a WritableStream in the writable state with { preventClose: true } should do nothing WritableStream constructor not implemented
-PASS should be able to acquire multiple readers, since they are all auto-released 
+PASS should be able to acquire multiple readers if they are released in succession 
+FAIL should not be able to acquire a second reader if we don't release the first one assert_throws: getting a second reader should throw function "function () { rs.getReader(); }" did not throw
 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 
+FAIL releasing the lock should cause closed to reject and change identity assert_not_equals: the closed promise should change identity got disallowed value object "[object Promise]"
 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 
+FAIL releasing the lock should cause closed to reject and change identity assert_not_equals: the closed promise should change identity got disallowed value object "[object Promise]"
 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 
@@ -39,12 +42,14 @@
 PASS getReader() should be OK 
 FAIL piping to a WritableStream in the writable state should close the writable stream WritableStream constructor not implemented
 FAIL piping to a WritableStream in the writable state with { preventClose: true } should do nothing WritableStream constructor not implemented
-PASS should be able to acquire multiple readers, since they are all auto-released 
+PASS should be able to acquire multiple readers if they are released in succession 
+FAIL should not be able to acquire a second reader if we don't release the first one assert_throws: getting a second reader should throw function "function () { rs.getReader(); }" did not throw
 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 
+FAIL releasing the lock should cause closed to reject and change identity assert_not_equals: the closed promise should change identity got disallowed value object "[object Promise]"
 PASS cancel() should return a distinct fulfilled promise each time 
 PASS Running templatedRSErrored with ReadableStream (errored via call in start) 
 FAIL piping to a WritableStream in the writable state should abort the writable stream WritableStream constructor not implemented
@@ -53,9 +58,9 @@
 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 
+FAIL should not be able to obtain additional readers if we don't release the first lock assert_throws: getting a second reader should throw a TypeError function "function () { rs.getReader(); }" did not throw
 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) 
 FAIL piping to a WritableStream in the writable state should abort the writable stream WritableStream constructor not implemented
 PASS getReader() should return a reader that acts errored 
@@ -67,12 +72,15 @@
 FAIL piping with { preventAbort: true } WritableStream constructor not implemented
 PASS Running templatedRSErroredReader with ReadableStream (errored via returning a rejected promise in start) reader 
 PASS closed should reject with the error 
+FAIL releasing the lock should cause closed to reject and change identity assert_not_equals: the closed promise should change identity got disallowed value object "[object Promise]"
 PASS read() should reject with the error 
 PASS Running templatedRSErroredReader with ReadableStream reader (errored before getting reader) 
 PASS closed should reject with the error 
+FAIL releasing the lock should cause closed to reject and change identity assert_not_equals: the closed promise should change identity got disallowed value object "[object Promise]"
 PASS read() should reject with the error 
 PASS Running templatedRSErroredReader with ReadableStream reader (errored after getting reader) 
 PASS closed should reject with the error 
+FAIL releasing the lock should cause closed to reject and change identity assert_not_equals: the closed promise should change identity got disallowed value object "[object Promise]"
 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 
@@ -103,8 +111,8 @@
 PASS Running templatedRSTwoChunksClosedReader with ReadableStream (two chunks enqueued, then closed) reader 
 PASS third read(), without waiting, should give { value: undefined, done: true } 
 PASS third read, with waiting, should give { value: undefined, done: true } 
-PASS draining the stream via read() should cause the reader closed promise to fulfill and locked to be false 
-PASS releasing the lock after the stream is closed should do nothing 
-PASS releasing the lock should cause read() to act as if the stream is closed 
+FAIL draining the stream via read() should cause the reader closed promise to fulfill, but locked stays true assert_true: stream should remain locked expected true got false
+FAIL releasing the lock after the stream is closed should cause locked to become false assert_true: the stream should start locked expected true got false
+TIMEOUT releasing the lock should cause further read() calls to reject with a TypeError Test timed out
 PASS reader's closed property always returns the same promise 
 

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


--- trunk/LayoutTests/streams/reference-implementation/readable-stream-templated.html	2015-10-20 09:57:23 UTC (rev 191336)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-templated.html	2015-10-20 10:07:36 UTC (rev 191337)
@@ -3,6 +3,8 @@
 <script src=''></script>
 <script src=''></script>
 <script>
+// This is updated till https://github.com/whatwg/streams/commit/ec5ffa036308d9f6350d2946560d48cdbf090939
+
 function templatedRSEmpty(label, factory) {
     test(function() {
     }, 'Running templatedRSEmpty with ' + label);
@@ -124,11 +126,23 @@
     test(function() {
         var rs = factory();
 
+        var reader = rs.getReader();
+        reader.releaseLock();
+
+        reader = rs.getReader(); // Getting a second reader should not throw.
+        reader.releaseLock();
+
+        rs.getReader(); // Getting a third reader should not throw.
+    }, 'should be able to acquire multiple readers if they are released in succession');
+
+    test(function() {
+        var rs = factory();
+
         rs.getReader();
 
-        rs.getReader(); // Getting a second reader should not throw.
-        rs.getReader(); // Getting a third reader should not throw.
-    }, 'should be able to acquire multiple readers, since they are all auto-released');
+        assert_throws(new TypeError(), function() { rs.getReader(); }, 'getting a second reader should throw');
+        assert_throws(new TypeError(), function() { rs.getReader(); }, 'getting a third reader should throw');
+    }, 'should not be able to acquire a second reader if we don\'t release the first one');
 };
 
 function templatedRSErrored(label, factory, error) {
@@ -300,7 +314,7 @@
     test1.step(function() {
         var rs = factory();
 
-        rs.getReader();
+        rs.getReader().releaseLock();
 
         var reader = rs.getReader(); // Calling getReader() twice does not throw (the stream is not locked).
 
@@ -313,6 +327,15 @@
         );
     });
 
+    test(function() {
+        var rs = factory();
+
+        rs.getReader();
+
+        assert_throws(new TypeError(), function() { rs.getReader(); }, 'getting a second reader should throw a TypeError');
+        assert_throws(new TypeError(), function() { rs.getReader(); }, 'getting a third reader should throw a TypeError');
+    }, 'should not be able to obtain additional readers if we don\'t release the first lock');
+
     var test2 = async_test('cancel() should return a distinct rejected promise each time');
     test2.step(function() {
         var rs = factory();
@@ -359,15 +382,6 @@
         assert_not_equals(cancelPromise1, cancelPromise2, 'cancel() calls should return distinct promises');
         allChecked = true;
     });
-
-    test(function() {
-        var rs = factory();
-
-        rs.getReader();
-
-        rs.getReader(); // Getting a second reader should not throw.
-        rs.getReader(); // Getting a third reader should not throw.
-    }, 'should be able to acquire multiple readers, since they are all auto-released');
 };
 
 function templatedRSTwoChunksClosed(label, factory, error) {
@@ -592,7 +606,7 @@
 
     var test3 = async_test('releasing the lock with pending read requests should throw but the read requests should stay pending');
     test3.step(function() {
-        var { reader } = factory();
+        var { stream, reader } = factory();
 
         reader.read().then(
             test3.step_func(function() { assert_unreached('first read() should not fulfill'); }),
@@ -611,42 +625,40 @@
 
         assert_throws(new TypeError(), function() { reader.releaseLock(); }, 'releaseLock should throw a TypeError');
 
+        assert_true(stream.locked, 'the stream should still be locked');
+
         setTimeout(test3.step_func(function() { test3.done(); }), 1000);
     });
 
-    var test4 = async_test('releasing the lock should cause further read() calls to resolve as if the stream is closed');
+    var test4 = async_test('releasing the lock should cause further read() calls to reject with a TypeError', { timeout: 50 });
     test4.step(function() {
+        var promiseCalls = 0;
         var { reader } = factory();
-        var promisesCount = 0;
 
         reader.releaseLock();
 
-        reader.read().then(test4.step_func(function(r) {
-            assert_object_equals(r, { value: undefined, done: true }, 'first read() should return closed result');
-            ++promisesCount;
+        reader.read().catch(test4.step_func(function(e) {
+            assert_throws(new TypeError(), function() { throw e; }, 'first read() should reject with a TypeError');
+            assert_equals(++promiseCalls, 1);
         }));
-        reader.read().then(test4.step_func(function(r) {
-            assert_object_equals(r, { value: undefined, done: true }, 'second read() should return closed result');
-            assert_equals(++promisesCount, 2);
+        reader.read().catch(test4.step_func(function(e) {
+            assert_throws(new TypeError(), function() { throw e; }, 'second read() should reject with a TypeError');
+            assert_equals(++promiseCalls, 2);
             test4.done();
         }));
     });
 
-    var test5 = async_test('releasing the lock should cause closed to fulfill');
+    var test5 = async_test('releasing the lock should cause closed to reject', { timeout: 50 });
     test5.step(function() {
         var { reader } = factory();
-        var promisesCount = 0;
 
-        reader.closed.then(test5.step_func(function(v) {
-            assert_equals(v, undefined, 'reader.closed got before release should fulfill with undefined');
-            ++promisesCount;
-        }));
-
+        var closedBefore = reader.closed;
         reader.releaseLock();
+        var closedAfter = reader.closed;
 
-        reader.closed.then(test5.step_func(function(v) {
-            assert_equals(v, undefined, 'reader.closed got after release should fulfill with undefined');
-            assert_equals(++promisesCount, 2);
+        assert_equals(closedBefore, closedAfter, 'the closed promise should not change identity')
+        closedBefore.catch(test5.step_func(function(e) {
+            assert_throws(new TypeError(), function() { throw e; }, 'reader.closed should reject with a TypeError');
             test5.done();
         }));
     });
@@ -739,9 +751,30 @@
         );
     });
 
-    var test5 = async_test('cancel() should return a distinct fulfilled promise each time');
+    var test5 = async_test('releasing the lock should cause closed to reject and change identity');
     test5.step(function() {
+        var promiseCalls = 0;
         var { reader } = factory();
+
+        var closedBefore = reader.closed;
+        reader.releaseLock();
+        var closedAfter = reader.closed;
+
+        assert_not_equals(closedBefore, closedAfter, 'the closed promise should change identity')
+        closedBefore.then(test5.step_func(function(v) {
+            assert_equals(v, undefined, 'reader.closed acquired before release should fulfill');
+            assert_equals(++promiseCalls, 1);
+        }));
+        closedAfter.catch(test5.step_func(function(e) {
+            assert_throws(new TypeError(), function() { throw e; }, 'reader.closed acquired after release should reject with a TypeError');
+            assert_equals(++promiseCalls, 2);
+            test5.done();
+        }));
+    });
+
+    var test6 = async_test('cancel() should return a distinct fulfilled promise each time');
+    test6.step(function() {
+        var { reader } = factory();
         var promiseCount = 0;
         var allChecked = false;
 
@@ -749,15 +782,15 @@
         var cancelPromise2 = reader.cancel();
         var closedReaderPromise = reader.closed;
 
-        cancelPromise1.then(test5.step_func(function(v) {
+        cancelPromise1.then(test6.step_func(function(v) {
             assert_equals(v, undefined, 'first cancel() call should fulfill with undefined');
             ++promiseCount;
         }));
-        cancelPromise2.then(test5.step_func(function(v) {
+        cancelPromise2.then(test6.step_func(function(v) {
             assert_equals(v, undefined, 'second cancel() call should fulfill with undefined');
             assert_equals(++promiseCount, 2);
             assert_true(allChecked);
-            test5.done();
+            test6.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');
@@ -783,17 +816,38 @@
         );
     });
 
-    var test2 = async_test('read() should reject with the error');
+    var test2 = async_test('releasing the lock should cause closed to reject and change identity');
     test2.step(function() {
         var { reader } = factory();
 
+        var closedBefore = reader.closed;
+
+        closedBefore.catch(test2.step_func(function(e) {
+            assert_equals(e, error, 'reader.closed acquired before release should reject with the error');
+
+            reader.releaseLock();
+            var closedAfter = reader.closed;
+
+            assert_not_equals(closedBefore, closedAfter, 'the closed promise should change identity');
+
+            return closedAfter.catch(test2.step_func(function(e) {
+                assert_throws(new TypeError(), function() { throw e; }, 'reader.closed acquired after release should reject with a TypeError');
+                test2.done();
+            }));
+        })).catch(test2.step_func(function(e) { assert_unreached(e); }));
+    });
+
+    var test3 = async_test('read() should reject with the error');
+    test3.step(function() {
+        var { reader } = factory();
+
         reader.read().then(
-            test2.step_func(function() {
+            test3.step_func(function() {
                 assert_unreached('read() should not fulfill');
             }),
-            test2.step_func(function(r) {
+            test3.step_func(function(r) {
                 assert_equals(r, error, 'read() should reject with the error');
-                test2.done();
+                test3.done();
             })
         );
     });
@@ -906,16 +960,16 @@
         })).catch(test2.step_func(function(e) { assert_unreached(e); }));
     });
 
-    var test3 = async_test('draining the stream via read() should cause the reader closed promise to fulfill and locked to be false');
+    var test3 = async_test('draining the stream via read() should cause the reader closed promise to fulfill, but locked stays true');
     test3.step(function() {
         var { stream, reader } = factory();
-        var readCalled = false;
 
+        assert_true(stream.locked, 'stream should start locked');
+
         reader.closed.then(
             test3.step_func(function(v) {
-                assert_true(readCalled);
                 assert_equals(v, undefined, 'reader closed should fulfill with undefined');
-                assert_false(stream.locked, 'stream should no longer be locked');
+                assert_true(stream.locked, 'stream should remain locked');
                 test3.done();
             }),
             test3.step_func(function() { assert_unreached('reader closed should not reject'); })
@@ -923,45 +977,43 @@
 
         reader.read();
         reader.read();
-        readCalled = true;
     });
 
-    var test4 = async_test('releasing the lock after the stream is closed should do nothing');
+    var test4 = async_test('releasing the lock after the stream is closed should cause locked to become false');
     test4.step(function() {
-        var { reader } = factory();
-        var readCalled = false;
+        var { stream, reader } = factory();
 
         reader.closed.then(test4.step_func(function() {
-            assert_true(readCalled);
+            assert_true(stream.locked, 'the stream should start locked');
             reader.releaseLock(); // Releasing the lock after reader closed should not throw.
+            assert_false(stream.locked, 'the stream should end unlocked');
             test4.done();
         }));
 
         reader.read();
         reader.read();
-        readCalled = true;
     });
 
-    var test5 = async_test('releasing the lock should cause read() to act as if the stream is closed');
+    var test5 = async_test('releasing the lock should cause further read() calls to reject with a TypeError', { timeout: 50});
     test5.step(function() {
+        var promiseCalls = 0;
         var { reader } = factory();
-        var promiseCalls = 0;
 
         reader.releaseLock();
 
-        reader.read().then(test5.step_func(function(r) {
-            assert_object_equals(r, { value: undefined, done: true }, 'first read() should return closed result');
-            ++promiseCalls;
+        reader.read().catch(test5.step_func(function(e) {
+            assert_throws(new TypeError(), function() { throw e; }, 'first read() should reject with a TypeError');
+            assert_equals(++promiseCalls, 1);
         }));
-        reader.read().then(test5.step_func(function(r) {
-            assert_object_equals(r, { value: undefined, done: true }, 'second read() should return closed result');
-            ++promiseCalls;
+        reader.read().catch(test5.step_func(function(e) {
+            assert_throws(new TypeError(), function() { throw e; }, 'second read() should reject with a TypeError');
+            assert_equals(++promiseCalls, 2);
         }));
-        reader.read().then(test5.step_func(function(r) {
-            assert_object_equals(r, { value: undefined, done: true }, 'third read() should return closed result');
+        reader.read().catch(test5.step_func(function(e) {
+            assert_throws(new TypeError(), function() { throw e; }, 'third read() should reject with a TypeError');
             assert_equals(++promiseCalls, 3);
             test5.done();
-        }))
+        }));
     });
 
     var test6 = async_test('reader\'s closed property always returns the same promise');
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to