Skip to content

Add "Emulate a focused page" feature#2316

Merged
hediet merged 2 commits intomainfrom
feature/focus-emulation
Feb 9, 2026
Merged

Add "Emulate a focused page" feature#2316
hediet merged 2 commits intomainfrom
feature/focus-emulation

Conversation

@hediet
Copy link
Member

@hediet hediet commented Feb 6, 2026

This PR adds support for Chrome DevTools' "Emulate a focused page" feature.

Problem

When debugging web applications, the debugged page may lose focus to VS Code, causing focus-dependent behaviors (:focus styles, document.hasFocus(), focus event handlers) to not work as expected.

Solution

  • Add new DAP custom requests canEmulate and setFocusEmulation to control focus emulation via CDP's Emulation domain
  • Create a new "Debug Options" tree view (jsDebugOptions) that appears when debugging browser targets
  • Allow users to toggle focus emulation with a checkbox that persists across debug sessions
  • Only show the option for targets that support emulation (browser pages, not Node.js)

Implementation Details

  • Uses Schema.getDomains to detect if Emulation domain is available
  • Uses Emulation.setFocusEmulationEnabled CDP method
  • Setting is persisted via workspace state

Closes #2315

Image

@hediet
Copy link
Member Author

hediet commented Feb 6, 2026

I tested the PR. Most of the changes come from updating the cdp d.ts files.

alexr00
alexr00 previously approved these changes Feb 6, 2026
@connor4312
Copy link
Member

This is a cool feature, although I'm unsure about adding a whole new view for this. Maybe the Event Listener Breakpoints view becomes like a "Browser Options" or "Browser Controls" view and this gets put in there. What do you think?

@hediet
Copy link
Member Author

hediet commented Feb 9, 2026

Update:
Code_-_Insiders_62BQZPUQVS

(I miss observables 😢)

@hediet hediet merged commit 6d05b46 into main Feb 9, 2026
7 checks passed
@hediet hediet deleted the feature/focus-emulation branch February 9, 2026 20:54
@hediet
Copy link
Member Author

hediet commented Feb 9, 2026

@connor4312 I did a thorough code review & tested the feature. Will monitor the feature & revert the PR if there are problems!

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.

Add "Emulate a focused page" feature

4 participants