[Streams API] In RS during enqueuing error should be reported only if readable
authorcalvaris@igalia.com <calvaris@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Dec 2015 18:13:57 +0000 (18:13 +0000)
committercalvaris@igalia.com <calvaris@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Dec 2015 18:13:57 +0000 (18:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152505

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Updated imported spec tests.

* web-platform-tests/streams-api/README.txt: Updated spec version.
* web-platform-tests/streams-api/readable-streams/bad-strategies-expected.txt: Expectations.
* web-platform-tests/streams-api/readable-streams/bad-strategies.js: Added two new tests.

Source/WebCore:

This commit fixes last spec change done in
https://github.com/whatwg/streams/commit/4ba861e6f60c248060811830e11271c84b439cc3.

Test: imported/w3c/web-platform-tests/streams-api/readable-streams/bad-strategies.html

* Modules/streams/ReadableStreamInternals.js:
(enqueueInReadableStream): Call @errorReadableStream only if state is readable.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194391 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/streams-api/README.txt
LayoutTests/imported/w3c/web-platform-tests/streams-api/readable-streams/bad-strategies-expected.txt
LayoutTests/imported/w3c/web-platform-tests/streams-api/readable-streams/bad-strategies.js
Source/WebCore/ChangeLog
Source/WebCore/Modules/streams/ReadableStreamInternals.js

index 54e41ca..c827080 100644 (file)
@@ -1,3 +1,16 @@
+2015-12-23  Xabier Rodriguez Calvar  <calvaris@igalia.com>
+
+        [Streams API] In RS during enqueuing error should be reported only if readable
+        https://bugs.webkit.org/show_bug.cgi?id=152505
+
+        Reviewed by Youenn Fablet.
+
+        Updated imported spec tests.
+
+        * web-platform-tests/streams-api/README.txt: Updated spec version.
+        * web-platform-tests/streams-api/readable-streams/bad-strategies-expected.txt: Expectations.
+        * web-platform-tests/streams-api/readable-streams/bad-strategies.js: Added two new tests.
+
 2015-12-21  Xabier Rodriguez Calvar  <calvaris@igalia.com>
 
         [Streams API] imported/w3c/web-platform-tests/streams-api/readable-streams/cancel.html has a flaky test
index 2f7f607..8195177 100644 (file)
@@ -3,4 +3,4 @@ This directory is imported from the the Streams API repository.
 There is a plan to move these tests to web-platform-tests repository so from that moment on this importation will be
 automatic.
 
-Current version: https://github.com/whatwg/streams/tree/f7cb0eac03e6a6d045d6e8c09df1f9f8a264fdef/reference-implementation/web-platform-tests.
+Current version: https://github.com/whatwg/streams/tree/2e7f87e45806d58114592c923aed299798d10161/reference-implementation/web-platform-tests.
index 8c9d27c..f2663f4 100644 (file)
@@ -1,5 +1,7 @@
 
 PASS Readable stream: throwing strategy.size getter 
+PASS Readable stream: strategy.size errors the stream and then throws 
+PASS Readable stream: strategy.size errors the stream and then returns Infinity 
 PASS Readable stream: throwing strategy.size method 
 PASS Readable stream: throwing strategy.highWaterMark getter 
 PASS Readable stream: invalid strategy.highWaterMark 
@@ -10,6 +12,8 @@ FAIL Readable stream: throwing strategy.size getter assert_throws: construction
     new ReadableStream({}, {
       get size() {
  ..." threw object "ReferenceError: Can't find variable: ReadableStream" ("ReferenceError") expected object "Error: a unique string" ("Error")
+FAIL Readable stream: strategy.size errors the stream and then throws Can't find variable: ReadableStream
+FAIL Readable stream: strategy.size errors the stream and then returns Infinity Can't find variable: ReadableStream
 FAIL Readable stream: throwing strategy.size method Can't find variable: ReadableStream
 FAIL Readable stream: throwing strategy.highWaterMark getter assert_throws: construction should re-throw the error function "() => {
     new ReadableStream({}, {
index 7d085c7..5cecb8f 100644 (file)
@@ -19,6 +19,60 @@ test(() => {
 
 }, 'Readable stream: throwing strategy.size getter');
 
+test(() => {
+
+  const theError = new Error('a unique string');
+
+  let controller;
+  const rs = new ReadableStream(
+    {
+      start(c) {
+        controller = c;
+      }
+    },
+    {
+      size() {
+        controller.error(theError);
+        throw theError;
+      },
+      highWaterMark: 5
+    }
+  );
+
+  assert_throws(theError, () => {
+    controller.enqueue('a');
+  }, 'enqueue should re-throw the error');
+
+}, 'Readable stream: strategy.size errors the stream and then throws');
+
+test(() => {
+
+  const theError = new Error('a unique string');
+
+  let controller;
+  const rs = new ReadableStream(
+    {
+      start(c) {
+        controller = c;
+      }
+    },
+    {
+      size() {
+        controller.error(theError);
+        return Infinity;
+      },
+      highWaterMark: 5
+    }
+  );
+
+  try {
+    controller.enqueue('a');
+  } catch (error) {
+    assert_equals(error.name, 'RangeError', 'enqueue should throw a RangeError');
+  }
+
+}, 'Readable stream: strategy.size errors the stream and then returns Infinity');
+
 promise_test(() => {
 
   const theError = new Error('a unique string');
index 729451a..7bce609 100644 (file)
@@ -1,3 +1,18 @@
+2015-12-23  Xabier Rodriguez Calvar  <calvaris@igalia.com>
+
+        [Streams API] In RS during enqueuing error should be reported only if readable
+        https://bugs.webkit.org/show_bug.cgi?id=152505
+
+        Reviewed by Youenn Fablet.
+
+        This commit fixes last spec change done in
+        https://github.com/whatwg/streams/commit/4ba861e6f60c248060811830e11271c84b439cc3.
+
+        Test: imported/w3c/web-platform-tests/streams-api/readable-streams/bad-strategies.html
+
+        * Modules/streams/ReadableStreamInternals.js:
+        (enqueueInReadableStream): Call @errorReadableStream only if state is readable.
+
 2015-12-23  Chris Aljoudi <chris@chrismatic.io> and Alex Christensen <achristensen@webkit.org>
 
         Content blockers should be able to promote http to https
index fb35dbb..e68676d 100644 (file)
@@ -328,7 +328,8 @@ function enqueueInReadableStream(stream, chunk)
         @enqueueValueWithSize(stream.@queue, chunk, size);
     }
     catch(error) {
-        @errorReadableStream(stream, error);
+        if (stream.@state === @streamReadable)
+            @errorReadableStream(stream, error);
         throw error;
     }
     @requestReadableStreamPull(stream);