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

DNR: Clarify precedence order across browsers. #26793

Merged
merged 3 commits into from
May 16, 2023

Conversation

Rob--W
Copy link
Member

@Rob--W Rob--W commented May 15, 2023

Description

The currently documented order is not cross-browser, see w3c/webextensions#280. Therefore, drop that part of the documentation and replace it with guidance on how to create stable rules.

Motivation

People following the documentation with the expectation of having the same browser across browsers will be disappointed. The documentation should offer guidance to have consistent behavior across browsers.

Additional details

The documentation currently lists 4 ways of affecting the outcome. Only the first two are kept, as these are also documented in Chrome's documentation (https://developer.chrome.com/docs/extensions/reference/declarativeNetRequest/#implementation-matching-algorithm). The other two (ruleset and rule ID) are not documented in Chrome, and cannot be relied upon. Therefore that part has been removed in favor of a note to emphasize the risk of having ambiguous outcomes, along with recommendations to resolve this.

Related issues and pull requests

The currently documented order is not cross-browser, see WECG issue 280.
Therefore, drop that part of the documentation and replace it with
guidance on how to create stable rules.
@Rob--W Rob--W added the Content:WebExt WebExtensions docs label May 15, 2023
@Rob--W Rob--W requested a review from rpl May 15, 2023 22:43
@Rob--W Rob--W requested a review from a team as a code owner May 15, 2023 22:43
@github-actions github-actions bot added the Content:Other Any docs not covered by another "Content:" label label May 15, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 15, 2023

Preview URLs

Flaws (3)

URL: /en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest
Title: declarativeNetRequest
Flaw count: 3

  • broken_links:
    • Can't resolve /docs/Mozilla/Add-ons/WebExtensions/manifest.json/declarative_net_request
    • Can't resolve /docs/Mozilla/Add-ons/WebExtensions/manifest.json/declarative_net_request
    • Can't resolve /docs/Mozilla/Add-ons/WebExtensions/manifest.json/declarative_net_request
External URLs (1)

URL: /en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest
Title: declarativeNetRequest

(comment last updated: 2023-05-16 14:19:00)

Copy link
Member

@rpl rpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rob--W I just took a quick look to this PR, the content looks good from a technical perspective, but I have a thought about the terminology currently used to describe the issue that I'd like to pass by you (described in the inline comment below), let me know wdyt.

4. the order of the rule in the ruleset, determined as the lowest value rule ID.
6. "modifyHeaders" rewrites request and/or response headers.

> **Note:** When there are multiple matching rules with the same rule priority and rule action type, a problem occurs when the matched action support additional properties. These can result in different outcomes that cannot be combined. For example:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rob--W I'm wondering if instead of using the terms problem / no problem we may consider using the terms ambiguous / non-ambiguous instead, e.g.

Note: When there are multiple matching rules with the same rule priority and rule action type, the outcome of the rules evaluation is going to be potentially ambiguous when the matched action support additional properties. For example:

  • "block" action rules: when multiple rules with the "block" action are matching, there wouldn't be any ambiguity because all "block" actions would result in the same outcome.
  • "redirect" action rules: on the contrary when multiple with the "redirect" action are matching, the url each of the rules would be redirecting the request to may be different and that would make the outcome to become ambiguous, and so all but one of the matching "redirect" rules are going to be ignored. Note that it is still possible, ...
  • "modifyHeaders" action rules: multiple rules with the "modifyHeaders" action are non-ambiguous if they all touch a different header and ambiguous if they touch the exact same header (as also explained at {{WebExtAPIRef("declarativeNetRequest.ModifyHeaderInfo")}}). The evaluation order of "modifyHeaders" is therefore important.

...

Not necessarily with this exact wording, but the idea was to make it more immediately clear what I meant with considering using the term "ambiguous/non-ambiguous" instead of "problem/no problem".

@Rob--W
Copy link
Member Author

Rob--W commented May 16, 2023

FYI: the dnr-redirect-url example at mdn/webextensions-examples#526 demonstrates the difference between Firefox and Chrome. They now behave identically, but when "priority" is removed from redirect-rules.json, the behavior differs.

Copy link
Member

@rpl rpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:Other Any docs not covered by another "Content:" label Content:WebExt WebExtensions docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants