[Bug]: Full-page screenshots in Chromium lose forcedColors: 'active' rendering, and the page doesn't recover
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 52/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- playwright, typescript
- 领域
- backend, testing-qa
调研方向
The reproduction uses page.screenshot() and expect(locator).toHaveScreenshot() with Chromium and forced colors; the report points to Page.captureScreenshot with captureBeyondViewport: true. Start by tracing full-page screenshot capture and forced-colors emulation in Chromium. Reproduce with the provided test in the Playwright 1.65.0 Chromium project; done means full-page captures preserve forced-colors rendering and the page remains in that rendering afterward.
由索引模型根据 Issue 内容生成。
描述
Version
1.65.0
Steps to reproduce
import { expect, test } from '@playwright/test'
test.use({ colorScheme: 'dark', forcedColors: 'active' })
test('forced colors survive a full-page screenshot', async ({ page }) => {
await page.setContent('<p>Text</p><div style="height: 3000px"></div>')
const bodyColor = () => page.evaluate(() => getComputedStyle(document.body).color)
expect(await bodyColor()).toBe('rgb(255, 255, 255)')
await page.screenshot()
expect(await bodyColor()).toBe('rgb(255, 255, 255)')
await page.screenshot({ fullPage: true })
expect(await bodyColor()).toBe('rgb(255, 255, 255)')
})
Run with the Chromium project in mcr.microsoft.com/playwright:v1.65.0-jammy.
Expected behavior
The page keeps forced-colours rendering after every screenshot, and the full-page screenshot is drawn with forced colours.
Actual behavior
- The viewport screenshot is fine.
- The full-page screenshot comes out without forced colours: normal colours on a white background.
- After it, the page stays out of forced-colours rendering. Body text is
rgb(0, 0, 0)instead ofrgb(255, 255, 255), and later viewport screenshots are wrong too. matchMedia('(forced-colors: active)').matches stillreturns true throughout. Only the rendering is lost, not the media query.
The same thing happens with expect(locator).toHaveScreenshot() when the element is taller than the viewport. That's how we found it: all our high-contrast visual regression snapshots came out in light mode after upgrading.
Additional context
- It seems to happen whenever Playwright sends
Page.captureScreenshotwithcaptureBeyondViewport: true(when the capture doesn't fit the viewport). Screenshots that fit the viewport are unaffected. - The screenshot code (
captureBeyondViewport: !fitsViewport) and the media emulation code look the same in 1.58.2 and 1.65.0. Our snapshots rendered correctly with 1.58.2 (Chromium 145), which suggests a change in Chromium rather than in Playwright. - Emulation works correctly without the full-page capture, with either
forcedColorsset directly orcontextOptions: { forcedColors: 'active' }.PLAYWRIGHT_LEGACY_SCREENSHOT=1makes no difference to a viewport-sized capture. We haven't tried it with a full-page capture. - We haven't tested Firefox, WebKit, or Playwright 1.64.
- #15211 is a different bug, but is in a similar area.
Environment
- Operating System: Ubuntu 22.04 (mcr.microsoft.com/playwright:v1.65.0-jammy)
- Browser: Chrome Headless Shell 158.0.8127.18
- @playwright/test: 1.65.0
- 主要语言
- TypeScript
- 星标
- 100k
- 派生
- 6.9k
- 平均合并
- 16 小时 8 分钟
- 30 天内合并 PR
- 281
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/playwright 的其他 Issue
-
[MCP]: page snapshots in .playwright-mcp/ are not git-ignored (.playwright-cli/ is, since #42318)未关闭
难度 2/5 1-3 小时 新手友好度 62/100
microsoft/playwright#44289 ·
维护者通常 1 天内回复
-
agent-triage-done
难度 2/5 1-3 小时 新手友好度 72/100
microsoft/playwright#44264 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 12/100
microsoft/playwright#44290 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 22/100
microsoft/playwright#44288 ·
维护者通常 1 天内回复
-
[Bug]: page.goto never returns for a load started as a newer service worker takes over (Chromium)未关闭
难度 5/5 一周以上 新手友好度 12/100
microsoft/playwright#44287 ·
维护者通常 1 天内回复
查看 microsoft/playwright 的全部 Issue
相似的 Issue
-
clawsweeper:needs-maintainer-review clawsweeper:needs-product-decision clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster P3
难度 2/5 1-3 小时 新手友好度 76/100
openclaw/openclaw#203385 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
nwverse/persona#12800 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 80/100
维护者通常 1 天内回复
-
good first issue
难度 2/5 半天 新手友好度 65/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
WISE-Community/WISE-Client#2404 ·
维护者通常 1 天内回复