-
Notifications
You must be signed in to change notification settings - Fork 22.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asyncBlocking in webRequest.onAuthRequired #34137
base: main
Are you sure you want to change the base?
asyncBlocking in webRequest.onAuthRequired #34137
Conversation
Preview URLs
External URLs (1)URL:
(comment last updated: 2024-06-19 09:51:15) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there may have been a miscommunication around how async handling of onAuthRequired events work in Firefox 128+. The version of this PR I'm reviewing seems to say that Firefox 128 and later no longer support asynchronous response handling in "blocking"
listeners. Based on my reading of Firefox source, it appears that blocking
listeners can still return return promises to asynchronously settle an onAuthRequired event. What has changed is that Firefox now supports registering onAuthRequired listeners with "asyncBlocking"
and these listeners match the behavior seen in Chrome.
All changes suggested in this review are for illustrative purposes. I'm happy to defer to your judgement on how best to structure the related content.
files/en-us/mozilla/add-ons/webextensions/api/webrequest/onauthrequired/index.md
Outdated
Show resolved
Hide resolved
- in addListener, pass `"asyncBlocking"` in the `extraInfoSpec` parameter | ||
- in the listener, return a `Promise` that resolves with an object containing an `authCredentials` property, set to the credentials to supply | ||
> **Note:** Chrome does not support a Promise as a return value ([Chromium issue 1510405](https://crbug.com/1510405)). For alternatives, see [the return value of the `listener`](#listener). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per comment 3 on bug 1889897 and the implementation (changeset), Firefox supports either "blocking"
or "asyncBlocking"
. Chrome only supports "asyncBlocking"
.
- If
"blocking"
is provided, the extension may either return awebRequest.BlockingResponse
object or a Promise that resolves to awebRequest.BlockingResponse
object. - If
"asyncBlocking"
is provided, the event listener function will receive aasyncCallback
function as it's second parameter.asyncCallback
may be called asynchronously and takes awebRequest.BlockingResponse
object as it's only parameter.
files/en-us/mozilla/add-ons/webextensions/api/webrequest/onauthrequired/index.md
Show resolved
Hide resolved
files/en-us/mozilla/add-ons/webextensions/api/webrequest/onauthrequired/index.md
Show resolved
Hide resolved
files/en-us/mozilla/add-ons/webextensions/api/webrequest/onauthrequired/index.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Simeon Vincent <[email protected]>
@@ -82,22 +82,29 @@ Events have three functions: | |||
|
|||
- `details` | |||
- : `object`. Details about the request. See the [details](#details_2) section for more information. | |||
- `asyncCallback` {{optional_inline}} | |||
- : A function to call, at most once, to asynchronously modify the request object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[mdn-linter] reported by reviewdog 🐶
- : A function to call, at most once, to asynchronously modify the request object. | |
- : A function to call, at most once, to asynchronously modify the request object. |
@@ -82,22 +82,29 @@ Events have three functions: | |||
|
|||
- `details` | |||
- : `object`. Details about the request. See the [details](#details_2) section for more information. | |||
- `asyncCallback` {{optional_inline}} | |||
- : A function to call, at most once, to asynchronously modify the request object. | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[mdn-linter] reported by reviewdog 🐶
|
||
- In Firefox, the event listener may return a Promise that resolves to a `BlockingResponse` object to respond to the event asynchronously. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[mdn-linter] reported by reviewdog 🐶
- In Firefox, the event listener may return a Promise that resolves to a `BlockingResponse` object to respond to the event asynchronously. | |
- In Firefox, the event listener may return a Promise that resolves to a `BlockingResponse` object to respond to the event asynchronously. | |
|
||
- In Firefox, the event listener may return a Promise that resolves to a `BlockingResponse` object to respond to the event asynchronously. | ||
- `"asyncBlocking"`: handle the request asynchronously. The return value of the event listener is ignored. To resolve the event, pass the `asyncCallback` parameter a `BlockingResponse` result, with its `cancel` or `authCredentials` properties set. | ||
- Supported in Chrome 120 and later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[mdn-linter] reported by reviewdog 🐶
- Supported in Chrome 120 and later. | |
- Supported in Chrome 120 and later. |
|
||
- `"blocking"`: make the request block so you can cancel the request or supply authentication credentials. Return a `BlockingResponse` object with its `cancel` or `authCredentials` properties set. | ||
|
||
- In Chrome, the event listener must respond synchronously. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dotproto why if "Chrome only supports "asyncBlocking"."?
@dotproto I need to check the language in the changes and fix some formatting issues but in the meanwhile, could you check my latest updates, do they address your feedback? |
Description
Addresses the documentation requirements of Bug 1889897 Implement asyncBlocking support for webRequest.onAuthRequired, including: