Title: [250686] trunk
- Revision
- 250686
- Author
- [email protected]
- Date
- 2019-10-03 15:16:46 -0700 (Thu, 03 Oct 2019)
Log Message
Provisional / scheduled loads in subframes should not prevent a page from entering the back/forward cache
https://bugs.webkit.org/show_bug.cgi?id=202474
Reviewed by Alex Christensen.
Source/WebCore:
Provisional / scheduled loads in subframes should not prevent a page from entering the back/forward cache.
To address the issue, we now make sure to stop all loads before checking for PageCache eligibility.
Test: fast/history/page-cache-quick-redirect-iframe.html
* history/PageCache.cpp:
(WebCore::PageCache::addIfCacheable):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::stopForPageCache):
* loader/FrameLoader.h:
LayoutTests:
Add layout test coverage.
* fast/history/page-cache-subframes-with-provisional-load-expected.txt: Added.
* fast/history/page-cache-subframes-with-provisional-load.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (250685 => 250686)
--- trunk/LayoutTests/ChangeLog 2019-10-03 21:41:24 UTC (rev 250685)
+++ trunk/LayoutTests/ChangeLog 2019-10-03 22:16:46 UTC (rev 250686)
@@ -1,5 +1,17 @@
2019-10-03 Chris Dumez <[email protected]>
+ Provisional / scheduled loads in subframes should not prevent a page from entering the back/forward cache
+ https://bugs.webkit.org/show_bug.cgi?id=202474
+
+ Reviewed by Alex Christensen.
+
+ Add layout test coverage.
+
+ * fast/history/page-cache-subframes-with-provisional-load-expected.txt: Added.
+ * fast/history/page-cache-subframes-with-provisional-load.html: Added.
+
+2019-10-03 Chris Dumez <[email protected]>
+
XMLHttpRequest sometimes prevents pages from entering the back/forward cache
https://bugs.webkit.org/show_bug.cgi?id=202434
<rdar://problem/55890340>
Added: trunk/LayoutTests/fast/history/page-cache-subframes-with-provisional-load-expected.txt (0 => 250686)
--- trunk/LayoutTests/fast/history/page-cache-subframes-with-provisional-load-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/history/page-cache-subframes-with-provisional-load-expected.txt 2019-10-03 22:16:46 UTC (rev 250686)
@@ -0,0 +1,13 @@
+Tests that iframes with a pending provisional or scheduled load do not prevent page caching.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+pageshow - not from cache
+pagehide - entering cache
+pageshow - from cache
+PASS Page restored from Page Cache.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/history/page-cache-subframes-with-provisional-load.html (0 => 250686)
--- trunk/LayoutTests/fast/history/page-cache-subframes-with-provisional-load.html (rev 0)
+++ trunk/LayoutTests/fast/history/page-cache-subframes-with-provisional-load.html 2019-10-03 22:16:46 UTC (rev 250686)
@@ -0,0 +1,50 @@
+<!-- webkit-test-runner [ enablePageCache=true ] -->
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<iframe id="testFrame1" src=""
+<iframe id="testFrame2" src=""
+<iframe id="testFrame3" src=""
+<iframe id="testFrame4" src=""
+<iframe id="testFrame5" src=""
+<a id="testLink" href="" style="display: none">Link</a>
+<script>
+description("Tests that iframes with a pending provisional or scheduled load do not prevent page caching.");
+jsTestIsAsync = true;
+
+window.addEventListener("pageshow", function(event) {
+ debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache");
+
+ if (event.persisted) {
+ testPassed("Page restored from Page Cache.");
+ finishJSTest();
+ }
+});
+
+window.addEventListener("pagehide", function(event) {
+ debug("pagehide - " + (event.persisted ? "" : "not ") + "entering cache");
+ if (!event.persisted) {
+ testFailed("Page did not enter the page cache.");
+ finishJSTest();
+ }
+
+ // Trigger a quick redirect in the subframe.
+ testFrame3.contentWindow.location.replace("resources/dummy.html");
+});
+
+testFrame5.contentWindow.location.replace("resources/dummy.html");
+
+_onload_ = () => {
+ testFrame4.contentWindow.location.replace("resources/dummy.html");
+ setTimeout(() => {
+ // Trigger a quick redirect in the subframe.
+ testFrame1.contentWindow.location.replace("resources/dummy.html");
+
+ testLink.click();
+
+ testFrame2.contentWindow.location.replace("resources/dummy.html");
+ }, 0);
+}
+</script>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (250685 => 250686)
--- trunk/Source/WebCore/ChangeLog 2019-10-03 21:41:24 UTC (rev 250685)
+++ trunk/Source/WebCore/ChangeLog 2019-10-03 22:16:46 UTC (rev 250686)
@@ -1,5 +1,23 @@
2019-10-03 Chris Dumez <[email protected]>
+ Provisional / scheduled loads in subframes should not prevent a page from entering the back/forward cache
+ https://bugs.webkit.org/show_bug.cgi?id=202474
+
+ Reviewed by Alex Christensen.
+
+ Provisional / scheduled loads in subframes should not prevent a page from entering the back/forward cache.
+ To address the issue, we now make sure to stop all loads before checking for PageCache eligibility.
+
+ Test: fast/history/page-cache-quick-redirect-iframe.html
+
+ * history/PageCache.cpp:
+ (WebCore::PageCache::addIfCacheable):
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::stopForPageCache):
+ * loader/FrameLoader.h:
+
+2019-10-03 Chris Dumez <[email protected]>
+
XMLHttpRequest sometimes prevents pages from entering the back/forward cache
https://bugs.webkit.org/show_bug.cgi?id=202434
<rdar://problem/55890340>
Modified: trunk/Source/WebCore/history/PageCache.cpp (250685 => 250686)
--- trunk/Source/WebCore/history/PageCache.cpp 2019-10-03 21:41:24 UTC (rev 250685)
+++ trunk/Source/WebCore/history/PageCache.cpp 2019-10-03 22:16:46 UTC (rev 250686)
@@ -421,9 +421,14 @@
if (item.isInPageCache())
return false;
- if (!page || !canCache(*page))
+ if (!page)
return false;
+ page->mainFrame().loader().stopForPageCache();
+
+ if (!canCache(*page))
+ return false;
+
ASSERT_WITH_MESSAGE(!page->isUtilityPage(), "Utility pages such as SVGImage pages should never go into PageCache");
setPageCacheState(*page, Document::AboutToEnterPageCache);
@@ -440,10 +445,7 @@
// Stop all loads again before checking if we can still cache the page after firing the pagehide
// event, since the page may have started ping loads in its pagehide event handler.
- for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
- if (auto* documentLoader = frame->loader().documentLoader())
- documentLoader->stopLoading();
- }
+ page->mainFrame().loader().stopForPageCache();
// Check that the page is still page-cacheable after firing the pagehide event. The JS event handlers
// could have altered the page in a way that could prevent caching.
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (250685 => 250686)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2019-10-03 21:41:24 UTC (rev 250685)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2019-10-03 22:16:46 UTC (rev 250686)
@@ -1845,6 +1845,27 @@
m_inStopAllLoaders = false;
}
+void FrameLoader::stopForPageCache()
+{
+ // Make sure there are no scheduled loads or policy checks.
+ policyChecker().stopCheck();
+ m_frame.navigationScheduler().cancel();
+
+ // Stop provisional loads in subframes (The one in the main frame is about to be committed).
+ if (!m_frame.isMainFrame()) {
+ if (m_provisionalDocumentLoader)
+ m_provisionalDocumentLoader->stopLoading();
+ setProvisionalDocumentLoader(nullptr);
+ }
+
+ // Stop current loads.
+ if (m_documentLoader)
+ m_documentLoader->stopLoading();
+
+ for (RefPtr<Frame> child = m_frame.tree().firstChild(); child; child = child->tree().nextSibling())
+ child->loader().stopForPageCache();
+}
+
void FrameLoader::stopAllLoadersAndCheckCompleteness()
{
stopAllLoaders();
Modified: trunk/Source/WebCore/loader/FrameLoader.h (250685 => 250686)
--- trunk/Source/WebCore/loader/FrameLoader.h 2019-10-03 21:41:24 UTC (rev 250685)
+++ trunk/Source/WebCore/loader/FrameLoader.h 2019-10-03 22:16:46 UTC (rev 250686)
@@ -147,6 +147,7 @@
void stopAllLoadersAndCheckCompleteness();
WEBCORE_EXPORT void stopAllLoaders(ClearProvisionalItemPolicy = ShouldClearProvisionalItem, StopLoadingPolicy = StopLoadingPolicy::PreventDuringUnloadEvents);
WEBCORE_EXPORT void stopForUserCancel(bool deferCheckLoadComplete = false);
+ void stopForPageCache();
void stop();
void stopLoading(UnloadEventPolicy);
bool closeURL();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes