Skip to content

Let browser pages handle key events first#304490

Merged
kycutler merged 5 commits intomainfrom
kycutler/defaultshortcuts
Mar 25, 2026
Merged

Let browser pages handle key events first#304490
kycutler merged 5 commits intomainfrom
kycutler/defaultshortcuts

Conversation

@kycutler
Copy link
Copy Markdown
Contributor

Fixes #303908

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Integrated Browser’s keyboard handling so embedded pages get first chance to consume key events (addressing shortcut interference reported in #303908), and adds smoke coverage for basic browser open/security expectations.

Changes:

  • Move key handling from Electron before-input-event interception to a preload-driven “forward only when unhandled” approach.
  • Remove the now-unneeded dispatchKeyEvent plumbing across the browser view service/model.
  • Add smoke tests for Integrated Browser open/title behavior and a Node-integration sanity check.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/smoke/src/main.ts Wires the new Integrated Browser smoke suite into the Electron (non-remote) smoke run.
test/smoke/src/areas/browser/browser.test.ts Adds smoke tests for loading a page title and verifying lack of Node globals in main frame + subframe.
src/vs/workbench/contrib/browserView/electron-browser/browserEditor.ts Stops “forwarding back” key events; always dispatches received key events to keybinding service.
src/vs/workbench/contrib/browserView/common/browserView.ts Removes model-level dispatchKeyEvent method as key event routing changes.
src/vs/platform/browserView/electron-main/browserViewMainService.ts Removes main service dispatchKeyEvent method and related import.
src/vs/platform/browserView/electron-main/browserView.ts Switches key event forwarding to an IPC signal from the preload; enables preload in subframes.
src/vs/platform/browserView/electron-browser/preload-browserView.ts Adds DOM keydown listener to forward “unhandled” keys to the main process for workbench shortcut dispatch.
src/vs/platform/browserView/common/browserView.ts Removes service-level dispatchKeyEvent API.

Copy link
Copy Markdown
Collaborator

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

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

nodeIntegrationInSubFrames will cause sandbox to be disabled for cross origin sub frame processes, only same origin sub frames will respect embedding frames sandbox properties. This is not desired and a security concern.

Can you rely on session api https://github.com/electron/electron/blob/main/docs/api/session.md#sesregisterpreloadscriptscript to inject browser view sessions preloadscript into frames

deepak1556
deepak1556 previously approved these changes Mar 24, 2026
Copy link
Copy Markdown
Collaborator

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

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

Thanks!

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.

Integrated Browser shortcut support interferes with page behavior

4 participants