Skip to content

refactor: emit WebContents' forwarded events natively - #53979

Merged
MarshallOfSound merged 8 commits into
45-x-yfrom
trop/45-x-y-bp-refactor-emit-webcontents-forwarded-events-natively-1789520520292
Sep 16, 2026
Merged

MarshallOfSound merged 8 commits into
45-x-yfrom
trop/45-x-y-bp-refactor-emit-webcontents-forwarded-events-natively-1789520520292

Conversation

@trop

@trop trop Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Backport of #53975

See that PR for details.

Notes: none

trop Bot and others added 7 commits September 16, 2026 01:02
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]>
@trop
trop Bot requested a review from MarshallOfSound September 16, 2026 01:02
@trop trop Bot added 45-x-y backport This is a backport PR semver/none labels 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
MarshallOfSound enabled auto-merge (squash) September 16, 2026 20:10
@MarshallOfSound
MarshallOfSound merged commit 35c8491 into 45-x-y Sep 16, 2026
75 checks passed
@MarshallOfSound
MarshallOfSound deleted the trop/45-x-y-bp-refactor-emit-webcontents-forwarded-events-natively-1789520520292 branch September 16, 2026 20:17
@release-clerk

release-clerk Bot commented Sep 16, 2026

Copy link
Copy Markdown

No Release Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants