Repository navigation
fix: renderer crash after IPC to a window.open() child with its own contextIsolation - #53535
Conversation
…ontextIsolation A window.open() child of an opener with contextIsolation: false gets contextIsolation: true unless the handler overrides it, but its synchronous about:blank document starts with the opener's WebPreferences. Its Node.js environment is therefore created in the main world. Once the browser sends the child's own preferences, the observer and GetContext() pick the isolated world instead, so the first IPC message to the child created a context there and hit CHECK(!environments_.contains(render_frame)). Navigating such a child skipped the release of its environment for the same reason. Record the world of each frame's environment when it is created. While the environment exists, only that world is notified of context creation and release, and GetContext() returns the environment's context, so IPC reaches the preload that ran in it.
|
Release Notes Persisted
|
|
I was unable to backport this PR to "44-x-y" cleanly; |
|
I was unable to backport this PR to "42-x-y" cleanly; |
|
I was unable to backport this PR to "43-x-y" cleanly; |
|
I have automatically backported this PR to "45-x-y", please check out #53538 |
|
@MarshallOfSound has manually backported this PR to "44-x-y", please check out #53539 |
|
@MarshallOfSound has manually backported this PR to "43-x-y", please check out #53540 |
|
@MarshallOfSound has manually backported this PR to "42-x-y", please check out #53541 |
…ontextIsolation (#53541) fix: renderer crash after IPC to a window.open() child with its own contextIsolation (#53535) A window.open() child of an opener with contextIsolation: false gets contextIsolation: true unless the handler overrides it, but its synchronous about:blank document starts with the opener's WebPreferences. Its Node.js environment is therefore created in the main world. Once the browser sends the child's own preferences, the observer and GetContext() pick the isolated world instead, so the first IPC message to the child created a context there and hit CHECK(!environments_.contains(render_frame)). Navigating such a child skipped the release of its environment for the same reason. Record the world of each frame's environment when it is created. While the environment exists, only that world is notified of context creation and release, and GetContext() returns the environment's context, so IPC reaches the preload that ran in it. (cherry picked from commit 5856ddc)
…ontextIsolation (#53539) fix: renderer crash after IPC to a window.open() child with its own contextIsolation (#53535) A window.open() child of an opener with contextIsolation: false gets contextIsolation: true unless the handler overrides it, but its synchronous about:blank document starts with the opener's WebPreferences. Its Node.js environment is therefore created in the main world. Once the browser sends the child's own preferences, the observer and GetContext() pick the isolated world instead, so the first IPC message to the child created a context there and hit CHECK(!environments_.contains(render_frame)). Navigating such a child skipped the release of its environment for the same reason. Record the world of each frame's environment when it is created. While the environment exists, only that world is notified of context creation and release, and GetContext() returns the environment's context, so IPC reaches the preload that ran in it. (cherry picked from commit 5856ddc)
…ontextIsolation (#53540) fix: renderer crash after IPC to a window.open() child with its own contextIsolation (#53535) A window.open() child of an opener with contextIsolation: false gets contextIsolation: true unless the handler overrides it, but its synchronous about:blank document starts with the opener's WebPreferences. Its Node.js environment is therefore created in the main world. Once the browser sends the child's own preferences, the observer and GetContext() pick the isolated world instead, so the first IPC message to the child created a context there and hit CHECK(!environments_.contains(render_frame)). Navigating such a child skipped the release of its environment for the same reason. Record the world of each frame's environment when it is created. While the environment exists, only that world is notified of context creation and release, and GetContext() returns the environment's context, so IPC reaches the preload that ran in it. (cherry picked from commit 5856ddc)
Description of Change
Fixes #53521.
A
window.open()child of an opener withcontextIsolation: falsegetscontextIsolation: trueunless the handler overrides it. Its synchronous about:blank document still starts with the opener's WebPreferences, so its Node.js environment is created in the main world. Once the browser sends the child's own preferences, the observer andGetContext()pick the isolated world instead.CHECK(!environments_.contains(render_frame)). Before fix: illegal access errors when a same-process child window or subframe closes #52964 this created a second environment and ran the preload again.ElectronRendererClientnow records the world of each frame's environment when it creates it. While the environment exists, only that world is notified of context creation and release (ShouldNotifyClient), andGetContext()returns the environment's context, so IPC reaches the preload that ran in it.Checklist
npm testpassesRelease Notes
Notes: Fixed a renderer crash when the main process sent IPC to, or a page navigated, a same-process
window.open()child whosecontextIsolationdiffered from its opener's.