<!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>[190505] 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/190505">190505</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-10-02 08:13:05 -0700 (Fri, 02 Oct 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>popstate is fired at the wrong time on load
https://bugs.webkit.org/show_bug.cgi?id=94265

Patch by Antoine Quint &lt;graouts@apple.com&gt; on 2015-10-02
Reviewed by Darin Adler.

Source/WebCore:

Don't fire popstate event on initial document load

According to the specification [1], a popstate event should only be fired
when the document has a &quot;last entry&quot; and the entry being navigated to isn't
it.  A document is created without a &quot;last entry&quot; and gets one just after
this check when it is first navigated to, so a popstate should be fired any
time a document is navigated to except for the first time after it has been
created.

Patch adapted from work by jl@opera.com on Blink [2].

[1] http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#traverse-the-history (step 12-14 in particular)
[2] https://src.chromium.org/viewvc/blink?revision=165221&amp;view=revision

* dom/Document.cpp:
(WebCore::Document::implicitClose):

Source/WebKit2:

Ensure we have a valid page before trying to get to its drawingArea as this could lead
to a crash as observed with fast/loader/stateobjects/pushstate-object-types.html.

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::restoreViewState):

LayoutTests:

Updating tests that relied on a &quot;popstate&quot; event being fired at page load.

* fast/history/same-document-iframes-changing-fragment-expected.txt:
* fast/history/same-document-iframes-changing-pushstate-expected.txt:
* fast/loader/javascript-url-iframe-remove-on-navigate.html:
* fast/loader/stateobjects/document-destroyed-navigate-back-with-fragment-scroll.html:
* fast/loader/stateobjects/document-destroyed-navigate-back.html:
* fast/loader/stateobjects/popstate-after-load-complete-addeventlistener.html:
* fast/loader/stateobjects/popstate-after-load-complete-body-attribute.html:
* fast/loader/stateobjects/popstate-after-load-complete-body-inline-attribute.html:
* fast/loader/stateobjects/popstate-after-load-complete-window-attribute.html:
* fast/loader/stateobjects/popstate-fires-on-history-traversal-expected.txt:
* fast/loader/stateobjects/popstate-fires-on-history-traversal.html:
* fast/loader/stateobjects/popstate-fires-with-page-cache-expected.txt:
* fast/loader/stateobjects/popstate-fires-with-page-cache.html:
* fast/loader/stateobjects/pushstate-object-types.html:
* fast/loader/stateobjects/pushstate-then-replacestate.html:
* fast/loader/stateobjects/pushstate-with-fragment-urls-and-hashchange.html:
* fast/loader/stateobjects/replacestate-then-pushstate.html:
* fast/loader/stateobjects/resources/popstate-fires-with-page-cache-1.html:
* fast/loader/stateobjects/resources/popstate-fires-with-page-cache-2.html:
* fast/loader/stateobjects/resources/replacestate-in-iframe-window-child.html:
* http/tests/history/popstate-fires-with-pending-requests.html:
* http/tests/navigation/redirect-on-back-updates-history-item-expected.txt:
* http/tests/navigation/redirect-on-reload-updates-history-item-expected.txt:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfasthistorysamedocumentiframeschangingfragmentexpectedtxt">trunk/LayoutTests/fast/history/same-document-iframes-changing-fragment-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasthistorysamedocumentiframeschangingpushstateexpectedtxt">trunk/LayoutTests/fast/history/same-document-iframes-changing-pushstate-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastloaderjavascripturliframeremoveonnavigatehtml">trunk/LayoutTests/fast/loader/javascript-url-iframe-remove-on-navigate.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectsdocumentdestroyednavigatebackwithfragmentscrollhtml">trunk/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back-with-fragment-scroll.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectsdocumentdestroyednavigatebackhtml">trunk/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectspopstateafterloadcompleteaddeventlistenerhtml">trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-addeventlistener.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectspopstateafterloadcompletebodyattributehtml">trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-body-attribute.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectspopstateafterloadcompletebodyinlineattributehtml">trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-body-inline-attribute.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectspopstateafterloadcompletewindowattributehtml">trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-window-attribute.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectspopstatefiresonhistorytraversalexpectedtxt">trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-on-history-traversal-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectspopstatefiresonhistorytraversalhtml">trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-on-history-traversal.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectspopstatefireswithpagecacheexpectedtxt">trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-with-page-cache-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectspopstatefireswithpagecachehtml">trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-with-page-cache.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectspushstateobjecttypeshtml">trunk/LayoutTests/fast/loader/stateobjects/pushstate-object-types.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectspushstatethenreplacestatehtml">trunk/LayoutTests/fast/loader/stateobjects/pushstate-then-replacestate.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectspushstatewithfragmenturlsandhashchangehtml">trunk/LayoutTests/fast/loader/stateobjects/pushstate-with-fragment-urls-and-hashchange.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectsreplacestatethenpushstatehtml">trunk/LayoutTests/fast/loader/stateobjects/replacestate-then-pushstate.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectsresourcespopstatefireswithpagecache1html">trunk/LayoutTests/fast/loader/stateobjects/resources/popstate-fires-with-page-cache-1.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectsresourcespopstatefireswithpagecache2html">trunk/LayoutTests/fast/loader/stateobjects/resources/popstate-fires-with-page-cache-2.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectsresourcesreplacestateiniframewindowchildhtml">trunk/LayoutTests/fast/loader/stateobjects/resources/replacestate-in-iframe-window-child.html</a></li>
<li><a href="#trunkLayoutTestshttptestshistorypopstatefireswithpendingrequestshtml">trunk/LayoutTests/http/tests/history/popstate-fires-with-pending-requests.html</a></li>
<li><a href="#trunkLayoutTestshttptestsnavigationredirectonbackupdateshistoryitemexpectedtxt">trunk/LayoutTests/http/tests/navigation/redirect-on-back-updates-history-item-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsnavigationredirectonreloadupdateshistoryitemexpectedtxt">trunk/LayoutTests/http/tests/navigation/redirect-on-reload-updates-history-item-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebFrameLoaderClientcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/ChangeLog        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2015-10-02  Antoine Quint  &lt;graouts@apple.com&gt;
+
+        popstate is fired at the wrong time on load
+        https://bugs.webkit.org/show_bug.cgi?id=94265
+
+        Reviewed by Darin Adler.
+
+        Updating tests that relied on a &quot;popstate&quot; event being fired at page load.
+
+        * fast/history/same-document-iframes-changing-fragment-expected.txt:
+        * fast/history/same-document-iframes-changing-pushstate-expected.txt:
+        * fast/loader/javascript-url-iframe-remove-on-navigate.html:
+        * fast/loader/stateobjects/document-destroyed-navigate-back-with-fragment-scroll.html:
+        * fast/loader/stateobjects/document-destroyed-navigate-back.html:
+        * fast/loader/stateobjects/popstate-after-load-complete-addeventlistener.html:
+        * fast/loader/stateobjects/popstate-after-load-complete-body-attribute.html:
+        * fast/loader/stateobjects/popstate-after-load-complete-body-inline-attribute.html:
+        * fast/loader/stateobjects/popstate-after-load-complete-window-attribute.html:
+        * fast/loader/stateobjects/popstate-fires-on-history-traversal-expected.txt:
+        * fast/loader/stateobjects/popstate-fires-on-history-traversal.html:
+        * fast/loader/stateobjects/popstate-fires-with-page-cache-expected.txt:
+        * fast/loader/stateobjects/popstate-fires-with-page-cache.html:
+        * fast/loader/stateobjects/pushstate-object-types.html:
+        * fast/loader/stateobjects/pushstate-then-replacestate.html:
+        * fast/loader/stateobjects/pushstate-with-fragment-urls-and-hashchange.html:
+        * fast/loader/stateobjects/replacestate-then-pushstate.html:
+        * fast/loader/stateobjects/resources/popstate-fires-with-page-cache-1.html:
+        * fast/loader/stateobjects/resources/popstate-fires-with-page-cache-2.html:
+        * fast/loader/stateobjects/resources/replacestate-in-iframe-window-child.html:
+        * http/tests/history/popstate-fires-with-pending-requests.html:
+        * http/tests/navigation/redirect-on-back-updates-history-item-expected.txt:
+        * http/tests/navigation/redirect-on-reload-updates-history-item-expected.txt:
+
</ins><span class="cx"> 2015-10-02  Javier Fernandez  &lt;jfernandez@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [CSS Grid Layout] Support for Content Alignment in grid layout
</span></span></pre></div>
<a id="trunkLayoutTestsfasthistorysamedocumentiframeschangingfragmentexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/history/same-document-iframes-changing-fragment-expected.txt (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/history/same-document-iframes-changing-fragment-expected.txt        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/history/same-document-iframes-changing-fragment-expected.txt        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -3,7 +3,6 @@
</span><span class="cx"> On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-popstate to state: null filename: same-document-iframes-changing-fragment.html
</del><span class="cx"> removing iframe2
</span><span class="cx"> navigating to #newState
</span><span class="cx"> popstate to state: null filename: same-document-iframes-changing-fragment.html#newState
</span></span></pre></div>
<a id="trunkLayoutTestsfasthistorysamedocumentiframeschangingpushstateexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/history/same-document-iframes-changing-pushstate-expected.txt (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/history/same-document-iframes-changing-pushstate-expected.txt        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/history/same-document-iframes-changing-pushstate-expected.txt        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -3,7 +3,6 @@
</span><span class="cx"> On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-popstate to state: null filename: same-document-iframes-changing-pushstate.html
</del><span class="cx"> removing iframe2
</span><span class="cx"> pushState to newState
</span><span class="cx"> going back
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderjavascripturliframeremoveonnavigatehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/javascript-url-iframe-remove-on-navigate.html (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/javascript-url-iframe-remove-on-navigate.html        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/loader/javascript-url-iframe-remove-on-navigate.html        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -9,7 +9,7 @@
</span><span class="cx">         document.getElementById(&quot;target&quot;).src = &quot;javascript:alert('FAIL')&quot;;
</span><span class="cx">     }, 0);
</span><span class="cx"> 
</span><del>-window.addEventListener(&quot;popstate&quot;, function() {
</del><ins>+window.addEventListener(&quot;load&quot;, function() {
</ins><span class="cx">         document.write(&quot;PASS - Javascript URL blocked without crashing.&quot;);
</span><span class="cx">         if (window.testRunner)
</span><span class="cx">             testRunner.notifyDone();
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectsdocumentdestroyednavigatebackwithfragmentscrollhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back-with-fragment-scroll.html (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back-with-fragment-scroll.html        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back-with-fragment-scroll.html        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -48,20 +48,8 @@
</span><span class="cx">         runThirdStageOfTest();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-var beganTest = false;
-
</del><span class="cx"> onpopstate = function()
</span><span class="cx"> {
</span><del>-    // The first time popstate fires, it's because the page has finished loading.
-    // Only then can we begin the test.
-    if (!beganTest) {
-        beganTest = true;
-        runTest();
-        // Continue with the handler if we've already began the test.
-        if (!sessionStorage.stage)
-            return;
-    }
-    
</del><span class="cx">     alert(&quot;State popped - &quot; + event.state + &quot; (type &quot; + typeof event.state + &quot;)&quot;);
</span><span class="cx"> 
</span><span class="cx">     // FIXME: Once the popstate and hashchange events fire asynchronously, we
</span><span class="lines">@@ -96,7 +84,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span><del>-&lt;body onunload=&quot;/* disable page cache */&quot;&gt;
</del><ins>+&lt;body onload=&quot;runTest();&quot; onunload=&quot;/* disable page cache */&quot;&gt;
</ins><span class="cx"> &lt;pre&gt;
</span><span class="cx"> This test:
</span><span class="cx"> -Builds up a list of state object entries with fragment URLs.
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectsdocumentdestroyednavigatebackhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back.html (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back.html        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back.html        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -42,20 +42,8 @@
</span><span class="cx">         runThirdStageOfTest();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-var beganTest = false;
-
</del><span class="cx"> function statePopped()
</span><span class="cx"> {
</span><del>-    // The first time popstate fires, it's because the page has finished loading.
-    // Only then can we begin the test.
-    if (!beganTest) {
-        beganTest = true;
-        runTest();
-        // Continue with the handler if we've already began the test.
-        if (!sessionStorage.stage)
-            return;
-    }
-    
</del><span class="cx">     alert(&quot;State popped - &quot; + event.state + &quot; (type &quot; + typeof event.state + &quot;)&quot;);
</span><span class="cx">     if (event.state == &quot;FirstEntry&quot;) {
</span><span class="cx">         history.replaceState(&quot;FirstEntryWillLaterBeReactivated&quot;, null, &quot;?FirstEntryWillLaterBeReactivated&quot;);
</span><span class="lines">@@ -74,7 +62,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span><del>-&lt;body onpopstate=&quot;statePopped();&quot; onunload=&quot;/* disable page cache */&quot;&gt;
</del><ins>+&lt;body onload=&quot;runTest();&quot; onpopstate=&quot;statePopped();&quot; onunload=&quot;/* disable page cache */&quot;&gt;
</ins><span class="cx"> &lt;pre&gt;
</span><span class="cx"> This test:
</span><span class="cx"> -Builds up a list of state object entries with fragment URLs.
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectspopstateafterloadcompleteaddeventlistenerhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-addeventlistener.html (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-addeventlistener.html        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-addeventlistener.html        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -20,18 +20,8 @@
</span><span class="cx">     history.back();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-var beganTest = false;
-
</del><span class="cx"> function statePopped()
</span><span class="cx"> {
</span><del>-    // The first time popstate fires, it's because the page has finished loading.
-    // Only then can we begin the test.
-    if (!beganTest) {
-        beganTest = true;
-        runTest();
-        return;
-    }
-    
</del><span class="cx">     log(&quot;State popped - &quot; + event.state + &quot; (type &quot; + typeof event.state + &quot;)&quot;);
</span><span class="cx">     if (event.state == null)
</span><span class="cx">         history.forward();
</span><span class="lines">@@ -42,7 +32,7 @@
</span><span class="cx"> window.addEventListener(&quot;popstate&quot;, statePopped);
</span><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span><del>-&lt;body&gt;
</del><ins>+&lt;body onload=&quot;runTest();&quot;&gt;
</ins><span class="cx"> &lt;pre&gt;
</span><span class="cx"> This test does the following:
</span><span class="cx"> -Listens for the popstate event using addEventListener
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectspopstateafterloadcompletebodyattributehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-body-attribute.html (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-body-attribute.html        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-body-attribute.html        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -20,18 +20,8 @@
</span><span class="cx">     history.back();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-var beganTest = false;
-
</del><span class="cx"> function statePopped()
</span><span class="cx"> {
</span><del>-    // The first time popstate fires, it's because the page has finished loading.
-    // Only then can we begin the test.
-    if (!beganTest) {
-        beganTest = true;
-        runTest();
-        return;
-    }
-    
</del><span class="cx">     log(&quot;State popped - &quot; + event.state + &quot; (type &quot; + typeof event.state + &quot;)&quot;);
</span><span class="cx">     if (event.state == null) {
</span><span class="cx">         document.body.onpopstate = statePopped;
</span><span class="lines">@@ -41,7 +31,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span><del>-&lt;body&gt;
</del><ins>+&lt;body onload=&quot;runTest();&quot;&gt;
</ins><span class="cx"> &lt;pre&gt;
</span><span class="cx"> This test does the following:
</span><span class="cx"> -Uses body.onpopstate to add a popstate handler (both by using the inline attribute and a script-assigned attribute)
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectspopstateafterloadcompletebodyinlineattributehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-body-inline-attribute.html (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-body-inline-attribute.html        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-body-inline-attribute.html        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -20,18 +20,8 @@
</span><span class="cx">     history.back();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-var beganTest = false;
-
</del><span class="cx"> function statePopped()
</span><span class="cx"> {
</span><del>-    // The first time popstate fires, it's because the page has finished loading.
-    // Only then can we begin the test.
-    if (!beganTest) {
-        beganTest = true;
-        runTest();
-        return;
-    }
-    
</del><span class="cx">     log(&quot;State popped - &quot; + event.state + &quot; (type &quot; + typeof event.state + &quot;)&quot;);
</span><span class="cx">     if (event.state == null) {
</span><span class="cx">         document.body.onpopstate = statePopped;
</span><span class="lines">@@ -41,7 +31,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span><del>-&lt;body onpopstate=&quot;statePopped();&quot;&gt;
</del><ins>+&lt;body onload=&quot;runTest();&quot; onpopstate=&quot;statePopped();&quot;&gt;
</ins><span class="cx"> &lt;pre&gt;
</span><span class="cx"> This test does the following:
</span><span class="cx"> -Uses body.onpopstate to add a popstate handler (both by using the inline attribute and a script-assigned attribute)
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectspopstateafterloadcompletewindowattributehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-window-attribute.html (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-window-attribute.html        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-window-attribute.html        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -20,18 +20,8 @@
</span><span class="cx">     history.back();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-var beganTest = false;
-
</del><span class="cx"> function statePopped()
</span><span class="cx"> {
</span><del>-    // The first time popstate fires, it's because the page has finished loading.
-    // Only then can we begin the test.
-    if (!beganTest) {
-        beganTest = true;
-        runTest();
-        return;
-    }
-
</del><span class="cx">     log(&quot;State popped - &quot; + event.state + &quot; (type &quot; + typeof event.state + &quot;)&quot;);
</span><span class="cx">     if (event.state == null)
</span><span class="cx">         history.forward();
</span><span class="lines">@@ -42,7 +32,7 @@
</span><span class="cx"> window.onpopstate = statePopped;
</span><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span><del>-&lt;body&gt;
</del><ins>+&lt;body onload=&quot;runTest();&quot;&gt;
</ins><span class="cx"> &lt;pre&gt;
</span><span class="cx"> This test does the following:
</span><span class="cx"> -Uses window.onpopstate to add a popstate handler
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectspopstatefiresonhistorytraversalexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-on-history-traversal-expected.txt (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-on-history-traversal-expected.txt        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-on-history-traversal-expected.txt        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -2,7 +2,6 @@
</span><span class="cx"> 
</span><span class="cx"> On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
</span><span class="cx"> 
</span><del>-popstate fired with state null
</del><span class="cx"> setting hash to #state1
</span><span class="cx"> popstate fired with state null
</span><span class="cx"> setting hash to #state2
</span><span class="lines">@@ -11,7 +10,7 @@
</span><span class="cx"> popstate fired with state null
</span><span class="cx"> going back
</span><span class="cx"> popstate fired with state null
</span><del>-PASS popstateFireCount is 5
</del><ins>+PASS popstateFireCount is 4
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectspopstatefiresonhistorytraversalhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-on-history-traversal.html (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-on-history-traversal.html        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-on-history-traversal.html        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -41,7 +41,7 @@
</span><span class="cx">         // 3. Navigating to #state2
</span><span class="cx">         // 4. Going back to #state1
</span><span class="cx">         // 5. Going back to the initial page state
</span><del>-        shouldBe('popstateFireCount', '5');
</del><ins>+        shouldBe('popstateFireCount', '4');
</ins><span class="cx">         finishJSTest();
</span><span class="cx">         return;
</span><span class="cx">     default:
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectspopstatefireswithpagecacheexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-with-page-cache-expected.txt (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-with-page-cache-expected.txt        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-with-page-cache-expected.txt        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -2,10 +2,10 @@
</span><span class="cx"> 
</span><span class="cx"> On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
</span><span class="cx"> 
</span><del>-popstate fired with state null
</del><ins>+load fired
</ins><span class="cx"> pushState with new state object for page 1
</span><span class="cx"> going to page 2
</span><del>-popstate fired with state null
</del><ins>+load fired
</ins><span class="cx"> going back to page 1 with new state object
</span><span class="cx"> popstate fired with state newState
</span><span class="cx"> going back to page 1 in initial state
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectspopstatefireswithpagecachehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-with-page-cache.html (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-with-page-cache.html        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-with-page-cache.html        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -20,8 +20,32 @@
</span><span class="cx">         testFailed('Could not open test window');
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+var testWindowLoadFireCount = 0;
</ins><span class="cx"> var testWindowPopstateFireCount = 0;
</span><span class="cx"> 
</span><ins>+function onTestWindowLoad(event)
+{
+    debug('load fired');
+    testWindowLoadFireCount++;
+
+    switch (testWindowLoadFireCount) {
+    case 1:
+        debug('pushState with new state object for page 1');
+        testWindow.history.pushState('newState');
+        debug('going to page 2');
+        // Set the location in a timeout to generate a history entry
+        setTimeout(function() {testWindow.location.href = 'resources/popstate-fires-with-page-cache-2.html';}, 0);            
+        break;            
+    case 2:
+        debug('going back to page 1 with new state object');
+        setTimeout(function() {testWindow.history.back();}, 0);
+        break;
+    default:
+        testFailed('unexpected load event state');
+        break;            
+    }
+}
+
</ins><span class="cx"> function onTestWindowPopState(event)
</span><span class="cx"> {
</span><span class="cx">     debug('popstate fired with state ' + event.state);
</span><span class="lines">@@ -29,21 +53,10 @@
</span><span class="cx">     
</span><span class="cx">     switch (testWindowPopstateFireCount) {
</span><span class="cx">         case 1:
</span><del>-            debug('pushState with new state object for page 1');
-            testWindow.history.pushState('newState');
-            debug('going to page 2');
-            // Set the location in a timeout to generate a history entry
-            setTimeout(function() {testWindow.location.href = 'resources/popstate-fires-with-page-cache-2.html';}, 0);            
-            break;            
-        case 2:
-            debug('going back to page 1 with new state object');
-            setTimeout(function() {testWindow.history.back();}, 0);
-            break;
-        case 3:
</del><span class="cx">             debug('going back to page 1 in initial state');
</span><span class="cx">             setTimeout(function() {testWindow.history.back();}, 0);
</span><span class="cx">             break;
</span><del>-        case 4:
</del><ins>+        case 2:
</ins><span class="cx">             // Close the window in a timeout to simulate popstate firing asynchronously, otherwise closing the window in a popstate handler results in a crash.
</span><span class="cx">             // FIXME: remove this when http://webkit.org/b/36202 is fixed.
</span><span class="cx">             setTimeout(function() {
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectspushstateobjecttypeshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/stateobjects/pushstate-object-types.html (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/pushstate-object-types.html        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/loader/stateobjects/pushstate-object-types.html        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -39,18 +39,8 @@
</span><span class="cx">     history.back();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-var beganTest = false;
-
</del><span class="cx"> onpopstate = function(event)
</span><span class="cx"> {
</span><del>-    // The first time popstate fires, it's because the page has finished loading.
-    // Only then can we begin the test.
-    if (!beganTest) {
-        beganTest = true;
-        runTest();
-        return;
-    }
-    
</del><span class="cx">     if (event.state instanceof Date)
</span><span class="cx">         log(&quot;State popped - &quot; + event.state.getTime() + &quot; (type &quot; + typeof event.state + &quot;)&quot;);
</span><span class="cx">     else
</span><span class="lines">@@ -64,7 +54,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span><del>-&lt;body&gt;
</del><ins>+&lt;body onload=&quot;runTest();&quot;&gt;
</ins><span class="cx"> &lt;p&gt;
</span><span class="cx"> This test calls pushState with state objects of all the different object types supported by the HTML5 &quot;internal structured cloning algorithm&quot; and makes sure the events contain the expected objects when the states are popped.
</span><span class="cx"> &lt;/p&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectspushstatethenreplacestatehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/stateobjects/pushstate-then-replacestate.html (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/pushstate-then-replacestate.html        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/loader/stateobjects/pushstate-then-replacestate.html        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -22,18 +22,8 @@
</span><span class="cx">     history.back();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-var beganTest = false;
-
</del><span class="cx"> onpopstate = function(event)
</span><span class="cx"> {
</span><del>-    // The first time popstate fires, it's because the page has finished loading.
-    // Only then can we begin the test.
-    if (!beganTest) {
-        beganTest = true;
-        runTest();
-        return;
-    }
-
</del><span class="cx">     log(&quot;State popped - &quot; + event.state + &quot; (type &quot; + typeof event.state + &quot;)&quot;);
</span><span class="cx">     if (event.state == null)
</span><span class="cx">         history.forward();
</span><span class="lines">@@ -42,7 +32,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span><del>-&lt;body&gt;
</del><ins>+&lt;body onload=&quot;runTest();&quot;&gt;
</ins><span class="cx"> &lt;pre&gt;
</span><span class="cx"> This test does the following:
</span><span class="cx"> -Makes a call to pushState()
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectspushstatewithfragmenturlsandhashchangehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/stateobjects/pushstate-with-fragment-urls-and-hashchange.html (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/pushstate-with-fragment-urls-and-hashchange.html        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/loader/stateobjects/pushstate-with-fragment-urls-and-hashchange.html        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -44,18 +44,8 @@
</span><span class="cx">     return url.split('/').pop();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-var beganTest = false;
-
</del><span class="cx"> onpopstate = function(event)
</span><span class="cx"> {
</span><del>-    // The first time popstate fires, it's because the page has finished loading.
-    // Only then can we begin the test.
-    if (!beganTest) {
-        beganTest = true;
-        runTest();
-        return;
-    }
-
</del><span class="cx">     log(&quot;State popped with event &quot; + event.state + &quot; (type &quot; + typeof event.state + &quot;) and last path component &quot; + lastPathComponent(location.href));
</span><span class="cx">     if (event.state != &quot;OriginalEntry&quot;)
</span><span class="cx">         setTimeout(&quot;history.back();&quot;, 0);
</span><span class="lines">@@ -69,7 +59,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span><del>-&lt;body&gt;
</del><ins>+&lt;body onload=&quot;runTest();&quot;&gt;
</ins><span class="cx"> &lt;pre&gt;
</span><span class="cx"> This test pushes a series of state objects with different URLs and fragment identifiers meant to test the hashChange event as states are popped.
</span><span class="cx"> &lt;/pre&gt;&lt;br&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectsreplacestatethenpushstatehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/stateobjects/replacestate-then-pushstate.html (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/replacestate-then-pushstate.html        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/loader/stateobjects/replacestate-then-pushstate.html        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -22,18 +22,8 @@
</span><span class="cx">     history.back();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-var beganTest = false;
-
</del><span class="cx"> onpopstate = function(event)
</span><span class="cx"> {
</span><del>-    // The first time popstate fires, it's because the page has finished loading.
-    // Only then can we begin the test.
-    if (!beganTest) {
-        beganTest = true;
-        runTest();
-        return;
-    }
-
</del><span class="cx">     log(&quot;State popped - &quot; + event.state + &quot; (type &quot; + typeof event.state + &quot;)&quot;);
</span><span class="cx">     if (event.state == &quot;OriginalHistoryItem&quot;)
</span><span class="cx">         history.forward();
</span><span class="lines">@@ -42,7 +32,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span><del>-&lt;body&gt;
</del><ins>+&lt;body onload=&quot;runTest();&quot;&gt;
</ins><span class="cx"> &lt;pre&gt;
</span><span class="cx"> This test does the following:
</span><span class="cx"> -Makes a call to replaceState()
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectsresourcespopstatefireswithpagecache1html"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/stateobjects/resources/popstate-fires-with-page-cache-1.html (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/resources/popstate-fires-with-page-cache-1.html        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/loader/stateobjects/resources/popstate-fires-with-page-cache-1.html        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -1 +1 @@
</span><del>-&lt;body onpopstate=&quot;opener.onTestWindowPopState(event)&quot;&gt;page 1&lt;/body&gt;
</del><span class="cx">\ No newline at end of file
</span><ins>+&lt;body onload=&quot;opener.onTestWindowLoad(event)&quot; onpopstate=&quot;opener.onTestWindowPopState(event)&quot;&gt;page 1&lt;/body&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectsresourcespopstatefireswithpagecache2html"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/stateobjects/resources/popstate-fires-with-page-cache-2.html (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/resources/popstate-fires-with-page-cache-2.html        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/loader/stateobjects/resources/popstate-fires-with-page-cache-2.html        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -1 +1 @@
</span><del>-&lt;body onpopstate=&quot;opener.onTestWindowPopState(event)&quot;&gt;page 2&lt;/body&gt;
</del><span class="cx">\ No newline at end of file
</span><ins>+&lt;body onload=&quot;opener.onTestWindowLoad(event)&quot; onpopstate=&quot;opener.onTestWindowPopState(event)&quot;&gt;page 2&lt;/body&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectsresourcesreplacestateiniframewindowchildhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/loader/stateobjects/resources/replacestate-in-iframe-window-child.html (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/resources/replacestate-in-iframe-window-child.html        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/fast/loader/stateobjects/resources/replacestate-in-iframe-window-child.html        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -1,15 +1,16 @@
</span><span class="cx"> &lt;script&gt;
</span><del>-onunload = function() {
</del><ins>+window.onload = function() {
+  if (!sessionStorage.beganTest) {
+    sessionStorage.beganTest = true; 
+    top.opener.windowLoaded();
+  }
+}
+
+window.onunload = function() {
</ins><span class="cx">   // No page cache
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-onpopstate = function(e) {
-  if (!sessionStorage.beganTest) {
-      sessionStorage.beganTest = true; 
-      top.opener.windowLoaded();
-      return;
-  }
-  
</del><ins>+window.onpopstate = function(e) {
</ins><span class="cx">   alert(&quot;onpopstate&quot;);
</span><span class="cx">   top.opener.notifyDone(window == parent ? &quot;FAIL&quot; : &quot;PASS&quot;);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkLayoutTestshttptestshistorypopstatefireswithpendingrequestshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/history/popstate-fires-with-pending-requests.html (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/history/popstate-fires-with-pending-requests.html        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/http/tests/history/popstate-fires-with-pending-requests.html        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -10,17 +10,8 @@
</span><span class="cx"> &lt;script&gt;
</span><span class="cx"> description('Tests that popstate events fire when going back, even when there are resource requests pending.');
</span><span class="cx"> 
</span><del>-onpopstate = function(event)
</del><ins>+window.onload = function(event)
</ins><span class="cx"> {
</span><del>-    if (event.state) {
-        shouldBe('event.state', '&quot;newState1&quot;');
-        // Stop the pending image request, otherwise the DRT doesn't consider the
-        // test over.
-        window.stop();
-        finishJSTest();
-        return;
-    }
-    
</del><span class="cx">     debug('Starting slow image request');
</span><span class="cx">       
</span><span class="cx">     var slowImage = document.createElement('img');
</span><span class="lines">@@ -43,6 +34,13 @@
</span><span class="cx">     }, 0);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+window.onpopstate = function(event) {
+    shouldBe('event.state', '&quot;newState1&quot;');
+    // Stop the pending image request, otherwise the DRT doesn't consider the
+    // test over.
+    window.stop();
+    finishJSTest();
+}
</ins><span class="cx"> 
</span><span class="cx"> var jsTestIsAsync = true;
</span><span class="cx"> &lt;/script&gt; 
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsnavigationredirectonbackupdateshistoryitemexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/navigation/redirect-on-back-updates-history-item-expected.txt (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/navigation/redirect-on-back-updates-history-item-expected.txt        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/http/tests/navigation/redirect-on-back-updates-history-item-expected.txt        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -1,8 +1,6 @@
</span><span class="cx"> main frame - has 1 onunload handler(s)
</span><span class="cx"> PASS
</span><del>-popstate: null
</del><span class="cx"> 
</span><del>-
</del><span class="cx"> ============== Back Forward List ==============
</span><span class="cx">         http://127.0.0.1:8000/navigation/redirect-on-back-updates-history-item.html  **nav target**
</span><span class="cx"> curr-&gt;  http://127.0.0.1:8000/navigation/resources/redirect-updates-history-item-done.html  **nav target**
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsnavigationredirectonreloadupdateshistoryitemexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/navigation/redirect-on-reload-updates-history-item-expected.txt (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/navigation/redirect-on-reload-updates-history-item-expected.txt        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/LayoutTests/http/tests/navigation/redirect-on-reload-updates-history-item-expected.txt        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -1,9 +1,7 @@
</span><span class="cx"> main frame - has 1 onunload handler(s)
</span><span class="cx"> main frame - has 1 onunload handler(s)
</span><span class="cx"> PASS
</span><del>-popstate: null
</del><span class="cx"> 
</span><del>-
</del><span class="cx"> ============== Back Forward List ==============
</span><span class="cx">         http://127.0.0.1:8000/navigation/redirect-on-reload-updates-history-item.html  **nav target**
</span><span class="cx"> curr-&gt;  http://127.0.0.1:8000/navigation/resources/redirect-updates-history-item-done.html  **nav target**
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/Source/WebCore/ChangeLog        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2015-10-02  Antoine Quint  &lt;graouts@apple.com&gt;
+
+        popstate is fired at the wrong time on load
+        https://bugs.webkit.org/show_bug.cgi?id=94265
+
+        Reviewed by Darin Adler.
+
+        Don't fire popstate event on initial document load
+
+        According to the specification [1], a popstate event should only be fired
+        when the document has a &quot;last entry&quot; and the entry being navigated to isn't
+        it.  A document is created without a &quot;last entry&quot; and gets one just after
+        this check when it is first navigated to, so a popstate should be fired any
+        time a document is navigated to except for the first time after it has been
+        created.
+
+        Patch adapted from work by jl@opera.com on Blink [2].
+
+        [1] http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#traverse-the-history (step 12-14 in particular)
+        [2] https://src.chromium.org/viewvc/blink?revision=165221&amp;view=revision
+
+        * dom/Document.cpp:
+        (WebCore::Document::implicitClose):
+
</ins><span class="cx"> 2015-10-02  Javier Fernandez  &lt;jfernandez@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [CSS Grid Layout] Support for Content Alignment in grid layout
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/Source/WebCore/dom/Document.cpp        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -2662,7 +2662,8 @@
</span><span class="cx"> 
</span><span class="cx">     dispatchWindowLoadEvent();
</span><span class="cx">     enqueuePageshowEvent(PageshowEventNotPersisted);
</span><del>-    enqueuePopstateEvent(m_pendingStateObject ? m_pendingStateObject.release() : SerializedScriptValue::nullValue());
</del><ins>+    if (m_pendingStateObject)
+        enqueuePopstateEvent(m_pendingStateObject.release());
</ins><span class="cx">     
</span><span class="cx">     if (f)
</span><span class="cx">         f-&gt;loader().handledOnloadEvents();
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/Source/WebKit2/ChangeLog        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2015-10-02  Antoine Quint  &lt;graouts@apple.com&gt;
+
+        popstate is fired at the wrong time on load
+        https://bugs.webkit.org/show_bug.cgi?id=94265
+
+        Reviewed by Darin Adler.
+
+        Ensure we have a valid page before trying to get to its drawingArea as this could lead
+        to a crash as observed with fast/loader/stateobjects/pushstate-object-types.html.
+
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::restoreViewState):
+
</ins><span class="cx"> 2015-10-01  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Network cache: Subresource referer header wrong after cached redirect
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebFrameLoaderClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (190504 => 190505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp        2015-10-02 14:08:18 UTC (rev 190504)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp        2015-10-02 15:13:05 UTC (rev 190505)
</span><span class="lines">@@ -1218,7 +1218,7 @@
</span><span class="cx"> 
</span><span class="cx">     // FIXME: This should not be necessary. WebCore should be correctly invalidating
</span><span class="cx">     // the view on restores from the back/forward cache.
</span><del>-    if (m_frame == m_frame-&gt;page()-&gt;mainWebFrame())
</del><ins>+    if (m_frame-&gt;page() &amp;&amp; m_frame == m_frame-&gt;page()-&gt;mainWebFrame())
</ins><span class="cx">         m_frame-&gt;page()-&gt;drawingArea()-&gt;setNeedsDisplay();
</span><span class="cx"> #endif
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>