[MCP]: --extension --background: noDefaults skips focus emulation, hidden tabs get no rAF and clicks time out
Los mantenedores suelen responder en 1 día
@microsoft-playwright-automation ya está trabajando en esto.
Desde el 13/11/2026.
- #44101 de @microsoft-playwright-automation — abierto
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- typescript
- Área
- testing-qa
Línea de trabajo
Read packages/playwright-core/src/tools/mcp/extensionContextFactory.ts and packages/playwright-core/src/server/chromium/crPage.ts to trace how noDefaults affects focus emulation; compare the issue’s hidden-tab reproduction with focus emulation enabled. Check linked PR #44101, which is already open. Done means the reported background-tab click and Enter failures are addressed without overriding the user's browser defaults.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Follow-up to #43868, as asked there: with extension 0.5.0 and @playwright/mcp 0.0.85, clicks and Enter still fail in --background tabs. In my setup focus emulation isn't enabled on the controlled tab.
What's going on?
In a tab controlled by @playwright/mcp --extension --background (not the active tab of its window), the page reports:
document.visibilityState === 'hidden',document.hasFocus() === false- 0
requestAnimationFramecallbacks in 2 s, and a 10 mssetTimeoutloop runs about once per second
On https://en.wikipedia.org/wiki/Main_Page:
browser_clickon the "Search" button fails withTimeoutError: browserBackend.callTool: Timeout 5000ms exceeded., and the call log ends atwaiting for element to be visible, enabled and stablebrowser_typewithsubmit: true, and a laterbrowser_press_keyEnter, leave the page on Main_Page: the search is never submitted
Why
In #43868 the comment says Playwright enables focus emulation on each page. On main today, the extension path still connects with noDefaults: true (packages/playwright-core/src/tools/mcp/extensionContextFactory.ts, line 45):
const browser = await playwright.chromium.connectOverCDP(relay.cdpEndpoint(), { isLocal: true, timeout: 0, noDefaults: true });
In packages/playwright-core/src/server/chromium/crPage.ts (lines 547-552), noDefaults on the default context also skips focus emulation:
const skipDefaultOverrides = browserOptions.noDefaults &&
this._crPage._browserContext === this._crPage._browserContext._browser._defaultContext;
...
if (this._isMainFrame() && !skipDefaultOverrides)
promises.push(this._client.send('Emulation.setFocusEmulationEnabled', { enabled: true }));
I understand noDefaults is there so the extension doesn't override the user's existing browser defaults (#42117). Focus emulation goes with them, and it's the setting that lets a background tab render and pass actionability checks.
Repro without the extension
Plain connectOverCDP with noDefaults: true, against Chrome started with --remote-debugging-port=9334 and a fresh --user-data-dir:
const { chromium } = require('playwright-core');
(async () => {
const b = await chromium.connectOverCDP('http://127.0.0.1:9334', { noDefaults: true });
const ctx = b.contexts()[0];
const bg = ctx.pages()[0];
await bg.goto('https://example.com');
const fg = await ctx.newPage(); await fg.goto('https://example.com'); await fg.bringToFront();
const frames = () => bg.evaluate(async () => { const t0 = performance.now(); let n = 0;
await new Promise(r => { const f = () => { n++; performance.now() < t0 + 2000 ? requestAnimationFrame(f) : r(); };
requestAnimationFrame(f); setTimeout(r, 2500); });
return { vis: document.visibilityState, raf: n }; });
console.log(await frames()); // { vis: 'hidden', raf: 0 }
await bg.click('a', { trial: true, timeout: 5000 }).catch(e => console.log('timeout')); // timeout
const s = await ctx.newCDPSession(bg);
await s.send('Emulation.setFocusEmulationEnabled', { enabled: true });
console.log(await frames()); // { vis: 'visible', raf: 97-103 }
await bg.click('a', { trial: true, timeout: 5000 }); // ok
await b.close();
})();
The same setup on the Wikipedia main page, filling the search box in the hidden tab and then pressing Enter or clicking "Search":
visibilityState |
Enter submits the search | click on "Search" | |
|---|---|---|---|
| focus emulation off | hidden | no (still on Main_Page after 8 s) | Timeout 5000ms exceeded, waiting for "stable" |
| focus emulation on | visible | yes | ok, 717 ms |
Through the extension I couldn't turn it on from the MCP side: browser_run_code_unsafe with page.context().newCDPSession(page) returns Protocol error (Target.attachToBrowserTarget): {"code":-32000,"message":"Not allowed"}, and I found no option for it.
Suggestion
Keep noDefaults for the user's browser defaults, but enable Emulation.setFocusEmulationEnabled on the tabs the MCP controls in extension mode, at least with --background.
Version
@playwright/mcp 0.0.85 (playwright-core 1.66.0-alpha-2026-11-09), Playwright Extension 0.5.0, Google Chrome 157.0.8103.52, macOS 27.2, Node 20.6.1. The test in #43868 used Chromium 158.0.8127.2. I haven't tested 158.
- Lenguaje dominante
- TypeScript
- Estrellas
- 99.7k
- Forks
- 6.8k
- Merge medio
- 16 h 10 min
- PR fusionados (30 d)
- 301
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/playwright
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
microsoft/playwright#44109 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: WebKit emits pageerror for native RTCDataChannel send diagnostics without a JS exceptionAbiertoagent-triage
Dificultad 5/5 Más de una semana Aptitud para principiantes 45/100
microsoft/playwright#44103 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Crash tests fail with the Chromium sandbox on LinuxPosiblemente ocupada @microsoft-playwright-automation la tomó hoy. Abiertoagent-triage needs-triage
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
microsoft/playwright#44094 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
api review feedback Nov 11th, 2026Posiblemente ocupada @luizpaulo-antunes la tomó hace 1 día. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 70/100
microsoft/playwright#44062 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Bug]: page.evaluate in Chromium never settles when its argument nests 60 objects deepPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertoagent-triage
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
microsoft/playwright#44060 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/playwright
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
pieterjanscheir/belgica#201 ·
Los mantenedores suelen responder en 1 día
-
No skip link to the main contentAbiertoaccessibility
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
numerique-gouv/lasuite-landingpage#311 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
oxc-project/tsgolint#1362 ·
Los mantenedores suelen responder en 1 día
-
bug external xai
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
langchain-ai/langchain#41854 ·
Los mantenedores suelen responder en 1 día
-
ready-for-agent
Dificultad 1/5 1-3 horas Aptitud para principiantes 72/100
nemchik/biome-plugin-suitescript#137 ·
Los mantenedores suelen responder en 1 día