Open Bug 1963072 Opened 4 months ago Updated 4 months ago

Define order of execution for registered userScripts; currently inconsistent

Categories

(WebExtensions :: General, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: robwu, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [wecg])

Bug 1792685 improved the guaranteed ordering of statically defined content scripts as defined in manifest.json. The bug did not specifically cover dynamic content script registration, but in practice the order is static content scripts, followed by dynamic content scripts and user scripts. And what bug 1792685 did guarantee, even for these, is that the order of internal registration is now also the order of execution.

The defined order of execution in the user scripts is specified in the WECG as follows:

https://github.com/w3c/webextensions/blob/8794f3a6e6e7684513132ddffce9a756c4c5861f/proposals/user-scripts-api.md#other-considerations

When multiple scripts match and have the same runAt schedule, the execution order is:

  • Scripts registered via the content_scripts key in the manifest file
  • Scripts registered via scripting.registerContentScripts(), following the order they were registered in. Updating a content script doesn't change its registration order.
  • Scripts registered via userScripts.register(), following the order they were registered in. Updating a user script doesn’t change its registration order.

In practice, Firefox behavior is as follows:

What Chrome does is:

Our current order is inconsistent. We should align across browsers what the order really should be, and implement that.

Severity: -- → N/A
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.