Title: [181728] trunk
Revision
181728
Author
[email protected]
Date
2015-03-18 22:21:40 -0700 (Wed, 18 Mar 2015)

Log Message

Test disk cache behavior when using back navigation cache policy
https://bugs.webkit.org/show_bug.cgi?id=142848

Reviewed by Chris Dumez.

Source/WebCore:

Add a way to override the normal cache policy so we can test reload behavior of cache without actually reloading.

Test: http/tests/cache/disk-cache-validation-back-navigation-policy.html

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::addExtraFieldsToRequest):
* loader/FrameLoader.h:
(WebCore::FrameLoader::setOverrideCachePolicyForTesting):
* testing/Internals.cpp:
(WebCore::Internals::setOverrideCachePolicy):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* http/tests/cache/disk-cache-validation-back-navigation-policy-expected.txt: Added.
* http/tests/cache/disk-cache-validation-back-navigation-policy.html: Added.

    Test permutations of cache headers on reload including Cache-control: must-revalidate.

* platform/mac-wk1/TestExpectations:
* platform/win/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (181727 => 181728)


--- trunk/LayoutTests/ChangeLog	2015-03-19 05:16:41 UTC (rev 181727)
+++ trunk/LayoutTests/ChangeLog	2015-03-19 05:21:40 UTC (rev 181728)
@@ -1,3 +1,18 @@
+2015-03-18  Antti Koivisto  <[email protected]>
+
+        Test disk cache behavior when using back navigation cache policy
+        https://bugs.webkit.org/show_bug.cgi?id=142848
+
+        Reviewed by Chris Dumez.
+
+        * http/tests/cache/disk-cache-validation-back-navigation-policy-expected.txt: Added.
+        * http/tests/cache/disk-cache-validation-back-navigation-policy.html: Added.
+
+            Test permutations of cache headers on reload including Cache-control: must-revalidate.
+
+        * platform/mac-wk1/TestExpectations:
+        * platform/win/TestExpectations:
+
 2015-03-18  Joseph Pecoraro  <[email protected]>
 
         ES6 Classes: Extends should accept an _expression_ without parenthesis

Added: trunk/LayoutTests/http/tests/cache/disk-cache-validation-back-navigation-policy-expected.txt (0 => 181728)


--- trunk/LayoutTests/http/tests/cache/disk-cache-validation-back-navigation-policy-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cache/disk-cache-validation-back-navigation-policy-expected.txt	2015-03-19 05:21:40 UTC (rev 181728)
@@ -0,0 +1,173 @@
+Test permutations of various cache headers when using back navigation cache policy
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+running 54 tests
+
+response headers: undefined
+response source: Disk cache
+
+response headers: {"Cache-control":"max-age=0"}
+response source: Disk cache
+
+response headers: {"Cache-control":"max-age=100"}
+response source: Disk cache
+
+response headers: {"Cache-control":"no-store"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=0, no-store"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=100, no-store"}
+response source: Network
+
+response headers: {"Cache-control":"no-cache"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=0, no-cache"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=100, no-cache"}
+response source: Network
+
+response headers: {"ETag":"match"}
+response source: Disk cache
+
+response headers: {"Cache-control":"max-age=0","ETag":"match"}
+response source: Disk cache
+
+response headers: {"Cache-control":"max-age=100","ETag":"match"}
+response source: Disk cache
+
+response headers: {"Cache-control":"no-store","ETag":"match"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=0, no-store","ETag":"match"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=100, no-store","ETag":"match"}
+response source: Network
+
+response headers: {"Cache-control":"no-cache","ETag":"match"}
+response source: Disk cache after validation
+
+response headers: {"Cache-control":"max-age=0, no-cache","ETag":"match"}
+response source: Disk cache after validation
+
+response headers: {"Cache-control":"max-age=100, no-cache","ETag":"match"}
+response source: Disk cache after validation
+
+response headers: {"ETag":"nomatch"}
+response source: Disk cache
+
+response headers: {"Cache-control":"max-age=0","ETag":"nomatch"}
+response source: Disk cache
+
+response headers: {"Cache-control":"max-age=100","ETag":"nomatch"}
+response source: Disk cache
+
+response headers: {"Cache-control":"no-store","ETag":"nomatch"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=0, no-store","ETag":"nomatch"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=100, no-store","ETag":"nomatch"}
+response source: Network
+
+response headers: {"Cache-control":"no-cache","ETag":"nomatch"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=0, no-cache","ETag":"nomatch"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=100, no-cache","ETag":"nomatch"}
+response source: Network
+
+response headers: {"Cache-control":"must-revalidate"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=0, must-revalidate"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=100, must-revalidate"}
+response source: Disk cache
+
+response headers: {"Cache-control":"no-store, must-revalidate"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=0, no-store, must-revalidate"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=100, no-store, must-revalidate"}
+response source: Network
+
+response headers: {"Cache-control":"no-cache, must-revalidate"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=0, no-cache, must-revalidate"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=100, no-cache, must-revalidate"}
+response source: Network
+
+response headers: {"ETag":"match","Cache-control":"must-revalidate"}
+response source: Disk cache after validation
+
+response headers: {"Cache-control":"max-age=0, must-revalidate","ETag":"match"}
+response source: Disk cache after validation
+
+response headers: {"Cache-control":"max-age=100, must-revalidate","ETag":"match"}
+response source: Disk cache
+
+response headers: {"Cache-control":"no-store, must-revalidate","ETag":"match"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=0, no-store, must-revalidate","ETag":"match"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=100, no-store, must-revalidate","ETag":"match"}
+response source: Network
+
+response headers: {"Cache-control":"no-cache, must-revalidate","ETag":"match"}
+response source: Disk cache after validation
+
+response headers: {"Cache-control":"max-age=0, no-cache, must-revalidate","ETag":"match"}
+response source: Disk cache after validation
+
+response headers: {"Cache-control":"max-age=100, no-cache, must-revalidate","ETag":"match"}
+response source: Disk cache after validation
+
+response headers: {"ETag":"nomatch","Cache-control":"must-revalidate"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=0, must-revalidate","ETag":"nomatch"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=100, must-revalidate","ETag":"nomatch"}
+response source: Disk cache
+
+response headers: {"Cache-control":"no-store, must-revalidate","ETag":"nomatch"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=0, no-store, must-revalidate","ETag":"nomatch"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=100, no-store, must-revalidate","ETag":"nomatch"}
+response source: Network
+
+response headers: {"Cache-control":"no-cache, must-revalidate","ETag":"nomatch"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=0, no-cache, must-revalidate","ETag":"nomatch"}
+response source: Network
+
+response headers: {"Cache-control":"max-age=100, no-cache, must-revalidate","ETag":"nomatch"}
+response source: Network
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/cache/disk-cache-validation-back-navigation-policy.html (0 => 181728)


--- trunk/LayoutTests/http/tests/cache/disk-cache-validation-back-navigation-policy.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cache/disk-cache-validation-back-navigation-policy.html	2015-03-19 05:21:40 UTC (rev 181728)
@@ -0,0 +1,42 @@
+<script src=""
+<script src=""
+<body>
+<script>
+
+var testMatrix =
+[
+ [
+  {},
+  { responseHeaders: {'Cache-control': 'max-age=0' } },
+  { responseHeaders: {'Cache-control': 'max-age=100' } },
+  ],
+ [
+  {},
+  { responseHeaders: {'Cache-control': 'no-store' } },
+  { responseHeaders: {'Cache-control': 'no-cache' } },
+  ],
+ [
+  {},
+  { responseHeaders: {'ETag': 'match' } },
+  { responseHeaders: {'ETag': 'nomatch' } },
+  ],
+ [
+  {},
+  { responseHeaders: {'Cache-control': 'must-revalidate' } },
+  ],
+ ];
+
+description("Test permutations of various cache headers when using back navigation cache policy");
+
+// Simulate cache behavior on back navigation.
+internals.setOverrideCachePolicy("ReturnCacheDataElseLoad");
+
+var tests = generateTests(testMatrix);
+
+debug("running " + tests.length + " tests");
+debug("");
+
+runTests(tests);
+
+</script>
+<script src=""

Modified: trunk/LayoutTests/http/tests/cache/disk-cache-validation.html (181727 => 181728)


--- trunk/LayoutTests/http/tests/cache/disk-cache-validation.html	2015-03-19 05:16:41 UTC (rev 181727)
+++ trunk/LayoutTests/http/tests/cache/disk-cache-validation.html	2015-03-19 05:21:40 UTC (rev 181728)
@@ -39,7 +39,7 @@
 debug("running " + tests.length + " tests");
 debug("");
 
-runTests(generateTests(testMatrix));
+runTests(tests);
 
 </script>
 <script src=""

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (181727 => 181728)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2015-03-19 05:16:41 UTC (rev 181727)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2015-03-19 05:21:40 UTC (rev 181728)
@@ -93,6 +93,7 @@
 
 # Disk cache is WK2 only
 http/tests/cache/disk-cache-validation.html
+http/tests/cache/disk-cache-validation-back-navigation-policy.html
 http/tests/cache/disk-cache-disable.html
 http/tests/cache/disk-cache-vary-cookie.html
 

Modified: trunk/LayoutTests/platform/win/TestExpectations (181727 => 181728)


--- trunk/LayoutTests/platform/win/TestExpectations	2015-03-19 05:16:41 UTC (rev 181727)
+++ trunk/LayoutTests/platform/win/TestExpectations	2015-03-19 05:21:40 UTC (rev 181728)
@@ -2230,6 +2230,7 @@
 
 # Disk cache is WK2 only
 http/tests/cache/disk-cache-validation.html
+http/tests/cache/disk-cache-validation-back-navigation-policy.html
 http/tests/cache/disk-cache-disable.html
 http/tests/cache/disk-cache-vary-cookie.html
 

Modified: trunk/Source/WebCore/ChangeLog (181727 => 181728)


--- trunk/Source/WebCore/ChangeLog	2015-03-19 05:16:41 UTC (rev 181727)
+++ trunk/Source/WebCore/ChangeLog	2015-03-19 05:21:40 UTC (rev 181728)
@@ -1,3 +1,23 @@
+2015-03-18  Antti Koivisto  <[email protected]>
+
+        Test disk cache behavior when using back navigation cache policy
+        https://bugs.webkit.org/show_bug.cgi?id=142848
+
+        Reviewed by Chris Dumez.
+
+        Add a way to override the normal cache policy so we can test reload behavior of cache without actually reloading.
+
+        Test: http/tests/cache/disk-cache-validation-back-navigation-policy.html
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::addExtraFieldsToRequest):
+        * loader/FrameLoader.h:
+        (WebCore::FrameLoader::setOverrideCachePolicyForTesting):
+        * testing/Internals.cpp:
+        (WebCore::Internals::setOverrideCachePolicy):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2015-03-18  Yusuke Suzuki  <[email protected]>
 
         TextFragment#start() is always >= 0 since its type is unsigned

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (181727 => 181728)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2015-03-19 05:16:41 UTC (rev 181727)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2015-03-19 05:21:40 UTC (rev 181728)
@@ -2558,6 +2558,9 @@
     } else if (loadType == FrameLoadType::Reload || loadType == FrameLoadType::ReloadFromOrigin || request.isConditional())
         request.setCachePolicy(ReloadIgnoringCacheData);
 
+    if (m_overrideCachePolicyForTesting)
+        request.setCachePolicy(m_overrideCachePolicyForTesting.value());
+
     if (request.cachePolicy() == ReloadIgnoringCacheData) {
         if (loadType == FrameLoadType::Reload)
             request.setHTTPHeaderField(HTTPHeaderName::CacheControl, "max-age=0");

Modified: trunk/Source/WebCore/loader/FrameLoader.h (181727 => 181728)


--- trunk/Source/WebCore/loader/FrameLoader.h	2015-03-19 05:16:41 UTC (rev 181727)
+++ trunk/Source/WebCore/loader/FrameLoader.h	2015-03-19 05:21:40 UTC (rev 181728)
@@ -41,10 +41,12 @@
 #include "PageThrottler.h"
 #include "ResourceHandleTypes.h"
 #include "ResourceLoadNotifier.h"
+#include "ResourceRequestBase.h"
 #include "SecurityContext.h"
 #include "Timer.h"
 #include <wtf/Forward.h>
 #include <wtf/HashSet.h>
+#include <wtf/Optional.h>
 
 namespace WebCore {
 
@@ -287,6 +289,9 @@
 
     void forcePageTransitionIfNeeded();
 
+    void setOverrideCachePolicyForTesting(ResourceRequestCachePolicy policy) { m_overrideCachePolicyForTesting = policy; }
+    void clearOverrideCachePolicyForTesting() { m_overrideCachePolicyForTesting = Nullopt; }
+
 private:
     enum FormSubmissionCacheLoadPolicy {
         MayAttemptCacheOnlyLoadForFormSubmissionItem,
@@ -436,6 +441,8 @@
 
     RefPtr<FrameNetworkingContext> m_networkingContext;
 
+    Optional<ResourceRequestCachePolicy> m_overrideCachePolicyForTesting;
+
     URL m_previousURL;
     RefPtr<HistoryItem> m_requestedHistoryItem;
     PageActivityAssertionToken m_activityAssertion;

Modified: trunk/Source/WebCore/testing/Internals.cpp (181727 => 181728)


--- trunk/Source/WebCore/testing/Internals.cpp	2015-03-19 05:16:41 UTC (rev 181727)
+++ trunk/Source/WebCore/testing/Internals.cpp	2015-03-19 05:21:40 UTC (rev 181728)
@@ -308,6 +308,7 @@
         page->mainFrame().editor().toggleContinuousSpellChecking();
     if (page->mainFrame().editor().isOverwriteModeEnabled())
         page->mainFrame().editor().toggleOverwriteModeEnabled();
+    page->mainFrame().loader().clearOverrideCachePolicyForTesting();
     ApplicationCacheStorage::singleton().setDefaultOriginQuota(ApplicationCacheStorage::noQuota());
 #if ENABLE(VIDEO)
     MediaSessionManager::sharedManager().resetRestrictions();
@@ -425,6 +426,25 @@
     return "Error";
 }
 
+static ResourceRequestCachePolicy stringToResourceRequestCachePolicy(const String& policy)
+{
+    if (policy == "UseProtocolCachePolicy")
+        return UseProtocolCachePolicy;
+    if (policy == "ReloadIgnoringCacheData")
+        return ReloadIgnoringCacheData;
+    if (policy == "ReturnCacheDataElseLoad")
+        return ReturnCacheDataElseLoad;
+    if (policy == "ReturnCacheDataDontLoad")
+        return ReturnCacheDataDontLoad;
+    ASSERT_NOT_REACHED();
+    return UseProtocolCachePolicy;
+}
+
+void Internals::setOverrideCachePolicy(const String& policy)
+{
+    frame()->loader().setOverrideCachePolicyForTesting(stringToResourceRequestCachePolicy(policy));
+}
+
 void Internals::clearMemoryCache()
 {
     MemoryCache::singleton().evictResources();

Modified: trunk/Source/WebCore/testing/Internals.h (181727 => 181728)


--- trunk/Source/WebCore/testing/Internals.h	2015-03-19 05:16:41 UTC (rev 181727)
+++ trunk/Source/WebCore/testing/Internals.h	2015-03-19 05:21:40 UTC (rev 181728)
@@ -89,6 +89,7 @@
     bool isPreloaded(const String& url);
     bool isLoadingFromMemoryCache(const String& url);
     String xhrResponseSource(XMLHttpRequest*);
+    void setOverrideCachePolicy(const String&);
 
     void clearMemoryCache();
     void pruneMemoryCacheToSize(unsigned size);

Modified: trunk/Source/WebCore/testing/Internals.idl (181727 => 181728)


--- trunk/Source/WebCore/testing/Internals.idl	2015-03-19 05:16:41 UTC (rev 181727)
+++ trunk/Source/WebCore/testing/Internals.idl	2015-03-19 05:21:40 UTC (rev 181728)
@@ -29,6 +29,15 @@
 "document"
 };
 
+// These map to ResourceRequestCachePolicy.
+enum CachePolicy {
+    "UseProtocolCachePolicy",
+    "ReloadIgnoringCacheData",
+    "ReturnCacheDataElseLoad",
+    "ReturnCacheDataDontLoad"
+};
+
+
 [
     NoInterfaceObject,
 ] interface Internals {
@@ -46,6 +55,7 @@
     void clearMemoryCache();
     void pruneMemoryCacheToSize(long size);
     long memoryCacheSize();
+    void setOverrideCachePolicy(CachePolicy policy);
 
     void clearPageCache();
     unsigned int pageCacheSize();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to