[Streams API] Support the start function parameter in ReadableStream constructor
authoryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Apr 2015 06:48:16 +0000 (06:48 +0000)
committeryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Apr 2015 06:48:16 +0000 (06:48 +0000)
commit6067c1317059aef8ebe81aa0166bd3469da6cbc3
tree26bf9da85c1c997bd45419f374fa233122fbf5ae
parentd04050f4a1c5238a5d9baf2dd73a24a3ea3c687e
[Streams API] Support the start function parameter in ReadableStream constructor
https://bugs.webkit.org/show_bug.cgi?id=141160

Source/WebCore:

Reviewed by Benjamin Poulain.

Stores the JS source object in ReadableStreamJSSource and calls its "start" function.
This function takes a controller object that has three JS functions as members: close, enqueue and error.
This controller is stored in ReadableStreamJSSource as it will be reused as "pull" parameter.
All three JS functions do not currently do anything.

Test: streams/readablestream-start.html

* Modules/streams/ReadableStream.cpp:
(WebCore::ReadableStream::start): Place holder for step 11 of https://streams.spec.whatwg.org/#rs-constructor.
* Modules/streams/ReadableStream.h:
* bindings/js/JSReadableStreamCustom.cpp:
(WebCore::constructJSReadableStream):
* bindings/js/ReadableStreamJSSource.cpp:
(WebCore::getPropertyFromObject): Helper function to get a public property from an object.
(WebCore::setPropertyToObject): Helper function to set a public property to an object.
(WebCore::callFunction): Helper function to call a JS function from C++.
(WebCore::ReadableStreamJSSource::ReadableStreamJSSource):
(WebCore::notImplementedFunction):
(WebCore::createReadableStreamEnqueueFunction): Creates the JS function for enqueue.
(WebCore::createReadableStreamCloseFunction): Creates the JS function for close.
(WebCore::createReadableStreamErrorFunction): Creates the JS function for error.
(WebCore::startReadableStreamAsync): Equivalent of promise resolution for start.
(WebCore::ReadableStreamJSSource::start): Calls the "start" function of the JS source with all three JS functions (enqueue, close, error) as parameters.
* bindings/js/ReadableStreamJSSource.h:

LayoutTests:

Reviewed by Benjamin Poulain.

Added tests to check that start JS function is called with the right parameters and can throw errors.

* streams/readablestream-start-expected.txt: Added.
* streams/readablestream-start.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182591 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/streams/readablestream-constructor.html
LayoutTests/streams/readablestream-start-expected.txt [new file with mode: 0644]
LayoutTests/streams/readablestream-start.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/streams/ReadableStream.cpp
Source/WebCore/Modules/streams/ReadableStream.h
Source/WebCore/bindings/js/JSReadableStreamCustom.cpp
Source/WebCore/bindings/js/ReadableStreamJSSource.cpp
Source/WebCore/bindings/js/ReadableStreamJSSource.h