Bug 161961 - callPromiseFunction should be made usable for custom binding code
Summary: callPromiseFunction should be made usable for custom binding code
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-14 07:26 PDT by youenn fablet
Modified: 2016-09-15 00:42 PDT (History)
4 users (show)

See Also:


Attachments
Patch (11.00 KB, patch)
2016-09-14 07:32 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Adding binding test (22.26 KB, patch)
2016-09-14 08:38 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (22.92 KB, patch)
2016-09-14 23:51 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2016-09-14 07:26:32 PDT
Custom binding code is not always handling promise correctly as can be seen from SubtleCrypto and getUserMedia, especially the handling of exceptions.
Having a wrapper function would be useful for these.
Comment 1 youenn fablet 2016-09-14 07:32:37 PDT
Created attachment 288812 [details]
Patch
Comment 2 youenn fablet 2016-09-14 08:38:31 PDT
Created attachment 288817 [details]
Adding binding test
Comment 3 youenn fablet 2016-09-14 08:40:00 PDT
(In reply to comment #2)
> Created attachment 288817 [details]
> Adding binding test

Patch only updates getUserMedia
SubtleCrypto should follow with the same routines.
Comment 4 Darin Adler 2016-09-14 10:04:09 PDT
Comment on attachment 288817 [details]
Adding binding test

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

> Source/WebCore/bindings/js/JSDOMPromise.h:162
> +template<PromiseFunction promiseFunction, bool canBeCalledInWorker = false>

The use of a boolean here probably makes this hard to read at call sites. Is there a better way do this? We can use our typical enum approach, for example.

> Source/WebCore/bindings/js/JSDOMPromise.h:189
> +template<BindingPromiseFunction bindingPromiseFunction, bool canBeCalledInWorker>

Ditto.

> Source/WebCore/bindings/js/JSMediaDevicesCustom.cpp:386
> +    return callPromiseFunction<JSMediaDevicesGetUserMediaPromiseFunction, false>(state);

The "false" here is completely unclear.

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3414
>  static EncodedJSValue ${functionName}Promise(ExecState*, Ref<DeferredWrapper>&&);
>  ${functionReturn} ${functionName}(ExecState* state)

I’d like to see a blank line between these two lines.

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3420
>  static inline EncodedJSValue ${functionName}Promise(ExecState* state, Ref<DeferredWrapper>&&  deferredWrapper)

There is an extra space here after the "&&".

> LayoutTests/fast/mediastream/MediaDevices-getUserMedia.html:140
> +                testPassed(" navigator.mediaDevices.getUserMedia() rejected with error: " + error);

Why the leading space here?

> LayoutTests/fast/mediastream/MediaDevices-getUserMedia.html:143
>                  testPassed(" navigator.mediaDevices.getUserMedia({}) rejected with error: " + error);

Why the leading space here?
Comment 5 youenn fablet 2016-09-14 23:51:33 PDT
Created attachment 288933 [details]
Patch for landing
Comment 6 WebKit Commit Bot 2016-09-15 00:23:26 PDT
Comment on attachment 288933 [details]
Patch for landing

Clearing flags on attachment: 288933

Committed r205953: <http://trac.webkit.org/changeset/205953>
Comment 7 WebKit Commit Bot 2016-09-15 00:23:30 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 youenn fablet 2016-09-15 00:42:09 PDT
Thanks for the review.

(In reply to comment #4)
> Comment on attachment 288817 [details]
> Adding binding test
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=288817&action=review
> 
> > Source/WebCore/bindings/js/JSDOMPromise.h:162
> > +template<PromiseFunction promiseFunction, bool canBeCalledInWorker = false>
> 
> The use of a boolean here probably makes this hard to read at call sites. Is
> there a better way do this? We can use our typical enum approach, for
> example.

Done with a PromiseExecutionScope enum class.

> The "false" here is completely unclear.
> 
> > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3414
> >  static EncodedJSValue ${functionName}Promise(ExecState*, Ref<DeferredWrapper>&&);
> >  ${functionReturn} ${functionName}(ExecState* state)
> 
> I’d like to see a blank line between these two lines.

Done

> > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3420
> >  static inline EncodedJSValue ${functionName}Promise(ExecState* state, Ref<DeferredWrapper>&&  deferredWrapper)
> 
> There is an extra space here after the "&&".

Done

> > LayoutTests/fast/mediastream/MediaDevices-getUserMedia.html:140
> > +                testPassed(" navigator.mediaDevices.getUserMedia() rejected with error: " + error);
> 
> Why the leading space here?
> 
> > LayoutTests/fast/mediastream/MediaDevices-getUserMedia.html:143
> >                  testPassed(" navigator.mediaDevices.getUserMedia({}) rejected with error: " + error);
> 
> Why the leading space here?

Fixed