Prevent new navigations from onbeforeunload handler
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Mar 2017 23:07:50 +0000 (23:07 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Mar 2017 23:07:50 +0000 (23:07 +0000)
commit872db6108518a1e7d02fc1f2042bd2871cb53de2
tree1607a37446727da5958952d8f3b1b0d22774084e
parentfe9ed381688181348438675de027dfdf4afb7b5f
Prevent new navigations from onbeforeunload handler
https://bugs.webkit.org/show_bug.cgi?id=169891
<rdar://problem/31155736>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Ensure that all navigations initiated from an onbeforeunload handler are disallowed
regardless of how they were scheduled. Such navigations go against the expectation
of a user.

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::isNavigationAllowed): Added.
(WebCore::FrameLoader::loadURL): Modified code to call FrameLoader::isNavigationAllowed().
(WebCore::FrameLoader::loadWithDocumentLoader): Ditto.
(WebCore::FrameLoader::stopAllLoaders): Ditto.
* loader/FrameLoader.h:

LayoutTests:

Update test to ensure that we disallow navigation initiated via a DOM click event from
an onbeforeunload handler.

* fast/events/before-unload-forbidden-navigation.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@214194 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/events/before-unload-forbidden-navigation.html
Source/WebCore/ChangeLog
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/FrameLoader.h