Pages should not be able to abuse users inside beforeunload handlers.
<rdar://problem/14475779> and https://bugs.webkit.org/show_bug.cgi?id=118871.

Reviewed by Alexey Proskuryakov.

Source/WebCore:

Tests: fast/loader/show-only-one-beforeunload-dialog.html
       http/tests/misc/iframe-beforeunload-dialog-matching-ancestor-securityorigin.html
       http/tests/misc/iframe-beforeunload-dialog-not-matching-ancestor-securityorigin.html

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::FrameLoader):
(WebCore::FrameLoader::shouldClose):
(WebCore::FrameLoader::handleBeforeUnloadEvent):
(WebCore::FrameLoader::shouldCloseFiringBeforeUnloadEvent): Renamed from fireBeforeUnloadEvent.
  Add logic to enforce "1 beforeunload dialog per navigation" as well as "iframes can only show beforeunload
  dialogs if their entire ancestry's security origins match the navigating frame."
* loader/FrameLoader.h:
* loader/FrameLoader.h:

Add the ability for Page to know when any frame is dispatching beforeunload:
* page/Page.cpp:
(WebCore::Page::Page):
(WebCore::Page::incrementFrameHandlingBeforeUnloadEventCount):
(WebCore::Page::decrementFrameHandlingBeforeUnloadEventCount):
(WebCore::Page::isAnyFrameHandlingBeforeUnloadEvent):
* page/Page.h:

* page/DOMWindow.cpp:
(WebCore::DOMWindow::print): Disallow if any frame is in beforeunload dispatch.
(WebCore::DOMWindow::alert): Ditto.
(WebCore::DOMWindow::confirm): Ditto.
(WebCore::DOMWindow::prompt): Ditto.
(WebCore::DOMWindow::showModalDialog): Ditto.

LayoutTests:

In addition to the new tests, updated some results of previous tests that were relying on "alert"
as a poor man's logging method.

* fast/events/onbeforeunload-focused-iframe-expected.txt:
* fast/events/onbeforeunload-focused-iframe.html:
* fast/events/onunload-clears-onbeforeunload-expected.txt:
* fast/events/onunload-clears-onbeforeunload.html:
* fast/loader/page-dismissal-modal-dialogs-expected.txt:
* fast/loader/page-dismissal-modal-dialogs.html:
* fast/loader/recursive-before-unload-crash-expected.txt:
* fast/loader/recursive-before-unload-crash.html:
* fast/loader/resources/iframe-with-beforeunload.html: Added.
* fast/loader/show-only-one-beforeunload-dialog-expected.txt: Added.
* fast/loader/show-only-one-beforeunload-dialog.html: Added.
* http/tests/misc/iframe-beforeunload-dialog-matching-ancestor-securityorigin-expected.txt: Added.
* http/tests/misc/iframe-beforeunload-dialog-matching-ancestor-securityorigin.html: Added.
* http/tests/misc/iframe-beforeunload-dialog-not-matching-ancestor-securityorigin-expected.txt: Added.
* http/tests/misc/iframe-beforeunload-dialog-not-matching-ancestor-securityorigin.html: Added.
* http/tests/misc/resources/iframe-with-beforeunload.html: Added.
* http/tests/misc/resources/notify-done.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@152941 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Pagination: Do not paint the baseBackgroundColor if asked to skipRootBackground.
https://bugs.webkit.org/show_bug.cgi?id=118933

Reviewed by Simon Fraser.

Captions rendered through TextTrackRepresentation are rendered with a background
color when in paginated views. Do not fill the paint area with the
baseBackgroundColor when the paint flags include SkipRootBackground.

* rendering/RenderView.cpp:
(WebCore::RenderView::paint):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@152943 268f45cc-cd09-0410-ab3c-d52691b4dbfc