[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

joepeck at webkit.org joepeck at webkit.org
Wed Dec 22 16:05:20 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 853e686d3e6225bd874fe360370949122f6da937
Author: joepeck at webkit.org <joepeck at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Nov 18 17:59:53 2010 +0000

    2010-11-18  Joseph Pecoraro  <joepeck at webkit.org>
    
            Reviewed by Darin Adler.
    
            Allow no-store resources to be used for back navigation
            https://bugs.webkit.org/show_bug.cgi?id=49672
    
            Add tests for checking if the cache was used for a "Cache-control: no-store"
            resource in back navigation, reload navigation, and normal navigation.
    
            * http/tests/cache/history-only-cached-subresource-loads-expected.txt: Added.
            * http/tests/cache/history-only-cached-subresource-loads.html: Added.
            * http/tests/cache/resources/no-store-resource-forward.html: Added.
            * http/tests/cache/resources/no-store-resource-next.html: Added.
            * http/tests/cache/resources/no-store-resource.html: Added.
            * http/tests/cache/resources/random.cgi: Added.
    
    2010-11-18  Joseph Pecoraro  <joepeck at webkit.org>
    
            Reviewed by Darin Adler.
    
            Allow no-store resources to be used for back navigation
            https://bugs.webkit.org/show_bug.cgi?id=49672
    
            Test: http/tests/cache/history-only-cached-subresource-loads.html
    
            HTTP allows "Cache-Control: no-store" resources to "cached" for the
            purposes of history, such as back/forward navigation. Previously
            WebCore just immediately evicted these resources, now we leave them in
            the cache as long as they are not "https". This allows us to use them
            if they are used in a back navigation, or lazily evict and replace
            them on other load types expecting non-stale resources.
    
            (WebCore::CachedResource::CachedResource):
            (WebCore::CachedResource::removeClient): instead of immediately removing the resource from the cache, leave it in the cache.
            * loader/cache/CachedResourceLoader.cpp:
            (WebCore::CachedResourceLoader::checkForReload):
            (WebCore::CachedResourceLoader::requestResource): allow history only resources if the CachePolicy is CachePolicyHistoryBuffer (back/forward navigation).
            * loader/cache/MemoryCache.cpp:
            (WebCore::MemoryCache::requestResource): lazily remove history only resources if it is requested for a load type expecting non-stale resources.
            * loader/cache/MemoryCache.h: default the forHistory parameter to false.
    
              Rename cache policy CachePolicyAllowStale to CachePolicyHistoryBuffer.
    
            * loader/FrameLoader.cpp:
            (WebCore::FrameLoader::subresourceCachePolicy):
            * loader/cache/CachePolicy.h:
            * loader/cache/CachedResource.cpp:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72303 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 0a56bd2..f9efa8f 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,20 @@
+2010-11-18  Joseph Pecoraro  <joepeck at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        Allow no-store resources to be used for back navigation
+        https://bugs.webkit.org/show_bug.cgi?id=49672
+
+        Add tests for checking if the cache was used for a "Cache-control: no-store"
+        resource in back navigation, reload navigation, and normal navigation.
+
+        * http/tests/cache/history-only-cached-subresource-loads-expected.txt: Added.
+        * http/tests/cache/history-only-cached-subresource-loads.html: Added.
+        * http/tests/cache/resources/no-store-resource-forward.html: Added.
+        * http/tests/cache/resources/no-store-resource-next.html: Added.
+        * http/tests/cache/resources/no-store-resource.html: Added.
+        * http/tests/cache/resources/random.cgi: Added.
+
 2010-11-18  Tony Chang  <tony at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/LayoutTests/http/tests/cache/history-only-cached-subresource-loads-expected.txt b/LayoutTests/http/tests/cache/history-only-cached-subresource-loads-expected.txt
new file mode 100644
index 0000000..1125eff
--- /dev/null
+++ b/LayoutTests/http/tests/cache/history-only-cached-subresource-loads-expected.txt
@@ -0,0 +1,8 @@
+This test checks that loading a subresource with "Cache-Control: no-store" is cached and reused in back navigation when the page is not in the page cache.
+
+We then test that loading the same subresource is refetched when used in non-stale loads such as refreshes or normal navigation.
+
+PASS - no-store subresource was cached and used for a back navigation
+PASS - no-store subresource was refetched with a reload
+PASS - no-store subresource was refetched with a normal navigation
+
diff --git a/LayoutTests/http/tests/cache/history-only-cached-subresource-loads.html b/LayoutTests/http/tests/cache/history-only-cached-subresource-loads.html
new file mode 100644
index 0000000..1ad03c0
--- /dev/null
+++ b/LayoutTests/http/tests/cache/history-only-cached-subresource-loads.html
@@ -0,0 +1,89 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Test Caching "no-store" For History Only</title>
+</head>
+<body>
+    <p>
+        This test checks that loading a subresource with "Cache-Control: no-store" is
+        cached and reused in back navigation when the page is not in the page cache.
+    </p>
+    <p>
+        We then test that loading the same subresource is refetched when used in
+        non-stale loads such as refreshes or normal navigation.
+    </p>
+    <pre id="console"></pre>
+    <script>
+    // Asynchronous test because this requires a new window to perform multiple navigations.
+    if (window.layoutTestController) {
+        window.layoutTestController.dumpAsText();
+        window.layoutTestController.waitUntilDone();
+        window.layoutTestController.setCanOpenWindows();
+    }
+
+    // Values to check.
+    var originalRandomNumber = 0;
+    var backLoadRandomNumber = 0;
+    var refreshRandomNumber  = 0;
+    var nextLoadRandomNumber = 0;
+
+    // Window we will be controlling.
+    var target;
+
+    // Pass messages between windows to control the navigation types.
+    var pre = document.getElementById('console');
+    window.addEventListener('message', function(event) {
+
+        // First time, record the first number, and tell the target window to trigger a back navigation.
+        if (!originalRandomNumber) {
+            originalRandomNumber = event.data;
+            target.postMessage('go-forward-and-back', '*');
+            return;
+        }
+
+        // Second time, record the second number. It should be identical. Also tell the target window to reload.
+        if (!backLoadRandomNumber) {
+            backLoadRandomNumber = event.data;
+            var wasCached = (backLoadRandomNumber === originalRandomNumber);
+            if (wasCached)
+                pre.appendChild(document.createTextNode('PASS - no-store subresource was cached and used for a back navigation\n'));
+            else
+                pre.appendChild(document.createTextNode('FAIL - no-store subresource should have been cached and used in a back navigation\n'));
+            target.postMessage('reload', '*');
+            return;
+        }
+
+        // Third time, record the third number. It should not match. Also tell the target window to navigate forward.
+        if (!refreshRandomNumber) {
+            refreshRandomNumber = event.data;
+            var wasCached = (refreshRandomNumber === originalRandomNumber);
+            if (wasCached)
+                pre.appendChild(document.createTextNode('FAIL - no-store subresource should have been refetched with a reload\n'));
+            else
+                pre.appendChild(document.createTextNode('PASS - no-store subresource was refetched with a reload\n'));
+            target.postMessage('next', '*');
+            return;
+        }
+
+        // Fourth time, record the fourth number. It should not match any numbers so far.
+        if (!nextLoadRandomNumber) {
+            nextLoadRandomNumber = event.data;
+            var wasCached = (nextLoadRandomNumber === originalRandomNumber || nextLoadRandomNumber === refreshRandomNumber);
+            if (wasCached)
+                pre.appendChild(document.createTextNode('FAIL - no-store subresource should have been refetched with a normal navigation\n'));
+            else
+                pre.appendChild(document.createTextNode('PASS - no-store subresource was refetched with a normal navigation\n'));
+        }
+
+        // Test completed.
+        target.close();
+        if (window.layoutTestController)
+            window.layoutTestController.notifyDone();
+
+    }, false);
+
+    // Open the target window and it will begin to send us messages.
+    target = window.open('resources/no-store-resource.html');
+    </script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/cache/resources/no-store-resource-forward.html b/LayoutTests/http/tests/cache/resources/no-store-resource-forward.html
new file mode 100644
index 0000000..eb28e43
--- /dev/null
+++ b/LayoutTests/http/tests/cache/resources/no-store-resource-forward.html
@@ -0,0 +1,4 @@
+<p>Now go back</p>
+<script>
+window.history.back();
+</script>
diff --git a/LayoutTests/http/tests/cache/resources/no-store-resource-next.html b/LayoutTests/http/tests/cache/resources/no-store-resource-next.html
new file mode 100644
index 0000000..bde8cdf
--- /dev/null
+++ b/LayoutTests/http/tests/cache/resources/no-store-resource-next.html
@@ -0,0 +1,7 @@
+<h1></h1>
+<script src="random.cgi"></script>
+<script>
+// Random.cgi will include a global "randomNumber".
+// Send this back to our opener.
+opener.postMessage(randomNumber, '*');
+</script>
diff --git a/LayoutTests/http/tests/cache/resources/no-store-resource.html b/LayoutTests/http/tests/cache/resources/no-store-resource.html
new file mode 100644
index 0000000..34ba550
--- /dev/null
+++ b/LayoutTests/http/tests/cache/resources/no-store-resource.html
@@ -0,0 +1,30 @@
+<h1></h1>
+<script src="random.cgi"></script>
+<script>
+// Random.cgi will include a global "randomNumber".
+// Always send this back to our opener.
+opener.postMessage(randomNumber, '*');
+
+// Our opener will tell us to perform various loads.
+window.addEventListener('message', function(event) {
+
+    // Go forward and back.
+    if (event.data === 'go-forward-and-back') {
+        window.location = 'no-store-resource-forward.html';
+        return;
+    }
+
+    // Reload.
+    if (event.data === 'reload') {
+        window.location.reload();
+        return;
+    }
+
+    // Normal navigation, next.
+    if (event.data === 'next') {
+        window.location = 'no-store-resource-next.html';
+        return;
+    }
+
+}, false);
+</script>
diff --git a/LayoutTests/http/tests/cache/resources/random.cgi b/LayoutTests/http/tests/cache/resources/random.cgi
new file mode 100755
index 0000000..8f6621c
--- /dev/null
+++ b/LayoutTests/http/tests/cache/resources/random.cgi
@@ -0,0 +1,9 @@
+#!/usr/bin/perl -w
+
+print "Content-type: text/javascript\n";
+print "Cache-control: no-store\n";
+print "\n";
+
+my $random_number = int(rand(1000000000000));
+print "randomNumber = " . $random_number . ";\n";
+print "document.querySelector('h1').textContent = randomNumber;";
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 993c1d6..c6c32c1 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,35 @@
+2010-11-18  Joseph Pecoraro  <joepeck at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        Allow no-store resources to be used for back navigation
+        https://bugs.webkit.org/show_bug.cgi?id=49672
+
+        Test: http/tests/cache/history-only-cached-subresource-loads.html
+
+        HTTP allows "Cache-Control: no-store" resources to "cached" for the
+        purposes of history, such as back/forward navigation. Previously
+        WebCore just immediately evicted these resources, now we leave them in
+        the cache as long as they are not "https". This allows us to use them
+        if they are used in a back navigation, or lazily evict and replace
+        them on other load types expecting non-stale resources.
+
+        (WebCore::CachedResource::CachedResource):
+        (WebCore::CachedResource::removeClient): instead of immediately removing the resource from the cache, leave it in the cache.
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::checkForReload):
+        (WebCore::CachedResourceLoader::requestResource): allow history only resources if the CachePolicy is CachePolicyHistoryBuffer (back/forward navigation).
+        * loader/cache/MemoryCache.cpp:
+        (WebCore::MemoryCache::requestResource): lazily remove history only resources if it is requested for a load type expecting non-stale resources.
+        * loader/cache/MemoryCache.h: default the forHistory parameter to false.
+
+          Rename cache policy CachePolicyAllowStale to CachePolicyHistoryBuffer.
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::subresourceCachePolicy):
+        * loader/cache/CachePolicy.h:
+        * loader/cache/CachedResource.cpp:
+
 2010-11-18  Alexey Proskuryakov  <ap at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp
index 58113c2..768c8e3 100644
--- a/WebCore/loader/FrameLoader.cpp
+++ b/WebCore/loader/FrameLoader.cpp
@@ -2319,7 +2319,7 @@ CachePolicy FrameLoader::subresourceCachePolicy() const
         return CachePolicyRevalidate;
 
     if (request.cachePolicy() == ReturnCacheDataElseLoad)
-        return CachePolicyAllowStale;
+        return CachePolicyHistoryBuffer;
 
     return CachePolicyVerify;
 }
diff --git a/WebCore/loader/cache/CachePolicy.h b/WebCore/loader/cache/CachePolicy.h
index 2639caa..0b9010b 100644
--- a/WebCore/loader/cache/CachePolicy.h
+++ b/WebCore/loader/cache/CachePolicy.h
@@ -33,7 +33,7 @@ namespace WebCore {
         CachePolicyVerify,
         CachePolicyRevalidate,
         CachePolicyReload,
-        CachePolicyAllowStale
+        CachePolicyHistoryBuffer
     };
 
 }
diff --git a/WebCore/loader/cache/CachedResource.cpp b/WebCore/loader/cache/CachedResource.cpp
index d4eac2e..844065d 100644
--- a/WebCore/loader/cache/CachedResource.cpp
+++ b/WebCore/loader/cache/CachedResource.cpp
@@ -252,8 +252,11 @@ void CachedResource::removeClient(CachedResourceClient* client)
         allClientsRemoved();
         if (response().cacheControlContainsNoStore()) {
             // RFC2616 14.9.2:
-            // "no-store: ...MUST make a best-effort attempt to remove the information from volatile storage as promptly as possible"
-            cache()->remove(this);
+            // "no-store: ... MUST make a best-effort attempt to remove the information from volatile storage as promptly as possible"
+            // "... History buffers MAY store such responses as part of their normal operation."
+            // We allow non-secure content to be reused in history, but we do not allow secure content to be reused.
+            if (protocolIs(url(), "https"))
+                cache()->remove(this);
         } else
             cache()->prune();
     }
diff --git a/WebCore/loader/cache/CachedResourceLoader.cpp b/WebCore/loader/cache/CachedResourceLoader.cpp
index 3d4244c..15c5f03 100644
--- a/WebCore/loader/cache/CachedResourceLoader.cpp
+++ b/WebCore/loader/cache/CachedResourceLoader.cpp
@@ -113,7 +113,7 @@ void CachedResourceLoader::checkForReload(const KURL& fullURL)
     case CachePolicyRevalidate:
         cache()->revalidateResource(existing, this);
         break;
-    case CachePolicyAllowStale:
+    case CachePolicyHistoryBuffer:
         return;
     }
 
@@ -263,7 +263,8 @@ CachedResource* CachedResourceLoader::requestResource(CachedResource::Type type,
 
     checkForReload(fullURL);
 
-    CachedResource* resource = cache()->requestResource(this, type, fullURL, charset, isPreload);
+    bool allowForHistoryOnlyResources = cachePolicy() == CachePolicyHistoryBuffer;
+    CachedResource* resource = cache()->requestResource(this, type, fullURL, charset, isPreload, allowForHistoryOnlyResources);
     if (resource) {
         // Check final URL of resource to catch redirects.
         // See <https://bugs.webkit.org/show_bug.cgi?id=21963>.
diff --git a/WebCore/loader/cache/MemoryCache.cpp b/WebCore/loader/cache/MemoryCache.cpp
index 25af774..79dfc03 100644
--- a/WebCore/loader/cache/MemoryCache.cpp
+++ b/WebCore/loader/cache/MemoryCache.cpp
@@ -94,9 +94,9 @@ static CachedResource* createResource(CachedResource::Type type, const KURL& url
     return 0;
 }
 
-CachedResource* MemoryCache::requestResource(CachedResourceLoader* cachedResourceLoader, CachedResource::Type type, const KURL& url, const String& charset, bool requestIsPreload)
+CachedResource* MemoryCache::requestResource(CachedResourceLoader* cachedResourceLoader, CachedResource::Type type, const KURL& url, const String& charset, bool requestIsPreload, bool forHistory)
 {
-    LOG(ResourceLoading, "MemoryCache::requestResource '%s', charset '%s', preload=%u", url.string().latin1().data(), charset.latin1().data(), requestIsPreload);
+    LOG(ResourceLoading, "MemoryCache::requestResource '%s', charset '%s', preload=%u, forHistory=%u", url.string().latin1().data(), charset.latin1().data(), requestIsPreload, forHistory);
 
     // FIXME: Do we really need to special-case an empty URL?
     // Would it be better to just go on with the cache code and let it fail later?
@@ -106,6 +106,15 @@ CachedResource* MemoryCache::requestResource(CachedResourceLoader* cachedResourc
     // Look up the resource in our map.
     CachedResource* resource = resourceForURL(url.string());
 
+    // Non https "no-store" resources are left in the cache to be used for back/forward navigation only.
+    // If this is not a request forHistory and the resource was served with "no-store" we should evict
+    // it here and make a fresh request.
+    if (!forHistory && resource && resource->response().cacheControlContainsNoStore()) {
+        LOG(ResourceLoading, "MemoryCache::requestResource cleared a for history only resource due to a non-history request for the resource");
+        evict(resource);
+        resource = 0;
+    }
+
     if (resource && requestIsPreload && !resource->isPreloaded()) {
         LOG(ResourceLoading, "MemoryCache::requestResource already has a preload request for this request, and it hasn't been preloaded yet");
         return 0;
diff --git a/WebCore/loader/cache/MemoryCache.h b/WebCore/loader/cache/MemoryCache.h
index bf0f32c..15ce9da 100644
--- a/WebCore/loader/cache/MemoryCache.h
+++ b/WebCore/loader/cache/MemoryCache.h
@@ -109,7 +109,7 @@ public:
 
     // Request resources from the cache.  A load will be initiated and a cache object created if the object is not
     // found in the cache.
-    CachedResource* requestResource(CachedResourceLoader*, CachedResource::Type, const KURL& url, const String& charset, bool isPreload = false);
+    CachedResource* requestResource(CachedResourceLoader*, CachedResource::Type, const KURL& url, const String& charset, bool isPreload = false, bool forHistory = false);
 
     CachedCSSStyleSheet* requestUserCSSStyleSheet(CachedResourceLoader*, const String& url, const String& charset);
     

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list