Open Bug 1624738 Opened 5 years ago Updated 2 years ago

commands API does not provide context (e.g. tabId + frameId) when shortcut is triggered

Categories

(WebExtensions :: Frontend, enhancement, P5)

74 Branch
enhancement

Tracking

(Not tracked)

People

(Reporter: mozbug, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0

Steps to reproduce:

It doesn't appear to be possible to reliably implement a feature that pastes content on a keyboard shortcut in a web extension.

Actual results:

The onCommand event provides no information about context, therefore the handler must use tabs.query to get information on the current tab. However, this still does not tell us what the current frame ID is.

Therefore, when sending a message to the content script to paste into the current element, we have no way to know which frame to send the data to.

Expected results:

There should be a way to get the current active frame ID, either via a query, or as information about the context the command was triggered in.

Component: Untriaged → Frontend
Product: Firefox → WebExtensions

The commands API as currently designed is about global shortcuts, e.g. including shortcuts when non-webcontent is focused.

To support the request here, shortcuts need more context, from the content (web pages). This means that shortcuts should be registered in individual content processes. Given the performance cost of this, the feature must be opt-in, if we decide to implement it at all. E.g. by adding a new property to the commands definition.

The case for supporting this feature is that it removes the need for extensions to request access to all URLs and register a content script in every page and frame that registers a keyup event handler (which would be the next best alternative).

At the bug triage we decided that this is not something that we would work on ourselves, but that we are willing to review patches that provide this functionality.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P5
Summary: No way to get frame ID from command → commands API does not provide context (e.g. tabId + frameId) when shortcut is triggered
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.