Skip to content

emulate without geolocation pins the page to latitude 0, longitude 0 instead of clearing the override #2964

Closed

Description

@coygeek

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.

  1. 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>
  1. 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>
  1. 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.mjs and run node grant.mjs ws://127.0.0.1:DEVTOOLS_PORT/devtools/browser/<id> 90 & (Node 22 has a global WebSocket):
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); };
  1. Start the server under test with --browserUrl http://127.0.0.1:DEVTOOLS_PORT --no-usage-statistics --no-performance-crux and send these tools/call requests in order (GEO stands 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_REDACTED is 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 main at commit 5ddb0a3 (the main build).
  • 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.geolocation description, "Omit to clear the geolocation override.", in src/tools/emulation.ts and docs/tool-reference.md at both builds.
  • Failure source: scripted MCP runs above on both builds. The handler path is McpPage.emulate() at src/McpPage.ts:1056-1062 on the main build (src/McpPage.ts:921-927 at the 1.10.1 tag): when options.geolocation is falsy it calls page.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

  1. added theissue type on Oct 13, 2026
  2. nancy6547 commented on Oct 14, 2026

    @nancy6547
    Contributor

    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.

  3. added a commit that references this issue on Oct 20, 2026
    6282f54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions