#53981: refactor: follow-ups to emitting WebContents' forwarded events natively
Description of Change
Follow-up to #53975 addressing @ckerr's review:
render-process-gone/login: the WebContents' own listeners now run off the wrapper captured before the app emit, so they still run if an app listener destroys the WebContents (as the remainder of an in-progressemit()did before), and the native object is not touched after the app emit.select-bluetooth-device: the chooser and the WebContents are re-checked after callinglistenerCount(), which an app can replace.- Removed the unused weak pointer in
OnFirstNonEmptyLayout;constisolate locals; brace-initialised the callback scopes. - Specs for the ordering guarantees: app listeners before the webContents', one microtask/nextTick drain after both, and the destroyed-by-app-listener case.
On the microtask question: the paired emits share one outer node::CallbackScope, so the inner MakeCallback scopes are nested (depth > 1) and neither they nor gin's kRunMicrotasks scope (explicit microtask policy in the browser process) checkpoint; ticks and microtasks run once when the outer scope closes, after both emits — the new spec asserts exactly that and matches the pre-#53975 behaviour. One ordering difference does remain and is intentional: a webContents.prependListener('login' | 'render-process-gone', …) listener used to run before app listeners (it sat ahead of the internal forwarding listener) and now runs after them.
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
-
npm testpasses - PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, and past tense.
Release Notes
Notes: none
Backports
Semver Impact
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