[Streams API] Reading ReadableStream ready and closed attributes should not always...
authoryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Feb 2015 14:48:34 +0000 (14:48 +0000)
committeryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Feb 2015 14:48:34 +0000 (14:48 +0000)
commit76a280f409d4a52ba3ab02ee869c86043689085e
tree97cb16a935bbd538961e5ea0f60c50b0e26f33c7
parentd1ea0488fc857d8123076a987dbfbcc8bdece2c3
[Streams API] Reading ReadableStream ready and closed attributes should not always create a new promise
https://bugs.webkit.org/show_bug.cgi?id=141650

Reviewed by Benjamin Poulain.

Source/WebCore:

The JSPromiseDeferred objects returned by JSReadableStream::ready and JSReadableStream::closed should be stored somewhere.
This patch stores them as private slots in JSReadableStream.
This is close to the description in https://streams.spec.whatwg.org/#rs-internal-slots.

An alternative would be to have these objects as JSReadableStream class members, thus modifying the binding generator.
That may be the cleanest solution, especially if other APIs express the same need.
Another alternative is to store DeferredWrapper in ReadableStream objects.
But it is currently preferred to keep DeferredWrapper in bindings/js code.

Added new constructor for DeferredWrapper to use these stored values.
Updated ready and closed methods to use that new constructor.
Changes are covered by new test in streams/readablestream-constructor.html.

* bindings/js/JSDOMPromise.cpp:
(WebCore::DeferredWrapper::DeferredWrapper):
* bindings/js/JSDOMPromise.h:
* bindings/js/JSReadableStreamCustom.cpp:
(WebCore::closedPromiseSlotName):
(WebCore::getOrCreatePromiseDeferredFromObject):
(WebCore::readyPromiseSlotName):
(WebCore::JSReadableStream::ready):
(WebCore::JSReadableStream::closed):
* bindings/js/ReadableStreamJSSource.cpp:
(WebCore::setInternalSlotToObject):
(WebCore::getInternalSlotFromObject):
* bindings/js/ReadableStreamJSSource.h:

LayoutTests:

* streams/readablestream-constructor-expected.txt:
* streams/readablestream-constructor.html: Added test to ensure ready and closed always return the same promise object.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180559 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/streams/readablestream-constructor-expected.txt
LayoutTests/streams/readablestream-constructor.html
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDOMPromise.cpp
Source/WebCore/bindings/js/JSDOMPromise.h
Source/WebCore/bindings/js/JSReadableStreamCustom.cpp
Source/WebCore/bindings/js/ReadableStreamJSSource.cpp
Source/WebCore/bindings/js/ReadableStreamJSSource.h