- Revision
- 205248
- Author
- [email protected]
- Date
- 2016-08-31 08:36:32 -0700 (Wed, 31 Aug 2016)
Log Message
[Streams API] Align getReader() with spec
https://bugs.webkit.org/show_bug.cgi?id=160508
Patch by Romain Bellessort <[email protected]> on 2016-08-31
Reviewed by Xabier Rodriguez-Calvar.
LayoutTests/imported/w3c:
Changed 2 expectations, 1 that passes thanks to patch, the other that
now fails as getReader() has 1 parameter (0 expected, bug to be filed).
* web-platform-tests/streams/readable-streams/general.https-expected.txt:
* web-platform-tests/streams/readable-streams/templated.https-expected.txt:
Source/WebCore:
Aligned getReader() with spec following replacement of ReadableStreamReader by
ReadableStreamDefaultReader.
Test: streams/readable-stream-getReader.html
* Modules/streams/ReadableStream.js:
(getReader):
LayoutTests:
* streams/readable-stream-getReader-expected.txt: Added.
* streams/readable-stream-getReader.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (205247 => 205248)
--- trunk/LayoutTests/ChangeLog 2016-08-31 14:38:21 UTC (rev 205247)
+++ trunk/LayoutTests/ChangeLog 2016-08-31 15:36:32 UTC (rev 205248)
@@ -1,3 +1,13 @@
+2016-08-31 Romain Bellessort <[email protected]>
+
+ [Streams API] Align getReader() with spec
+ https://bugs.webkit.org/show_bug.cgi?id=160508
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ * streams/readable-stream-getReader-expected.txt: Added.
+ * streams/readable-stream-getReader.html: Added.
+
2016-08-31 Antti Koivisto <[email protected]>
REGRESSION (r201701): Unable to copy from CodeMirror editor version used in Jenkins install website
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (205247 => 205248)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2016-08-31 14:38:21 UTC (rev 205247)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2016-08-31 15:36:32 UTC (rev 205248)
@@ -1,3 +1,16 @@
+2016-08-31 Romain Bellessort <[email protected]>
+
+ [Streams API] Align getReader() with spec
+ https://bugs.webkit.org/show_bug.cgi?id=160508
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ Changed 2 expectations, 1 that passes thanks to patch, the other that
+ now fails as getReader() has 1 parameter (0 expected, bug to be filed).
+
+ * web-platform-tests/streams/readable-streams/general.https-expected.txt:
+ * web-platform-tests/streams/readable-streams/templated.https-expected.txt:
+
2016-08-30 Youenn Fablet <[email protected]>
[Fetch API] Blob not found URL should result in a network error
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/general.https-expected.txt (205247 => 205248)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/general.https-expected.txt 2016-08-31 14:38:21 UTC (rev 205247)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/general.https-expected.txt 2016-08-31 15:36:32 UTC (rev 205248)
@@ -2,7 +2,7 @@
PASS ReadableStream can be constructed with no errors
PASS ReadableStream can't be constructed with garbage
FAIL ReadableStream can't be constructed with an invalid type assert_throws: constructor should throw when the type is null function "() => new ReadableStream({ type: null })" did not throw
-PASS ReadableStream instances should have the correct list of properties
+FAIL ReadableStream instances should have the correct list of properties assert_equals: getReader should have no parameters expected 0 but got 1
PASS ReadableStream constructor should throw for non-function start arguments
PASS ReadableStream constructor can get initial garbage as cancel argument
PASS ReadableStream constructor can get initial garbage as pull argument
@@ -39,7 +39,7 @@
PASS ReadableStream can be constructed with no errors
PASS ReadableStream can't be constructed with garbage
FAIL ReadableStream can't be constructed with an invalid type assert_throws: constructor should throw when the type is null function "() => new ReadableStream({ type: null })" did not throw
-PASS ReadableStream instances should have the correct list of properties
+FAIL ReadableStream instances should have the correct list of properties assert_equals: getReader should have no parameters expected 0 but got 1
PASS ReadableStream constructor should throw for non-function start arguments
PASS ReadableStream constructor can get initial garbage as cancel argument
PASS ReadableStream constructor can get initial garbage as pull argument
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/templated.https-expected.txt (205247 => 205248)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/templated.https-expected.txt 2016-08-31 14:38:21 UTC (rev 205247)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/templated.https-expected.txt 2016-08-31 15:36:32 UTC (rev 205248)
@@ -1,7 +1,7 @@
PASS Running templatedRSEmpty with ReadableStream (empty)
PASS instances have the correct methods and properties
-FAIL calling getReader with invalid arguments should throw appropriate errors assert_throws: empty string mode should throw function "() => rs.getReader({ mode: '' })" did not throw
+PASS calling getReader with invalid arguments should throw appropriate errors
PASS Running templatedRSEmptyReader with ReadableStream (empty) reader
PASS instances have the correct methods and properties
PASS locked should be true
@@ -89,7 +89,7 @@
FAIL Untitled undefined is not an object (evaluating 'navigator.serviceWorker.getRegistration')
PASS Running templatedRSEmpty with ReadableStream (empty)
PASS instances have the correct methods and properties
-FAIL calling getReader with invalid arguments should throw appropriate errors assert_throws: empty string mode should throw function "() => rs.getReader({ mode: '' })" did not throw
+PASS calling getReader with invalid arguments should throw appropriate errors
PASS Running templatedRSEmptyReader with ReadableStream (empty) reader
PASS instances have the correct methods and properties
PASS locked should be true
Added: trunk/LayoutTests/streams/readable-stream-getReader-expected.txt (0 => 205248)
--- trunk/LayoutTests/streams/readable-stream-getReader-expected.txt (rev 0)
+++ trunk/LayoutTests/streams/readable-stream-getReader-expected.txt 2016-08-31 15:36:32 UTC (rev 205248)
@@ -0,0 +1,5 @@
+
+PASS getReader() should return a ReadableStreamDefaultReader
+PASS getReader({mode: 'byob'}) should return a TypeError as BYOB reader is not yet implemented
+PASS getReader({mode: 'aMode'}) should return a RangeError as 'aMode' is different from undefined and 'byob'
+
Added: trunk/LayoutTests/streams/readable-stream-getReader.html (0 => 205248)
--- trunk/LayoutTests/streams/readable-stream-getReader.html (rev 0)
+++ trunk/LayoutTests/streams/readable-stream-getReader.html 2016-08-31 15:36:32 UTC (rev 205248)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<script src=''></script>
+<script src=''></script>
+<script>
+// This is updated till https://github.com/whatwg/streams/commit/8d5f2ec3d74d501988e00b427468e11aa7855637
+
+test(function() {
+ const rs = new ReadableStream();
+ const reader = rs.getReader();
+ assert_equals(reader.constructor.name, 'ReadableStreamDefaultReader');
+}, 'getReader() should return a ReadableStreamDefaultReader');
+
+test(function() {
+ const rs = new ReadableStream();
+ assert_throws(new TypeError(), function() { rs.getReader({mode: 'byob'}) });
+}, "getReader({mode: 'byob'}) should return a TypeError as BYOB reader is not yet implemented");
+
+test(function() {
+ const rs = new ReadableStream();
+ // Any value different from undefined and 'byob' should throw a TypeError.
+ assert_throws(new RangeError(), function() { rs.getReader({mode : 'aMode'}) });
+}, "getReader({mode: 'aMode'}) should return a RangeError as 'aMode' is different from undefined and 'byob'");
+</script>
Modified: trunk/Source/WebCore/ChangeLog (205247 => 205248)
--- trunk/Source/WebCore/ChangeLog 2016-08-31 14:38:21 UTC (rev 205247)
+++ trunk/Source/WebCore/ChangeLog 2016-08-31 15:36:32 UTC (rev 205248)
@@ -1,3 +1,18 @@
+2016-08-31 Romain Bellessort <[email protected]>
+
+ [Streams API] Align getReader() with spec
+ https://bugs.webkit.org/show_bug.cgi?id=160508
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ Aligned getReader() with spec following replacement of ReadableStreamReader by
+ ReadableStreamDefaultReader.
+
+ Test: streams/readable-stream-getReader.html
+
+ * Modules/streams/ReadableStream.js:
+ (getReader):
+
2016-08-31 Brady Eidson <[email protected]>
WK2 Gamepad provider on iOS.
Modified: trunk/Source/WebCore/Modules/streams/ReadableStream.js (205247 => 205248)
--- trunk/Source/WebCore/Modules/streams/ReadableStream.js 2016-08-31 14:38:21 UTC (rev 205247)
+++ trunk/Source/WebCore/Modules/streams/ReadableStream.js 2016-08-31 15:36:32 UTC (rev 205248)
@@ -79,7 +79,7 @@
return @cancelReadableStream(this, reason);
}
-function getReader()
+function getReader(options)
{
"use strict";
@@ -86,7 +86,18 @@
if (!@isReadableStream(this))
throw @makeThisTypeError("ReadableStream", "getReader");
- return new @ReadableStreamDefaultReader(this);
+ if (options === @undefined)
+ options = { };
+
+ if (options.mode === 'byob') {
+ // FIXME: Update once ReadableByteStreamContoller and ReadableStreamBYOBReader are implemented.
+ throw new @TypeError("ReadableStreamBYOBReader is not implemented");
+ }
+
+ if (options.mode === @undefined)
+ return new @ReadableStreamDefaultReader(this);
+
+ throw new @RangeError("Invalid mode is specified");
}
function pipeThrough(streams, options)