CA-6409: Add an API to allow a site to change the user agent to Safari#266
Merged
Conversation
davertay-j
approved these changes
Jun 12, 2026
sdonn3
approved these changes
Jun 15, 2026
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.
Note
Medium Risk
Any page can change the reported user agent mid-session, which can alter server routing, feature flags, and compatibility behavior; the bridge is narrow but not origin-restricted in this diff.
Overview
Adds
topaz.setUserAgentMode('topaz' | 'safari')so loaded pages can switch the WebView user agent at runtime, mainly to present a Safari-like UA when sites gate on it.The flow is a new
topazWebKit JS message channel (topazRequestin TS and the injected polyfill) handled byTopazScriptHandlerinCoordinator, which updatesWebPageModel.userAgentModeand appliesWKWebView.customUserAgent.WebPageModelnow picks between fixed Topaz and Safari UA strings (default remains Topaz).Coordinator.updatealso reapplies the model’s UA when the web view updates.The large
BluetoothPolyfill.jsdiff is mostly a rebuild (e.g.topazRequest, class field style, docs); behavior changes there are incidental to shipping the new Topaz API in the bundle.Reviewed by Cursor Bugbot for commit 4ca839f. Configure here.