Skip to content
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: don't execute preload scripts for internal <iframe> in <webview> when nodeIntegrationInSubFrames is enabled #19260

Merged
merged 1 commit into from
Jul 17, 2019

Conversation

miniak
Copy link
Contributor

@miniak miniak commented Jul 15, 2019

Description of Change

Fixes #18429.

The problem is that before the webContents is attached to the internal <iframe> inside of the <webview>, it's treated as a regular frame and the preload scripts are executed there.

Fix by checking v8Util.getHiddenValue(window.frameElement, 'internal') on context initialization, which is set by the <webview> implementation:

createInternalElement () {
const iframeElement = document.createElement('iframe')
iframeElement.style.flex = '1 1 auto'
iframeElement.style.width = '100%'
iframeElement.style.border = '0'
v8Util.setHiddenValue(iframeElement, 'internal', this)
return iframeElement
}

Checklist

Release Notes

Notes: Preload scripts for internal <iframe> in <webview> are not longer executed when nodeIntegrationInSubFrames is enabled.

@miniak miniak self-assigned this Jul 15, 2019
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jul 15, 2019
shell/renderer/atom_renderer_client.cc Outdated Show resolved Hide resolved
shell/renderer/atom_renderer_client.cc Outdated Show resolved Hide resolved
shell/renderer/atom_sandboxed_renderer_client.cc Outdated Show resolved Hide resolved
@miniak miniak force-pushed the miniak/webview-iframe-preload branch 3 times, most recently from 5c37424 to 894703c Compare July 15, 2019 19:19
@miniak miniak force-pushed the miniak/webview-iframe-preload branch from 894703c to 6b19def Compare July 15, 2019 22:22
@miniak miniak changed the title fix: don't execute preload scripts for internal <iframe> in <webview> fix: don't execute preload scripts for internal <iframe> in <webview> when nodeIntegrationInSubFrames is enabled Jul 15, 2019
@miniak miniak force-pushed the miniak/webview-iframe-preload branch 2 times, most recently from 6e41c14 to 756f6eb Compare July 15, 2019 23:20
@zcbenz
Copy link
Member

zcbenz commented Jul 16, 2019

The test is failing on Windows CI:

not ok 515 renderer nodeIntegrationInSubFrames with context isolation, webview on should correctly reply to the sub-frames with using event.reply
23533  Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (C:\projects\src\electron\spec\api-subframe-spec.js)
23534      at Test.Runnable._timeoutError (C:\projects\src\electron\spec\node_modules\mocha\lib\runnable.js:440:10)
23535      at C:\projects\src\electron\spec\node_modules\mocha\lib\runnable.js:251:24
23536

@miniak miniak force-pushed the miniak/webview-iframe-preload branch 3 times, most recently from c521176 to 4f1dcea Compare July 16, 2019 13:15
@miniak miniak force-pushed the miniak/webview-iframe-preload branch from 4f1dcea to 1597f25 Compare July 16, 2019 13:29
@miniak
Copy link
Contributor Author

miniak commented Jul 16, 2019

@zcbenz I've fixed the tests

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jul 16, 2019
@zcbenz zcbenz merged commit d1c9f5e into master Jul 17, 2019
@release-clerk
Copy link

release-clerk bot commented Jul 17, 2019

Release Notes Persisted

Preload scripts for internal <iframe> in <webview> are not longer executed when nodeIntegrationInSubFrames is enabled.

@zcbenz zcbenz deleted the miniak/webview-iframe-preload branch July 17, 2019 00:13
@trop
Copy link
Contributor

trop bot commented Jul 17, 2019

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

@trop
Copy link
Contributor

trop bot commented Jul 17, 2019

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

@trop
Copy link
Contributor

trop bot commented Jul 17, 2019

A maintainer has manually backported this PR to "6-0-x", please check out #19298

@trop
Copy link
Contributor

trop bot commented Jul 17, 2019

A maintainer has manually backported this PR to "5-0-x", please check out #19299

@KochiyaOcean
Copy link

KochiyaOcean commented Jul 17, 2019

https://github.com/electron/electron/blob/master/docs/api/webview-tag.md#nodeintegrationinsubframes
The document still says All your preloads will load for every iframe. Is that behavior no longer occurs after this commit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
6.1.x
Fixed in 6.0.0-beta.14
Development

Successfully merging this pull request may close these issues.

nodeIntegrationInSubFrames webview attribute causes preload script to run multiple times
5 participants