[Streams API] ReadableJSStream should handle promises returned by JS source start...
authoryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 Jun 2015 09:09:53 +0000 (09:09 +0000)
committeryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 Jun 2015 09:09:53 +0000 (09:09 +0000)
commita62589b2e5f66ce4b02ba638f59469c8b8d68b97
treeb53914342b3217cc212d9bb9b2ee1c71fad374c8
parent950ade49ee1a19454f8097a9ab5d509b9a853fb9
[Streams API] ReadableJSStream should handle promises returned by JS source start callback
https://bugs.webkit.org/show_bug.cgi?id=145792

Source/JavaScriptCore:

Reviewed by Darin Adler.

Added support for JSFunction implemented by std::function.

* runtime/JSFunction.cpp:
(JSC::getNativeExecutable): Refactored code to share it with the two JSFunction::create
(JSC::JSFunction::create):
(JSC::runStdFunction):
* runtime/JSFunction.h: Added std::function based JSFunction::create prototype.
* runtime.JSPromise.h:

Source/WebCore:

Reviewed by Darin Adler.

Covered by rebased tests.

When calling start callback, the returned value is checked.
If it is not a promise, we do as if it is a resolved promise.
If it is a promise, we call its then() method with two resolve/reject JS functions.

* Modules/streams/ReadableStream.cpp:
* bindings/js/ReadableJSStream.cpp:
(WebCore::ReadableJSStream::invoke): Returns a JSPromise* if any is returned by the JS source callback.
(WebCore::thenPromise): Utility method to call the promise.
(WebCore::createStartResultFulfilledFunction): The promise resolve callback.
(WebCore::ReadableJSStream::doStart): Calls thenPromise if a JSPromise* is returned by invoke.
(WebCore::ReadableJSStream::ReadableJSStream):
* bindings/js/ReadableJSStream.h:

LayoutTests:

Reviewed by Darin Adler.

Rebasing expectations, and removing timeouts for tests that no longer timeout.

* streams/reference-implementation/readable-stream-expected.txt:
* streams/reference-implementation/readable-stream.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185537 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/streams/reference-implementation/readable-stream-expected.txt
LayoutTests/streams/reference-implementation/readable-stream.html
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSFunction.cpp
Source/JavaScriptCore/runtime/JSFunction.h
Source/JavaScriptCore/runtime/JSPromise.h
Source/WebCore/ChangeLog
Source/WebCore/Modules/streams/ReadableStream.cpp
Source/WebCore/bindings/js/ReadableJSStream.cpp
Source/WebCore/bindings/js/ReadableJSStream.h