haikuwebkit/LayoutTests/fast/events/before-unload-sibling-frame...

5 lines
103 B
Plaintext
Raw Permalink Normal View History

REGRESSION(r214194): Safari leaves a popup window open opened during before unload https://bugs.webkit.org/show_bug.cgi?id=174016 Reviewed by Chris Dumez. Source/WebCore: The bug was caused by WebKit allowing the opening of a new window via window.open but disallowing the initial navigation within the newly opened window while a beforeunload event is being dispatched. Because some websites which opens a window during a beforeunload event relies on the opened page to communicate back in order to close it. This resulted in a newly opened popup window with about:blank being left out on those websites. Fixed the bug by allowing the navigation of a new window as well as an existing another window. More concretely, we disallow navigations within the same frame tree as the one in which a beforeunload event is being dispatched, and allow navigations elsewhere (i.e. different window / page). During the destruction of a frame-less document, disallow all the navigations. Tests: fast/events/before-unload-navigate-different-window.html fast/events/before-unload-open-window.html fast/events/before-unload-sibling-frame.html * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::prepareForDestruction): * loader/FrameLoader.cpp: (WebCore::FrameLoader::isNavigationAllowed): (WebCore::FrameLoader::shouldClose): * loader/NavigationDisabler.h: Added. Extracted from NavigationScheduler.h (WebCore::NavigationDisabler::NavigationDisabler): Increment the newly added counter on MainFrame unless the frame is null (during the destruction of a frameless document) in which case we increment the global disable count. (WebCore::NavigationDisabler::~NavigationDisabler): Ditto for decrementation. (WebCore::NavigationDisabler::isNavigationAllowed): Only allow the navigation when there is no frameless document in destruction, and none of the frame in the same frame tree as the one given is currently in the process of dispatching a beforeunload event. * loader/NavigationScheduler.cpp: (WebCore::NavigationScheduler::shouldScheduleNavigation): * loader/NavigationScheduler.h: (WebCore::NavigationDisabler): Moved to NavigationDisabler.h. * page/MainFrame.h: (WebCore::MainFrame): Added s_globalNavigationDisableCount. LayoutTests: Added regression tests for navigating a new window, a sibling iframe, and another existing window. * fast/events/before-unload-navigate-different-window-expected.txt: Added. * fast/events/before-unload-navigate-different-window.html: Added. * fast/events/before-unload-open-window-expected.txt: Added. * fast/events/before-unload-open-window.html: Added. * fast/events/before-unload-sibling-frame-expected.txt: Added. * fast/events/before-unload-sibling-frame.html: Added. * fast/events/resources/message-opener.html: Added. * fast/events/resources/message-top.html: Added. Canonical link: https://commits.webkit.org/190863@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219008 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-06-30 19:32:41 +00:00
This tests navigating a sibling iframe during beforeunload. The navigation should be prevented.
PASS