[webkit-changes] [226005] trunk

2017-12-16 Thread romain . bellessort
Title: [226005] trunk








Revision 226005
Author romain.belless...@crf.canon.fr
Date 2017-12-16 10:59:29 -0800 (Sat, 16 Dec 2017)


Log Message
[Readable Streams API] Fix filling of descriptor from queue
https://bugs.webkit.org/show_bug.cgi?id=172717

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Updated test expectations.

* web-platform-tests/streams/readable-byte-streams/detached-buffers-expected.txt: Updated.
* web-platform-tests/streams/readable-byte-streams/detached-buffers.dedicatedworker-expected.txt: Updated.
* web-platform-tests/streams/readable-byte-streams/general-expected.txt: Updated.
* web-platform-tests/streams/readable-byte-streams/general.dedicatedworker-expected.txt: Updated.

Source/WebCore:

Fixed the filling of descriptor from queue (step 10.d at [1]). When first implemented,
spec comprised a bug and code was not reachable. Spec has now been fixed and code can
now be reached.

[1] https://streams.spec.whatwg.org/#readable-byte-stream-controller-fill-pull-into-descriptor-from-queue

No new tests (covered by WPT tests, whose expectations have been updated).

* Modules/streams/ReadableByteStreamInternals.js:
(readableByteStreamControllerFillDescriptorFromQueue): Updated.

Modified Paths

trunk/LayoutTests/imported/w3c/ChangeLog
trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/detached-buffers-expected.txt
trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/detached-buffers.dedicatedworker-expected.txt
trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general-expected.txt
trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general.dedicatedworker-expected.txt
trunk/Source/WebCore/ChangeLog
trunk/Source/WebCore/Modules/streams/ReadableByteStreamInternals.js




Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (226004 => 226005)

--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-12-16 18:57:21 UTC (rev 226004)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-12-16 18:59:29 UTC (rev 226005)
@@ -1,3 +1,17 @@
+2017-12-16  Romain Bellessort  
+
+[Readable Streams API] Fix filling of descriptor from queue
+https://bugs.webkit.org/show_bug.cgi?id=172717
+
+Reviewed by Youenn Fablet.
+
+Updated test expectations.
+
+* web-platform-tests/streams/readable-byte-streams/detached-buffers-expected.txt: Updated.
+* web-platform-tests/streams/readable-byte-streams/detached-buffers.dedicatedworker-expected.txt: Updated.
+* web-platform-tests/streams/readable-byte-streams/general-expected.txt: Updated.
+* web-platform-tests/streams/readable-byte-streams/general.dedicatedworker-expected.txt: Updated.
+
 2017-12-16  Youenn Fablet  
 
 Skip SharedWorker and NavigationPreload service worker tests


Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/detached-buffers-expected.txt (226004 => 226005)

--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/detached-buffers-expected.txt	2017-12-16 18:57:21 UTC (rev 226004)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/detached-buffers-expected.txt	2017-12-16 18:59:29 UTC (rev 226005)
@@ -2,7 +2,7 @@
 Harness Error (TIMEOUT), message = null
 
 FAIL ReadableStream with byte source: read()ing from a closed stream still transfers the buffer assert_not_equals: a different ArrayBuffer must underlie the value got disallowed value object "[object ArrayBuffer]"
-FAIL ReadableStream with byte source: read()ing from a stream with queued chunks still transfers the buffer assert_array_equals: The value read must be the enqueued Uint8Array, not the original values property 0, expected 1 but got 4
+FAIL ReadableStream with byte source: read()ing from a stream with queued chunks still transfers the buffer assert_not_equals: a different ArrayBuffer must underlie the value got disallowed value object "[object ArrayBuffer]"
 FAIL ReadableStream with byte source: enqueuing an already-detached buffer throws assert_throws: enqueuing an already-detached buffer must throw function "() => c.enqueue(view)" did not throw
 TIMEOUT ReadableStream with byte source: reading into an already-detached buffer rejects Test timed out
 FAIL ReadableStream with byte source: respond() throws if the BYOB request's buffer has been detached (in the readable state) assert_throws: respond() must throw if the corresponding view has become detached function "() => c.byobRequest.respond(1)" did not throw


Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/detached-buffers.dedicatedworker-expected.txt (226004 => 226005)

--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/detached-buffers.dedicatedworker-expected.txt	2017-12-16 18:57:21 UTC (rev 226004)
+++ trunk/Layou

[webkit-changes] [225906] trunk/LayoutTests

2017-12-14 Thread romain . bellessort
Title: [225906] trunk/LayoutTests








Revision 225906
Author romain.belless...@crf.canon.fr
Date 2017-12-14 09:04:21 -0800 (Thu, 14 Dec 2017)


Log Message
[Readable Streams API] Remove properties tests covered by WPT
https://bugs.webkit.org/show_bug.cgi?id=180809

Reviewed by Youenn Fablet.

Removed WebKit properties/methods tests for ReadableByteStreamController,
ReadableStreamBYOBReader and ReadableStreamBYOBRequest. Indeed, these
tests are also present in WPT streams/readable-byte-streams/properties.js.

* streams/readable-byte-stream-controller-expected.txt: Updated expectations.
* streams/readable-byte-stream-controller.js: Remove ReadableByteStreamController properties test.
* streams/readable-stream-byob-reader-expected.txt: Updated expectations.
* streams/readable-stream-byob-reader.js: Remove ReadableStreamBYOBReader properties test.
* streams/readable-stream-byob-request-expected.txt: Updated expectations.
* streams/readable-stream-byob-request.js: Remove ReadableStreamBYOBRequest properties test.

Modified Paths

trunk/LayoutTests/ChangeLog
trunk/LayoutTests/streams/readable-byte-stream-controller-expected.txt
trunk/LayoutTests/streams/readable-byte-stream-controller.js
trunk/LayoutTests/streams/readable-stream-byob-reader-expected.txt
trunk/LayoutTests/streams/readable-stream-byob-reader.js
trunk/LayoutTests/streams/readable-stream-byob-request-expected.txt
trunk/LayoutTests/streams/readable-stream-byob-request.js




Diff

Modified: trunk/LayoutTests/ChangeLog (225905 => 225906)

--- trunk/LayoutTests/ChangeLog	2017-12-14 17:03:56 UTC (rev 225905)
+++ trunk/LayoutTests/ChangeLog	2017-12-14 17:04:21 UTC (rev 225906)
@@ -1,3 +1,21 @@
+2017-12-14  Romain Bellessort  
+
+[Readable Streams API] Remove properties tests covered by WPT
+https://bugs.webkit.org/show_bug.cgi?id=180809
+
+Reviewed by Youenn Fablet.
+
+Removed WebKit properties/methods tests for ReadableByteStreamController,
+ReadableStreamBYOBReader and ReadableStreamBYOBRequest. Indeed, these
+tests are also present in WPT streams/readable-byte-streams/properties.js.
+
+* streams/readable-byte-stream-controller-expected.txt: Updated expectations.
+* streams/readable-byte-stream-controller.js: Remove ReadableByteStreamController properties test.
+* streams/readable-stream-byob-reader-expected.txt: Updated expectations.
+* streams/readable-stream-byob-reader.js: Remove ReadableStreamBYOBReader properties test.
+* streams/readable-stream-byob-request-expected.txt: Updated expectations.
+* streams/readable-stream-byob-request.js: Remove ReadableStreamBYOBRequest properties test.
+
 2017-12-14  Miguel Gomez  
 
 [GTK] Gardening bug after r225898


Modified: trunk/LayoutTests/streams/readable-byte-stream-controller-expected.txt (225905 => 225906)

--- trunk/LayoutTests/streams/readable-byte-stream-controller-expected.txt	2017-12-14 17:03:56 UTC (rev 225905)
+++ trunk/LayoutTests/streams/readable-byte-stream-controller-expected.txt	2017-12-14 17:04:21 UTC (rev 225906)
@@ -1,6 +1,5 @@
 
 PASS Creating a ReadableStream with an underlyingSource with type property set to 'bytes' should succeed 
-PASS ReadableByteStreamController instances should have the correct list of properties 
 PASS Calling error() with a this object different from ReadableByteStreamController should throw a TypeError 
 PASS Calling close() with a this object different from ReadableByteStreamController should throw a TypeError 
 PASS Calling enqueue() with a this object different from ReadableByteStreamController should throw a TypeError 
@@ -26,7 +25,6 @@
 PASS For a ReadableStream created with a highWaterMark of 1 and a ReadableByteStreamController, calling cancel after pull has thrown an error should result in a promise rejected with the same error 
 PASS Calling cancel after creating a ReadableStream with an underlyingByteStream's start function returning a rejected promise should result in a promise rejected with the same error 
 PASS Creating a ReadableStream with an underlyingSource with type property set to 'bytes' should succeed 
-PASS ReadableByteStreamController instances should have the correct list of properties 
 PASS Calling error() with a this object different from ReadableByteStreamController should throw a TypeError 
 PASS Calling close() with a this object different from ReadableByteStreamController should throw a TypeError 
 PASS Calling enqueue() with a this object different from ReadableByteStreamController should throw a TypeError 


Modified: trunk/LayoutTests/streams/readable-byte-stream-controller.js (225905 => 225906)

--- trunk/LayoutTests/streams/readable-byte-stream-controller.js	2017-12-14 17:03:56 UTC (rev 225905)
+++ trunk/LayoutTests/streams/readable-byte-stream-controller.js	2017-12-14 17:04:21 UTC (rev 225906)
@@ -10,50 +10,6 @@
 });
 }, "Creating a ReadableStream with an underlyingSource w

[webkit-changes] [225784] trunk

2017-12-12 Thread romain . bellessort
Title: [225784] trunk








Revision 225784
Author romain.belless...@crf.canon.fr
Date 2017-12-12 08:51:54 -0800 (Tue, 12 Dec 2017)


Log Message
[Readable Streams API] Throw RangeError if a size is provided when creating a readable byte stream
https://bugs.webkit.org/show_bug.cgi?id=180470

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

One new test imported from WPT to check that RangeError is thrown if a size is provided.

* web-platform-tests/streams/readable-byte-streams/general-expected.txt: Updated expectations.
* web-platform-tests/streams/readable-byte-streams/general.dedicatedworker-expected.txt: Updated expectations.
* web-platform-tests/streams/readable-byte-streams/general.js: Imported one test case from WPT.
* web-platform-tests/streams/readable-byte-streams/general.serviceworker.https-expected.txt: Updated expectations.

Source/WebCore:

Throw a RangeError if a ReadableStream is created with type 'bytes' and with a
non-undefined strategy size, as per latest spec:
- https://github.com/whatwg/streams/pull/856
- https://streams.spec.whatwg.org/#rs-constructor (step 4.c)

One new test imported from WPT to check that RangeError is thrown.

* Modules/streams/ReadableStream.js:
(initializeReadableStream): Check strategy size and throw RangeError if needed.

Modified Paths

trunk/LayoutTests/imported/w3c/ChangeLog
trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general-expected.txt
trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general.dedicatedworker-expected.txt
trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general.js
trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general.serviceworker.https-expected.txt
trunk/Source/WebCore/ChangeLog
trunk/Source/WebCore/Modules/streams/ReadableStream.js




Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (225783 => 225784)

--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-12-12 16:46:09 UTC (rev 225783)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-12-12 16:51:54 UTC (rev 225784)
@@ -1,3 +1,17 @@
+2017-12-12  Romain Bellessort  
+
+[Readable Streams API] Throw RangeError if a size is provided when creating a readable byte stream
+https://bugs.webkit.org/show_bug.cgi?id=180470
+
+Reviewed by Youenn Fablet.
+
+One new test imported from WPT to check that RangeError is thrown if a size is provided.
+
+* web-platform-tests/streams/readable-byte-streams/general-expected.txt: Updated expectations.
+* web-platform-tests/streams/readable-byte-streams/general.dedicatedworker-expected.txt: Updated expectations.
+* web-platform-tests/streams/readable-byte-streams/general.js: Imported one test case from WPT.
+* web-platform-tests/streams/readable-byte-streams/general.serviceworker.https-expected.txt: Updated expectations.
+
 2017-12-12  Ms2ger  
 
 [GTK] Update some test expectations.


Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general-expected.txt (225783 => 225784)

--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general-expected.txt	2017-12-12 16:46:09 UTC (rev 225783)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general-expected.txt	2017-12-12 16:51:54 UTC (rev 225784)
@@ -71,4 +71,5 @@
 PASS ReadableStreamBYOBReader constructor requires a ReadableStream argument 
 PASS ReadableStreamBYOBReader constructor requires an unlocked ReadableStream 
 PASS ReadableStreamBYOBReader constructor requires a ReadableStream with type "bytes" 
+PASS ReadableStream constructor should not accept a strategy with a size defined if type is "bytes" 
 


Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general.dedicatedworker-expected.txt (225783 => 225784)

--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general.dedicatedworker-expected.txt	2017-12-12 16:46:09 UTC (rev 225783)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general.dedicatedworker-expected.txt	2017-12-12 16:51:54 UTC (rev 225784)
@@ -71,4 +71,5 @@
 PASS ReadableStreamBYOBReader constructor requires a ReadableStream argument 
 PASS ReadableStreamBYOBReader constructor requires an unlocked ReadableStream 
 PASS ReadableStreamBYOBReader constructor requires a ReadableStream with type "bytes" 
+PASS ReadableStream constructor should not accept a strategy with a size defined if type is "bytes" 
 


Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general.js (225783 => 225784)

--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general.js	2017-12-12 16:46:09 UTC (rev 225783)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams

[webkit-changes] [223279] trunk

2017-10-13 Thread romain . bellessort
Title: [223279] trunk








Revision 223279
Author romain.belless...@crf.canon.fr
Date 2017-10-13 02:22:48 -0700 (Fri, 13 Oct 2017)


Log Message
[Readable Streams API] Align queue with spec for ReadableStreamDefaultController
https://bugs.webkit.org/show_bug.cgi?id=178082

Reviewed by Xabier Rodriguez-Calvar.

LayoutTests/imported/w3c:

Updated test expectations for tests that were previously failing but now pass.

* web-platform-tests/streams/readable-streams/floating-point-total-queue-size-expected.txt:
* web-platform-tests/streams/readable-streams/floating-point-total-queue-size.dedicatedworker-expected.txt:

Source/WebCore:

Implemented new queue behavior for dequeueValue (used by ReadableStreamDefaultController),
which fixes rounding errors (as described in https://github.com/whatwg/streams/pull/661).
Also aligned ReadableByteStreamController queue so that both queues are implemented in
the same way.

No new tests (covered by existing tests, especially WPT tests that now pass).

* Modules/streams/ReadableByteStreamInternals.js:
(privateInitializeReadableByteStreamController): Aligned queue with RSDC.
(readableByteStreamControllerCancel): Aligned queue with RSDC.
(readableByteStreamControllerError): Aligned queue with RSDC.
(readableByteStreamControllerClose): Aligned queue with RSDC.
(readableByteStreamControllerHandleQueueDrain): Aligned queue with RSDC.
(readableByteStreamControllerPull): Aligned queue with RSDC.
(readableByteStreamControllerEnqueue): Aligned queue with RSDC.
(readableByteStreamControllerEnqueueChunk): Aligned queue with RSDC.
(readableByteStreamControllerProcessPullDescriptors): Aligned queue with RSDC.
(readableByteStreamControllerFillDescriptorFromQueue): Aligned queue with RSDC.
(readableByteStreamControllerPullInto): Aligned queue with RSDC.
* Modules/streams/StreamInternals.js:
(dequeueValue): Updated to match spec.
* bindings/js/WebCoreBuiltinNames.h: Removed now useless "totalQueuedBytes".

Modified Paths

trunk/LayoutTests/imported/w3c/ChangeLog
trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/floating-point-total-queue-size-expected.txt
trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/floating-point-total-queue-size.dedicatedworker-expected.txt
trunk/Source/WebCore/ChangeLog
trunk/Source/WebCore/Modules/streams/ReadableByteStreamInternals.js
trunk/Source/WebCore/Modules/streams/StreamInternals.js
trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h




Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (223278 => 223279)

--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-10-13 07:14:29 UTC (rev 223278)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-10-13 09:22:48 UTC (rev 223279)
@@ -1,3 +1,15 @@
+2017-10-13  Romain Bellessort  
+
+[Readable Streams API] Align queue with spec for ReadableStreamDefaultController
+https://bugs.webkit.org/show_bug.cgi?id=178082
+
+Reviewed by Xabier Rodriguez-Calvar.
+
+Updated test expectations for tests that were previously failing but now pass.
+
+* web-platform-tests/streams/readable-streams/floating-point-total-queue-size-expected.txt:
+* web-platform-tests/streams/readable-streams/floating-point-total-queue-size.dedicatedworker-expected.txt:
+
 2017-10-12  Chris Dumez  
 
 import-w3c-tests modifies test sources and sometimes causes them to fail


Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/floating-point-total-queue-size-expected.txt (223278 => 223279)

--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/floating-point-total-queue-size-expected.txt	2017-10-13 07:14:29 UTC (rev 223278)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/floating-point-total-queue-size-expected.txt	2017-10-13 09:22:48 UTC (rev 223279)
@@ -1,6 +1,6 @@
 
-FAIL Floating point arithmetic must manifest near NUMBER.MAX_SAFE_INTEGER (total ends up positive) assert_equals: [[queueTotalSize]] must clamp to 0 if it becomes negative expected 0 but got 1
-FAIL Floating point arithmetic must manifest near 0 (total ends up positive, but clamped) assert_equals: [[queueTotalSize]] must clamp to 0 if it becomes negative expected 0 but got 1.1102230246251565e-16
+PASS Floating point arithmetic must manifest near NUMBER.MAX_SAFE_INTEGER (total ends up positive) 
+PASS Floating point arithmetic must manifest near 0 (total ends up positive, but clamped) 
 PASS Floating point arithmetic must manifest near 0 (total ends up positive, and not clamped) 
 PASS Floating point arithmetic must manifest near 0 (total ends up zero) 
 


Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/floating-point-total-queue-size.dedicatedworker-expected.txt (223278 => 223279)

--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/floating-point-total-queue-size.dedicatedworker-expected.txt	2017-10-13 07:14

[webkit-changes] [223044] trunk/Source/WebCore

2017-10-09 Thread romain . bellessort
Title: [223044] trunk/Source/WebCore








Revision 223044
Author romain.belless...@crf.canon.fr
Date 2017-10-09 05:53:11 -0700 (Mon, 09 Oct 2017)


Log Message
[Readable Streams API] Implement canCloseOrEnqueue
https://bugs.webkit.org/show_bug.cgi?id=178005

Reviewed by Youenn Fablet.

Implemented readableStreamDefaultControllerCanCloseOrEnqueue [1]. This is
just a refactoring (based on spec) aiming at factorizing a set of tests
that are done at multiple places.

[1] https://streams.spec.whatwg.org/#readable-stream-default-controller-can-close-or-enqueue

No new tests (refactoring, no new behavior).

* Modules/streams/ReadableStreamDefaultController.js:
(enqueue): Updated.
(close): Updated.
* Modules/streams/ReadableStreamInternals.js:
(readableStreamDefaultControllerClose): Updated.
(readableStreamDefaultControllerCanCloseOrEnqueue): Added.

Modified Paths

trunk/Source/WebCore/ChangeLog
trunk/Source/WebCore/Modules/streams/ReadableStreamDefaultController.js
trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js




Diff

Modified: trunk/Source/WebCore/ChangeLog (223043 => 223044)

--- trunk/Source/WebCore/ChangeLog	2017-10-09 09:59:26 UTC (rev 223043)
+++ trunk/Source/WebCore/ChangeLog	2017-10-09 12:53:11 UTC (rev 223044)
@@ -1,3 +1,25 @@
+2017-10-09  Romain Bellessort  
+
+[Readable Streams API] Implement canCloseOrEnqueue
+https://bugs.webkit.org/show_bug.cgi?id=178005
+
+Reviewed by Youenn Fablet.
+
+Implemented readableStreamDefaultControllerCanCloseOrEnqueue [1]. This is
+just a refactoring (based on spec) aiming at factorizing a set of tests
+that are done at multiple places.
+
+[1] https://streams.spec.whatwg.org/#readable-stream-default-controller-can-close-or-enqueue
+
+No new tests (refactoring, no new behavior).
+
+* Modules/streams/ReadableStreamDefaultController.js:
+(enqueue): Updated.
+(close): Updated.
+* Modules/streams/ReadableStreamInternals.js:
+(readableStreamDefaultControllerClose): Updated.
+(readableStreamDefaultControllerCanCloseOrEnqueue): Added.
+
 2017-10-05  Frederic Wang  
 
 Remove WOFF2 from Source/ThirdParty.


Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamDefaultController.js (223043 => 223044)

--- trunk/Source/WebCore/Modules/streams/ReadableStreamDefaultController.js	2017-10-09 09:59:26 UTC (rev 223043)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamDefaultController.js	2017-10-09 12:53:11 UTC (rev 223044)
@@ -32,12 +32,9 @@
 if (!@isReadableStreamDefaultController(this))
 throw @makeThisTypeError("ReadableStreamDefaultController", "enqueue");
 
-if (this.@closeRequested)
-@throwTypeError("ReadableStreamDefaultController is requested to close");
+if (!@readableStreamDefaultControllerCanCloseOrEnqueue(this))
+@throwTypeError("ReadableStreamDefaultController is not in a state where chunk can be enqueued");
 
-if (this.@controlledReadableStream.@state !== @streamReadable)
-@throwTypeError("ReadableStream is not readable");
-
 return @readableStreamDefaultControllerEnqueue(this, chunk);
 }
 
@@ -61,12 +58,9 @@
 if (!@isReadableStreamDefaultController(this))
 throw @makeThisTypeError("ReadableStreamDefaultController", "close");
 
-if (this.@closeRequested)
-@throwTypeError("ReadableStreamDefaultController is already requested to close");
+if (!@readableStreamDefaultControllerCanCloseOrEnqueue(this))
+@throwTypeError("ReadableStreamDefaultController is not in a state where it can be closed");
 
-if (this.@controlledReadableStream.@state !== @streamReadable)
-@throwTypeError("ReadableStream is not readable");
-
 @readableStreamDefaultControllerClose(this);
 }
 


Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js (223043 => 223044)

--- trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js	2017-10-09 09:59:26 UTC (rev 223043)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js	2017-10-09 12:53:11 UTC (rev 223044)
@@ -319,10 +319,8 @@
 
 const stream = controller.@controlledReadableStream;
 
-if (stream.@state === @streamClosed || stream.@state === @streamErrored)
+if (!@readableStreamDefaultControllerCanCloseOrEnqueue(controller))
 return;
-if (controller.@closeRequested)
-return;
 if (!controller.@started)
 return;
 if ((!@isReadableStreamLocked(stream) || !stream.@reader.@readRequests.length) && @readableStreamDefaultControllerGetDesiredSize(controller) <= 0)
@@ -423,12 +421,10 @@
 {
 "use strict";
 
-const stream = controller.@controlledReadableStream;
-@assert(!controller.@closeRequested);
-@assert(stream.@state === @streamReadable);
+@assert(@readableStreamDefaul