Skip to content

feat(browse): add geolocation CDP override methods to allowlist#1470

Open
cl0ckt0wer wants to merge 1 commit into
garrytan:mainfrom
cl0ckt0wer:feat/geolocation-cdp
Open

feat(browse): add geolocation CDP override methods to allowlist#1470
cl0ckt0wer wants to merge 1 commit into
garrytan:mainfrom
cl0ckt0wer:feat/geolocation-cdp

Conversation

@cl0ckt0wer
Copy link
Copy Markdown

@cl0ckt0wer cl0ckt0wer commented May 13, 2026

Summary

Adds Emulation.setGeolocationOverride and Emulation.clearGeolocationOverride to the CDP allowlist, enabling GPS/geolocation coordinate simulation via the browse daemon.

Why

Testing location-aware web apps (maps, GPS trackers, proximity search) currently requires a separate Playwright script because the browse daemon blocks all CDP methods by default (deny-default posture). Geolocation override has the same threat profile as the already-allowed Emulation.setDeviceMetricsOverride: pure input to the active tab, no data exfiltration surface.

What changed

  • browse/src/cdp-allowlist.ts — added 2 entries under the Emulation section:
    • Emulation.setGeolocationOverride (tab, trusted) — sets geolocation coordinates for the active tab
    • Emulation.clearGeolocationOverride (tab, trusted) — clears the override, mirrors clearDeviceMetricsOverride
  • Added a NOTE documenting that Browser.grantPermissions cannot work through the page-scoped CDPSession and needs a separate browser-scope routing path in the future

Usage

# Set geolocation to London
$B cdp Emulation.setGeolocationOverride '{"latitude":51.5074,"longitude":-0.1278,"accuracy":10}'

# Clear override
$B cdp Emulation.clearGeolocationOverride '{}'

Known limitation

Full end-to-end GPS testing (permission grant + coordinate override) still requires either:

  1. A Playwright script that creates a context with permissions: ['geolocation'] and geolocation: {...}, or
  2. A future browser-scope CDP routing path in the bridge that can forward Browser.grantPermissions

The setGeolocationOverride alone overrides coordinates when geolocation permission is already granted (e.g., after user interaction or via a Playwright-launched context).

Testing

All 6 existing CDP allowlist tests pass (199 expect calls). No new tests needed — existing test suite validates that every entry has required fields, no duplicates exist, and the deny-default posture is maintained.

bun test browse/test/cdp-allowlist.test.ts
 6 pass  0 fail  199 expect() calls

View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

…Override to CDP allowlist

Enables GPS/geolocation testing via the browse daemon. Same threat
profile as existing Emulation.setDeviceMetricsOverride: pure input
to the active tab, no data exfiltration surface.

Usage after this change:
  $B cdp Emulation.setGeolocationOverride '{"latitude":51.5,"longitude":-0.1}'

Limitation: Browser.grantPermissions cannot be routed through the
page-scoped CDPSession the bridge uses. Full GPS testing (permission
grant + coordinate override) requires either a Playwright script
(context-level permission grant) or a future browser-scope CDP
routing path. Left a NOTE in the allowlist documenting this.
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.

1 participant