WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
206364
Make the callAsyncJavaScriptFunction function actually be async (so await works)
https://bugs.webkit.org/show_bug.cgi?id=206364
Summary
Make the callAsyncJavaScriptFunction function actually be async (so await works)
Brady Eidson
Reported
2020-01-16 11:22:16 PST
Make the callAsyncJavaScriptFunction function actually be async (so await works) <
rdar://problem/58571682
>
Attachments
Patch
(7.49 KB, patch)
2020-01-16 11:39 PST
,
Brady Eidson
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Brady Eidson
Comment 1
2020-01-16 11:39:11 PST
Created
attachment 387938
[details]
Patch
Geoffrey Garen
Comment 2
2020-01-16 11:41:31 PST
Comment on
attachment 387938
[details]
Patch r=me
Devin Rousso
Comment 3
2020-01-16 11:47:02 PST
Comment on
attachment 387938
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=387938&action=review
> Source/WebCore/bindings/js/ScriptController.cpp:607 > + functionStringBuilder.append("(async function(");
One issue with making a function `async` is that they _always_ return a `Promise`. I think it would be better to have `ScriptController:callInWorld` take an `enum class IsAsync { Yes, No };` so that callers can decide whether or not they want this.
Brady Eidson
Comment 4
2020-01-16 11:57:38 PST
(In reply to Devin Rousso from
comment #3
)
> Comment on
attachment 387938
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=387938&action=review
> > > Source/WebCore/bindings/js/ScriptController.cpp:607 > > + functionStringBuilder.append("(async function("); > > One issue with making a function `async` is that they _always_ return a > `Promise`.
Which is fine, because literally the only client of this is "callAsyncJavaScriptFunction" which expects promise results.
> I think it would be better to have > `ScriptController:callInWorld` take an `enum class IsAsync { Yes, No };` so > that callers can decide whether or not they want this.
There's no reason to do now that because there would be no client of "No"
WebKit Commit Bot
Comment 5
2020-01-16 13:30:43 PST
Comment on
attachment 387938
[details]
Patch Clearing flags on attachment: 387938 Committed
r254704
: <
https://trac.webkit.org/changeset/254704
>
WebKit Commit Bot
Comment 6
2020-01-16 13:30:45 PST
All reviewed patches have been landed. Closing bug.
Saam Barati
Comment 7
2020-01-16 23:45:11 PST
(In reply to Devin Rousso from
comment #3
)
> Comment on
attachment 387938
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=387938&action=review
> > > Source/WebCore/bindings/js/ScriptController.cpp:607 > > + functionStringBuilder.append("(async function("); > > One issue with making a function `async` is that they _always_ return a > `Promise`. I think it would be better to have > `ScriptController:callInWorld` take an `enum class IsAsync { Yes, No };` so > that callers can decide whether or not they want this.
Why would the API change here? When the Promise that’s returned is resolved, we IPC the result back to the UI process, so I think it should not be (very) observable to users. (Like if you treat it like a non async function, and do something like “return 42;”, everything Just Works and the UI process is called back with “42”.) I think the only concern here is that async functions have slightly different semantics than non async functions. I think(?) things like reserved identifiers and such. But I think that’s ok here, especially because this will be documented.
Devin Rousso
Comment 8
2020-01-17 10:47:05 PST
Comment on
attachment 387938
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=387938&action=review
>>>> Source/WebCore/bindings/js/ScriptController.cpp:607 >>>> + functionStringBuilder.append("(async function("); >>> >>> One issue with making a function `async` is that they _always_ return a `Promise`. I think it would be better to have `ScriptController:callInWorld` take an `enum class IsAsync { Yes, No };` so that callers can decide whether or not they want this. >> >> Which is fine, because literally the only client of this is "callAsyncJavaScriptFunction" which expects promise results. > > Why would the API change here? When the Promise that’s returned is resolved, we IPC the result back to the UI process, so I think it should not be (very) observable to users. (Like if you treat it like a non async function, and do something like “return 42;”, everything Just Works and the UI process is called back with “42”.) > > I think the only concern here is that async functions have slightly different semantics than non async functions. I think(?) things like reserved identifiers and such. But I think that’s ok here, especially because this will be documented.
I misread how `ScriptController::callInWorld` was being used. My apologies for the confusion.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug