Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rebloor
Copy link
Contributor

@rebloor rebloor commented Jun 14, 2024

Description

Addresses the documentation requirements of Bug 1889897 Implement asyncBlocking support for webRequest.onAuthRequired, including:

  • a release note
  • update to the webRequest.onAuthRequired event documentation. This also included some changes to avoid repetition in that documentation.

@rebloor rebloor added the Content:WebExt WebExtensions docs label Jun 14, 2024
@rebloor rebloor requested a review from dotproto June 14, 2024 03:02
@rebloor rebloor self-assigned this Jun 14, 2024
@rebloor rebloor requested review from a team as code owners June 14, 2024 03:02
@rebloor rebloor requested review from hamishwillee and removed request for a team June 14, 2024 03:02
@github-actions github-actions bot added Content:Firefox Content in the Mozilla/Firefox subtree size/s 6-50 LoC changed labels Jun 14, 2024
Copy link
Contributor

github-actions bot commented Jun 14, 2024

Preview URLs

External URLs (1)

URL: /en-US/docs/Mozilla/Firefox/Releases/128
Title: Firefox 128 for developers

(comment last updated: 2024-06-18 04:25:27)

@hamishwillee hamishwillee removed their request for review June 17, 2024 02:20
Copy link
Collaborator

@dotproto dotproto left a 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.

Comment on lines +34 to 36
- 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).
Copy link
Collaborator

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 a webRequest.BlockingResponse object or a Promise that resolves to a webRequest.BlockingResponse object.
  • If "asyncBlocking" is provided, the event listener function will receive a asyncCallback function as it's second parameter. asyncCallback may be called asynchronously and takes a webRequest.BlockingResponse object as it's only parameter.

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.
Copy link
Contributor

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 🐶

Suggested change
- : 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.

Copy link
Contributor

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 🐶

Suggested change

Comment on lines +101 to +102

- In Firefox, the event listener may return a Promise that resolves to a `BlockingResponse` object to respond to the event asynchronously.
Copy link
Contributor

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 🐶

Suggested change
- 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.
Copy link
Contributor

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 🐶

Suggested change
- Supported in Chrome 120 and later.
- Supported in Chrome 120 and later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:Firefox Content in the Mozilla/Firefox subtree Content:WebExt WebExtensions docs size/s 6-50 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants