Title: [252301] trunk/Source/WebCore
Revision
252301
Author
cdu...@apple.com
Date
2019-11-08 19:29:14 -0800 (Fri, 08 Nov 2019)

Log Message

Add back/forward cache quirk for Vimeo.com
https://bugs.webkit.org/show_bug.cgi?id=204025
<rdar://problem/56996057>

Reviewed by Antti Koivisto.

Vimeo.com used to bypass the back/forward cache by serving "Cache-Control: no-store" over HTTPS.
We started caching such content in r250437 but the vimeo.com content unfortunately is not currently compatible
because it changes the opacity of its body to 0 when navigating away and fails to restore the original opacity
when coming back from the back/forward cache (e.g. in 'pageshow' event handler).

To address the issue, this patch introduces a quirk to restore pre-r250437 on Vimeo.com, until they get
a chance to fix their content.

* history/BackForwardCache.cpp:
(WebCore::canCacheFrame):
* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::siteSpecificQuirkKey):
* page/DiagnosticLoggingKeys.h:
* page/Quirks.cpp:
(WebCore::Quirks::shouldBypassBackForwardCache const):
* page/Quirks.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (252300 => 252301)


--- trunk/Source/WebCore/ChangeLog	2019-11-09 03:02:59 UTC (rev 252300)
+++ trunk/Source/WebCore/ChangeLog	2019-11-09 03:29:14 UTC (rev 252301)
@@ -1,3 +1,28 @@
+2019-11-08  Chris Dumez  <cdu...@apple.com>
+
+        Add back/forward cache quirk for Vimeo.com
+        https://bugs.webkit.org/show_bug.cgi?id=204025
+        <rdar://problem/56996057>
+
+        Reviewed by Antti Koivisto.
+
+        Vimeo.com used to bypass the back/forward cache by serving "Cache-Control: no-store" over HTTPS.
+        We started caching such content in r250437 but the vimeo.com content unfortunately is not currently compatible
+        because it changes the opacity of its body to 0 when navigating away and fails to restore the original opacity
+        when coming back from the back/forward cache (e.g. in 'pageshow' event handler).
+
+        To address the issue, this patch introduces a quirk to restore pre-r250437 on Vimeo.com, until they get
+        a chance to fix their content.
+
+        * history/BackForwardCache.cpp:
+        (WebCore::canCacheFrame):
+        * page/DiagnosticLoggingKeys.cpp:
+        (WebCore::DiagnosticLoggingKeys::siteSpecificQuirkKey):
+        * page/DiagnosticLoggingKeys.h:
+        * page/Quirks.cpp:
+        (WebCore::Quirks::shouldBypassBackForwardCache const):
+        * page/Quirks.h:
+
 2019-11-08  Youenn Fablet  <you...@apple.com>
 
         SWServerWorker in redundant state do not need to process messages from the context process

Modified: trunk/Source/WebCore/history/BackForwardCache.cpp (252300 => 252301)


--- trunk/Source/WebCore/history/BackForwardCache.cpp	2019-11-09 03:02:59 UTC (rev 252300)
+++ trunk/Source/WebCore/history/BackForwardCache.cpp	2019-11-09 03:29:14 UTC (rev 252301)
@@ -45,6 +45,7 @@
 #include "IgnoreOpensDuringUnloadCountIncrementer.h"
 #include "Logging.h"
 #include "Page.h"
+#include "Quirks.h"
 #include "ScriptDisallowedScope.h"
 #include "Settings.h"
 #include "SubframeLoader.h"
@@ -116,6 +117,13 @@
         PCLOG(" Determining if subframe with URL (", currentURL.string(), ") can be cached:");
 
     bool isCacheable = true;
+
+    if (frame.isMainFrame() && frame.document()->quirks().shouldBypassBackForwardCache()) {
+        PCLOG("   -Disabled by site-specific quirk");
+        logBackForwardCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::siteSpecificQuirkKey());
+        isCacheable = false;
+    }
+
     // Do not cache error pages (these can be recognized as pages with substitute data or unreachable URLs).
     if (documentLoader->substituteData().isValid() && !documentLoader->substituteData().failingURL().isEmpty()) {
         PCLOG("   -Frame is an error page");

Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp (252300 => 252301)


--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp	2019-11-09 03:02:59 UTC (rev 252300)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp	2019-11-09 03:29:14 UTC (rev 252301)
@@ -535,6 +535,11 @@
     return "serviceWorker"_s;
 }
 
+String DiagnosticLoggingKeys::siteSpecificQuirkKey()
+{
+    return "siteSpecificQuirk"_s;
+}
+
 String DiagnosticLoggingKeys::streamingMedia()
 {
     return "streamingMedia"_s;

Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.h (252300 => 252301)


--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.h	2019-11-09 03:02:59 UTC (rev 252300)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.h	2019-11-09 03:29:14 UTC (rev 252301)
@@ -149,6 +149,7 @@
     static String sameLoadKey();
     static String scriptKey();
     static String serviceWorkerKey();
+    static String siteSpecificQuirkKey();
     WEBCORE_EXPORT static String streamingMedia();
     static String styleSheetKey();
     WEBCORE_EXPORT static String succeededLessThan2SecondsKey();

Modified: trunk/Source/WebCore/page/Quirks.cpp (252300 => 252301)


--- trunk/Source/WebCore/page/Quirks.cpp	2019-11-09 03:02:59 UTC (rev 252300)
+++ trunk/Source/WebCore/page/Quirks.cpp	2019-11-09 03:29:14 UTC (rev 252301)
@@ -609,4 +609,24 @@
     return m_needsFullWidthHeightFullscreenStyleQuirk.value();
 }
 
+bool Quirks::shouldBypassBackForwardCache() const
+{
+    if (!needsQuirks())
+        return false;
+
+    auto topURL = m_document->topDocument().url();
+    auto host = topURL.host();
+
+    // Vimeo.com used to bypass the back/forward cache by serving "Cache-Control: no-store" over HTTPS.
+    // We started caching such content in r250437 but the vimeo.com content unfortunately is not currently compatible
+    // because it changes the opacity of its body to 0 when navigating away and fails to restore the original opacity
+    // when coming back from the back/forward cache (e.g. in 'pageshow' event handler). See <rdar://problem/56996057>.
+    if (topURL.protocolIs("https") && equalLettersIgnoringASCIICase(host, "vimeo.com")) {
+        if (auto* documentLoader = m_document->frame() ? m_document->frame()->loader().documentLoader() : nullptr)
+            return documentLoader->response().cacheControlContainsNoStore();
+    }
+
+    return false;
 }
+
+}

Modified: trunk/Source/WebCore/page/Quirks.h (252300 => 252301)


--- trunk/Source/WebCore/page/Quirks.h	2019-11-09 03:02:59 UTC (rev 252300)
+++ trunk/Source/WebCore/page/Quirks.h	2019-11-09 03:29:14 UTC (rev 252301)
@@ -82,6 +82,8 @@
     bool needsPreloadAutoQuirk() const;
     bool needsFullWidthHeightFullscreenStyleQuirk() const;
 
+    bool shouldBypassBackForwardCache() const;
+
 private:
     bool needsQuirks() const;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to