Diff
Modified: trunk/LayoutTests/ChangeLog (279471 => 279472)
--- trunk/LayoutTests/ChangeLog 2021-07-01 17:37:38 UTC (rev 279471)
+++ trunk/LayoutTests/ChangeLog 2021-07-01 17:41:51 UTC (rev 279472)
@@ -1,3 +1,15 @@
+2021-07-01 Youenn Fablet <[email protected]>
+
+ ReadableStream.getReader do not throw a proper exception when parameter is of wrong type
+ https://bugs.webkit.org/show_bug.cgi?id=226220
+ <rdar://problem/78711382>
+
+ Reviewed by Chris Dumez.
+
+ * streams/readable-stream-getReader-expected.txt:
+ * streams/readable-stream-getReader.html:
+ Update test to match latest spec.
+
2021-07-01 Alan Bujtas <[email protected]>
VisiblePosition::absoluteSelectionBoundsForLine fails on multiline vertical-rl content
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (279471 => 279472)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-07-01 17:37:38 UTC (rev 279471)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-07-01 17:41:51 UTC (rev 279472)
@@ -1,5 +1,20 @@
2021-07-01 Youenn Fablet <[email protected]>
+ ReadableStream.getReader do not throw a proper exception when parameter is of wrong type
+ https://bugs.webkit.org/show_bug.cgi?id=226220
+ <rdar://problem/78711382>
+
+ Reviewed by Chris Dumez.
+
+ * web-platform-tests/streams/readable-streams/default-reader.any-expected.txt:
+ * web-platform-tests/streams/readable-streams/default-reader.any.worker-expected.txt:
+ * web-platform-tests/streams/readable-streams/general.any-expected.txt:
+ * web-platform-tests/streams/readable-streams/general.any.worker-expected.txt:
+ * web-platform-tests/streams/readable-streams/templated.any-expected.txt:
+ * web-platform-tests/streams/readable-streams/templated.any.worker-expected.txt:
+
+2021-07-01 Youenn Fablet <[email protected]>
+
[Cocoa] Migrate WebRTC UDP socket handling to NW API
https://bugs.webkit.org/show_bug.cgi?id=227210
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/default-reader.any-expected.txt (279471 => 279472)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/default-reader.any-expected.txt 2021-07-01 17:37:38 UTC (rev 279471)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/default-reader.any-expected.txt 2021-07-01 17:41:51 UTC (rev 279472)
@@ -29,8 +29,6 @@
PASS Reading twice on a closed stream
PASS Reading twice on an errored stream
PASS Reading twice on a stream that gets errored
-FAIL getReader() should call ToString() on mode assert_throws_js: getReader() should throw function "() => rs.getReader({ mode })" threw object "RangeError: Invalid mode is specified" ("RangeError") expected instance of function "function TypeError() {
- [native code]
-}" ("TypeError")
+PASS getReader() should call ToString() on mode
PASS controller.close() should clear the list of pending read requests
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/default-reader.any.worker-expected.txt (279471 => 279472)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/default-reader.any.worker-expected.txt 2021-07-01 17:37:38 UTC (rev 279471)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/default-reader.any.worker-expected.txt 2021-07-01 17:41:51 UTC (rev 279472)
@@ -29,8 +29,6 @@
PASS Reading twice on a closed stream
PASS Reading twice on an errored stream
PASS Reading twice on a stream that gets errored
-FAIL getReader() should call ToString() on mode assert_throws_js: getReader() should throw function "() => rs.getReader({ mode })" threw object "RangeError: Invalid mode is specified" ("RangeError") expected instance of function "function TypeError() {
- [native code]
-}" ("TypeError")
+PASS getReader() should call ToString() on mode
PASS controller.close() should clear the list of pending read requests
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/general.any-expected.txt (279471 => 279472)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/general.any-expected.txt 2021-07-01 17:37:38 UTC (rev 279471)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/general.any-expected.txt 2021-07-01 17:41:51 UTC (rev 279472)
@@ -9,9 +9,7 @@
FAIL ReadableStream constructor will not tolerate initial garbage as pull argument assert_throws_js: constructor should throw function "() => new ReadableStream({ pull: { } })" did not throw
PASS ReadableStream start should be called with the proper thisArg
PASS ReadableStream start controller parameter should be extensible
-FAIL default ReadableStream getReader() should only accept mode:undefined assert_throws_js: function "() => (new ReadableStream()).getReader({ mode: 'potato' })" threw object "RangeError: Invalid mode is specified" ("RangeError") expected instance of function "function TypeError() {
- [native code]
-}" ("TypeError")
+PASS default ReadableStream getReader() should only accept mode:undefined
PASS ReadableStream should be able to call start method within prototype chain of its source
PASS ReadableStream start should be able to return a promise
PASS ReadableStream start should be able to return a promise and reject it
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/general.any.worker-expected.txt (279471 => 279472)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/general.any.worker-expected.txt 2021-07-01 17:37:38 UTC (rev 279471)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/general.any.worker-expected.txt 2021-07-01 17:41:51 UTC (rev 279472)
@@ -9,9 +9,7 @@
FAIL ReadableStream constructor will not tolerate initial garbage as pull argument assert_throws_js: constructor should throw function "() => new ReadableStream({ pull: { } })" did not throw
PASS ReadableStream start should be called with the proper thisArg
PASS ReadableStream start controller parameter should be extensible
-FAIL default ReadableStream getReader() should only accept mode:undefined assert_throws_js: function "() => (new ReadableStream()).getReader({ mode: 'potato' })" threw object "RangeError: Invalid mode is specified" ("RangeError") expected instance of function "function TypeError() {
- [native code]
-}" ("TypeError")
+PASS default ReadableStream getReader() should only accept mode:undefined
PASS ReadableStream should be able to call start method within prototype chain of its source
PASS ReadableStream start should be able to return a promise
PASS ReadableStream start should be able to return a promise and reject it
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/templated.any-expected.txt (279471 => 279472)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/templated.any-expected.txt 2021-07-01 17:37:38 UTC (rev 279471)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/templated.any-expected.txt 2021-07-01 17:41:51 UTC (rev 279472)
@@ -1,9 +1,7 @@
PASS Running templatedRSEmpty with ReadableStream (empty)
PASS ReadableStream (empty): instances have the correct methods and properties
-FAIL ReadableStream (empty): calling getReader with invalid arguments should throw appropriate errors assert_throws_js: empty string mode should throw function "() => rs.getReader({ mode: '' })" threw object "RangeError: Invalid mode is specified" ("RangeError") expected instance of function "function TypeError() {
- [native code]
-}" ("TypeError")
+PASS ReadableStream (empty): calling getReader with invalid arguments should throw appropriate errors
PASS Running templatedRSEmptyReader with ReadableStream (empty) reader
PASS ReadableStream (empty) reader: instances have the correct methods and properties
PASS ReadableStream (empty) reader: locked should be true
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/templated.any.worker-expected.txt (279471 => 279472)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/templated.any.worker-expected.txt 2021-07-01 17:37:38 UTC (rev 279471)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/templated.any.worker-expected.txt 2021-07-01 17:41:51 UTC (rev 279472)
@@ -1,9 +1,7 @@
PASS Running templatedRSEmpty with ReadableStream (empty)
PASS ReadableStream (empty): instances have the correct methods and properties
-FAIL ReadableStream (empty): calling getReader with invalid arguments should throw appropriate errors assert_throws_js: empty string mode should throw function "() => rs.getReader({ mode: '' })" threw object "RangeError: Invalid mode is specified" ("RangeError") expected instance of function "function TypeError() {
- [native code]
-}" ("TypeError")
+PASS ReadableStream (empty): calling getReader with invalid arguments should throw appropriate errors
PASS Running templatedRSEmptyReader with ReadableStream (empty) reader
PASS ReadableStream (empty) reader: instances have the correct methods and properties
PASS ReadableStream (empty) reader: locked should be true
Modified: trunk/LayoutTests/streams/readable-stream-getReader-expected.txt (279471 => 279472)
--- trunk/LayoutTests/streams/readable-stream-getReader-expected.txt 2021-07-01 17:37:38 UTC (rev 279471)
+++ trunk/LayoutTests/streams/readable-stream-getReader-expected.txt 2021-07-01 17:41:51 UTC (rev 279472)
@@ -1,5 +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'
+PASS getReader({mode: 'aMode'}) should return a TypeError as 'aMode' is different from undefined and 'byob'
Modified: trunk/LayoutTests/streams/readable-stream-getReader.html (279471 => 279472)
--- trunk/LayoutTests/streams/readable-stream-getReader.html 2021-07-01 17:37:38 UTC (rev 279471)
+++ trunk/LayoutTests/streams/readable-stream-getReader.html 2021-07-01 17:41:51 UTC (rev 279472)
@@ -18,6 +18,6 @@
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'");
+ assert_throws(new TypeError(), function() { rs.getReader({mode : 'aMode'}) });
+}, "getReader({mode: 'aMode'}) should return a TypeError as 'aMode' is different from undefined and 'byob'");
</script>
Modified: trunk/Source/WebCore/ChangeLog (279471 => 279472)
--- trunk/Source/WebCore/ChangeLog 2021-07-01 17:37:38 UTC (rev 279471)
+++ trunk/Source/WebCore/ChangeLog 2021-07-01 17:41:51 UTC (rev 279472)
@@ -1,3 +1,18 @@
+2021-07-01 Youenn Fablet <[email protected]>
+
+ ReadableStream.getReader do not throw a proper exception when parameter is of wrong type
+ https://bugs.webkit.org/show_bug.cgi?id=226220
+ <rdar://problem/78711382>
+
+ Reviewed by Chris Dumez.
+
+ Covered by rebased tests.
+
+ * Modules/streams/ReadableStream.js:
+ (getReader):
+ Tighten option parameter check.
+ In case mode is bad, fire a type error instead of range error.
+
2021-07-01 Amir Mark Jr <[email protected]>
Unreviewed, reverting r279452.
Modified: trunk/Source/WebCore/Modules/streams/ReadableStream.js (279471 => 279472)
--- trunk/Source/WebCore/Modules/streams/ReadableStream.js 2021-07-01 17:37:38 UTC (rev 279471)
+++ trunk/Source/WebCore/Modules/streams/ReadableStream.js 2021-07-01 17:41:51 UTC (rev 279472)
@@ -100,17 +100,15 @@
if (!@isReadableStream(this))
throw @makeThisTypeError("ReadableStream", "getReader");
- if (options === @undefined)
- options = { };
-
- if (options.mode === @undefined)
+ const mode = @toDictionary(options, { }, "ReadableStream.getReader takes an object as first argument").mode;
+ if (mode === @undefined)
return new @ReadableStreamDefaultReader(this);
// String conversion is required by spec, hence double equals.
- if (options.mode == 'byob')
+ if (mode == 'byob')
return new @ReadableStreamBYOBReader(this);
- @throwRangeError("Invalid mode is specified");
+ @throwTypeError("Invalid mode is specified");
}
function pipeThrough(streams, options)
Modified: trunk/Source/WebCore/Modules/streams/StreamInternals.js (279471 => 279472)
--- trunk/Source/WebCore/Modules/streams/StreamInternals.js 2021-07-01 17:37:38 UTC (rev 279471)
+++ trunk/Source/WebCore/Modules/streams/StreamInternals.js 2021-07-01 17:41:51 UTC (rev 279472)
@@ -194,3 +194,12 @@
@fulfillPromise(promise, value);
return promise;
}
+
+function toDictionary(value, defaultValue, errorMessage)
+{
+ if (value === @undefined || value === null)
+ return defaultValue;
+ if (!@isObject(value))
+ @throwTypeError(errorMessage);
+ return value;
+}