Repository navigation
fix(browser): give CDP-attached guests an opaque base background - #11192
iamcardimage wants to merge 2 commits into
Conversation
📝 WalkthroughWalkthroughDebugger attachment flows now issue 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/browser/cdp-bridge-integration.test.ts (1)
178-179: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winValidate the new CDP payload in the mock.
Returning
{}unconditionally lets an out-of-range alpha pass unnoticed. Asserta: 1here so this test catches the production regression. CDP 1.3 defines alpha in[0, 1]. (chromedevtools.github.io)
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2b5fd4a3-5e04-4f17-912d-56e23daa93d5
📒 Files selected for processing (7)
src/main/browser/browser-manager.tssrc/main/browser/cdp-bridge-integration.test.tssrc/main/browser/cdp-bridge.tssrc/main/browser/cdp-ws-proxy-focus-replay.test.tssrc/main/browser/cdp-ws-proxy.test.tssrc/main/browser/cdp-ws-proxy.tssrc/renderer/src/components/browser-pane/browser-page-webview.ts
|
Thanks for digging into this and for the clear write-up in #11190. We're closing this in favour of #32975. Browser tabs already show JSON and plain-text pages properly on main. #18738 (shipped in v1.4.198) made the page's background opaque with a webview setting, and Chromium then draws its dark background for dark-scheme pages. That gives the same result as |
Fixes #11190.
Summary
application/jsonresponses rendered as a blank white page in the embedded browser with the dark theme. Chromium's JSON viewer document declarescolor-scheme: light dark, so its text goes white in dark mode, but it paints no background. Webview guests have a transparent base background and the pane forces a white CSS fallback, so the page came out white-on-white. Details and repro in the issue.This adds
Emulation.setDefaultBackgroundColorOverride(opaque white) where the guest debugger gets bootstrapped:injectAntiDetectionin browser-manager, plus cdp-bridge and cdp-ws-proxy so the override survives takeovers, same wayANTI_DETECTION_SCRIPTis kept alive. With an opaque base Blink picks the canvas color per document color scheme: JSON pages get a dark canvas in dark mode, CSS-less pages keep the white one. The white CSS fallback on the<webview>element stays for guests wheredebugger.attachfails (DevTools open).Screenshots
Before/after screenshots are in #11190: the blank white page vs a dark canvas with readable JSON, plus a CSS-less page that keeps its white background with the fix applied.
Testing
pnpm lintpnpm typecheckpnpm test— ran the affected suitevitest run src/main/browser/: 526 passed. Updated command-sequence expectations incdp-ws-proxy.test.ts/cdp-ws-proxy-focus-replay.test.ts; thecdp-bridge-integration.test.tsmock now handles the new command and rejects an out-of-range RGBA alpha so it can't regresspnpm buildAI Review Report
Ran an AI-assisted review of the change. Risks checked: regressions for pages that paint no background (the case the white CSS fallback was originally added for) — verified a CSS-less page still renders white with black text; override survival across bridge/proxy debugger takeovers — the override is installed at all three bootstrap sites, mirroring how
ANTI_DETECTION_SCRIPTis kept alive; behavior when no debugger can attach (DevTools open) — the CSS fallback keeps today's behavior for that guest. The review also flagged an out-of-spec RGBA alpha (a: 255instead of the 0–1 float the protocol defines), fixed toa: 1. Cross-platform: the change is a CDP command with a constant payload — no shortcuts, labels, paths, or shell behavior involved; the call sites are shared (not platform-gated) code, so macOS/Linux/Windows behave the same, and headlessorca servegets the same override through cdp-bridge / cdp-ws-proxy.Security Audit
No input handling, command execution, path handling, auth, secrets, or dependency changes. The added CDP command sends a constant color payload to already-attached debugger sessions over the existing internal channel; no page- or user-controlled data flows into it. IPC surfaces are unchanged.
Notes
debugger.attachfails (e.g. DevTools open on the tab), the white CSS fallback preserves the current behavior for that guest.pnpm buildwas not run locally; the change is main-process/renderer TypeScript only, no build-config or asset changes.