Don't put pages that have not reached the non-visually empty layout milestone in the back/forward cache
https://bugs.webkit.org/show_bug.cgi?id=203108
<rdar://problem/56375671>
Reviewed by Geoff Garen.
Source/WebCore:
We don't want to go back to a visually empty page on back/forward navigation.
* history/BackForwardCache.cpp:
(WebCore::canCacheFrame):
* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::visuallyEmptyKey):
* page/DiagnosticLoggingKeys.h:
LayoutTests:
* http/tests/navigation/page-cache-pending-load.html:
Tweak test to add the stylesheet to the body instead of the head since a document
with a pending stylesheet before the body qualifies as visually empty. The test
would be flaky otherwise.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251275 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 626e03a..7e95287 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2019-10-17 Chris Dumez <cdumez@apple.com>
+
+ Don't put pages that have not reached the non-visually empty layout milestone in the back/forward cache
+ https://bugs.webkit.org/show_bug.cgi?id=203108
+ <rdar://problem/56375671>
+
+ Reviewed by Geoff Garen.
+
+ * http/tests/navigation/page-cache-pending-load.html:
+ Tweak test to add the stylesheet to the body instead of the head since a document
+ with a pending stylesheet before the body qualifies as visually empty. The test
+ would be flaky otherwise.
+
2019-10-17 Simon Fraser <simon.fraser@apple.com>
Only include "deep color" in layer tree dumps if a tests requests it
diff --git a/LayoutTests/http/tests/navigation/page-cache-pending-load.html b/LayoutTests/http/tests/navigation/page-cache-pending-load.html
index 176f1b8..2bd495e 100644
--- a/LayoutTests/http/tests/navigation/page-cache-pending-load.html
+++ b/LayoutTests/http/tests/navigation/page-cache-pending-load.html
@@ -33,7 +33,7 @@
link.rel = "stylesheet";
link.type = "text/css";
link.href = "/incremental/resources/slow-utf8-css.pl";
- document.head.appendChild(link);
+ document.body.appendChild(link);
var script = document.createElement("script");
script.async = true;
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 2db0719..05dcb20 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,19 @@
+2019-10-17 Chris Dumez <cdumez@apple.com>
+
+ Don't put pages that have not reached the non-visually empty layout milestone in the back/forward cache
+ https://bugs.webkit.org/show_bug.cgi?id=203108
+ <rdar://problem/56375671>
+
+ Reviewed by Geoff Garen.
+
+ We don't want to go back to a visually empty page on back/forward navigation.
+
+ * history/BackForwardCache.cpp:
+ (WebCore::canCacheFrame):
+ * page/DiagnosticLoggingKeys.cpp:
+ (WebCore::DiagnosticLoggingKeys::visuallyEmptyKey):
+ * page/DiagnosticLoggingKeys.h:
+
2019-10-17 Simon Fraser <simon.fraser@apple.com>
Only include "deep color" in layer tree dumps if a tests requests it
diff --git a/Source/WebCore/history/BackForwardCache.cpp b/Source/WebCore/history/BackForwardCache.cpp
index 937353f..02acd95 100644
--- a/Source/WebCore/history/BackForwardCache.cpp
+++ b/Source/WebCore/history/BackForwardCache.cpp
@@ -132,6 +132,11 @@
logBackForwardCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::noCurrentHistoryItemKey());
isCacheable = false;
}
+ if (frame.isMainFrame() && frame.view() && !frame.view()->isVisuallyNonEmpty()) {
+ PCLOG(" -Main frame is visually empty");
+ logBackForwardCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::visuallyEmptyKey());
+ isCacheable = false;
+ }
if (frameLoader.quickRedirectComing()) {
PCLOG(" -Quick redirect is coming");
logBackForwardCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::quirkRedirectComingKey());
diff --git a/Source/WebCore/page/DiagnosticLoggingKeys.cpp b/Source/WebCore/page/DiagnosticLoggingKeys.cpp
index 98bd0c7..84ff08b 100644
--- a/Source/WebCore/page/DiagnosticLoggingKeys.cpp
+++ b/Source/WebCore/page/DiagnosticLoggingKeys.cpp
@@ -218,6 +218,11 @@
return "backForwardCacheFailure"_s;
}
+String DiagnosticLoggingKeys::visuallyEmptyKey()
+{
+ return "visuallyEmpty"_s;
+}
+
String DiagnosticLoggingKeys::noDocumentLoaderKey()
{
return "noDocumentLoader"_s;
diff --git a/Source/WebCore/page/DiagnosticLoggingKeys.h b/Source/WebCore/page/DiagnosticLoggingKeys.h
index 972a0df..92ac3b6 100644
--- a/Source/WebCore/page/DiagnosticLoggingKeys.h
+++ b/Source/WebCore/page/DiagnosticLoggingKeys.h
@@ -116,6 +116,7 @@
WEBCORE_EXPORT static String otherKey();
static String backForwardCacheKey();
static String backForwardCacheFailureKey();
+ static String visuallyEmptyKey();
static String pageContainsAtLeastOneMediaEngineKey();
static String pageContainsAtLeastOnePluginKey();
static String pageContainsMediaEngineKey();