MarshallOfSound

#53975: refactor: emit WebContents' forwarded events natively

Merged
Created: Sep 15, 2026, 6:57:33 PM
Merged: Sep 15, 2026, 8:01:53 PM
4 comments
Target: main

Description of Change

WebContents' JS _init registered listeners on itself only to re-emit with data C++ already had. Those are now emitted where they originate: console-message (with the deprecated positional args), unresponsive (when not ignored/hidden/uninitialised), app login / render-process-gone (plus the logging hint), the owner window's ready-to-show, the -before-unload-fired veto for non-interactive types, devtools-reload-page → reload, select-bluetooth-device cancellation when nobody listens, and app web-contents-created. Listener order and microtask/nextTick phase are kept as the JS trampoline (always the first listener) produced them.

Two intentional differences: the console-message deprecation warning is given when an old-signature listener is added rather than on its first message, and web-contents-created carries a real Event and is emitted once _init has finished.

No runtime change intended beyond one JS hop less per event; ~90 lines out of lib/browser/api/web-contents.ts.

Checklist

Release Notes

Notes: none

Backports

45-x-y
In-flight
PR Number
#53979
Waiting to be merged

Semver Impact

Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.

Semantic Versioning helps users understand the impact of updates:

  • Major (X.y.z): Breaking changes that may require code modifications
  • Minor (x.Y.z): New features that maintain backward compatibility
  • Patch (x.y.Z): Bug fixes that don't change the API
  • None: Changes that don't affect using facing parts of Electron