Repository navigation
refactor: follow-ups to emitting WebContents' forwarded events natively - #53981
Merged
Merged
Conversation
- 'render-process-gone' and 'login': the WebContents' own listeners run off the wrapper saved before the app emit, so they still run when an app listener destroys the WebContents (as the rest of an emit in progress did), and nothing of the native object is used after the app emit - select-bluetooth-device: re-check the chooser and the WebContents after calling the app-replaceable listenerCount() - drop the now-unused weak pointer in OnFirstNonEmptyLayout, make the isolate locals const, brace-initialise the callback scopes - specs for the app-before-webContents order, the shared microtask drain, and the destroyed-by-app-listener case
5 tasks done
codebytere
approved these changes
Sep 16, 2026
ckerr
approved these changes
Sep 16, 2026
|
No Release Notes |
Contributor
|
I was unable to backport this PR to "45-x-y" cleanly; |
MarshallOfSound
added a commit
that referenced
this pull request
Sep 16, 2026
…ly (#53981) - 'render-process-gone' and 'login': the WebContents' own listeners run off the wrapper saved before the app emit, so they still run when an app listener destroys the WebContents (as the rest of an emit in progress did), and nothing of the native object is used after the app emit - select-bluetooth-device: re-check the chooser and the WebContents after calling the app-replaceable listenerCount() - drop the now-unused weak pointer in OnFirstNonEmptyLayout, make the isolate locals const, brace-initialise the callback scopes - specs for the app-before-webContents order, the shared microtask drain, and the destroyed-by-app-listener case (cherry picked from commit 4d10ef9)
MarshallOfSound
added a commit
that referenced
this pull request
Sep 16, 2026
* refactor: emit WebContents' forwarded events natively WebContents' JS _init registered listeners on itself whose only job was to re-emit with data C++ already had: '-console-message' -> 'console-message' (plus the deprecated positional arguments), '-unresponsive' -> 'unresponsive' (when not ignored/hidden/uninitialised), 'login' and 'render-process-gone' -> app (and a debugging hint when logging is on), 'ready-to-show' -> the owner BrowserWindow, '-before-unload-fired' -> preventDefault for non-interactive types, 'devtools-reload-page' -> reload(), 'select-bluetooth-device' -> cancel when nobody listens, and app 'web-contents-created' at the end of _init. Each is now done where the event originates, in the order the JS listener (always the first one) gave: app before the WebContents' own listeners for login/render-process-gone, the window after the WebContents for ready-to-show, reload() before 'devtools-reload-page'. The 'console-message' deprecation warning is now given when a listener with the old signature is added rather than on its first message. Co-authored-by: Sam Attard <[email protected]> * fix: take the weak pointer before app listeners can destroy the WebContents Co-authored-by: Sam Attard <[email protected]> * fix: run paired emits under one callback scope so ticks and microtasks drain after both Co-authored-by: Sam Attard <[email protected]> * fix: read the login event's defaultPrevented after listeners' microtasks have run Co-authored-by: Sam Attard <[email protected]> * fix: notify the window that owned the WebContents before its ready-to-show listeners ran Co-authored-by: Sam Attard <[email protected]> * fix: hand app and webContents 'login' listeners the same authInfo object Co-authored-by: Sam Attard <[email protected]> * fix: count select-bluetooth-device listeners under the emit's callback scope Co-authored-by: Sam Attard <[email protected]> * refactor: follow-ups to emitting WebContents' forwarded events natively (#53981) - 'render-process-gone' and 'login': the WebContents' own listeners run off the wrapper saved before the app emit, so they still run when an app listener destroys the WebContents (as the rest of an emit in progress did), and nothing of the native object is used after the app emit - select-bluetooth-device: re-check the chooser and the WebContents after calling the app-replaceable listenerCount() - drop the now-unused weak pointer in OnFirstNonEmptyLayout, make the isolate locals const, brace-initialise the callback scopes - specs for the app-before-webContents order, the shared microtask drain, and the destroyed-by-app-listener case (cherry picked from commit 4d10ef9) --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Sam Attard <[email protected]> Co-authored-by: Samuel Attard <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.OnFirstNonEmptyLayout;constisolate locals; brace-initialised the callback scopes.On the microtask question: the paired emits share one outer
node::CallbackScope, so the innerMakeCallbackscopes are nested (depth > 1) and neither they nor gin'skRunMicrotasksscope (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: awebContents.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
npm testpassesRelease Notes
Notes: none