Don't put pages that have not reached the non-visually empty layout milestone in...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Oct 2019 05:01:50 +0000 (05:01 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Oct 2019 05:01:50 +0000 (05:01 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@251275 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/navigation/page-cache-pending-load.html
Source/WebCore/ChangeLog
Source/WebCore/history/BackForwardCache.cpp
Source/WebCore/page/DiagnosticLoggingKeys.cpp
Source/WebCore/page/DiagnosticLoggingKeys.h

index 626e03a..7e95287 100644 (file)
@@ -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
index 176f1b8..2bd495e 100644 (file)
@@ -33,7 +33,7 @@ window.addEventListener('load', function() {
     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;
index 2db0719..05dcb20 100644 (file)
@@ -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
index 937353f..02acd95 100644 (file)
@@ -132,6 +132,11 @@ static bool canCacheFrame(Frame& frame, DiagnosticLoggingClient& diagnosticLoggi
         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());
index 98bd0c7..84ff08b 100644 (file)
@@ -218,6 +218,11 @@ String DiagnosticLoggingKeys::backForwardCacheFailureKey()
     return "backForwardCacheFailure"_s;
 }
 
+String DiagnosticLoggingKeys::visuallyEmptyKey()
+{
+    return "visuallyEmpty"_s;
+}
+
 String DiagnosticLoggingKeys::noDocumentLoaderKey()
 {
     return "noDocumentLoader"_s;
index 972a0df..92ac3b6 100644 (file)
@@ -116,6 +116,7 @@ public:
     WEBCORE_EXPORT static String otherKey();
     static String backForwardCacheKey();
     static String backForwardCacheFailureKey();
+    static String visuallyEmptyKey();
     static String pageContainsAtLeastOneMediaEngineKey();
     static String pageContainsAtLeastOnePluginKey();
     static String pageContainsMediaEngineKey();