[Bug]: connectOverCDP({ noDefaults: true }) still overrides font families (Page.setFontFamilies) on headless browsers
Los mantenedores suelen responder en 1 día
@microsoft-playwright-automation ya está trabajando en esto.
Desde el 29/10/2026.
- #43773 de @microsoft-playwright-automation — abierto
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 42/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- node.js, playwright, typescript
Línea de trabajo
Read packages/playwright-core/src/server/chromium/crPage.ts, especially FrameSession._initialize, and compare the font override call with the focus and media defaults gated by skipDefaultOverrides. Then inspect tests/library/chromium/connect-over-cdp.spec.ts for coverage of noDefaults; done means existing pages receive no font override when it is true, while default behavior remains when it is false. The issue author says they plan to work on this and a test, so check with them before starting.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Version
1.64.1 (reproduced on 1.63.0; the relevant code is unchanged in 1.64.1 and on main)
Steps to reproduce
- Start a headless Chrome with a DevTools endpoint. Any headless Chromium build should do, since the code path only depends on the user agent containing
Headless:
google-chrome --headless=new --remote-debugging-port=9222 --user-data-dir=/tmp/pw-repro
- Save this as
repro.js:
const { chromium } = require('playwright');
(async () => {
const noDefaults = process.env.NO_DEFAULTS !== '0';
const browser = await chromium.connectOverCDP('http://127.0.0.1:9222', { noDefaults });
const page = await browser.contexts()[0].newPage();
await page.goto('about:blank');
// Leave the attached browser running: exit without browser.close().
process.exit(0);
})();
- Run it with protocol logging and count which default overrides were sent:
DEBUG=pw:protocol node repro.js 2>&1 \
| grep -oE '"method":"(Page\.setFontFamilies|Emulation\.setFocusEmulationEnabled|Emulation\.setEmulatedMedia)"' \
| sort | uniq -c
Expected behavior
With noDefaults: true, none of Playwright's default overrides are applied to the existing default context, so the command above prints nothing. From the noDefaults docs: "When true, Playwright will not apply its default overrides to the existing default browser context."
Actual behavior
Focus emulation and media emulation are skipped as documented, but Page.setFontFamilies is still sent to every page of the default context, including tabs that were already open before connecting:
3 "method":"Page.setFontFamilies"
This is the message that is sent:
{"method":"Page.setFontFamilies","params":{"fontFamilies":{"standard":"Times New Roman","fixed":"Monospace","serif":"Times New Roman","sansSerif":"Arial","cursive":"Comic Sans MS","fantasy":"Impact"}}}
For comparison, NO_DEFAULTS=0 sends all three, as expected.
Additional context
The font defaults are applied in FrameSession._initialize in packages/playwright-core/src/server/chromium/crPage.ts, gated only on headless mode:
if (!browserOptions.headful)
promises.push(this._setDefaultFontFamilies(this._client));
For connectOverCDP, headful is inferred from the user agent (browser.options.headful = !version.userAgent.includes('Headless') in crBrowser.ts), so this runs for any headless target. The other two defaults next to it are gated on skipDefaultOverrides, which is why only the fonts leak through. The change that added noDefaults (#40185) gated focus and media emulation but left this call as is.
This changes how the user's existing tabs render. In a headless Chrome profile whose fonts are all set to DejaVu Sans Mono, a span of 20 i characters measures 192.7px for every generic family before connecting. Right after connectOverCDP(url, { noDefaults: true }) it measures 88.9px for the default, serif, cursive and fantasy families and 71.1px for sans-serif (numbers from my machine). The override is still in effect in those tabs after Playwright disconnects, until each tab is reloaded. Since Playwright MCP always passes noDefaults for CDP connections (#41676), --cdp-endpoint against a headless Chrome is affected as well.
Proposed fix, gating the call like the other defaults:
if (!browserOptions.headful && !skipDefaultOverrides)
promises.push(this._setDefaultFontFamilies(this._client));
I tested this change against 1.63.0: with noDefaults: true nothing from the list above is sent and the custom fonts stay at 192.7px; with noDefaults: false the behavior is unchanged. The noDefaults docs could also mention that font families are left alone.
I would like to work on this and can send a PR with the fix and a test in tests/library/chromium/connect-over-cdp.spec.ts.
Environment
System:
OS: Linux 7.0 Ubuntu 24.04.5 LTS
CPU: (24) x64 Intel(R) Core(TM) Ultra 9 275HX
Memory: 62 GB
Binaries:
Node: 24.21.0
Browsers:
Google Chrome: 156.0.8078.47 (--headless=new)
npmPackages:
playwright-core: 1.63.0
- Lenguaje dominante
- TypeScript
- Estrellas
- 98.5k
- Forks
- 6.7k
- Merge medio
- 15 h 42 min
- PR fusionados (30 d)
- 313
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
-
needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
microsoft/playwright#43762 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[Feature]: Node 26 Docker ImagesAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
microsoft/playwright#43759 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
microsoft/playwright#43741 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
[Bug]: Uncaught TypeError in captureSecurityDetails when APIRequestContext reuses a destroyed keep-alive socketPosiblemente ocupada @microsoft-playwright-automation la tomó hace 1 día. Abiertoneeds-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
microsoft/playwright#43728 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
[Feature]: Set `this.name` in `TargetClosedError` constructorQuizá libre de nuevo @LeonxLJX la tomó hace 55 días y no hay ningún pull request abierto. AbiertoP3-collecting-feedback
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
microsoft/playwright#42522 · 7 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 65/100
lichess-org/lila#22324 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Feature Request] [Web] Expose kvCacheQuantizationBits in the onnxruntime-web WebGPU EP optionsAbiertoep:WebGPU platform:web quantization
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
microsoft/onnxruntime#33752 ·
Los mantenedores suelen responder en 2 días
-
[Skill Bug]: entra-agent-id: inaccurate blueprint permission inheritance and parent token sub claimAbiertobug entra-agent-id
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/GitHub-Copilot-for-Azure#3467 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
fix(worker): keep normal prepare waiting states failure-freePosiblemente ocupada @LichKing-2234 la tomó hoy. Abiertoagent:codex priority:P1
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
AgoraIO-Extensions/agent-infra#3745 ·
Los mantenedores suelen responder en 1 día
-
The five-line work window can drop its oldest line: the per-line byte share ignores the JSON framingPosiblemente ocupada @Eapp1e la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
makecindy/cindy#7973 · 1 comentario ·
Los mantenedores suelen responder en 1 día