Bug 145792

Summary: [Streams API] ReadableJSStream should handle promises returned by JS source start callback
Product: WebKit Reporter: youenn fablet <youennf>
Component: WebCore Misc.Assignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, benjamin, calvaris, commit-queue, darin
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 145893    
Bug Blocks: 138967    
Attachments:
Description Flags
Patch
none
Trying to fix Win build
none
Fixing log
none
Cleaning NativeStdFunction definition
none
Fixing JSStdFunction none

Description youenn fablet 2015-06-09 01:29:56 PDT
"start", "pull" and "cancel" may finish asynchronously by returning promises.
ReadableJSStream should handle these promises.
To start with, this should be done for the "start" callback.
Comment 1 youenn fablet 2015-06-10 01:32:04 PDT
Created attachment 254636 [details]
Patch
Comment 2 youenn fablet 2015-06-10 02:25:21 PDT
Created attachment 254641 [details]
Trying to fix Win build
Comment 3 youenn fablet 2015-06-10 03:34:21 PDT
Comment on attachment 254641 [details]
Trying to fix Win build

View in context: https://bugs.webkit.org/attachment.cgi?id=254641&action=review

> Source/WebCore/bindings/js/ReadableJSStream.cpp:78
> +    JSPromise* promise = jsDynamicCast<JSPromise*>(callFunction(state, function, m_source.get(), arguments));

By doing the cast here, we ensure that thenPromise is only called if JS callback returns a promise.
But the code inside thenPromise is nothing special to promise.
We could call thenPromise whenever callback returned value has a then property which is callable.
Comment 4 WebKit Commit Bot 2015-06-11 10:36:36 PDT
Comment on attachment 254641 [details]
Trying to fix Win build

Rejecting attachment 254641 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.appspot.com', '--bot-id=webkit-cq-02', 'validate-changelog', '--check-oops', '--non-interactive', 254641, '--port=mac']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit

ChangeLog entry in LayoutTests/ChangeLog contains OOPS!.

Full output: http://webkit-queues.appspot.com/results/6265508483563520
Comment 5 youenn fablet 2015-06-11 11:36:12 PDT
Created attachment 254734 [details]
Fixing log
Comment 6 WebKit Commit Bot 2015-06-11 12:31:00 PDT
Comment on attachment 254734 [details]
Fixing log

Clearing flags on attachment: 254734

Committed r185465: <http://trac.webkit.org/changeset/185465>
Comment 7 WebKit Commit Bot 2015-06-11 12:31:04 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Alex Christensen 2015-06-11 13:05:22 PDT
This broke at least the 32-bit mac build.
https://build.webkit.org/builders/Apple%20Yosemite%20Release%20%2832-bit%20Build%29/builds/3693
Comment 9 WebKit Commit Bot 2015-06-11 13:07:29 PDT
Re-opened since this is blocked by bug 145893
Comment 10 youenn fablet 2015-06-12 10:28:40 PDT
Created attachment 254807 [details]
Cleaning NativeStdFunction definition
Comment 11 youenn fablet 2015-06-12 10:29:29 PDT
Comment on attachment 254807 [details]
Cleaning NativeStdFunction definition

Let's try it again
Comment 12 Darin Adler 2015-06-12 10:30:54 PDT
Comment on attachment 254807 [details]
Cleaning NativeStdFunction definition

View in context: https://bugs.webkit.org/attachment.cgi?id=254807&action=review

> Source/JavaScriptCore/runtime/JSFunction.cpp:78
>      } else

WebKit coding style normally omits else after a return.
Comment 13 Darin Adler 2015-06-12 10:31:56 PDT
Comment on attachment 254807 [details]
Cleaning NativeStdFunction definition

View in context: https://bugs.webkit.org/attachment.cgi?id=254807&action=review

> Source/JavaScriptCore/runtime/JSFunction.cpp:92
> +struct JSStdFunction: public JSFunction {

In a struct we normally omit public since it’s the default. We also put a space before the colon here.

I’m not sure it’s right to make this a struct, though, since it’s derived from a a class. I think this should probably be a class instead.
Comment 14 youenn fablet 2015-06-12 10:33:50 PDT
(In reply to comment #13)
> Comment on attachment 254807 [details]
> Cleaning NativeStdFunction definition
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=254807&action=review
> 
> > Source/JavaScriptCore/runtime/JSFunction.cpp:92
> > +struct JSStdFunction: public JSFunction {
> 
> In a struct we normally omit public since it’s the default. We also put a
> space before the colon here.
> 
> I’m not sure it’s right to make this a struct, though, since it’s derived
> from a a class. I think this should probably be a class instead.

Thanks.
I am postponing cq until processing further feedback
Comment 15 youenn fablet 2015-06-12 12:44:43 PDT
Created attachment 254815 [details]
Fixing JSStdFunction
Comment 16 WebKit Commit Bot 2015-06-13 02:10:30 PDT
Comment on attachment 254815 [details]
Fixing JSStdFunction

Clearing flags on attachment: 254815

Committed r185537: <http://trac.webkit.org/changeset/185537>
Comment 17 WebKit Commit Bot 2015-06-13 02:10:35 PDT
All reviewed patches have been landed.  Closing bug.