Diff
Modified: trunk/LayoutTests/ChangeLog (201309 => 201310)
--- trunk/LayoutTests/ChangeLog 2016-05-24 00:50:32 UTC (rev 201309)
+++ trunk/LayoutTests/ChangeLog 2016-05-24 01:03:13 UTC (rev 201310)
@@ -1,3 +1,18 @@
+2016-05-23 Jiewen Tan <[email protected]>
+
+ 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.
+
2016-05-23 Ryan Haddad <[email protected]>
Marking inspector/console/console-time.html as a flaky timeout
Added: trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-expected.txt (0 => 201310)
--- 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)
@@ -0,0 +1,14 @@
+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
+
Added: trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache-expected.txt (0 => 201310)
--- 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)
@@ -0,0 +1,13 @@
+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
+
Added: trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache.html (0 => 201310)
--- 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)
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<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 = '';}, 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=""
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry.html (0 => 201310)
--- 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)
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<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 = '';}, 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=""
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/fast/loader/stateobjects/resources/no-popstate-when-back-to-stateless-entry-1.html (0 => 201310)
--- 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)
@@ -0,0 +1 @@
+<body _onload_="opener.onTestWindowLoad(event)" _onpopstate_="opener.onTestWindowPopState(event)" id="1">page 1</body>
Added: trunk/LayoutTests/fast/loader/stateobjects/resources/no-popstate-when-back-to-stateless-entry-2.html (0 => 201310)
--- 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)
@@ -0,0 +1 @@
+<body _onload_="opener.onTestWindowLoad(event)" _onpopstate_="opener.onTestWindowPopState(event)" id="2">page 2</body>
Modified: trunk/Source/WebCore/ChangeLog (201309 => 201310)
--- 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)
@@ -1,3 +1,23 @@
+2016-05-23 Jiewen Tan <[email protected]>
+
+ 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):
+
2016-05-23 Chris Dumez <[email protected]>
Generate bindings code for EventTarget.addEventListener() / removeEventListener()
Modified: trunk/Source/WebCore/history/CachedFrame.cpp (201309 => 201310)
--- 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)
@@ -127,7 +127,8 @@
m_document->enqueuePageshowEvent(PageshowEventPersisted);
HistoryItem* historyItem = frame.loader().history().currentItem();
- m_document->enqueuePopstateEvent(historyItem && historyItem->stateObject() ? historyItem->stateObject() : SerializedScriptValue::nullValue());
+ if (historyItem && historyItem->stateObject())
+ m_document->enqueuePopstateEvent(historyItem->stateObject());
#if ENABLE(TOUCH_EVENTS) && !PLATFORM(IOS)
if (m_document->hasTouchEventHandlers())