alert, confirm, prompt, showModalDialog should be forbidden during page close and navigation
https://bugs.webkit.org/show_bug.cgi?id=150980
Reviewed by Chris Dumez.
Source/WebCore:
Tests: fast/events/beforeunload-alert.html
fast/events/beforeunload-confirm.html
fast/events/beforeunload-prompt.html
fast/events/beforeunload-showModalDialog.html
fast/events/pagehide-alert.html
fast/events/pagehide-confirm.html
fast/events/pagehide-prompt.html
fast/events/pagehide-showModalDialog.html
fast/events/unload-alert.html
fast/events/unload-confirm.html
fast/events/unload-prompt.html
fast/events/unload-showModalDialog.html
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::stopLoading): Factored out a helper function for
unload event processing.
(WebCore::FrameLoader::handleUnloadEvents): Forbid prompts in unload
events just like we do in beforeunload events, and for the same reasons.
(WebCore::FrameLoader::handleBeforeUnloadEvent): Updated for renames.
* loader/FrameLoader.h:
* page/DOMWindow.cpp:
(WebCore::DOMWindow::print):
(WebCore::DOMWindow::alert):
(WebCore::DOMWindow::confirm):
(WebCore::DOMWindow::prompt):
(WebCore::DOMWindow::showModalDialog): Updated for renames. Refactored
some of this code to handle null pages more cleanly. In particular, we
sometimes used to treat null page as "everything is permitted" -- but it
is best practice in a permissions context to treat lack of information
as no permission granted rather than all permissions granted. (I don't
know of a way to trigger this condition in practice.)
* page/Page.cpp:
(WebCore::Page::Page):
(WebCore::Page::forbidPrompts):
(WebCore::Page::allowPrompts):
(WebCore::Page::arePromptsAllowed): Renamed to make these functions
reflect their new, broader context.
(WebCore::Page::incrementFrameHandlingBeforeUnloadEventCount): Deleted.
(WebCore::Page::decrementFrameHandlingBeforeUnloadEventCount): Deleted.
(WebCore::Page::isAnyFrameHandlingBeforeUnloadEvent): Deleted.
* page/Page.h:
LayoutTests:
Added tests to cover the matrix of [ alert, confirm, prompt, showModalDialog ] x [ beforeunload, unload, pagehide ].
* fast/events/beforeunload-alert-expected.txt: Added.
* fast/events/beforeunload-alert.html: Added.
* fast/events/beforeunload-confirm-expected.txt: Added.
* fast/events/beforeunload-confirm.html: Added.
* fast/events/beforeunload-prompt-expected.txt: Added.
* fast/events/beforeunload-prompt.html: Added.
* fast/events/beforeunload-showModalDialog-expected.txt: Added.
* fast/events/beforeunload-showModalDialog.html: Added.
* fast/events/onunload-expected.txt:
* fast/events/onunload-not-on-body-expected.txt:
* fast/events/onunload-window-property-expected.txt:
* fast/events/pagehide-alert-expected.txt: Added.
* fast/events/pagehide-alert.html: Added.
* fast/events/pagehide-confirm-expected.txt: Added.
* fast/events/pagehide-confirm.html: Added.
* fast/events/pagehide-prompt-expected.txt: Added.
* fast/events/pagehide-prompt.html: Added.
* fast/events/pagehide-showModalDialog-expected.txt: Added.
* fast/events/pagehide-showModalDialog.html: Added.
* fast/events/pageshow-pagehide-on-back-cached-expected.txt:
* fast/events/pageshow-pagehide-on-back-uncached-expected.txt:
* fast/events/resources/prompt-landing-page.html: Added.
* fast/events/unload-alert-expected.txt: Added.
* fast/events/unload-alert.html: Added.
* fast/events/unload-confirm-expected.txt: Added.
* fast/events/unload-confirm.html: Added.
* fast/events/unload-prompt-expected.txt: Added.
* fast/events/unload-prompt.html: Added.
* fast/events/unload-showModalDialog-expected.txt: Added.
* fast/events/unload-showModalDialog.html: Added.
* platform/wk2/TestExpectations: WebKit2 can't handle showModalDialog tests.
* compositing/iframes/page-cache-layer-tree-expected.txt:
* fast/dom/Geolocation/notimer-after-unload-expected.txt:
* fast/history/timed-refresh-in-cached-frame-expected.txt:
* fast/loader/frames-with-unload-handlers-in-page-cache-expected.txt:
* fast/loader/page-dismissal-modal-dialogs-expected.txt: These were
pre-existing tests that tried to alert during unload.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@192270 268f45cc-cd09-0410-ab3c-d52691b4dbfc
43 files changed