Skip to content

fix: renderer crash after IPC to a window.open() child with its own contextIsolation - #53535

Merged
MarshallOfSound merged 1 commit into
mainfrom
fix/window-open-context-isolation-env
Sep 4, 2026
Merged

MarshallOfSound merged 1 commit into
mainfrom
fix/window-open-context-isolation-env

Conversation

@MarshallOfSound

Copy link
Copy Markdown
Member

Description of Change

Fixes #53521.

A window.open() child of an opener with contextIsolation: false gets contextIsolation: true unless 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 and GetContext() pick the isolated world instead.

Build IPC to the child Child navigates
42.9.3 survives SIGSEGV
42.11.2 CHECK CHECK
this PR survives, preload receives the message survives

Checklist

  • PR description included
  • npm test passes
  • tests are added

Release Notes

Notes: Fixed a renderer crash when the main process sent IPC to, or a page navigated, a same-process window.open() child whose contextIsolation differed from its opener's.

…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.
@MarshallOfSound MarshallOfSound added semver/patch backwards-compatible bug fixes target/42-x-y PR should also be added to the "42-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. target/44-x-y PR should also be added to the "44-x-y" branch. target/45-x-y PR should also be added to the "45-x-y" branch. labels Sep 4, 2026
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Sep 4, 2026
@MarshallOfSound MarshallOfSound added the fast-track 🚅 Indicates that this PR is intended to bypass the 24 hour rule. Needs approval from Releases label Sep 4, 2026
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Sep 4, 2026
@MarshallOfSound
MarshallOfSound enabled auto-merge (squash) September 4, 2026 18:33
@MarshallOfSound
MarshallOfSound merged commit 5856ddc into main Sep 4, 2026
126 checks passed
@MarshallOfSound
MarshallOfSound deleted the fix/window-open-context-isolation-env branch September 4, 2026 18:51
@release-clerk

release-clerk Bot commented Sep 4, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed a renderer crash when the main process sent IPC to, or a page navigated, a same-process window.open() child whose contextIsolation differed from its opener's.

@github-actions github-actions Bot added the 46-x-y label Sep 4, 2026
@trop

trop Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "44-x-y" cleanly;
you will need to perform this backport manually.

@trop

trop Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "42-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot removed the target/44-x-y PR should also be added to the "44-x-y" branch. label Sep 4, 2026
@trop

trop Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "43-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot added needs-manual-bp/44-x-y needs-manual-bp/42-x-y needs-manual-bp/43-x-y and removed target/42-x-y PR should also be added to the "42-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. labels Sep 4, 2026
@trop

trop Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "45-x-y", please check out #53538

@trop

trop Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@MarshallOfSound has manually backported this PR to "44-x-y", please check out #53539

@trop

trop Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@MarshallOfSound has manually backported this PR to "43-x-y", please check out #53540

@trop

trop Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@MarshallOfSound has manually backported this PR to "42-x-y", please check out #53541

MarshallOfSound added a commit that referenced this pull request Sep 4, 2026
…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)
@trop trop Bot added merged/42-x-y PR was merged to the "42-x-y" branch. and removed in-flight/42-x-y labels Sep 4, 2026
MarshallOfSound added a commit that referenced this pull request Sep 4, 2026
…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)
@trop trop Bot added merged/44-x-y PR was merged to the "44-x-y" branch. and removed in-flight/44-x-y labels Sep 4, 2026
MarshallOfSound added a commit that referenced this pull request Sep 4, 2026
…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)
@trop trop Bot added merged/43-x-y PR was merged to the "43-x-y" branch. and removed in-flight/43-x-y labels Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

46-x-y fast-track 🚅 Indicates that this PR is intended to bypass the 24 hour rule. Needs approval from Releases merged/42-x-y PR was merged to the "42-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Renderer crashes with CHECK in DidCreateScriptContext after same-process window.open (regression in 42.10.0)

3 participants