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 #8911 #9292

Merged
merged 1 commit into from May 9, 2017

Conversation

Projects
None yet
3 participants
@22222
Contributor

22222 commented Apr 26, 2017

This would be an addition to the changes in #8724 to handle cases where the navigation is cancelled.

I'm not completely sure that overriding the BeforeUnloadDialogCancelled method is the best way to handle this, or if there's more that should be cleaned up. This fixes the one case I was testing for (#8911) and doesn't break any unit tests (at least when I run them), but I didn't do much other testing to see if there are any other negative side-effects.

And this is my first time even looking at the Electron source code, so don't make any assumptions that I know what I'm doing here.

Fixes #8911

@kevinsawicki kevinsawicki requested a review from deepak1556 Apr 26, 2017

@deepak1556

LGTM on the approach, requires some minor fixes. Thanks @22222 !

@@ -861,6 +861,12 @@ void WebContents::Observe(int type,
}
}
void WebContents::BeforeUnloadDialogCancelled() {
if (deferred_load_url_.id) {

This comment has been minimized.

@deepak1556

deepak1556 Apr 27, 2017

Member

BeforeUnloadDialogCancelled will also be called for any cancellation inside iframes, we do not want to clear the defer load params in that situation, it would have been better if there was an argument that contained the frame id. The only way now is to check if there is an pending entry or not. This observer will be called only after clearing navigation controller states for this webContents, so we can be sure any pending entry would have been cleared.

if (deferrer_load_url_.id && !controller.GetPendingEntry())
@deepak1556

deepak1556 Apr 27, 2017

Member

BeforeUnloadDialogCancelled will also be called for any cancellation inside iframes, we do not want to clear the defer load params in that situation, it would have been better if there was an argument that contained the frame id. The only way now is to check if there is an pending entry or not. This observer will be called only after clearing navigation controller states for this webContents, so we can be sure any pending entry would have been cleared.

if (deferrer_load_url_.id && !controller.GetPendingEntry())

This comment has been minimized.

@22222

22222 Apr 28, 2017

Contributor

Awesome, thanks for this feedback. I figured there'd be some special case I hadn't considered.

@22222

22222 Apr 28, 2017

Contributor

Awesome, thanks for this feedback. I figured there'd be some special case I hadn't considered.

Show outdated Hide outdated spec/api-browser-window-spec.js
Show outdated Hide outdated spec/api-browser-window-spec.js
@deepak1556

👍

@kevinsawicki kevinsawicki merged commit 8c85692 into electron:master May 9, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@kevinsawicki

This comment has been minimized.

Show comment
Hide comment
@kevinsawicki

kevinsawicki May 9, 2017

Contributor

Thanks for this @22222 👍 👍

Contributor

kevinsawicki commented May 9, 2017

Thanks for this @22222 👍 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment