-
Notifications
You must be signed in to change notification settings - Fork 56
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
Support multiple user script worlds in the user scripts API #565
Comments
I am currently working on the implementation of multiple user script worlds in Firefox, and while examining Chrome's implementation more closely, I found an issue with the currently specified/implemented behavior for The current spec is at https://github.com/w3c/webextensions/blob/main/proposals/multiple_user_script_worlds.md and describes
This description (and the spec in general) does not specify the worldId to use for the "default user script world". Chrome's current implementation seems to use Example (requires starting Chrome with await chrome.userScripts.register([{
id: "id",
js: [{ code: "alert(0)" }],
matches: ["https://example.com/*"],
worldId: "x",
}]);
await chrome.userScripts.update([{
id: "id",
// Also weird: Chrome requires js to be set in update()
js: [{ code: "alert(1)" }],
worldId: null, // intent to change to default world
}]);
var scripts = await chrome.userScripts.getScripts({ ids: ["id"] });
console.log(scripts[0].worldId);
// Expected: null (default?)
// Actual: "x" (unchanged) If we want to keep the default at null, it is technically possible to distinguish "property set" (=set to null) from "property not set" (= do not update) in Firefox's implementation. However, this is unusual and I would prefer a different solution that is easier to explain. Last time we discussed the worldId format, I mentioned two options at #560 (comment)
Given this all, I propose to establish |
Thanks, @Rob--W ! Agreed this is something we should fix, and I'm supportive of using the empty string ( |
The user scripts API allows scripts to inject in a new "user script" world (in addition to the main world), which has slightly different properties than the isolated world content scripts inject in. From early discussions (e.g. this comment from issue #279 ), we have supported the idea of multiple user script worlds.
This issue tracks that work.
The text was updated successfully, but these errors were encountered: