Support Promise as return value from webRequest.onAuthRequired #490
Labels
implemented: firefox
Implemented in Firefox
inconsistency
Inconsistent behavior across browsers
neutral: safari
Not opposed or supportive from Safari
supportive: chrome
Supportive from Chrome
The
webRequest.onAuthRequired
event is the only webRequest event that can block a request asynchronously in Chrome (In Firefox, all webRequest events can be async; Safari does not support any blocking webRequest API).Firefox and Chrome have an interoperable API when an extension wants to return the result synchronously from the event handler function of
webRequest.onAuthRequired
. But for asynchronous results, there is currently a large discrepancy, as I elaborated at mdn/content#30188 (review) (The permission aspect is out-of-scope for this issue, that's part of #264).Chrome and Firefox support this syntax to handle an event synchronously:
Firefox also supports asynchronous results through a Promise. In the above example, replace "function (details) {" with "async function (details) {`, and it would be effectively the same as the following. Note that the event registration looks identical to before:
Chrome does not support
Promise
as return value. Instead, it requires a different way to register the listener, and passing the result via a callback:I propose to update Chrome's implementation to support
Promise
, with the following remarks:asyncBlocking
is used, the return value is ignored. This should continue, in case extensions useasync function
and still callasyncCallback
asynchronously after the Promise resolves.Promise
is returned).The text was updated successfully, but these errors were encountered: