Skip to content

feat: support background color emulation - #3457

Open
lisa0314 wants to merge 2 commits into
ChromeDevTools:mainfrom
lisa0314:feat/806-background-color
Open

lisa0314 wants to merge 2 commits into
ChromeDevTools:mainfrom
lisa0314:feat/806-background-color

Conversation

@lisa0314

Copy link
Copy Markdown
Contributor

Adds backgroundColor to emulate, following the direction in #806. Callers can specify #RRGGBB or #RRGGBBAA to choose the default backdrop for transparent page content, including fully transparent PNG screenshots. Explicit CSS backgrounds retain their colors.

The override belongs to the target page, persists across navigation, and participates in emulation restoration. Omitting it from a subsequent emulate call clears it, consistent with the existing replacement semantics. Responses report the active background color in both text and structured content. The generated CLI option, tool reference, metrics metadata, and tool-selection guidance are updated.

Refs #806.

Validation: generation, formatting checks, and focused tests pass. The full suite has one existing failure, with full page resulting in a large screenshot (Page is too large), reproduced with the same focused command on unchanged main at 44e06b1.

@nattallius nattallius left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, @OrKoN What do you think on this change? Does it follow the correct direction?

Comment thread src/McpPage.ts
}

if (options.backgroundColor || this.emulationSettings.backgroundColor) {
if (!secondarySession) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check runs after network, CPU, user agent and media features are already applied to the browser, but before this.emulationSettings is updated. If it throws, the browser state and the stored settings diverge. Can we validate the session at the start of emulate(), before any side effects?

@OrKoN
OrKoN self-requested a review November 14, 2026 08:31
Comment thread src/config/cli-options.ts
positional: false,
},
backgroundColor: {
name: 'backgroundColor',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would supporting omitBackground on screenshots also solve the issue? https://pptr.dev/next/api/puppeteer.screenshotoptions#omitbackground

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants