Title: [251019] trunk
- Revision
- 251019
- Author
- [email protected]
- Date
- 2019-10-11 13:26:15 -0700 (Fri, 11 Oct 2019)
Log Message
Pages frequently fail to enter the back/forward cache due to frames with a quick redirect coming
https://bugs.webkit.org/show_bug.cgi?id=202768
<rdar://problem/56132022>
Reviewed by Alex Christensen.
Source/WebCore:
When a quick redirect is scheduled with the navigation scheduler, we set the m_quickRedirectComing flag.
This flag is supposed to get unset if the navigation gets cancelled and when the navigation actually
happens. However, for a navigation to a _javascript_: URL, we would return early after executing the JS
and fail to reset the m_quickRedirectComing flag. Later on, we would fail to enter the page cache because
we would think that the iframe still has a quick redirect scheduled.
Test: fast/history/page-cache-iframe-js-url.html
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::urlSelected):
Reset the m_quickRedirectComing flag if we return early after executing
the _javascript_ URL.
(WebCore::FrameLoader::stopForPageCache):
Stop policy checks & cancel scheduled navigations after stopping loads. Stopping loads may
run script which may in theory schedule new navigations. This is hardening.
LayoutTests:
Add lauout test coverage.
* fast/history/page-cache-iframe-js-url-expected.txt: Added.
* fast/history/page-cache-iframe-js-url.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (251018 => 251019)
--- trunk/LayoutTests/ChangeLog 2019-10-11 20:20:31 UTC (rev 251018)
+++ trunk/LayoutTests/ChangeLog 2019-10-11 20:26:15 UTC (rev 251019)
@@ -1,3 +1,16 @@
+2019-10-11 Chris Dumez <[email protected]>
+
+ Pages frequently fail to enter the back/forward cache due to frames with a quick redirect coming
+ https://bugs.webkit.org/show_bug.cgi?id=202768
+ <rdar://problem/56132022>
+
+ Reviewed by Alex Christensen.
+
+ Add lauout test coverage.
+
+ * fast/history/page-cache-iframe-js-url-expected.txt: Added.
+ * fast/history/page-cache-iframe-js-url.html: Added.
+
2019-10-11 Kate Cheney <[email protected]>
Get StorageAccess API features working on SQLite database implementation (195422)
Added: trunk/LayoutTests/fast/history/page-cache-iframe-js-url-expected.txt (0 => 251019)
--- trunk/LayoutTests/fast/history/page-cache-iframe-js-url-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/history/page-cache-iframe-js-url-expected.txt 2019-10-11 20:26:15 UTC (rev 251019)
@@ -0,0 +1,13 @@
+Tests that a page with an iframe that ran a _javascript_ URL is able to enter the page cache.
+
+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 did enter and was restored from the page cache
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/history/page-cache-iframe-js-url.html (0 => 251019)
--- trunk/LayoutTests/fast/history/page-cache-iframe-js-url.html (rev 0)
+++ trunk/LayoutTests/fast/history/page-cache-iframe-js-url.html 2019-10-11 20:26:15 UTC (rev 251019)
@@ -0,0 +1,41 @@
+<!-- webkit-test-runner [ enablePageCache=true ] -->
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<img src=""
+<a id="testLink" style="display: none" href=""
+<iframe id="testFrame" src=""
+<script>
+description('Tests that a page with an iframe that ran a _javascript_ URL is able to enter the page cache.');
+jsTestIsAsync = true;
+
+window.addEventListener("pageshow", function(event) {
+ debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache");
+ if (event.persisted) {
+ debug("PASS - Page did enter and was restored from the page cache");
+ finishJSTest();
+ }
+});
+
+window.addEventListener("pagehide", function(event) {
+ debug("pagehide - " + (event.persisted ? "" : "not ") + "entering cache");
+ if (!event.persisted) {
+ debug("FAIL - Page did not enter the page cache.");
+ finishJSTest();
+ }
+});
+
+window.addEventListener('load', function() {
+ setTimeout(() => {
+ document.getElementById("testFrame").contentWindow.location.replace("_javascript_:'foo';");
+ setTimeout(() => {
+ testLink.click();
+ }, 0);
+ }, 0);
+});
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (251018 => 251019)
--- trunk/Source/WebCore/ChangeLog 2019-10-11 20:20:31 UTC (rev 251018)
+++ trunk/Source/WebCore/ChangeLog 2019-10-11 20:26:15 UTC (rev 251019)
@@ -1,3 +1,28 @@
+2019-10-11 Chris Dumez <[email protected]>
+
+ Pages frequently fail to enter the back/forward cache due to frames with a quick redirect coming
+ https://bugs.webkit.org/show_bug.cgi?id=202768
+ <rdar://problem/56132022>
+
+ Reviewed by Alex Christensen.
+
+ When a quick redirect is scheduled with the navigation scheduler, we set the m_quickRedirectComing flag.
+ This flag is supposed to get unset if the navigation gets cancelled and when the navigation actually
+ happens. However, for a navigation to a _javascript_: URL, we would return early after executing the JS
+ and fail to reset the m_quickRedirectComing flag. Later on, we would fail to enter the page cache because
+ we would think that the iframe still has a quick redirect scheduled.
+
+ Test: fast/history/page-cache-iframe-js-url.html
+
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::urlSelected):
+ Reset the m_quickRedirectComing flag if we return early after executing
+ the _javascript_ URL.
+
+ (WebCore::FrameLoader::stopForPageCache):
+ Stop policy checks & cancel scheduled navigations after stopping loads. Stopping loads may
+ run script which may in theory schedule new navigations. This is hardening.
+
2019-10-11 Antti Koivisto <[email protected]>
Position::upstream/downstream should not need to call ensureLineBoxes
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (251018 => 251019)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2019-10-11 20:20:31 UTC (rev 251018)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2019-10-11 20:26:15 UTC (rev 251019)
@@ -395,8 +395,10 @@
Ref<Frame> protect(m_frame);
- if (m_frame.script().executeIfJavaScriptURL(frameRequest.resourceRequest().url(), frameRequest.shouldReplaceDocumentIfJavaScriptURL()))
+ if (m_frame.script().executeIfJavaScriptURL(frameRequest.resourceRequest().url(), frameRequest.shouldReplaceDocumentIfJavaScriptURL())) {
+ m_quickRedirectComing = false;
return;
+ }
if (frameRequest.frameName().isEmpty())
frameRequest.setFrameName(m_frame.document()->baseTarget());
@@ -1847,10 +1849,6 @@
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)
@@ -1864,6 +1862,10 @@
for (RefPtr<Frame> child = m_frame.tree().firstChild(); child; child = child->tree().nextSibling())
child->loader().stopForPageCache();
+
+ // Make sure there are no scheduled loads or policy checks.
+ policyChecker().stopCheck();
+ m_frame.navigationScheduler().cancel();
}
void FrameLoader::stopAllLoadersAndCheckCompleteness()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes