<!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>[201310] 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/201310">201310</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2016-05-23 18:03:13 -0700 (Mon, 23 May 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Null popstate event fired when navigating back to a cached page with a stateless history entry
https://bugs.webkit.org/show_bug.cgi?id=157963
<rdar://problem/23414840>
Source/WebCore:
Popstate events are not fired when WebKit navigates back to a history entry that doesn't
have a state object if the entry's page is not cached. However, we fire popstate events
unconditionally if the page is cached. This results in inconsistent behavior between
initial navigations and cached navigations. Align the behavior of initial and cached
navigations so that we produce consistent events.
Reviewed by Brent Fulgham.
Tests: fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache.html
fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry.html
* history/CachedFrame.cpp:
(WebCore::CachedFrameBase::restore):
LayoutTests:
Reviewed by Brent Fulgham.
* fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-expected.txt: Added.
* fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache-expected.txt: Added.
* fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache.html: Added.
* fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry.html: Added.
* fast/loader/stateobjects/resources/no-popstate-when-back-to-stateless-entry-1.html: Added.
* fast/loader/stateobjects/resources/no-popstate-when-back-to-stateless-entry-2.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehistoryCachedFramecpp">trunk/Source/WebCore/history/CachedFrame.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastloaderstateobjectsnopopstatewhenbacktostatelessentryexpectedtxt">trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectsnopopstatewhenbacktostatelessentrywithpagecacheexpectedtxt">trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectsnopopstatewhenbacktostatelessentrywithpagecachehtml">trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectsnopopstatewhenbacktostatelessentryhtml">trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectsresourcesnopopstatewhenbacktostatelessentry1html">trunk/LayoutTests/fast/loader/stateobjects/resources/no-popstate-when-back-to-stateless-entry-1.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderstateobjectsresourcesnopopstatewhenbacktostatelessentry2html">trunk/LayoutTests/fast/loader/stateobjects/resources/no-popstate-when-back-to-stateless-entry-2.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (201309 => 201310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-05-24 00:50:32 UTC (rev 201309)
+++ trunk/LayoutTests/ChangeLog        2016-05-24 01:03:13 UTC (rev 201310)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-05-23 Jiewen Tan <jiewen_tan@apple.com>
+
+ Null popstate event fired when navigating back to a cached page with a stateless history entry
+ https://bugs.webkit.org/show_bug.cgi?id=157963
+ <rdar://problem/23414840>
+
+ Reviewed by Brent Fulgham.
+
+ * fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-expected.txt: Added.
+ * fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache-expected.txt: Added.
+ * fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache.html: Added.
+ * fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry.html: Added.
+ * fast/loader/stateobjects/resources/no-popstate-when-back-to-stateless-entry-1.html: Added.
+ * fast/loader/stateobjects/resources/no-popstate-when-back-to-stateless-entry-2.html: Added.
+
</ins><span class="cx"> 2016-05-23 Ryan Haddad <ryanhaddad@apple.com>
</span><span class="cx">
</span><span class="cx"> Marking inspector/console/console-time.html as a flaky timeout
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectsnopopstatewhenbacktostatelessentryexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-expected.txt (0 => 201310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-expected.txt        2016-05-24 01:03:13 UTC (rev 201310)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+No popstate event should be fired when WebKit navigates back to a stateless history entry.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+load fired
+going to page 2
+load fired
+going back to page 1
+load fired
+back at page 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectsnopopstatewhenbacktostatelessentrywithpagecacheexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache-expected.txt (0 => 201310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache-expected.txt        2016-05-24 01:03:13 UTC (rev 201310)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+No popstate event should be fired when WebKit navigates back to a stateless history entry with page cached.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+load fired
+going to page 2
+load fired
+going back to page 1
+back at page 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectsnopopstatewhenbacktostatelessentrywithpagecachehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache.html (0 => 201310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache.html         (rev 0)
+++ trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache.html        2016-05-24 01:03:13 UTC (rev 201310)
</span><span class="lines">@@ -0,0 +1,65 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../../resources/js-test-pre.js"></script>
+<div id="description"></div>
+<pre id="console"></pre>
+<script>
+description('No popstate event should be fired when WebKit navigates back to a stateless history entry with page cached.');
+
+var testWindow;
+
+onload = function()
+{
+ if (window.testRunner) {
+ testRunner.setCanOpenWindows();
+ testRunner.overridePreference('WebKitUsesPageCachePreferenceKey', 1);
+ }
+ testWindow = window.open('resources/no-popstate-when-back-to-stateless-entry-1.html');
+ if (!testWindow)
+ testFailed('Could not open test window');
+}
+
+var testWindowLoadFireCount = 0;
+
+function onTestWindowLoad(event)
+{
+ debug('load fired');
+ testWindowLoadFireCount++;
+
+ switch (testWindowLoadFireCount) {
+ case 1:
+ debug('going to page 2');
+ // Set the location in a timeout to generate a history entry
+ setTimeout(function() {testWindow.location.href = 'resources/no-popstate-when-back-to-stateless-entry-2.html';}, 0);
+ break;
+ case 2:
+ debug('going back to page 1');
+ setTimeout(function() {testWindow.history.back();}, 0);
+ setTimeout(timeOut, 5);
+ break;
+ default:
+ testFailed('unexpected load event state');
+ break;
+ }
+}
+
+function onTestWindowPopState(event)
+{
+ testFailed('unexpected pop state event state');
+}
+
+function timeOut()
+{
+ if (testWindow.document.body.id == "1") {
+ debug('back at page 1');
+ testWindow.close();
+ finishJSTest();
+ } else
+ setTimeout(timeOut, 5);
+}
+
+var jsTestIsAsync = true;
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</html>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectsnopopstatewhenbacktostatelessentryhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry.html (0 => 201310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry.html         (rev 0)
+++ trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry.html        2016-05-24 01:03:13 UTC (rev 201310)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../../resources/js-test-pre.js"></script>
+<div id="description"></div>
+<pre id="console"></pre>
+<script>
+description('No popstate event should be fired when WebKit navigates back to a stateless history entry.');
+
+var testWindow;
+
+onload = function()
+{
+ if (window.testRunner)
+ testRunner.setCanOpenWindows();
+ testWindow = window.open('resources/no-popstate-when-back-to-stateless-entry-1.html');
+ if (!testWindow)
+ testFailed('Could not open test window');
+}
+
+var testWindowLoadFireCount = 0;
+
+function onTestWindowLoad(event)
+{
+ debug('load fired');
+ testWindowLoadFireCount++;
+
+ switch (testWindowLoadFireCount) {
+ case 1:
+ debug('going to page 2');
+ // Set the location in a timeout to generate a history entry
+ setTimeout(function() {testWindow.location.href = 'resources/no-popstate-when-back-to-stateless-entry-2.html';}, 0);
+ break;
+ case 2:
+ debug('going back to page 1');
+ setTimeout(function() {testWindow.history.back();}, 0);
+ break;
+ default:
+ debug('back at page 1');
+ // Close the window in a timeout to guarantee that the test will not finish before a potential popstate event.
+ setTimeout(function() {
+ testWindow.close();
+ finishJSTest();
+ }, 0);
+ break;
+ }
+}
+
+function onTestWindowPopState(event)
+{
+ testFailed('unexpected pop state event state');
+}
+
+var jsTestIsAsync = true;
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</html>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectsresourcesnopopstatewhenbacktostatelessentry1html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/loader/stateobjects/resources/no-popstate-when-back-to-stateless-entry-1.html (0 => 201310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/resources/no-popstate-when-back-to-stateless-entry-1.html         (rev 0)
+++ trunk/LayoutTests/fast/loader/stateobjects/resources/no-popstate-when-back-to-stateless-entry-1.html        2016-05-24 01:03:13 UTC (rev 201310)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+<body onload="opener.onTestWindowLoad(event)" onpopstate="opener.onTestWindowPopState(event)" id="1">page 1</body>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastloaderstateobjectsresourcesnopopstatewhenbacktostatelessentry2html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/loader/stateobjects/resources/no-popstate-when-back-to-stateless-entry-2.html (0 => 201310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/stateobjects/resources/no-popstate-when-back-to-stateless-entry-2.html         (rev 0)
+++ trunk/LayoutTests/fast/loader/stateobjects/resources/no-popstate-when-back-to-stateless-entry-2.html        2016-05-24 01:03:13 UTC (rev 201310)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+<body onload="opener.onTestWindowLoad(event)" onpopstate="opener.onTestWindowPopState(event)" id="2">page 2</body>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (201309 => 201310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-05-24 00:50:32 UTC (rev 201309)
+++ trunk/Source/WebCore/ChangeLog        2016-05-24 01:03:13 UTC (rev 201310)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-05-23 Jiewen Tan <jiewen_tan@apple.com>
+
+ Null popstate event fired when navigating back to a cached page with a stateless history entry
+ https://bugs.webkit.org/show_bug.cgi?id=157963
+ <rdar://problem/23414840>
+
+ Popstate events are not fired when WebKit navigates back to a history entry that doesn't
+ have a state object if the entry's page is not cached. However, we fire popstate events
+ unconditionally if the page is cached. This results in inconsistent behavior between
+ initial navigations and cached navigations. Align the behavior of initial and cached
+ navigations so that we produce consistent events.
+
+ Reviewed by Brent Fulgham.
+
+ Tests: fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache.html
+ fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry.html
+
+ * history/CachedFrame.cpp:
+ (WebCore::CachedFrameBase::restore):
+
</ins><span class="cx"> 2016-05-23 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> Generate bindings code for EventTarget.addEventListener() / removeEventListener()
</span></span></pre></div>
<a id="trunkSourceWebCorehistoryCachedFramecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/history/CachedFrame.cpp (201309 => 201310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/history/CachedFrame.cpp        2016-05-24 00:50:32 UTC (rev 201309)
+++ trunk/Source/WebCore/history/CachedFrame.cpp        2016-05-24 01:03:13 UTC (rev 201310)
</span><span class="lines">@@ -127,7 +127,8 @@
</span><span class="cx"> m_document->enqueuePageshowEvent(PageshowEventPersisted);
</span><span class="cx">
</span><span class="cx"> HistoryItem* historyItem = frame.loader().history().currentItem();
</span><del>- m_document->enqueuePopstateEvent(historyItem && historyItem->stateObject() ? historyItem->stateObject() : SerializedScriptValue::nullValue());
</del><ins>+ if (historyItem && historyItem->stateObject())
+ m_document->enqueuePopstateEvent(historyItem->stateObject());
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(TOUCH_EVENTS) && !PLATFORM(IOS)
</span><span class="cx"> if (m_document->hasTouchEventHandlers())
</span></span></pre>
</div>
</div>
</body>
</html>