<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[192270] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/192270">192270</a></dd>
<dt>Author</dt> <dd>ggaren@apple.com</dd>
<dt>Date</dt> <dd>2015-11-10 14:19:44 -0800 (Tue, 10 Nov 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>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 &quot;everything is permitted&quot; -- 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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestscompositingiframespagecachelayertreeexpectedtxt">trunk/LayoutTests/compositing/iframes/page-cache-layer-tree-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomGeolocationnotimerafterunloadexpectedtxt">trunk/LayoutTests/fast/dom/Geolocation/notimer-after-unload-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventsonunloadexpectedtxt">trunk/LayoutTests/fast/events/onunload-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventsonunloadnotonbodyexpectedtxt">trunk/LayoutTests/fast/events/onunload-not-on-body-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventsonunloadwindowpropertyexpectedtxt">trunk/LayoutTests/fast/events/onunload-window-property-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventspageshowpagehideonbackcachedexpectedtxt">trunk/LayoutTests/fast/events/pageshow-pagehide-on-back-cached-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventspageshowpagehideonbackuncachedexpectedtxt">trunk/LayoutTests/fast/events/pageshow-pagehide-on-back-uncached-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasthistorytimedrefreshincachedframeexpectedtxt">trunk/LayoutTests/fast/history/timed-refresh-in-cached-frame-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastloaderframeswithunloadhandlersinpagecacheexpectedtxt">trunk/LayoutTests/fast/loader/frames-with-unload-handlers-in-page-cache-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastloaderpagedismissalmodaldialogsexpectedtxt">trunk/LayoutTests/fast/loader/page-dismissal-modal-dialogs-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformwk2TestExpectations">trunk/LayoutTests/platform/wk2/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoadercpp">trunk/Source/WebCore/loader/FrameLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoaderh">trunk/Source/WebCore/loader/FrameLoader.h</a></li>
<li><a href="#trunkSourceWebCorepageDOMWindowcpp">trunk/Source/WebCore/page/DOMWindow.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePagecpp">trunk/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePageh">trunk/Source/WebCore/page/Page.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasteventsbeforeunloadalertexpectedtxt">trunk/LayoutTests/fast/events/beforeunload-alert-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventsbeforeunloadalerthtml">trunk/LayoutTests/fast/events/beforeunload-alert.html</a></li>
<li><a href="#trunkLayoutTestsfasteventsbeforeunloadconfirmexpectedtxt">trunk/LayoutTests/fast/events/beforeunload-confirm-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventsbeforeunloadconfirmhtml">trunk/LayoutTests/fast/events/beforeunload-confirm.html</a></li>
<li><a href="#trunkLayoutTestsfasteventsbeforeunloadpromptexpectedtxt">trunk/LayoutTests/fast/events/beforeunload-prompt-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventsbeforeunloadprompthtml">trunk/LayoutTests/fast/events/beforeunload-prompt.html</a></li>
<li><a href="#trunkLayoutTestsfasteventsbeforeunloadshowModalDialogexpectedtxt">trunk/LayoutTests/fast/events/beforeunload-showModalDialog-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventsbeforeunloadshowModalDialoghtml">trunk/LayoutTests/fast/events/beforeunload-showModalDialog.html</a></li>
<li><a href="#trunkLayoutTestsfasteventspagehidealertexpectedtxt">trunk/LayoutTests/fast/events/pagehide-alert-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventspagehidealerthtml">trunk/LayoutTests/fast/events/pagehide-alert.html</a></li>
<li><a href="#trunkLayoutTestsfasteventspagehideconfirmexpectedtxt">trunk/LayoutTests/fast/events/pagehide-confirm-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventspagehideconfirmhtml">trunk/LayoutTests/fast/events/pagehide-confirm.html</a></li>
<li><a href="#trunkLayoutTestsfasteventspagehidepromptexpectedtxt">trunk/LayoutTests/fast/events/pagehide-prompt-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventspagehideprompthtml">trunk/LayoutTests/fast/events/pagehide-prompt.html</a></li>
<li><a href="#trunkLayoutTestsfasteventspagehideshowModalDialogexpectedtxt">trunk/LayoutTests/fast/events/pagehide-showModalDialog-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventspagehideshowModalDialoghtml">trunk/LayoutTests/fast/events/pagehide-showModalDialog.html</a></li>
<li><a href="#trunkLayoutTestsfasteventsresourcespromptlandingpagehtml">trunk/LayoutTests/fast/events/resources/prompt-landing-page.html</a></li>
<li><a href="#trunkLayoutTestsfasteventsunloadalertexpectedtxt">trunk/LayoutTests/fast/events/unload-alert-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventsunloadalerthtml">trunk/LayoutTests/fast/events/unload-alert.html</a></li>
<li><a href="#trunkLayoutTestsfasteventsunloadconfirmexpectedtxt">trunk/LayoutTests/fast/events/unload-confirm-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventsunloadconfirmhtml">trunk/LayoutTests/fast/events/unload-confirm.html</a></li>
<li><a href="#trunkLayoutTestsfasteventsunloadpromptexpectedtxt">trunk/LayoutTests/fast/events/unload-prompt-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventsunloadprompthtml">trunk/LayoutTests/fast/events/unload-prompt.html</a></li>
<li><a href="#trunkLayoutTestsfasteventsunloadshowModalDialogexpectedtxt">trunk/LayoutTests/fast/events/unload-showModalDialog-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventsunloadshowModalDialoghtml">trunk/LayoutTests/fast/events/unload-showModalDialog.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (192269 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-11-10 22:04:34 UTC (rev 192269)
+++ trunk/LayoutTests/ChangeLog        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -1,3 +1,52 @@
</span><ins>+2015-11-10  Geoffrey Garen  &lt;ggaren@apple.com&gt;
+
+        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.
+
+        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.
+
</ins><span class="cx"> 2015-11-09  David Hyatt  &lt;hyatt@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         tate-chu-yoko should shrink to fit when it exceeds the available width.
</span></span></pre></div>
<a id="trunkLayoutTestscompositingiframespagecachelayertreeexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/compositing/iframes/page-cache-layer-tree-expected.txt (192269 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/iframes/page-cache-layer-tree-expected.txt        2015-11-10 22:04:34 UTC (rev 192269)
+++ trunk/LayoutTests/compositing/iframes/page-cache-layer-tree-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> ALERT: pageshow - not from cache
</span><del>-ALERT: pagehide - entering cache
</del><ins>+CONSOLE MESSAGE: line 70: Use of window.alert is not allowed while unloading a page.
</ins><span class="cx"> ALERT: pageshow - from cache
</span><span class="cx"> This tests that layers are rebuilt properly after the page is restored from the page cache.
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomGeolocationnotimerafterunloadexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/Geolocation/notimer-after-unload-expected.txt (192269 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Geolocation/notimer-after-unload-expected.txt        2015-11-10 22:04:34 UTC (rev 192269)
+++ trunk/LayoutTests/fast/dom/Geolocation/notimer-after-unload-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -1,3 +1,3 @@
</span><span class="cx"> main frame - has 1 onunload handler(s)
</span><del>-ALERT: unload-called
</del><ins>+CONSOLE MESSAGE: line 15: Use of window.alert is not allowed while unloading a page.
</ins><span class="cx"> You should have seen one unload alert appear.
</span></span></pre></div>
<a id="trunkLayoutTestsfasteventsbeforeunloadalertexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/beforeunload-alert-expected.txt (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/beforeunload-alert-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/events/beforeunload-alert-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+CONSOLE MESSAGE: line 8: Use of window.alert is not allowed while unloading a page.
+This test verifies that prompts are forbidden when leaving a webpage.
+
+Prompts include alert, confirm, prompt, and showModalDialog.
+
+If there is no prompt, the test passed.
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsbeforeunloadalerthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/beforeunload-alert.html (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/beforeunload-alert.html                                (rev 0)
+++ trunk/LayoutTests/fast/events/beforeunload-alert.html        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;script&gt;
+if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+}
+
+window.onbeforeunload = function() {
+        alert(&quot;FAIL: This prompt should have been ignored.&quot;);
+}
+
+setTimeout(function() { window.location = &quot;resources/prompt-landing-page.html&quot; }, 0);
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsbeforeunloadconfirmexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/beforeunload-confirm-expected.txt (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/beforeunload-confirm-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/events/beforeunload-confirm-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+CONSOLE MESSAGE: line 8: Use of window.confirm is not allowed while unloading a page.
+This test verifies that prompts are forbidden when leaving a webpage.
+
+Prompts include alert, confirm, prompt, and showModalDialog.
+
+If there is no prompt, the test passed.
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsbeforeunloadconfirmhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/beforeunload-confirm.html (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/beforeunload-confirm.html                                (rev 0)
+++ trunk/LayoutTests/fast/events/beforeunload-confirm.html        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;script&gt;
+if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+}
+
+window.onbeforeunload = function() {
+        confirm(&quot;FAIL: This prompt should have been ignored.&quot;);
+}
+
+setTimeout(function() { window.location = &quot;resources/prompt-landing-page.html&quot; }, 0);
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsbeforeunloadpromptexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/beforeunload-prompt-expected.txt (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/beforeunload-prompt-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/events/beforeunload-prompt-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+CONSOLE MESSAGE: line 8: Use of window.prompt is not allowed while unloading a page.
+This test verifies that prompts are forbidden when leaving a webpage.
+
+Prompts include alert, confirm, prompt, and showModalDialog.
+
+If there is no prompt, the test passed.
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsbeforeunloadprompthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/beforeunload-prompt.html (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/beforeunload-prompt.html                                (rev 0)
+++ trunk/LayoutTests/fast/events/beforeunload-prompt.html        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;script&gt;
+if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+}
+
+window.onbeforeunload = function() {
+        prompt(&quot;FAIL: This prompt should have been ignored.&quot;);
+}
+
+setTimeout(function() { window.location = &quot;resources/prompt-landing-page.html&quot; }, 0);
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsbeforeunloadshowModalDialogexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/beforeunload-showModalDialog-expected.txt (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/beforeunload-showModalDialog-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/events/beforeunload-showModalDialog-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+CONSOLE MESSAGE: line 14: Use of window.showModalDialog is not allowed while unloading a page.
+This test verifies that prompts are forbidden when leaving a webpage.
+
+Prompts include alert, confirm, prompt, and showModalDialog.
+
+If there is no prompt, the test passed.
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsbeforeunloadshowModalDialoghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/beforeunload-showModalDialog.html (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/beforeunload-showModalDialog.html                                (rev 0)
+++ trunk/LayoutTests/fast/events/beforeunload-showModalDialog.html        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+&lt;script&gt;
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.setCanOpenWindows();
+    testRunner.waitUntilDone();
+}
+
+function log()
+{
+        alert(&quot;FAIL: This prompt should have been ignored.&quot;);
+}
+
+window.onbeforeunload = function() {
+        showModalDialog(&quot;resources/modal-dialog.html&quot;);
+}
+
+setTimeout(function() { window.location = &quot;resources/prompt-landing-page.html&quot; }, 0);
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsonunloadexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/events/onunload-expected.txt (192269 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/onunload-expected.txt        2015-11-10 22:04:34 UTC (rev 192269)
+++ trunk/LayoutTests/fast/events/onunload-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -1,3 +1,3 @@
</span><span class="cx"> main frame - has 1 onunload handler(s)
</span><del>-ALERT: unload
</del><ins>+CONSOLE MESSAGE: line 16: Use of window.alert is not allowed while unloading a page.
</ins><span class="cx"> You should have seen an unload alert appear.
</span></span></pre></div>
<a id="trunkLayoutTestsfasteventsonunloadnotonbodyexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/events/onunload-not-on-body-expected.txt (192269 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/onunload-not-on-body-expected.txt        2015-11-10 22:04:34 UTC (rev 192269)
+++ trunk/LayoutTests/fast/events/onunload-not-on-body-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -1,3 +1,3 @@
</span><span class="cx"> frame &quot;&lt;!--framePath //&lt;!--frame2--&gt;--&gt;&quot; - has 1 onunload handler(s)
</span><del>-ALERT: unload
</del><ins>+CONSOLE MESSAGE: line 1: Use of window.alert is not allowed while unloading a page.
</ins><span class="cx"> you should only see one unload alert appear.
</span></span></pre></div>
<a id="trunkLayoutTestsfasteventsonunloadwindowpropertyexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/events/onunload-window-property-expected.txt (192269 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/onunload-window-property-expected.txt        2015-11-10 22:04:34 UTC (rev 192269)
+++ trunk/LayoutTests/fast/events/onunload-window-property-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -1,2 +1,2 @@
</span><del>-ALERT: unload
</del><ins>+CONSOLE MESSAGE: line 13: Use of window.alert is not allowed while unloading a page.
</ins><span class="cx"> You should have seen an unload alert appear.
</span></span></pre></div>
<a id="trunkLayoutTestsfasteventspagehidealertexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/pagehide-alert-expected.txt (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/pagehide-alert-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/events/pagehide-alert-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+CONSOLE MESSAGE: line 8: Use of window.alert is not allowed while unloading a page.
+This test verifies that prompts are forbidden when leaving a webpage.
+
+Prompts include alert, confirm, prompt, and showModalDialog.
+
+If there is no prompt, the test passed.
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventspagehidealerthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/pagehide-alert.html (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/pagehide-alert.html                                (rev 0)
+++ trunk/LayoutTests/fast/events/pagehide-alert.html        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;script&gt;
+if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+}
+
+window.onpagehide = function() {
+        alert(&quot;FAIL: This prompt should have been ignored.&quot;);
+}
+
+setTimeout(function() { window.location = &quot;resources/prompt-landing-page.html&quot; }, 0);
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventspagehideconfirmexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/pagehide-confirm-expected.txt (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/pagehide-confirm-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/events/pagehide-confirm-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+CONSOLE MESSAGE: line 8: Use of window.confirm is not allowed while unloading a page.
+This test verifies that prompts are forbidden when leaving a webpage.
+
+Prompts include alert, confirm, prompt, and showModalDialog.
+
+If there is no prompt, the test passed.
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventspagehideconfirmhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/pagehide-confirm.html (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/pagehide-confirm.html                                (rev 0)
+++ trunk/LayoutTests/fast/events/pagehide-confirm.html        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;script&gt;
+if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+}
+
+window.onpagehide = function() {
+        confirm(&quot;FAIL: This prompt should have been ignored.&quot;);
+}
+
+setTimeout(function() { window.location = &quot;resources/prompt-landing-page.html&quot; }, 0);
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventspagehidepromptexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/pagehide-prompt-expected.txt (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/pagehide-prompt-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/events/pagehide-prompt-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+CONSOLE MESSAGE: line 8: Use of window.prompt is not allowed while unloading a page.
+This test verifies that prompts are forbidden when leaving a webpage.
+
+Prompts include alert, confirm, prompt, and showModalDialog.
+
+If there is no prompt, the test passed.
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventspagehideprompthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/pagehide-prompt.html (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/pagehide-prompt.html                                (rev 0)
+++ trunk/LayoutTests/fast/events/pagehide-prompt.html        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;script&gt;
+if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+}
+
+window.onpagehide = function() {
+        prompt(&quot;FAIL: This prompt should have been ignored.&quot;);
+}
+
+setTimeout(function() { window.location = &quot;resources/prompt-landing-page.html&quot; }, 0);
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventspagehideshowModalDialogexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/pagehide-showModalDialog-expected.txt (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/pagehide-showModalDialog-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/events/pagehide-showModalDialog-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+CONSOLE MESSAGE: line 14: Use of window.showModalDialog is not allowed while unloading a page.
+This test verifies that prompts are forbidden when leaving a webpage.
+
+Prompts include alert, confirm, prompt, and showModalDialog.
+
+If there is no prompt, the test passed.
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventspagehideshowModalDialoghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/pagehide-showModalDialog.html (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/pagehide-showModalDialog.html                                (rev 0)
+++ trunk/LayoutTests/fast/events/pagehide-showModalDialog.html        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+&lt;script&gt;
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.setCanOpenWindows();
+    testRunner.waitUntilDone();
+}
+
+function log()
+{
+        alert(&quot;FAIL: This prompt should have been ignored.&quot;);
+}
+
+window.onpagehide = function() {
+        showModalDialog(&quot;resources/modal-dialog.html&quot;);
+}
+
+setTimeout(function() { window.location = &quot;resources/prompt-landing-page.html&quot; }, 0);
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventspageshowpagehideonbackcachedexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/events/pageshow-pagehide-on-back-cached-expected.txt (192269 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/pageshow-pagehide-on-back-cached-expected.txt        2015-11-10 22:04:34 UTC (rev 192269)
+++ trunk/LayoutTests/fast/events/pageshow-pagehide-on-back-cached-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> ALERT: window.onload
</span><span class="cx"> ALERT: window.onpageshow, target = [object HTMLDocument], persisted = false
</span><del>-ALERT: window.onpagehide, target = [object HTMLDocument], persisted = true
</del><ins>+CONSOLE MESSAGE: line 25: Use of window.alert is not allowed while unloading a page.
</ins><span class="cx"> ALERT: window.onpageshow, target = [object HTMLDocument], persisted = true
</span><span class="cx"> Test pageshow/pagehide event behavior when navigating back to an cached page.
</span></span></pre></div>
<a id="trunkLayoutTestsfasteventspageshowpagehideonbackuncachedexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/events/pageshow-pagehide-on-back-uncached-expected.txt (192269 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/pageshow-pagehide-on-back-uncached-expected.txt        2015-11-10 22:04:34 UTC (rev 192269)
+++ trunk/LayoutTests/fast/events/pageshow-pagehide-on-back-uncached-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> main frame - has 1 onunload handler(s)
</span><span class="cx"> ALERT: window.onload
</span><span class="cx"> ALERT: window.onpageshow, target = [object HTMLDocument], persisted = false
</span><del>-ALERT: window.onpagehide, target = [object HTMLDocument], persisted = false
</del><ins>+CONSOLE MESSAGE: line 28: Use of window.alert is not allowed while unloading a page.
</ins><span class="cx"> main frame &quot;pageshow/pagehide&quot; - has 1 onunload handler(s)
</span><span class="cx"> ALERT: window.onload
</span><span class="cx"> ALERT: window.onpageshow, target = [object HTMLDocument], persisted = false
</span></span></pre></div>
<a id="trunkLayoutTestsfasteventsresourcespromptlandingpagehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/resources/prompt-landing-page.html (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/resources/prompt-landing-page.html                                (rev 0)
+++ trunk/LayoutTests/fast/events/resources/prompt-landing-page.html        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;p&gt;This test verifies that prompts are forbidden when leaving a webpage.&lt;/p&gt;
+
+&lt;p&gt;Prompts include alert, confirm, prompt, and showModalDialog.&lt;/p&gt;
+
+&lt;p&gt;If there is no prompt, the test passed.&lt;/p&gt;
+
+&lt;script&gt;
+if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.notifyDone();
+}
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsunloadalertexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/unload-alert-expected.txt (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/unload-alert-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/events/unload-alert-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+main frame - has 1 onunload handler(s)
+CONSOLE MESSAGE: line 8: Use of window.alert is not allowed while unloading a page.
+This test verifies that prompts are forbidden when leaving a webpage.
+
+Prompts include alert, confirm, prompt, and showModalDialog.
+
+If there is no prompt, the test passed.
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsunloadalerthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/unload-alert.html (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/unload-alert.html                                (rev 0)
+++ trunk/LayoutTests/fast/events/unload-alert.html        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;script&gt;
+if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+}
+
+window.onunload = function() {
+        alert(&quot;FAIL: This prompt should have been ignored.&quot;);
+}
+
+setTimeout(function() { window.location = &quot;resources/prompt-landing-page.html&quot; }, 0);
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsunloadconfirmexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/unload-confirm-expected.txt (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/unload-confirm-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/events/unload-confirm-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+main frame - has 1 onunload handler(s)
+CONSOLE MESSAGE: line 8: Use of window.confirm is not allowed while unloading a page.
+This test verifies that prompts are forbidden when leaving a webpage.
+
+Prompts include alert, confirm, prompt, and showModalDialog.
+
+If there is no prompt, the test passed.
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsunloadconfirmhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/unload-confirm.html (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/unload-confirm.html                                (rev 0)
+++ trunk/LayoutTests/fast/events/unload-confirm.html        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;script&gt;
+if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+}
+
+window.onunload = function() {
+        confirm(&quot;FAIL: This prompt should have been ignored.&quot;);
+}
+
+setTimeout(function() { window.location = &quot;resources/prompt-landing-page.html&quot; }, 0);
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsunloadpromptexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/unload-prompt-expected.txt (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/unload-prompt-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/events/unload-prompt-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+main frame - has 1 onunload handler(s)
+CONSOLE MESSAGE: line 8: Use of window.prompt is not allowed while unloading a page.
+This test verifies that prompts are forbidden when leaving a webpage.
+
+Prompts include alert, confirm, prompt, and showModalDialog.
+
+If there is no prompt, the test passed.
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsunloadprompthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/unload-prompt.html (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/unload-prompt.html                                (rev 0)
+++ trunk/LayoutTests/fast/events/unload-prompt.html        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;script&gt;
+if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+}
+
+window.onunload = function() {
+        prompt(&quot;FAIL: This prompt should have been ignored.&quot;);
+}
+
+setTimeout(function() { window.location = &quot;resources/prompt-landing-page.html&quot; }, 0);
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsunloadshowModalDialogexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/unload-showModalDialog-expected.txt (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/unload-showModalDialog-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/events/unload-showModalDialog-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+main frame - has 1 onunload handler(s)
+CONSOLE MESSAGE: line 14: Use of window.showModalDialog is not allowed while unloading a page.
+This test verifies that prompts are forbidden when leaving a webpage.
+
+Prompts include alert, confirm, prompt, and showModalDialog.
+
+If there is no prompt, the test passed.
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsunloadshowModalDialoghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/unload-showModalDialog.html (0 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/unload-showModalDialog.html                                (rev 0)
+++ trunk/LayoutTests/fast/events/unload-showModalDialog.html        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+&lt;script&gt;
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.setCanOpenWindows();
+    testRunner.waitUntilDone();
+}
+
+function log()
+{
+        alert(&quot;FAIL: This prompt should have been ignored.&quot;);
+}
+
+window.onunload = function() {
+        showModalDialog(&quot;resources/modal-dialog.html&quot;);
+}
+
+setTimeout(function() { window.location = &quot;resources/prompt-landing-page.html&quot; }, 0);
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthistorytimedrefreshincachedframeexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/history/timed-refresh-in-cached-frame-expected.txt (192269 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/history/timed-refresh-in-cached-frame-expected.txt        2015-11-10 22:04:34 UTC (rev 192269)
+++ trunk/LayoutTests/fast/history/timed-refresh-in-cached-frame-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -1,2 +1,2 @@
</span><del>-ALERT: pagehide true
</del><ins>+CONSOLE MESSAGE: line 1: Use of window.alert is not allowed while unloading a page.
</ins><span class="cx"> PASSED if didn't crash in two seconds.
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderframeswithunloadhandlersinpagecacheexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/frames-with-unload-handlers-in-page-cache-expected.txt (192269 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/frames-with-unload-handlers-in-page-cache-expected.txt        2015-11-10 22:04:34 UTC (rev 192269)
+++ trunk/LayoutTests/fast/loader/frames-with-unload-handlers-in-page-cache-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> frame &quot;&lt;!--framePath //&lt;!--frame0--&gt;/&lt;!--frame0--&gt;--&gt;&quot; - has 1 onunload handler(s)
</span><span class="cx"> ALERT: Subframe onload
</span><span class="cx"> ALERT: Subframe onpageshow
</span><del>-ALERT: Main frame window.onpagehide called
-ALERT: Subframe onpagehide
-ALERT: Subframe onunload
</del><ins>+CONSOLE MESSAGE: line 16: Use of window.alert is not allowed while unloading a page.
+CONSOLE MESSAGE: line 18: Use of window.alert is not allowed while unloading a page.
+CONSOLE MESSAGE: line 10: Use of window.alert is not allowed while unloading a page.
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderpagedismissalmodaldialogsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/page-dismissal-modal-dialogs-expected.txt (192269 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/page-dismissal-modal-dialogs-expected.txt        2015-11-10 22:04:34 UTC (rev 192269)
+++ trunk/LayoutTests/fast/loader/page-dismissal-modal-dialogs-expected.txt        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -1,32 +1,32 @@
</span><span class="cx"> frame &quot;&lt;!--framePath //&lt;!--frame0--&gt;--&gt;&quot; - has 1 onunload handler(s)
</span><del>-CONSOLE MESSAGE: line 8: Use of window.alert is not allowed during beforeunload event dispatch.
-CONSOLE MESSAGE: line 9: Use of window.confirm is not allowed during beforeunload event dispatch.
-CONSOLE MESSAGE: line 10: Use of window.prompt is not allowed during beforeunload event dispatch.
-CONSOLE MESSAGE: line 8: Use of window.alert is not allowed during beforeunload event dispatch.
-CONSOLE MESSAGE: line 9: Use of window.confirm is not allowed during beforeunload event dispatch.
-CONSOLE MESSAGE: line 10: Use of window.prompt is not allowed during beforeunload event dispatch.
-CONSOLE MESSAGE: line 8: Use of window.alert is not allowed during beforeunload event dispatch.
-CONSOLE MESSAGE: line 9: Use of window.confirm is not allowed during beforeunload event dispatch.
-CONSOLE MESSAGE: line 10: Use of window.prompt is not allowed during beforeunload event dispatch.
-CONSOLE MESSAGE: line 8: Use of window.alert is not allowed during beforeunload event dispatch.
-CONSOLE MESSAGE: line 9: Use of window.confirm is not allowed during beforeunload event dispatch.
-CONSOLE MESSAGE: line 10: Use of window.prompt is not allowed during beforeunload event dispatch.
-ALERT: mainFrame pagehide PASS
-CONFIRM: mainFrame pagehide PASS
-PROMPT: mainFrame pagehide PASS, default text: PASS
-ALERT: iFrame click PASS
-CONFIRM: iFrame click PASS
-PROMPT: iFrame click PASS, default text: PASS
-ALERT: mainFrame unload PASS
-CONFIRM: mainFrame unload PASS
-PROMPT: mainFrame unload PASS, default text: PASS
-ALERT: iFrame click PASS
-CONFIRM: iFrame click PASS
-PROMPT: iFrame click PASS, default text: PASS
-ALERT: iFrame pagehide PASS
-CONFIRM: iFrame pagehide PASS
-PROMPT: iFrame pagehide PASS, default text: PASS
-ALERT: iFrame unload PASS
-CONFIRM: iFrame unload PASS
-PROMPT: iFrame unload PASS, default text: PASS
</del><ins>+CONSOLE MESSAGE: line 8: Use of window.alert is not allowed while unloading a page.
+CONSOLE MESSAGE: line 9: Use of window.confirm is not allowed while unloading a page.
+CONSOLE MESSAGE: line 10: Use of window.prompt is not allowed while unloading a page.
+CONSOLE MESSAGE: line 8: Use of window.alert is not allowed while unloading a page.
+CONSOLE MESSAGE: line 9: Use of window.confirm is not allowed while unloading a page.
+CONSOLE MESSAGE: line 10: Use of window.prompt is not allowed while unloading a page.
+CONSOLE MESSAGE: line 8: Use of window.alert is not allowed while unloading a page.
+CONSOLE MESSAGE: line 9: Use of window.confirm is not allowed while unloading a page.
+CONSOLE MESSAGE: line 10: Use of window.prompt is not allowed while unloading a page.
+CONSOLE MESSAGE: line 8: Use of window.alert is not allowed while unloading a page.
+CONSOLE MESSAGE: line 9: Use of window.confirm is not allowed while unloading a page.
+CONSOLE MESSAGE: line 10: Use of window.prompt is not allowed while unloading a page.
+CONSOLE MESSAGE: line 8: Use of window.alert is not allowed while unloading a page.
+CONSOLE MESSAGE: line 9: Use of window.confirm is not allowed while unloading a page.
+CONSOLE MESSAGE: line 10: Use of window.prompt is not allowed while unloading a page.
+CONSOLE MESSAGE: line 8: Use of window.alert is not allowed while unloading a page.
+CONSOLE MESSAGE: line 9: Use of window.confirm is not allowed while unloading a page.
+CONSOLE MESSAGE: line 10: Use of window.prompt is not allowed while unloading a page.
+CONSOLE MESSAGE: line 8: Use of window.alert is not allowed while unloading a page.
+CONSOLE MESSAGE: line 9: Use of window.confirm is not allowed while unloading a page.
+CONSOLE MESSAGE: line 10: Use of window.prompt is not allowed while unloading a page.
+CONSOLE MESSAGE: line 8: Use of window.alert is not allowed while unloading a page.
+CONSOLE MESSAGE: line 9: Use of window.confirm is not allowed while unloading a page.
+CONSOLE MESSAGE: line 10: Use of window.prompt is not allowed while unloading a page.
+CONSOLE MESSAGE: line 8: Use of window.alert is not allowed while unloading a page.
+CONSOLE MESSAGE: line 9: Use of window.confirm is not allowed while unloading a page.
+CONSOLE MESSAGE: line 10: Use of window.prompt is not allowed while unloading a page.
+CONSOLE MESSAGE: line 8: Use of window.alert is not allowed while unloading a page.
+CONSOLE MESSAGE: line 9: Use of window.confirm is not allowed while unloading a page.
+CONSOLE MESSAGE: line 10: Use of window.prompt is not allowed while unloading a page.
</ins><span class="cx"> PASS
</span></span></pre></div>
<a id="trunkLayoutTestsplatformwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/wk2/TestExpectations (192269 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/wk2/TestExpectations        2015-11-10 22:04:34 UTC (rev 192269)
+++ trunk/LayoutTests/platform/wk2/TestExpectations        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -138,6 +138,9 @@
</span><span class="cx"> # WebKitTestRunner needs testRunner.abortModal
</span><span class="cx"> # &lt;https://bugs.webkit.org/show_bug.cgi?id=69548&gt;
</span><span class="cx"> fast/events/show-modal-dialog-onblur-onfocus.html
</span><ins>+fast/events/beforeunload-showModalDialog.html
+fast/events/pagehide-showModalDialog.html
+fast/events/unload-showModalDialog.html
</ins><span class="cx"> 
</span><span class="cx"> # WebKitTestRunner needs testRunner.setWillSendRequestClearHeader
</span><span class="cx"> # &lt;https://bugs.webkit.org/show_bug.cgi?id=42699&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (192269 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-11-10 22:04:34 UTC (rev 192269)
+++ trunk/Source/WebCore/ChangeLog        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -1,3 +1,58 @@
</span><ins>+2015-11-10  Geoffrey Garen  &lt;ggaren@apple.com&gt;
+
+        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.
+
+        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 &quot;everything is permitted&quot; -- 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:
+
</ins><span class="cx"> 2015-11-09  David Hyatt  &lt;hyatt@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         tate-chu-yoko should shrink to fit when it exceeds the available width.
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (192269 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.cpp        2015-11-10 22:04:34 UTC (rev 192269)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -175,6 +175,24 @@
</span><span class="cx">     return frame.document() &amp;&amp; frame.document()-&gt;isSandboxed(mask);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+struct ForbidPromptsScope {
+    ForbidPromptsScope(Page* page) : m_page(page)
+    {
+        if (!m_page)
+            return;
+        m_page-&gt;forbidPrompts();
+    }
+
+    ~ForbidPromptsScope()
+    {
+        if (!m_page)
+            return;
+        m_page-&gt;allowPrompts();
+    }
+
+    Page* m_page;
+};
+
</ins><span class="cx"> class FrameLoader::FrameProgressTracker {
</span><span class="cx"> public:
</span><span class="cx">     explicit FrameProgressTracker(Frame&amp; frame)
</span><span class="lines">@@ -418,55 +436,9 @@
</span><span class="cx">     if (m_frame.document() &amp;&amp; m_frame.document()-&gt;parser())
</span><span class="cx">         m_frame.document()-&gt;parser()-&gt;stopParsing();
</span><span class="cx"> 
</span><del>-    if (unloadEventPolicy != UnloadEventPolicyNone) {
-        if (m_frame.document()) {
-            if (m_didCallImplicitClose &amp;&amp; !m_wasUnloadEventEmitted) {
-                auto* currentFocusedElement = m_frame.document()-&gt;focusedElement();
-                if (is&lt;HTMLInputElement&gt;(currentFocusedElement))
-                    downcast&lt;HTMLInputElement&gt;(*currentFocusedElement).endEditing();
-                if (m_pageDismissalEventBeingDispatched == PageDismissalType::None) {
-                    if (unloadEventPolicy == UnloadEventPolicyUnloadAndPageHide) {
-                        m_pageDismissalEventBeingDispatched = PageDismissalType::PageHide;
-                        m_frame.document()-&gt;domWindow()-&gt;dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, m_frame.document()-&gt;inPageCache()), m_frame.document());
-                    }
</del><ins>+    if (unloadEventPolicy != UnloadEventPolicyNone)
+        handleUnloadEvents(unloadEventPolicy);
</ins><span class="cx"> 
</span><del>-                    // FIXME: update Page Visibility state here.
-                    // https://bugs.webkit.org/show_bug.cgi?id=116770
-
-                    if (!m_frame.document()-&gt;inPageCache()) {
-                        RefPtr&lt;Event&gt; unloadEvent(Event::create(eventNames().unloadEvent, false, false));
-                        // The DocumentLoader (and thus its DocumentLoadTiming) might get destroyed
-                        // while dispatching the event, so protect it to prevent writing the end
-                        // time into freed memory.
-                        RefPtr&lt;DocumentLoader&gt; documentLoader = m_provisionalDocumentLoader;
-                        m_pageDismissalEventBeingDispatched = PageDismissalType::Unload;
-                        if (documentLoader &amp;&amp; documentLoader-&gt;timing().navigationStart() &amp;&amp; !documentLoader-&gt;timing().unloadEventStart() &amp;&amp; !documentLoader-&gt;timing().unloadEventEnd()) {
-                            auto&amp; timing = documentLoader-&gt;timing();
-                            timing.markUnloadEventStart();
-                            m_frame.document()-&gt;domWindow()-&gt;dispatchEvent(unloadEvent, m_frame.document());
-                            timing.markUnloadEventEnd();
-                        } else
-                            m_frame.document()-&gt;domWindow()-&gt;dispatchEvent(unloadEvent, m_frame.document());
-                    }
-                }
-                m_pageDismissalEventBeingDispatched = PageDismissalType::None;
-                if (m_frame.document())
-                    m_frame.document()-&gt;updateStyleIfNeeded();
-                m_wasUnloadEventEmitted = true;
-            }
-        }
-
-        // Dispatching the unload event could have made m_frame.document() null.
-        if (m_frame.document() &amp;&amp; !m_frame.document()-&gt;inPageCache()) {
-            // Don't remove event listeners from a transitional empty document (see bug 28716 for more information).
-            bool keepEventListeners = m_stateMachine.isDisplayingInitialEmptyDocument() &amp;&amp; m_provisionalDocumentLoader
-                &amp;&amp; m_frame.document()-&gt;isSecureTransitionTo(m_provisionalDocumentLoader-&gt;url());
-
-            if (!keepEventListeners)
-                m_frame.document()-&gt;removeAllEventListeners();
-        }
-    }
-
</del><span class="cx">     m_isComplete = true; // to avoid calling completed() in finishedParsing()
</span><span class="cx">     m_didCallImplicitClose = true; // don't want that one either
</span><span class="cx"> 
</span><span class="lines">@@ -2865,6 +2837,64 @@
</span><span class="cx">     return shouldClose;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FrameLoader::handleUnloadEvents(UnloadEventPolicy unloadEventPolicy)
+{
+    if (!m_frame.document())
+        return;
+
+    // We store the frame's page in a local variable because the frame might get detached inside dispatchEvent.
+    ForbidPromptsScope forbidPrompts(m_frame.page());
+
+    if (m_didCallImplicitClose &amp;&amp; !m_wasUnloadEventEmitted) {
+        auto* currentFocusedElement = m_frame.document()-&gt;focusedElement();
+        if (is&lt;HTMLInputElement&gt;(currentFocusedElement))
+            downcast&lt;HTMLInputElement&gt;(*currentFocusedElement).endEditing();
+        if (m_pageDismissalEventBeingDispatched == PageDismissalType::None) {
+            if (unloadEventPolicy == UnloadEventPolicyUnloadAndPageHide) {
+                m_pageDismissalEventBeingDispatched = PageDismissalType::PageHide;
+                m_frame.document()-&gt;domWindow()-&gt;dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, m_frame.document()-&gt;inPageCache()), m_frame.document());
+            }
+
+            // FIXME: update Page Visibility state here.
+            // https://bugs.webkit.org/show_bug.cgi?id=116770
+
+            if (!m_frame.document()-&gt;inPageCache()) {
+                RefPtr&lt;Event&gt; unloadEvent(Event::create(eventNames().unloadEvent, false, false));
+                // The DocumentLoader (and thus its DocumentLoadTiming) might get destroyed
+                // while dispatching the event, so protect it to prevent writing the end
+                // time into freed memory.
+                RefPtr&lt;DocumentLoader&gt; documentLoader = m_provisionalDocumentLoader;
+                m_pageDismissalEventBeingDispatched = PageDismissalType::Unload;
+                if (documentLoader &amp;&amp; documentLoader-&gt;timing().navigationStart() &amp;&amp; !documentLoader-&gt;timing().unloadEventStart() &amp;&amp; !documentLoader-&gt;timing().unloadEventEnd()) {
+                    auto&amp; timing = documentLoader-&gt;timing();
+                    timing.markUnloadEventStart();
+                    m_frame.document()-&gt;domWindow()-&gt;dispatchEvent(unloadEvent, m_frame.document());
+                    timing.markUnloadEventEnd();
+                } else
+                    m_frame.document()-&gt;domWindow()-&gt;dispatchEvent(unloadEvent, m_frame.document());
+            }
+        }
+        m_pageDismissalEventBeingDispatched = PageDismissalType::None;
+        if (m_frame.document())
+            m_frame.document()-&gt;updateStyleIfNeeded();
+        m_wasUnloadEventEmitted = true;
+    }
+
+    // Dispatching the unload event could have made m_frame.document() null.
+    if (!m_frame.document())
+        return;
+
+    if (m_frame.document()-&gt;inPageCache())
+        return;
+
+    // Don't remove event listeners from a transitional empty document (see bug 28716 for more information).
+    bool keepEventListeners = m_stateMachine.isDisplayingInitialEmptyDocument() &amp;&amp; m_provisionalDocumentLoader
+        &amp;&amp; m_frame.document()-&gt;isSecureTransitionTo(m_provisionalDocumentLoader-&gt;url());
+
+    if (!keepEventListeners)
+        m_frame.document()-&gt;removeAllEventListeners();
+}
+
</ins><span class="cx"> bool FrameLoader::handleBeforeUnloadEvent(Chrome&amp; chrome, FrameLoader* frameLoaderBeingNavigated)
</span><span class="cx"> {
</span><span class="cx">     DOMWindow* domWindow = m_frame.document()-&gt;domWindow();
</span><span class="lines">@@ -2878,11 +2908,10 @@
</span><span class="cx">     RefPtr&lt;BeforeUnloadEvent&gt; beforeUnloadEvent = BeforeUnloadEvent::create();
</span><span class="cx">     m_pageDismissalEventBeingDispatched = PageDismissalType::BeforeUnload;
</span><span class="cx"> 
</span><del>-    // We store the frame's page in a local variable because the frame might get detached inside dispatchEvent.
-    Page* page = m_frame.page();
-    page-&gt;incrementFrameHandlingBeforeUnloadEventCount();
-    domWindow-&gt;dispatchEvent(beforeUnloadEvent.get(), domWindow-&gt;document());
-    page-&gt;decrementFrameHandlingBeforeUnloadEventCount();
</del><ins>+    {
+        ForbidPromptsScope forbidPrompts(m_frame.page());
+        domWindow-&gt;dispatchEvent(beforeUnloadEvent.get(), domWindow-&gt;document());
+    }
</ins><span class="cx"> 
</span><span class="cx">     m_pageDismissalEventBeingDispatched = PageDismissalType::None;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.h (192269 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.h        2015-11-10 22:04:34 UTC (rev 192269)
+++ trunk/Source/WebCore/loader/FrameLoader.h        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -321,6 +321,7 @@
</span><span class="cx">     SubstituteData defaultSubstituteDataForURL(const URL&amp;);
</span><span class="cx"> 
</span><span class="cx">     bool handleBeforeUnloadEvent(Chrome&amp;, FrameLoader* frameLoaderBeingNavigated);
</span><ins>+    void handleUnloadEvents(UnloadEventPolicy);
</ins><span class="cx"> 
</span><span class="cx">     void continueLoadAfterNavigationPolicy(const ResourceRequest&amp;, PassRefPtr&lt;FormState&gt;, bool shouldContinue, AllowNavigationToInvalidURL);
</span><span class="cx">     void continueLoadAfterNewWindowPolicy(const ResourceRequest&amp;, PassRefPtr&lt;FormState&gt;, const String&amp; frameName, const NavigationAction&amp;, bool shouldContinue, AllowNavigationToInvalidURL, NewFrameOpenerPolicy);
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMWindowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMWindow.cpp (192269 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DOMWindow.cpp        2015-11-10 22:04:34 UTC (rev 192269)
+++ trunk/Source/WebCore/page/DOMWindow.cpp        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -1047,13 +1047,12 @@
</span><span class="cx">     if (!m_frame)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    Page* page = m_frame-&gt;page();
</del><ins>+    auto* page = m_frame-&gt;page();
</ins><span class="cx">     if (!page)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    // Pages are not allowed to bring up a modal print dialog during BeforeUnload dispatch.
-    if (page-&gt;isAnyFrameHandlingBeforeUnloadEvent()) {
-        printErrorMessage(&quot;Use of window.print is not allowed during beforeunload event dispatch.&quot;);
</del><ins>+    if (!page-&gt;arePromptsAllowed()) {
+        printErrorMessage(&quot;Use of window.print is not allowed while unloading a page.&quot;);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1080,18 +1079,17 @@
</span><span class="cx">     if (!m_frame)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    // Pages are not allowed to cause modal alerts during BeforeUnload dispatch.
-    if (page() &amp;&amp; page()-&gt;isAnyFrameHandlingBeforeUnloadEvent()) {
-        printErrorMessage(&quot;Use of window.alert is not allowed during beforeunload event dispatch.&quot;);
</del><ins>+    auto* page = m_frame-&gt;page();
+    if (!page)
</ins><span class="cx">         return;
</span><ins>+
+    if (!page-&gt;arePromptsAllowed()) {
+        printErrorMessage(&quot;Use of window.alert is not allowed while unloading a page.&quot;);
+        return;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_frame-&gt;document()-&gt;updateStyleIfNeeded();
</span><span class="cx"> 
</span><del>-    Page* page = m_frame-&gt;page();
-    if (!page)
-        return;
-
</del><span class="cx">     page-&gt;chrome().runJavaScriptAlert(m_frame, message);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1100,18 +1098,17 @@
</span><span class="cx">     if (!m_frame)
</span><span class="cx">         return false;
</span><span class="cx">     
</span><del>-    // Pages are not allowed to cause modal alerts during BeforeUnload dispatch.
-    if (page() &amp;&amp; page()-&gt;isAnyFrameHandlingBeforeUnloadEvent()) {
-        printErrorMessage(&quot;Use of window.confirm is not allowed during beforeunload event dispatch.&quot;);
</del><ins>+    auto* page = m_frame-&gt;page();
+    if (!page)
</ins><span class="cx">         return false;
</span><ins>+
+    if (!page-&gt;arePromptsAllowed()) {
+        printErrorMessage(&quot;Use of window.confirm is not allowed while unloading a page.&quot;);
+        return false;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_frame-&gt;document()-&gt;updateStyleIfNeeded();
</span><span class="cx"> 
</span><del>-    Page* page = m_frame-&gt;page();
-    if (!page)
-        return false;
-
</del><span class="cx">     return page-&gt;chrome().runJavaScriptConfirm(m_frame, message);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1120,18 +1117,17 @@
</span><span class="cx">     if (!m_frame)
</span><span class="cx">         return String();
</span><span class="cx"> 
</span><del>-    // Pages are not allowed to cause modal alerts during BeforeUnload dispatch.
-    if (page() &amp;&amp; page()-&gt;isAnyFrameHandlingBeforeUnloadEvent()) {
-        printErrorMessage(&quot;Use of window.prompt is not allowed during beforeunload event dispatch.&quot;);
</del><ins>+    auto* page = m_frame-&gt;page();
+    if (!page)
</ins><span class="cx">         return String();
</span><ins>+
+    if (!page-&gt;arePromptsAllowed()) {
+        printErrorMessage(&quot;Use of window.prompt is not allowed while unloading a page.&quot;);
+        return String();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_frame-&gt;document()-&gt;updateStyleIfNeeded();
</span><span class="cx"> 
</span><del>-    Page* page = m_frame-&gt;page();
-    if (!page)
-        return String();
-
</del><span class="cx">     String returnValue;
</span><span class="cx">     if (page-&gt;chrome().runJavaScriptPrompt(m_frame, message, defaultValue, returnValue))
</span><span class="cx">         return returnValue;
</span><span class="lines">@@ -2237,10 +2233,13 @@
</span><span class="cx">     if (!firstFrame)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    // Pages are not allowed to cause modal alerts during BeforeUnload dispatch.
-    if (page() &amp;&amp; page()-&gt;isAnyFrameHandlingBeforeUnloadEvent()) {
-        printErrorMessage(&quot;Use of window.showModalDialog is not allowed during beforeunload event dispatch.&quot;);
</del><ins>+    auto* page = m_frame-&gt;page();
+    if (!page)
</ins><span class="cx">         return;
</span><ins>+
+    if (!page-&gt;arePromptsAllowed()) {
+        printErrorMessage(&quot;Use of window.showModalDialog is not allowed while unloading a page.&quot;);
+        return;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (!canShowModalDialogNow(m_frame) || !firstWindow.allowPopUp())
</span></span></pre></div>
<a id="trunkSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.cpp (192269 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.cpp        2015-11-10 22:04:34 UTC (rev 192269)
+++ trunk/Source/WebCore/page/Page.cpp        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -215,7 +215,7 @@
</span><span class="cx">     , m_inspectorDebuggable(std::make_unique&lt;PageDebuggable&gt;(*this))
</span><span class="cx"> #endif
</span><span class="cx">     , m_lastSpatialNavigationCandidatesCount(0) // NOTE: Only called from Internals for Spatial Navigation testing.
</span><del>-    , m_framesHandlingBeforeUnloadEvent(0)
</del><ins>+    , m_forbidPromptsDepth(0)
</ins><span class="cx">     , m_applicationCacheStorage(pageConfiguration.applicationCacheStorage ? *WTF::move(pageConfiguration.applicationCacheStorage) : ApplicationCacheStorage::singleton())
</span><span class="cx">     , m_databaseProvider(*WTF::move(pageConfiguration.databaseProvider))
</span><span class="cx">     , m_storageNamespaceProvider(*WTF::move(pageConfiguration.storageNamespaceProvider))
</span><span class="lines">@@ -1613,20 +1613,20 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void Page::incrementFrameHandlingBeforeUnloadEventCount()
</del><ins>+void Page::forbidPrompts()
</ins><span class="cx"> {
</span><del>-    ++m_framesHandlingBeforeUnloadEvent;
</del><ins>+    ++m_forbidPromptsDepth;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Page::decrementFrameHandlingBeforeUnloadEventCount()
</del><ins>+void Page::allowPrompts()
</ins><span class="cx"> {
</span><del>-    ASSERT(m_framesHandlingBeforeUnloadEvent);
-    --m_framesHandlingBeforeUnloadEvent;
</del><ins>+    ASSERT(m_forbidPromptsDepth);
+    --m_forbidPromptsDepth;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Page::isAnyFrameHandlingBeforeUnloadEvent()
</del><ins>+bool Page::arePromptsAllowed()
</ins><span class="cx"> {
</span><del>-    return m_framesHandlingBeforeUnloadEvent;
</del><ins>+    return !m_forbidPromptsDepth;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Page::setUserContentController(UserContentController* userContentController)
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.h (192269 => 192270)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.h        2015-11-10 22:04:34 UTC (rev 192269)
+++ trunk/Source/WebCore/page/Page.h        2015-11-10 22:19:44 UTC (rev 192270)
</span><span class="lines">@@ -423,9 +423,10 @@
</span><span class="cx">     void captionPreferencesChanged();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    void incrementFrameHandlingBeforeUnloadEventCount();
-    void decrementFrameHandlingBeforeUnloadEventCount();
-    bool isAnyFrameHandlingBeforeUnloadEvent();
</del><ins>+    void forbidPrompts();
+    void allowPrompts();
+    bool arePromptsAllowed();
+
</ins><span class="cx">     void setLastSpatialNavigationCandidateCount(unsigned count) { m_lastSpatialNavigationCandidatesCount = count; }
</span><span class="cx">     unsigned lastSpatialNavigationCandidateCount() const { return m_lastSpatialNavigationCandidatesCount; }
</span><span class="cx"> 
</span><span class="lines">@@ -631,7 +632,7 @@
</span><span class="cx">     HashSet&lt;String&gt; m_seenMediaEngines;
</span><span class="cx"> 
</span><span class="cx">     unsigned m_lastSpatialNavigationCandidatesCount;
</span><del>-    unsigned m_framesHandlingBeforeUnloadEvent;
</del><ins>+    unsigned m_forbidPromptsDepth;
</ins><span class="cx"> 
</span><span class="cx">     Ref&lt;ApplicationCacheStorage&gt; m_applicationCacheStorage;
</span><span class="cx">     Ref&lt;DatabaseProvider&gt; m_databaseProvider;
</span></span></pre>
</div>
</div>

</body>
</html>