[Streams API] ReadableStream should throw a RangeError in case of NaN highWaterMark
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Jul 2016 13:41:07 +0000 (13:41 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Jul 2016 13:41:07 +0000 (13:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=159870

Patch by Youenn Fablet <youenn@apple.com> on 2016-07-18
Reviewed by Xabier Rodriguez-Calvar.

LayoutTests/imported/w3c:

* web-platform-tests/streams/readable-streams/bad-strategies.https-expected.txt:

Source/WebCore:

Covered by rebased test.

* Modules/streams/StreamInternals.js:
(validateAndNormalizeQueuingStrategy): Throwing a RangeError in lieu of a TypeError in case of NaN highWaterMark.

LayoutTests:

* streams/reference-implementation/bad-strategies.html: Reflecting isNaN change in WritableStream test.

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

LayoutTests/ChangeLog
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/bad-strategies.https-expected.txt
LayoutTests/streams/reference-implementation/bad-strategies.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/streams/StreamInternals.js

index f0169f2..cb189c9 100644 (file)
@@ -1,3 +1,12 @@
+2016-07-18  Youenn Fablet  <youenn@apple.com>
+
+        [Streams API] ReadableStream should throw a RangeError in case of NaN highWaterMark
+        https://bugs.webkit.org/show_bug.cgi?id=159870
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        * streams/reference-implementation/bad-strategies.html: Reflecting isNaN change in WritableStream test.
+
 2016-07-17  Frederic Wang  <fwang@igalia.com>
 
         Rebaseline Windows and EFL MathML pixel tests after r203289.
index c884b43..02e1efc 100644 (file)
@@ -1,3 +1,12 @@
+2016-07-18  Youenn Fablet  <youenn@apple.com>
+
+        [Streams API] ReadableStream should throw a RangeError in case of NaN highWaterMark
+        https://bugs.webkit.org/show_bug.cgi?id=159870
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        * web-platform-tests/streams/readable-streams/bad-strategies.https-expected.txt:
+
 2016-07-17  Brady Eidson  <beidson@apple.com>
 
         Update DOMCoreException to use the description in toString().
index 6dac12f..fa8af34 100644 (file)
@@ -4,10 +4,7 @@ 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 
-FAIL Readable stream: invalid strategy.highWaterMark assert_throws: construction should throw a RangeError for NaN function "() => {
-      new ReadableStream({}, {
-        size() {
- ..." threw object "TypeError: highWaterMark parameter is not a number" ("TypeError") expected object "RangeError" ("RangeError")
+PASS Readable stream: invalid strategy.highWaterMark 
 PASS Readable stream: invalid strategy.size return value 
 FAIL Load bad-strategies.js with SharedWorker assert_unreached: SharedWorker is unavailable Reached unreachable code
 FAIL Untitled undefined is not an object (evaluating 'navigator.serviceWorker.getRegistration')
@@ -16,9 +13,6 @@ 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 
-FAIL Readable stream: invalid strategy.highWaterMark assert_throws: construction should throw a RangeError for NaN function "() => {
-      new ReadableStream({}, {
-        size() {
- ..." threw object "TypeError: highWaterMark parameter is not a number" ("TypeError") expected object "RangeError" ("RangeError")
+PASS Readable stream: invalid strategy.highWaterMark 
 PASS Readable stream: invalid strategy.size return value 
 
index 6708382..908b8ac 100644 (file)
@@ -111,7 +111,7 @@ test(function() {
     }
 
     for (var highWaterMark of [NaN, 'foo', {}]) {
-        assert_throws(new TypeError(), function() {
+        assert_throws(new RangeError(), function() {
             new WritableStream({}, {
                 size: function() {
                     return 1;
index abe43bc..972409a 100644 (file)
@@ -1,3 +1,15 @@
+2016-07-18  Youenn Fablet  <youenn@apple.com>
+
+        [Streams API] ReadableStream should throw a RangeError in case of NaN highWaterMark
+        https://bugs.webkit.org/show_bug.cgi?id=159870
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Covered by rebased test.
+
+        * Modules/streams/StreamInternals.js:
+        (validateAndNormalizeQueuingStrategy): Throwing a RangeError in lieu of a TypeError in case of NaN highWaterMark.
+
 2016-07-18  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         Windows buildfix after r203338
index 7f4c0ca..163ebc3 100644 (file)
@@ -85,10 +85,8 @@ function validateAndNormalizeQueuingStrategy(size, highWaterMark)
     normalizedStrategy.size = size;
     normalizedStrategy.highWaterMark = @Number(highWaterMark);
 
-    if (@isNaN(normalizedStrategy.highWaterMark))
-        throw new @TypeError("highWaterMark parameter is not a number");
-    if (normalizedStrategy.highWaterMark < 0)
-        throw new @RangeError("highWaterMark is negative");
+    if (@isNaN(normalizedStrategy.highWaterMark) || normalizedStrategy.highWaterMark < 0)
+        throw new @RangeError("highWaterMark value is negative or not a number");
 
     return normalizedStrategy;
 }