-
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
Proposal: Default to Active Tab in scripting.executeScript() #431
Comments
Also suggested in https://crbug.com/1194519. P.S. Note that there's no need for the |
Nit: "active tab" is a little overloaded due to it's close association with the @oliverdunk, can you speak to the rationale behind making tab selection explicit when calling |
Chrome's opposed to this. Determining the currently-active tab is fraught with complexity:
Instead of this, I think we should make it easy for extensions to find the tab they want to inject in. In cases where the extension "probably" wants to inject in the active tab (we've seen this most in response to action.onClicked, contextMenus.onClicked, commands.onCommand**, etc), we pass the tab object into the event so it's trivial to specify the ID. For cases where executeScript is being called from a background context and in response to an event that isn't tied to an event like that, I don't think we have high confidence that the developer wants to target the active tab (for instance, executeScript is often used for injecting scripts into newly opened tabs -- which may be background -- or in response to webnavigation events, which could easily be for background tabs). One case that was brought up by @carlosjeurissen that isn't well supported here is invoking executeScript() from an extension's popup. I would rather support this (more easily) by extending tabs.getCurrent() (which does not return the active tab, but rather the tab associated with the currently-running script) to return the tab the popup has. This would make the case of injecting in the tab under the popup simple and more reliable than defaulting to the active tab (since the popup may be open a tab in a backgrounded window). I think we should file an issue for that separately. ** Firefox does not currently include a tab for commands.onCommand. Chrome does. |
It sounds good, and as you have mentioned, often extensions that rely on Main areas where tabs.Tab would be needed
|
@rdcronin, 1) re "make it easy for extensions to find the tab" it would be nice if you add the popup's tabId to |
Preamble
scripting.executeScript()
is introduced as the replacement fortabs.executeScript()
, however:Proposal
Make TabId optional and default to the active tab in
scripting.executeScript()
liketabs.executeScript()
Purpose
Many extensions only require
"activeTab"
permission and if necessary,tabs.executeScript()
can be executed without any additional process or permission in MV2.Aforementioned extensions in MV3
scripting.executeScript()
would be required to include the active tab ID, e.g. via tabs.query()which would additionally require."tabs"
permissionA common example is onCommand API which does not include any tab information.
The text was updated successfully, but these errors were encountered: