Repository navigation
Description
Description of the bug
The emulate tool documents geolocation as "Omit to clear the geolocation override." Instead, every emulate call that omits geolocation, or passes an empty string, overrides the page's position to latitude 0, longitude 0 with accuracy 0. A call made only to change the color scheme, user agent or throttling therefore moves the page to 0,0, and there is no way through the tool to return the page to the browser's real (non-overridden) position once any emulate call has run. This is a reproducible version of the symptom reported in closed #2013.
Actual behavior
Both builds:
GEO_REDACTED before any emulate -> {"gotPosition":true,"nullIsland":false,"acc0":false} (a real position other than 0,0)
emulate {colorScheme:"dark"} -> "Emulation configured successfully\nEmulating color scheme: dark"
GEO -> {"lat":0,"lon":0,"acc":0}
emulate {geolocation:"37.42,-122.08"} -> "Emulating geolocation: latitude=37.42, longitude=-122.08"
GEO -> {"lat":37.42,"lon":-122.08,"acc":0}
emulate {geolocation:""} -> "Emulation configured successfully" (no geolocation line)
GEO -> {"lat":0,"lon":0,"acc":0}
emulate {geolocation:"37.42,-122.08"}, then emulate {} -> "Emulation configured successfully"
GEO -> {"lat":0,"lon":0,"acc":0}
The responses after the "clearing" calls print no Emulating geolocation line, so nothing tells the agent that the page is pinned to 0,0. The zero accuracy matches the override values the handler sends; the real position read before any emulate call had non-zero accuracy.
Reproduction
A page can only read its position when the geolocation permission is granted, and no tool grants permissions, so the steps grant it over CDP to a separately launched Chrome and attach the server with --browserUrl.
- Serve any HTML page from a loopback HTTP server at
http://127.0.0.1:PORT/min.html, for example:
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>min</title></head><body><h1>Hello</h1></body></html>- Launch a disposable Chrome and read its DevTools port and browser WebSocket path from
<profile>/DevToolsActivePort:
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --headless=new --remote-debugging-port=0 --user-data-dir=<tmp>/geo-profile --no-first-run --no-default-browser-check about:blank &
cat <tmp>/geo-profile/DevToolsActivePort # line 1: DEVTOOLS_PORT, line 2: /devtools/browser/<id>- Grant geolocation to all origins and keep that CDP session open for the rest of the test (the grant is dropped when the session closes). Save as
grant.mjsand runnode grant.mjs ws://127.0.0.1:DEVTOOLS_PORT/devtools/browser/<id> 90 &(Node 22 has a globalWebSocket):
const [ws, secs] = process.argv.slice(2);
const s = new WebSocket(ws);
s.onopen = () => s.send(JSON.stringify({id: 1, method: 'Browser.setPermission', params: {permission: {name: 'geolocation'}, setting: 'granted'}}));
s.onmessage = e => { console.log(e.data); setTimeout(() => s.close(), Number(secs) * 1000); };- Start the server under test with
--browserUrl http://127.0.0.1:DEVTOOLS_PORT --no-usage-statistics --no-performance-cruxand send thesetools/callrequests in order (GEOstands for() => new Promise(r => navigator.geolocation.getCurrentPosition(p => r({lat: p.coords.latitude, lon: p.coords.longitude, acc: p.coords.accuracy}), e => r({err: e.code, msg: e.message}), {timeout: 5000}));GEO_REDACTEDis the same call returning only{gotPosition: true, nullIsland: lat === 0 && lon === 0, acc0: accuracy === 0}, so the machine's real position is not printed):
{"name":"new_page","arguments":{"url":"http://127.0.0.1:PORT/min.html"}}
{"name":"evaluate_script","arguments":{"pageId":2,"function":"GEO_REDACTED"}}
{"name":"emulate","arguments":{"pageId":2,"colorScheme":"dark"}}
{"name":"evaluate_script","arguments":{"pageId":2,"function":"GEO"}}
{"name":"emulate","arguments":{"pageId":2,"geolocation":"37.42,-122.08"}}
{"name":"evaluate_script","arguments":{"pageId":2,"function":"GEO"}}
{"name":"emulate","arguments":{"pageId":2,"geolocation":""}}
{"name":"evaluate_script","arguments":{"pageId":2,"function":"GEO"}}
{"name":"emulate","arguments":{"pageId":2,"geolocation":"37.42,-122.08"}}
{"name":"emulate","arguments":{"pageId":2}}
{"name":"evaluate_script","arguments":{"pageId":2,"function":"GEO"}}The sequence was run once per build with identical results.
Expectation
emulate.geolocation in the tool schema (src/tools/emulation.ts) and in docs/tool-reference.md (emulate section) says: "Omit to clear the geolocation override." After an emulate call without geolocation (and, by the same reading, with an empty value), the page gets the position it would get with no override, the same result as before any emulate call, rather than a synthetic position.
MCP configuration
--headless --isolated --no-usage-statistics --no-performance-crux unless the reproduction states otherwise (update checks disabled with CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS=1).
Chrome DevTools MCP version
1.10.1 (npm) and main 5ddb0a3 (local build)
Chrome version
154.0.8037.98 (stable)
Node version
v22.23.2
Operating system
macOS 27.0
Environment details
- chrome-devtools-mcp 1.10.1 from npm (the release build).
- chrome-devtools-mcp built from
mainat commit 5ddb0a3 (themainbuild). - Google Chrome 154.0.8037.98 stable, headless; Node v22.23.2; macOS 27.
CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS=1; both builds driven by a scripted stdio MCP client.
Evidence
- Expected source:
emulate.geolocationdescription, "Omit to clear the geolocation override.", insrc/tools/emulation.tsanddocs/tool-reference.mdat both builds. - Failure source: scripted MCP runs above on both builds. The handler path is
McpPage.emulate()atsrc/McpPage.ts:1056-1062on themainbuild (src/McpPage.ts:921-927at the 1.10.1 tag): whenoptions.geolocationis falsy it callspage.setGeolocation({latitude: 0, longitude: 0}), which sets an override rather than removing one. - Evidence provenance: observed
- Local verification: reproduced
- Reproduction completeness: complete
Fix check
With the steps above, GEO_REDACTED after emulate {colorScheme:"dark"}, after emulate {geolocation:""}, and after emulate {} returns the same as before any emulate call ({"gotPosition":true,"nullIsland":false,"acc0":false}), or GEO returns the browser's normal error when no position is available; GEO no longer returns {"lat":0,"lon":0,"acc":0} after those calls. As a control, emulate {geolocation:"37.42,-122.08"} still yields {"lat":37.42,"lon":-122.08,...}, and an explicit geolocation:"0,0" still yields 0,0.
Additional context
The full open and closed issue and PR corpus was screened as of 2026-10-06. Closed #2013 ("if use chrome-devtools_emulate geo api will failed") reported positions stuck at 0,0 after emulating only a user agent and viewport and was closed as not planned after a maintainer could not reproduce it and suggested that an open DevTools window might apply its own geolocation override; the reporter's later reply that geolocation works when emulate is not used went unanswered. The steps above reproduce that symptom deterministically without DevTools open, and identify the omitted-geolocation branch as the trigger. On the main build, the unit test tests/McpPage.test.ts:508 ("calls setGeolocation with (0, 0) when geolocation is omitted") asserts the current call, while the user-facing description promises a clear; the test checks the CDP call, not the page-observable result. Fix #2036 ("fix: improve geolocation emulation") changed the coordinate separator and added the Emulating geolocation response line but left the omitted-value branch unchanged.
Activity
nancy6547 commentedon Oct 14, 2026
Hi! I’d like to take this one. Plan: when geolocation is omitted, send CDP Emulation.clearGeolocationOverride instead of setting (0, 0), with a real-browser test that the position is no longer 0,0 after clearing.
fix: bound take_snapshot wait and clear the geolocation override (Chr…