Source/WebCore: https://bugs.webkit.org/show_bug.cgi?id=52044
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Jan 2011 18:32:58 +0000 (18:32 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Jan 2011 18:32:58 +0000 (18:32 +0000)
REGRESSION(r74807): No-store is ignored within a document

Reviewed by Alexey Proskuryakov.

Don't use cached resources with Cache-control: no-store (unless cache policy is CachePolicyHistoryBuffer).
This matches a behavior that got lost in r74807.

Test: http/tests/misc/script-no-store.html
(by Alexey Proskuryakov)

* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::determineRevalidationPolicy):

LayoutTests: https://bugs.webkit.org/show_bug.cgi?id=52044
REGRESSION(r74807): No-store is ignored within a document

Reviewed by Alexey Proskuryakov.

* http/tests/misc/script-no-store-expected.txt: Added.
* http/tests/misc/script-no-store.html: Added.
* http/tests/misc/resources/random-no-store.php: Added.

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

LayoutTests/ChangeLog
LayoutTests/http/tests/misc/resources/random-no-store.php [new file with mode: 0644]
LayoutTests/http/tests/misc/script-no-store-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/misc/script-no-store.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/loader/cache/CachedResourceLoader.cpp

index a9084f8..3d7c17c 100644 (file)
@@ -1,3 +1,14 @@
+2011-01-10  Antti Koivisto  <antti@apple.com>
+
+        Reviewed by Alexey Proskuryakov.
+
+        https://bugs.webkit.org/show_bug.cgi?id=52044
+        REGRESSION(r74807): No-store is ignored within a document
+
+        * http/tests/misc/script-no-store-expected.txt: Added.
+        * http/tests/misc/script-no-store.html: Added.
+        * http/tests/misc/resources/random-no-store.php: Added.
+
 2011-01-10  Alejandro G. Castro  <alex@igalia.com>
 
         Reviewed by Martin Robinson.
diff --git a/LayoutTests/http/tests/misc/resources/random-no-store.php b/LayoutTests/http/tests/misc/resources/random-no-store.php
new file mode 100644 (file)
index 0000000..4b24786
--- /dev/null
@@ -0,0 +1,9 @@
+<?php
+    header("Cache-Control: no-store");
+?>
+var p = document.createElement("p");
+p.appendChild(document.createTextNode("<?php
+    print rand();
+?>
+"));
+document.body.appendChild(p);
diff --git a/LayoutTests/http/tests/misc/script-no-store-expected.txt b/LayoutTests/http/tests/misc/script-no-store-expected.txt
new file mode 100644 (file)
index 0000000..69cfc5a
--- /dev/null
@@ -0,0 +1,2 @@
+PASS
+
diff --git a/LayoutTests/http/tests/misc/script-no-store.html b/LayoutTests/http/tests/misc/script-no-store.html
new file mode 100644 (file)
index 0000000..fdbedf3
--- /dev/null
@@ -0,0 +1,30 @@
+<body>
+<script>
+var count = 0;
+
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+function addRandom()
+{
+    var script = document.createElement("script");
+    script.setAttribute("src", "resources/random-no-store.php");
+    document.body.appendChild(script);
+}
+++count;
+addRandom();
+
+setInterval(function() {
+    if (count == 1 && document.getElementsByTagName("p").length == 1) {
+        ++count;
+        addRandom();
+    } else if (document.getElementsByTagName("p").length == 2) {
+        document.write(document.getElementsByTagName("p")[0].innerHTML == document.getElementsByTagName("p")[1].innerHTML ? 
+            "FAIL<br>" : "PASS<br>");
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+    }
+}, 10);
+</script>
index 470898f..8870ba7 100644 (file)
@@ -1,3 +1,19 @@
+2011-01-10  Antti Koivisto  <antti@apple.com>
+
+        Reviewed by Alexey Proskuryakov.
+
+        https://bugs.webkit.org/show_bug.cgi?id=52044
+        REGRESSION(r74807): No-store is ignored within a document
+        
+        Don't use cached resources with Cache-control: no-store (unless cache policy is CachePolicyHistoryBuffer).
+        This matches a behavior that got lost in r74807.
+
+        Test: http/tests/misc/script-no-store.html
+        (by Alexey Proskuryakov)
+
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::determineRevalidationPolicy):
+
 2011-01-10  Patrick Gansterer  <paroga@webkit.org>
 
         Reviewed by Laszlo Gombos.
index b7060a8..4087622 100644 (file)
@@ -402,6 +402,16 @@ CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida
     if (existingResource->isPreloaded())
         return Use;
     
+    // CachePolicyHistoryBuffer uses the cache no matter what.
+    if (cachePolicy() == CachePolicyHistoryBuffer)
+        return Use;
+
+    // Don't reuse resources with Cache-control: no-store.
+    if (existingResource->response().cacheControlContainsNoStore()) {
+        LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to Cache-control: no-store.");
+        return Reload;
+    }
+
     // Avoid loading the same resource multiple times for a single document, even if the cache policies would tell us to.
     if (m_validatedURLs.contains(existingResource->url()))
         return Use;
@@ -412,10 +422,6 @@ CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida
         return Reload;
     }
     
-    // CachePolicyHistoryBuffer uses the cache no matter what.
-    if (cachePolicy() == CachePolicyHistoryBuffer)
-        return Use;
-    
     // We'll try to reload the resource if it failed last time.
     if (existingResource->errorOccurred()) {
         LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicye reloading due to resource being in the error state");