Open Bug 1555620 Opened 6 years ago Updated 1 year ago

WebExtensions command don't work when the key combination is used by the webpage

Categories

(WebExtensions :: Frontend, enhancement, P5)

enhancement

Tracking

(firefox-esr60 affected, firefox67 affected, firefox68 affected, firefox69 affected)

Tracking Status
firefox-esr60 --- affected
firefox67 --- affected
firefox68 --- affected
firefox69 --- affected

People

(Reporter: yuki, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: parity-chrome, Whiteboard: [design-decision-approved])

Abstract

Any keyboard shortcut for a WebExtensions command doesn't work if the shortcut is already used by the webpage currently shown.

Steps to reproduce

  1. Install any addon providing commands, for example: Second Search. It provides a keyboard shortcut Ctrl-Shift-L by default to open its toolbar button popup.
  2. Open http://example.com/ in the current tab.
  3. Hit Ctrl-Shift-L to confirm the effectivity of the shortcut.
  4. Hit Ctrl-Shift-K to open the web console.
  5. Run a script: addEventListener('keydown', e => { e.stopPropagation(); e.preventDefault(); }, true); with the console.
  6. Hit Ctrl-Shift-L.

Actual result

Nothing happen.

Expected result

The keyboard shortcut triggers its WebExtensions command.

Environment

  • Firefox 67.0 (64bit, build ID: 20190516215225) on Windows 10
  • Nightly 69.0a1 (64bit, build ID: 20190529215251) on Windows 10
Keywords: parity-chrome
Version: unspecified → Trunk

This is a Firefox specific restriction, and doesn't happen onChromium (Google Chrome). Steps to reproduce:

  1. Install any extension with commands, for example Reopen closed tab Button™. It reopens most recently closed tab.
  2. Go to chrome://extensions/shortcuts
  3. Set keyboard shortcut Ctrl-Shift-L for Reopen closed tab Button™.
  4. Open http://example.com/ in the current tab.
  5. Hit Ctrl-Shift-L to confirm the effectivity of the shortcut.
  6. Hit Ctrl-Shift-J to open the web console.
  7. Run a script: addEventListener('keydown', e => { e.stopPropagation(); e.preventDefault(); }, true); with the console.
  8. Hit Ctrl-Shift-L.

Then the command is invoked and most recently closed tab is restored for me.

This is more or less expected. We use the same command key processing for extension commands as for built-in commands, and we allow those to be overridden by site key listeners.

Whiteboard: [design-decision-needed]
Type: defect → enhancement
Component: General → Frontend

Then, this looks related to another bug 1325692. Due to the restriction, now priority order of shortcuts are:

  1. Important shortcuts of Firefox itself (highest priority, impossible to change/disable, impossible to be overridden by anyone)
  2. Shortcuts defined by the webpage (impossible to change/disable)
  3. Regular shortcuts of Firefox itself (impossible to change/disable)
  4. Shortcuts for WebExtensions commands (lowest priority, possible to change/disable)

As the result, shortcuts provided by addons are actually almost unusable. Firefox now allows us to customize shortcuts on about:addons, but it looks almost mean-less, because shortcuts defined by Firefox and webpages are basically uncustomizable.

Originally this bug was reported as an issue of my addon, and its motivation is that allowing to use a fixed shortcut for features used by the user himself very frequently. So, I think the following order looks better:

  1. Important shortcuts of Firefox itself (highest priority, impossible to change/disable, impossible to be overridden by anyone)
  2. Shortcuts for WebExtensions commands (possible to change/disable)
  3. Shortcuts defined by the webpage (impossible to change/disable)
  4. Regular shortcuts of Firefox itself (lowest priority, impossible to change/disable)

because only shortcuts for WebExtensions commands are customizable/clearable by the user himself. How about this viewpoint?

Priority: -- → P3

We are not convinced that extensions taking precedence over everything else is the majority case.
However, we are supportive of a way for users to opt in to allowing extension shortcuts to take precedence over web pages (e.g. via the shortcut management page at about:addons). There are clearly use cases (e.g Vimium extension, bug 1713794), and the current alternative is the use of a global content scripts (which is a less reliable and worse performing solution than a built-in feature).

As for choosing extension shortcuts without conflicts, we would prefer offering a way to query the availability of a shortcut over somehow magically resolving conflicts (which is not feasible) - bug 1654403.

Patches are welcome.

Priority: P3 → P5
See Also: → 1713794, 1654403
Whiteboard: [design-decision-needed] → [design-decision-approved]
Severity: normal → S3
See Also: → 1792010
Blocks: 1325692

This bug is growing more and more painful as a lot of websites find it's a good idea to remap lots and lots of keyboard shortcuts.
This makes a lot of firefox extensions break randomly.
This even makes Firefox (eg. quickfind) break randomly (please reopen #1455101)

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