New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: <webview> not working in scriptable popups #19198
Conversation
ea5ed3c
to
f2b5cc9
Compare
f2b5cc9
to
8eea944
Compare
A maintainer has manually backported this PR to "5-0-x", please check out #19206 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scary bug, nice find!
Release Notes Persisted
|
I have automatically backported this PR to "6-0-x", please check out #19218 |
Description of Change
In this PR #15859 I've added a check to prevent
<webview>
related IPCs from being handled whenwebviewTag
is not enabled for the given sender to increase security. It relies ongetLastWebPreferences()
:electron/lib/browser/guest-view-manager.js
Lines 319 to 326 in 692df80
When a scriptable popup is created, Chromium creates the
webContents
and Electron migrates thewebPreferences
electron/shell/browser/api/atom_api_browser_window.cc
Lines 51 to 66 in 692df80
The
webPreferences
are cloned to be returned bygetLastWebPreferences()
in the constructor ofWebContentsPreferences
. HoweverClear
andMerge
are called afterwards.electron/shell/browser/web_contents_preferences.cc
Line 169 in 692df80
In case of cross-origin popup a new renderer process is created and the
webPreferences
are turned into command-line switches inWebContentsPreferences::AppendCommandLineSwitches()
, which also clones them again (after theMerge
).electron/shell/browser/web_contents_preferences.cc
Lines 418 to 421 in 692df80
The problem is that in case of scriptable popup, the existing renderer process is reused. Therefore
WebContentsPreferences::AppendCommandLineSwitches()
is not called and thewebPreferences
are not cloned after the merge. Which means thatgetLastWebPreferences()
returns incorrect values (withwebviewTag
disabled).This PR fixes the
<webview>
issue by making sure thatgetLastWebPreferences()
returns correct values by cloning thewebPreferences
after the merge.Checklist
npm test
passesRelease Notes
Notes: Fixed
<webview>
not working in scriptable popups whennativeWindowOpen
is enabled.