Repository navigation
fix: honour trapLinkClicks for bare window.open() OAuth popups - #2573
Open
thejdubb02 wants to merge 1 commit into
Open
thejdubb02 wants to merge 1 commit into
thejdubb02 wants to merge 1 commit into
Conversation
"Open URLs within Ferdium" (Service#trapLinkClicks) was declared and persisted but never read anywhere. A window.open(url) call with no target name or window features, which is how Gmail, Google Voice and other OAuth sign-in flows open their popup, went through windowOpenShim's bare-url branch straight to the default browser regardless of the setting, so the sign-in completed in a window Ferdium can never see the session from. windowOpenShim.ts now asks window.ferdium.shouldTrapLinkClicks() for that branch and, when true, routes the call through the same real-window path already used when the page asks for window features, by synthesizing a 'popup=yes' features string. That existing path is what index.ts's setWindowOpenHandler already allows as a popup on the service's own session and preserves window.opener for the OAuth postMessage callback, so this reuses it instead of adding a new one. shouldTrapLinkClicks is exposed on the existing window.ferdium contextBridge object in recipe.ts and reads live off the single RecipeController instance's settings.service.trapLinkClicks, so it is correct on both the initial load (loadRecipeModule) and a live settings change (updateServiceSettings) without keeping a second synced copy of the flag. Fixes ferdium#2538.
2 tasks done
Author
|
Hi, friendly ping on this one. It is a small fix for OAuth popups that open via a bare window.open(), and it applies cleanly to current nightly. Happy to adjust anything. |
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.
Fixes #2538.
"Open URLs within Ferdium" (Service.trapLinkClicks) is declared and persisted but was never read anywhere in the app. A window.open(url) call with no target name or window features, which is how the Gmail and Google Voice sign-in popups (and others) open, went through windowOpenShim's bare url branch straight to the default browser regardless of the setting, so sign-in completed in a window Ferdium can never see the session from.
windowOpenShim.ts now asks window.ferdium.shouldTrapLinkClicks() in that branch and, when true, routes the call through the same real window path already used when the page asks for window features, by synthesizing a popup=yes features string. That existing path is what index.ts's setWindowOpenHandler already allows as a popup on the service's own session and preserves window.opener for the OAuth postMessage callback, so this reuses it instead of adding a new mechanism.
shouldTrapLinkClicks is exposed on the existing window.ferdium contextBridge object in recipe.ts and reads live off the single RecipeController instance's settings.service.trapLinkClicks, so it stays correct on both the initial load (loadRecipeModule) and a live settings change (updateServiceSettings) without a second, separately synced copy of the flag. An earlier version of this fix kept a duplicate copy that only synced on updateServiceSettings and missed the initial load and reload cases, which is exactly the repro in the issue, so I removed that and read the setting directly.
Added regression tests to test/webview/windowOpenShim.test.ts covering the new branch, confirmed they fail on the old code and pass with the fix. Ran the full existing suite (144 tests, 2 pre-existing skips unrelated to this change), pnpm typecheck, and pnpm lint (zero warnings) against src/webview/windowOpenShim.ts, src/webview/recipe.ts, and the test file, all clean. Also ran pnpm biome:check against the same three files.
Scope note: this fixes the window.open() based popup case from the issue, which covers the Gmail and Google Voice OAuth reports. A target=_blank link still takes the separate foreground-tab disposition path in index.ts's setWindowOpenHandler and still opens externally regardless of this setting. I left that alone since it is a different code path with different tradeoffs and wasn't part of the reported repro, but flagging it here in case a maintainer wants it folded into the same setting later.