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: emit will-navigate for sandboxed contents #22188

Merged
merged 7 commits into from
Feb 21, 2020
Merged

Conversation

nornagon
Copy link
Member

@nornagon nornagon commented Feb 13, 2020

Description of Change

Fixes #8841.

Checklist

Release Notes

Notes: Fixed "will-navigate" event not being emitted for sandboxed contents.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Feb 13, 2020
@nornagon
Copy link
Member Author

NB. this approach was previously attempted here #20050, but wasn't accepted because of an assertion that ShouldFork causes the renderer process to restart. I've tested this code locally and that doesn't seem to be the case—the navigation does not cause a new process to start. Cross-domain navigations still cause a new renderer, as expected, but within a single domain the process is reused.

Here's a test fiddle: https://gist.github.com/f4dfb4cd13e1a433b79a118a94a98965

Try watching ps or equivalent process monitor and watch for changing PIDs.

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Feb 14, 2020
@deepak1556
Copy link
Member

To add some notes on this mechanism:

ShouldFork by itself doesn't cause process restart, it gives access to us for all render initiated navigations and lets us decide whether we want it to turn into a browser process initiated navigation so that we can force our process policy through ShouldOverrideSiteInstanceForNavigation. There used to be bug with sandbox renderers to use this mechanism but it seems to have improved.

/cc @zcbenz incase I missed a scenario.

})
w.loadFile(path.join(fixtures, 'pages', 'will-navigate.html'))
for (const sandbox of [false, true]) {
describe(`navigation events${sandbox ? ' with sandbox' : ''}`, () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for will-navigate in the case when navigating from non-file scheme to file scheme ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that results in "Not allowed to load local resource: file://...", in both the sandbox and non-sandbox situations, with this patch.

Copy link
Member

@zcbenz zcbenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a few tests with the change and it works fine with old problematic scenarios.

@nornagon nornagon merged commit a25d7fa into master Feb 21, 2020
@release-clerk
Copy link

release-clerk bot commented Feb 21, 2020

Release Notes Persisted

Fixed "will-navigate" event not being emitted for sandboxed contents.

@nornagon nornagon deleted the sandbox-will-navigate branch February 21, 2020 19:08
@trop
Copy link
Contributor

trop bot commented Feb 21, 2020

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

@trop trop bot removed the target/7-1-x label Feb 21, 2020
@trop
Copy link
Contributor

trop bot commented Feb 21, 2020

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

@trop
Copy link
Contributor

trop bot commented Feb 21, 2020

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

@trop trop bot removed the target/9-x-y label Feb 21, 2020
@trop
Copy link
Contributor

trop bot commented Feb 21, 2020

@nornagon has manually backported this PR to "8-x-y", please check out #22328

@trop
Copy link
Contributor

trop bot commented Feb 21, 2020

@nornagon has manually backported this PR to "7-1-x", please check out #22329

zcbenz pushed a commit that referenced this pull request Feb 26, 2020
* fix: emit will-navigate for sandboxed contents (#22188)

* Update atom_sandboxed_renderer_client.cc

* Update atom_sandboxed_renderer_client.cc

* Update api-browser-window-spec.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

will-navigate event not fired when in sandbox mode
3 participants