Allow HTTPS + 'Cache-control: no-store' sub-frames into the page cache
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Jan 2015 20:59:05 +0000 (20:59 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Jan 2015 20:59:05 +0000 (20:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140302

Reviewed by Andreas Kling.

Source/WebCore:

Allow HTTPS + 'Cache-control: no-store' sub-frames into the page cache.
We already restore 'no-store' sub-resources on history navigation from
the memory cache so there is no reason for our page cache policy to be
more restrictive.

We should align our memory cache / history navigation policy with our
page cache policy.

For now, 'no-store' main resources are not restored from either cache
(memory cache / page cache) on history navigation though. This behavior
does not change.

Test: http/tests/navigation/https-no-store-subframe-in-page-cache.html

* history/PageCache.cpp:
(WebCore::logCanCacheFrameDecision):
(WebCore::PageCache::canCachePageContainingThisFrame):

LayoutTests:

Add a layout test to make sure a page is restored from the page cache
on history navigation, even though its has an HTTPS sub-frame with
"cache-control: no-cache".

* http/tests/navigation/https-no-store-subframe-in-page-cache-expected.txt: Added.
* http/tests/navigation/https-no-store-subframe-in-page-cache.html: Added.
* http/tests/navigation/resources/https-no-store-subframe-in-page-cache.html: Added.
* http/tests/navigation/resources/no-store-frame.php: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178191 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/navigation/https-no-store-subframe-in-page-cache-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/navigation/https-no-store-subframe-in-page-cache.html [new file with mode: 0644]
LayoutTests/http/tests/navigation/resources/https-no-store-subframe-in-page-cache.html [new file with mode: 0644]
LayoutTests/http/tests/navigation/resources/no-store-frame.php [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/history/PageCache.cpp

index 2e67dca..3f462bc 100644 (file)
@@ -1,3 +1,19 @@
+2015-01-09  Chris Dumez  <cdumez@apple.com>
+
+        Allow HTTPS + 'Cache-control: no-store' sub-frames into the page cache
+        https://bugs.webkit.org/show_bug.cgi?id=140302
+
+        Reviewed by Andreas Kling.
+
+        Add a layout test to make sure a page is restored from the page cache
+        on history navigation, even though its has an HTTPS sub-frame with
+        "cache-control: no-cache".
+
+        * http/tests/navigation/https-no-store-subframe-in-page-cache-expected.txt: Added.
+        * http/tests/navigation/https-no-store-subframe-in-page-cache.html: Added.
+        * http/tests/navigation/resources/https-no-store-subframe-in-page-cache.html: Added.
+        * http/tests/navigation/resources/no-store-frame.php: Added.
+
 2015-01-08  Anders Carlsson  <andersca@apple.com>
 
         Start removing Web Database support from workers
diff --git a/LayoutTests/http/tests/navigation/https-no-store-subframe-in-page-cache-expected.txt b/LayoutTests/http/tests/navigation/https-no-store-subframe-in-page-cache-expected.txt
new file mode 100644 (file)
index 0000000..21c45f1
--- /dev/null
@@ -0,0 +1,3 @@
+ALERT: This page is https and has has a subframe with the no-store cache-control directive. It should go in to the page cache.
+ALERT: PASS: The page was restored from the page cache. Good job!
+
diff --git a/LayoutTests/http/tests/navigation/https-no-store-subframe-in-page-cache.html b/LayoutTests/http/tests/navigation/https-no-store-subframe-in-page-cache.html
new file mode 100644 (file)
index 0000000..c24cb59
--- /dev/null
@@ -0,0 +1,12 @@
+<script>
+
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+    testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+}
+
+if (location.protocol != "https:")
+    location = "https://127.0.0.1:8443/navigation/resources/https-no-store-subframe-in-page-cache.html";
+
+</script>
diff --git a/LayoutTests/http/tests/navigation/resources/https-no-store-subframe-in-page-cache.html b/LayoutTests/http/tests/navigation/resources/https-no-store-subframe-in-page-cache.html
new file mode 100644 (file)
index 0000000..636d118
--- /dev/null
@@ -0,0 +1,27 @@
+<iframe src="no-store-frame.php"></iframe>
+
+<script>
+window.onpageshow = function(evt)
+{
+    if (!evt.persisted)
+        return;
+
+    alert("PASS: The page was restored from the page cache. Good job!");
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+window.onload = function()
+{
+    if (window.sessionStorage.https_in_page_cache_started) {
+        alert("FAIL: The page was reloaded on back. It should NOT have been.");
+        if (window.testRunner)
+            testRunner.notifyDone();
+        return;
+    }
+
+    alert("This page is https and has has a subframe with the no-store cache-control directive. It should go in to the page cache.");
+    window.sessionStorage.https_in_page_cache_started = true;
+    setTimeout('window.location = "go-back.html"', 0);
+}
+</script>
diff --git a/LayoutTests/http/tests/navigation/resources/no-store-frame.php b/LayoutTests/http/tests/navigation/resources/no-store-frame.php
new file mode 100644 (file)
index 0000000..6a16e11
--- /dev/null
@@ -0,0 +1,4 @@
+<?php
+header("cache-control: no-store");
+?>
+TEST FRAME
index c7db082..65fd763 100644 (file)
@@ -1,3 +1,28 @@
+2015-01-09  Chris Dumez  <cdumez@apple.com>
+
+        Allow HTTPS + 'Cache-control: no-store' sub-frames into the page cache
+        https://bugs.webkit.org/show_bug.cgi?id=140302
+
+        Reviewed by Andreas Kling.
+
+        Allow HTTPS + 'Cache-control: no-store' sub-frames into the page cache.
+        We already restore 'no-store' sub-resources on history navigation from
+        the memory cache so there is no reason for our page cache policy to be
+        more restrictive.
+
+        We should align our memory cache / history navigation policy with our
+        page cache policy.
+
+        For now, 'no-store' main resources are not restored from either cache
+        (memory cache / page cache) on history navigation though. This behavior
+        does not change.
+
+        Test: http/tests/navigation/https-no-store-subframe-in-page-cache.html
+
+        * history/PageCache.cpp:
+        (WebCore::logCanCacheFrameDecision):
+        (WebCore::PageCache::canCachePageContainingThisFrame):
+
 2015-01-09  Anders Carlsson  <andersca@apple.com>
 
         Try to trigger a rebuild of generated JS bindings.
index 02c3af8..cdf4aab 100644 (file)
@@ -135,7 +135,7 @@ static unsigned logCanCacheFrameDecision(Frame* frame, int indentLevel)
         FEATURE_COUNTER_INCREMENT_KEY(frame->page(), FeatureCounterPageCacheFailureHasPlugins);
         rejectReasons |= 1 << HasPlugins;
     }
-    if (frame->document()->url().protocolIs("https") && frame->loader().documentLoader()->response().cacheControlContainsNoStore()) {
+    if (frame->isMainFrame() && frame->document()->url().protocolIs("https") && frame->loader().documentLoader()->response().cacheControlContainsNoStore()) {
         PCLOG("   -Frame is HTTPS, and cache control prohibits storing");
         FEATURE_COUNTER_INCREMENT_KEY(frame->page(), FeatureCounterPageCacheFailureHTTPSNoStoreKey);
         rejectReasons |= 1 << IsHttpsAndCacheControlled;
@@ -315,7 +315,7 @@ bool PageCache::canCachePageContainingThisFrame(Frame* frame)
         // Do not cache error pages (these can be recognized as pages with substitute data or unreachable URLs).
         && !(documentLoader->substituteData().isValid() && !documentLoader->substituteData().failingURL().isEmpty())
         && (!frameLoader.subframeLoader().containsPlugins() || frame->page()->settings().pageCacheSupportsPlugins())
-        && !(document->url().protocolIs("https") && documentLoader->response().cacheControlContainsNoStore())
+        && !(frame->isMainFrame() && document->url().protocolIs("https") && documentLoader->response().cacheControlContainsNoStore())
 #if ENABLE(SQL_DATABASE)
         && !DatabaseManager::manager().hasOpenDatabases(document)
 #endif