Skip to content
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

[Enhancement] API for other extension to toggle visibilty of sidebar #3588

Closed
chaserhkj opened this issue Jul 5, 2024 · 2 comments
Closed
Labels
enhancement Firefox-issue bug of Firefox itself

Comments

@chaserhkj
Copy link

Abstract

I am trying to use Gesturefy to bind gestures onto TST actions. Since Gesturefy allows binding against external messages to other extensions, so far I've found much success in this integration with TST's external messaging APIs.

However, it seems that TST does not have an API for toggling the sidebar visibility. I tried to look for a Firefox-native solution of activating another extension, but it seems that no such solutions exist due to the strict separation of different extension sandboxes.

If I did miss out an existing solution of this problem from Gesturefy side, please do enlighten me.

Expected result

TST messaging API takes messages like { type: 'toggle-sidebar'} for toggling the visibility of TST sidebar.

@piroor
Copy link
Owner

piroor commented Jul 5, 2024

It is impossible to provide such an API by an addon due to the restriction of WebExtensions API. The document sais:

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/sidebarAction/open

You can only call this function from inside the handler for a user action.

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/User_actions

To follow the principle of "no surprises", APIs like this can only be called from inside the handler for a user action. User actions
include the following:

  • Clicking the extension's browser action or page action.
  • Selecting a context menu item defined by the extension.
  • Activating a keyboard shortcut defined by the extension (this only treated as a user action from Firefox 63 onwards).
  • Clicking a button in a page bundled with the extension.

@piroor piroor added Firefox-issue bug of Firefox itself and removed needs-triage labels Jul 5, 2024
@chaserhkj
Copy link
Author

Thanks for the reply. That pretty much looks like a dead end for this issue.

I think on the Gesturefy side the handler for the gesture itself is definitely considered a user action. But if I understand it correctly as long as the call is passed through the messaging on the other end the user action flag is dropped. Ideally we probably want Firefox to preserve this flag across messaging since the message is sent from a user action handler, but that could be a tricky feature to push for since it may have very bad security implications.

For this issue itself, the workaround I am thinking is either to use Gesturefy to simulate key presses to activate TST, or just to bind TST activation shortcuts to the side keys on my mouse. But both of them will be out of the scope of TST so I am closing the issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Firefox-issue bug of Firefox itself
Projects
None yet
Development

No branches or pull requests

2 participants