Skip to content

fix(ext): request tabs permission synchronously in the click gesture (Firefox)#69

Merged
paperhurts merged 1 commit into
mainfrom
fix/firefox-tabs-permission-gesture
Jul 3, 2026
Merged

fix(ext): request tabs permission synchronously in the click gesture (Firefox)#69
paperhurts merged 1 commit into
mainfrom
fix/firefox-tabs-permission-gesture

Conversation

@paperhurts

Copy link
Copy Markdown
Owner

Summary

"Save all tabs" was silently dead in Firefox (#68). The click handler awaited permissions.contains() before calling permissions.request(); Firefox voids the user-input gesture across awaits and rejects request() outside a gesture — and that rejection happened outside the try, so the popup showed nothing at all. Chrome is lenient about the gesture, which is how the bug shipped unnoticed.

Changes

  • New lib/tabs-permission.tsrequestTabsPermission() issues browser.permissions.request({permissions:["tabs"]}) synchronously within the caller's stack and never rejects: grant/denial/failure all come back as a discriminated result.
  • popup.ts — the save-all handler calls it as its first statement (no contains() pre-check; requesting an already-granted permission resolves true without prompting in both browsers) and surfaces denial/failure in the status line.
  • Test stub gains permissions.request; 5 new unit tests cover the synchronous-call ordering (the gesture-preservation property), grant, denial, rejection, and synchronous throw.

Testing

  • pnpm --filter @gitmarks/extension-shared test — 127 passed (5 new)
  • pnpm --filter @gitmarks/extension-shared typecheck — clean
  • Firefox dist rebuilt; manual smoke test of the permission prompt + batch save to follow (temporary add-on)

Closes #68

🤖 Generated with Claude Code

…(Firefox)

Firefox voids the user-input gesture across awaits, so the old
permissions.contains() pre-check made the subsequent permissions.request()
reject with "may only be called from a user input handler" — and the
rejection escaped the try block, leaving the popup silently dead. Chrome
is lenient about the gesture, which is how this shipped.

Drop the contains() pre-check (requesting an already-granted permission
resolves true without prompting in both browsers), issue request() as the
first statement of the click handler via a new requestTabsPermission()
helper that never rejects, and surface denial/failure in the popup status
line instead of dying silently.

Closes #68

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@paperhurts paperhurts merged commit ba0f179 into main Jul 3, 2026
1 check passed
@paperhurts paperhurts deleted the fix/firefox-tabs-permission-gesture branch July 3, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Firefox: 'Save all tabs' silently does nothing (permissions.request after await loses the user-input gesture)

1 participant