Open Bug 1736575 Opened 2 years ago Updated 11 days ago

Support execution world MAIN in `scripting.executeScript()`

Categories

(WebExtensions :: General, enhancement, P2)

enhancement
Points:
8

Tracking

(Not tracked)

People

(Reporter: willdurand, Unassigned)

References

(Depends on 1 open bug, Blocks 2 open bugs)

Details

(Whiteboard: [mv3-m2][wecg])

Severity: -- → N/A
Blocks: 1735474
No longer depends on: 1735474
Type: task → enhancement
Points: --- → 8

Unassigned myself because this is not a high priority bug for now.

Assignee: wdurand → nobody
Blocks: 1687764

"ISOLATED" was supported in bug 1759932.
This bug is currently about supporting execution in the "MAIN" world (i.e. the web page).

Whiteboard: [mv3-m2] → [mv3-m2][wecg]

When we commence work on this, we should also create new bugs or patches to introduce support for world to scripting.registerContentScripts and content_scripts in manifest.json. Chromium implemented that in https://crbug.com/1330986

The userScripts API proposal at https://github.com/w3c/webextensions/pull/331 includes the "USER_SCRIPT" world, after my feedback to the initial proposal. That is out of scope for this bug, we will file new bugs to implement the USER_SCRIPT world and new APIs when we get there (and these would be part of the userScripts namespace, not the scripting namespace anyway).

When this bug is fixed, we have to adjust the BCD that I added in https://github.com/mdn/browser-compat-data/pull/18878

Summary: Support execution world in `scripting.executeScript()` → Support execution world MAIN in `scripting.executeScript()`
Depends on: 1743790

I have worked on the Adobe Flash Player emulator Ruffle. There are a few things we've had to do differently between Firefox and Chromium to make sure it works on both browsers, and this is the cause of one of them.

On Chromium browsers, we are able to use scripting.registerContentScripts with the MAIN execution world to run a script (https://github.com/ruffle-rs/ruffle/blob/feacbdc118c92ff30f686c1203c6f08ccd92833d/web/packages/core/src/plugin-polyfill.ts#L203) to add "Shockwave Flash" to navigator.plugins to fool Flash detection scripts. The faster the script is run, the more likely it is to run before any Flash detection scripts. On Firefox, we instead have to add a raw script tag with the compiled form of that script as its source to do the same thing, which isn't as fast so is more likely to run after the detection already fails and is also a bit more roundabout.

On Firefox, we instead have to add a raw script tag with the compiled form of that script as its source to do the same thing

Hi Daniel, that shouldn't be necessary. See Sharing objects with page scripts.

(In reply to Gregory Pappas [:gregp] from comment #7)

On Firefox, we instead have to add a raw script tag with the compiled form of that script as its source to do the same thing

Hi Daniel, that shouldn't be necessary. See Sharing objects with page scripts.

That doesn't allow for running the script quickly enough that it can add "Shockwave Flash" to navigator.plugins before inline scripts on the page check for and don't see the presence of Shockwave Flash in navigator.plugins.

You need to log in before you can comment on or make changes to this bug.