Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Unified Diff: content/browser/service_worker/service_worker_cache_unittest.cc

Issue 574393002: Add Vary support for ServiceWorkerCache::Match. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/service_worker/service_worker_cache.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_cache_unittest.cc
diff --git a/content/browser/service_worker/service_worker_cache_unittest.cc b/content/browser/service_worker/service_worker_cache_unittest.cc
index 715565b802d9fb1741a5f69bdac56c7ed63df09c..b4dcc3a1f2cb23d421ac09e7d0c8310880dd0edb 100644
--- a/content/browser/service_worker/service_worker_cache_unittest.cc
+++ b/content/browser/service_worker/service_worker_cache_unittest.cc
@@ -319,6 +319,66 @@ TEST_P(ServiceWorkerCacheTestP, MatchBody) {
EXPECT_STREQ(expected_blob_data_.c_str(), response_body.c_str());
}
+TEST_P(ServiceWorkerCacheTestP, Vary) {
+ body_request_.headers["vary_foo"] = "foo";
+ body_response_.headers["vary"] = "vary_foo";
+ EXPECT_TRUE(Put(body_request_, body_response_));
+ EXPECT_TRUE(Match(body_request_));
+
+ body_request_.headers["vary_foo"] = "bar";
+ EXPECT_FALSE(Match(body_request_));
+
+ body_request_.headers.erase("vary_foo");
+ EXPECT_FALSE(Match(body_request_));
+}
+
+TEST_P(ServiceWorkerCacheTestP, EmptyVary) {
+ body_response_.headers["vary"] = "";
+ EXPECT_TRUE(Put(body_request_, body_response_));
+ EXPECT_TRUE(Match(body_request_));
+
+ body_request_.headers["zoo"] = "zoo";
+ EXPECT_TRUE(Match(body_request_));
+}
+
+TEST_P(ServiceWorkerCacheTestP, NoVaryButDiffHeaders) {
+ EXPECT_TRUE(Put(body_request_, body_response_));
+ EXPECT_TRUE(Match(body_request_));
+
+ body_request_.headers["zoo"] = "zoo";
+ EXPECT_TRUE(Match(body_request_));
+}
+
+TEST_P(ServiceWorkerCacheTestP, VaryMultiple) {
+ body_request_.headers["vary_foo"] = "foo";
+ body_request_.headers["vary_bar"] = "bar";
+ body_response_.headers["vary"] = " vary_foo , vary_bar";
+ EXPECT_TRUE(Put(body_request_, body_response_));
+ EXPECT_TRUE(Match(body_request_));
+
+ body_request_.headers["vary_bar"] = "foo";
+ EXPECT_FALSE(Match(body_request_));
+
+ body_request_.headers.erase("vary_bar");
+ EXPECT_FALSE(Match(body_request_));
+}
+
+TEST_P(ServiceWorkerCacheTestP, VaryNewHeader) {
+ body_request_.headers["vary_foo"] = "foo";
+ body_response_.headers["vary"] = " vary_foo, vary_bar";
+ EXPECT_TRUE(Put(body_request_, body_response_));
+ EXPECT_TRUE(Match(body_request_));
+
+ body_request_.headers["vary_bar"] = "bar";
+ EXPECT_FALSE(Match(body_request_));
+}
+
+TEST_P(ServiceWorkerCacheTestP, VaryStar) {
+ body_response_.headers["vary"] = "*";
+ EXPECT_TRUE(Put(body_request_, body_response_));
+ EXPECT_FALSE(Match(body_request_));
+}
+
TEST_P(ServiceWorkerCacheTestP, EmptyKeys) {
EXPECT_TRUE(Keys());
EXPECT_EQ(0u, callback_strings_.size());
« no previous file with comments | « content/browser/service_worker/service_worker_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698