Android: run beforeunload handler when pressing system back button
Before this patch, when the history stack was empty and the user pressed the system back button, the tab would be closed (usually --- depending on how the tab was opened). The beforeunload handler, if any, would be skipped, even though navigating in a different manner *would* trigger beforeunload. In comparison, desktop Chrome does run beforeunload when closing a tab (via the tab close button, for example). So this discrepancy seems unintended. This fix *only* affects system back and not other ways of closing tabs. So, for example, closing from the tab switcher UI will still immediately close, but offer an undo notification bar. This should not have any effect if a page does not have a beforeunload handler (or the handler is not active due to the lack of a user gesture), except that closing will be asynchronous. The same sequence happens in TabModelImpl, as TabModel#closeTab is called with the same arguments by way of TabWebContentsDelegateAndroid#closeContents. Bug: 1055540 Change-Id: Ie9e45692b920db54fd3d00f06466edee01771d47 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2071491 Commit-Queue: Evan Stade <estade@chromium.org> Reviewed-by:Ted Choc <tedchoc@chromium.org> Reviewed-by:
David Trainor <dtrainor@chromium.org> Cr-Commit-Position: refs/heads/master@{#746645}
Showing
Please register or sign in to comment