fix(ext): request tabs permission synchronously in the click gesture (Firefox)#69
Merged
Merged
Conversation
…(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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
"Save all tabs" was silently dead in Firefox (#68). The click handler awaited
permissions.contains()before callingpermissions.request(); Firefox voids the user-input gesture acrossawaits and rejectsrequest()outside a gesture — and that rejection happened outside thetry, so the popup showed nothing at all. Chrome is lenient about the gesture, which is how the bug shipped unnoticed.Changes
lib/tabs-permission.ts—requestTabsPermission()issuesbrowser.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 (nocontains()pre-check; requesting an already-granted permission resolves true without prompting in both browsers) and surfaces denial/failure in the status line.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— cleanCloses #68
🤖 Generated with Claude Code