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

Side by Side 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, 2 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 unified diff | Download patch
« no previous file with comments | « content/browser/service_worker/service_worker_cache.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/service_worker/service_worker_cache.h" 5 #include "content/browser/service_worker/service_worker_cache.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 EXPECT_TRUE(Match(body_request_)); 312 EXPECT_TRUE(Match(body_request_));
313 EXPECT_EQ(200, callback_response_->status_code); 313 EXPECT_EQ(200, callback_response_->status_code);
314 EXPECT_STREQ("OK", callback_response_->status_text.c_str()); 314 EXPECT_STREQ("OK", callback_response_->status_text.c_str());
315 EXPECT_STREQ("http://example.com/body.html", 315 EXPECT_STREQ("http://example.com/body.html",
316 callback_response_->url.spec().c_str()); 316 callback_response_->url.spec().c_str());
317 std::string response_body; 317 std::string response_body;
318 CopyBody(callback_response_data_.get(), &response_body); 318 CopyBody(callback_response_data_.get(), &response_body);
319 EXPECT_STREQ(expected_blob_data_.c_str(), response_body.c_str()); 319 EXPECT_STREQ(expected_blob_data_.c_str(), response_body.c_str());
320 } 320 }
321 321
322 TEST_P(ServiceWorkerCacheTestP, Vary) {
323 body_request_.headers["vary_foo"] = "foo";
324 body_response_.headers["vary"] = "vary_foo";
325 EXPECT_TRUE(Put(body_request_, body_response_));
326 EXPECT_TRUE(Match(body_request_));
327
328 body_request_.headers["vary_foo"] = "bar";
329 EXPECT_FALSE(Match(body_request_));
330
331 body_request_.headers.erase("vary_foo");
332 EXPECT_FALSE(Match(body_request_));
333 }
334
335 TEST_P(ServiceWorkerCacheTestP, EmptyVary) {
336 body_response_.headers["vary"] = "";
337 EXPECT_TRUE(Put(body_request_, body_response_));
338 EXPECT_TRUE(Match(body_request_));
339
340 body_request_.headers["zoo"] = "zoo";
341 EXPECT_TRUE(Match(body_request_));
342 }
343
344 TEST_P(ServiceWorkerCacheTestP, NoVaryButDiffHeaders) {
345 EXPECT_TRUE(Put(body_request_, body_response_));
346 EXPECT_TRUE(Match(body_request_));
347
348 body_request_.headers["zoo"] = "zoo";
349 EXPECT_TRUE(Match(body_request_));
350 }
351
352 TEST_P(ServiceWorkerCacheTestP, VaryMultiple) {
353 body_request_.headers["vary_foo"] = "foo";
354 body_request_.headers["vary_bar"] = "bar";
355 body_response_.headers["vary"] = " vary_foo , vary_bar";
356 EXPECT_TRUE(Put(body_request_, body_response_));
357 EXPECT_TRUE(Match(body_request_));
358
359 body_request_.headers["vary_bar"] = "foo";
360 EXPECT_FALSE(Match(body_request_));
361
362 body_request_.headers.erase("vary_bar");
363 EXPECT_FALSE(Match(body_request_));
364 }
365
366 TEST_P(ServiceWorkerCacheTestP, VaryNewHeader) {
367 body_request_.headers["vary_foo"] = "foo";
368 body_response_.headers["vary"] = " vary_foo, vary_bar";
369 EXPECT_TRUE(Put(body_request_, body_response_));
370 EXPECT_TRUE(Match(body_request_));
371
372 body_request_.headers["vary_bar"] = "bar";
373 EXPECT_FALSE(Match(body_request_));
374 }
375
376 TEST_P(ServiceWorkerCacheTestP, VaryStar) {
377 body_response_.headers["vary"] = "*";
378 EXPECT_TRUE(Put(body_request_, body_response_));
379 EXPECT_FALSE(Match(body_request_));
380 }
381
322 TEST_P(ServiceWorkerCacheTestP, EmptyKeys) { 382 TEST_P(ServiceWorkerCacheTestP, EmptyKeys) {
323 EXPECT_TRUE(Keys()); 383 EXPECT_TRUE(Keys());
324 EXPECT_EQ(0u, callback_strings_.size()); 384 EXPECT_EQ(0u, callback_strings_.size());
325 } 385 }
326 386
327 TEST_P(ServiceWorkerCacheTestP, TwoKeys) { 387 TEST_P(ServiceWorkerCacheTestP, TwoKeys) {
328 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); 388 EXPECT_TRUE(Put(no_body_request_, no_body_response_));
329 EXPECT_TRUE(Put(body_request_, body_response_)); 389 EXPECT_TRUE(Put(body_request_, body_response_));
330 EXPECT_TRUE(Keys()); 390 EXPECT_TRUE(Keys());
331 EXPECT_EQ(2u, callback_strings_.size()); 391 EXPECT_EQ(2u, callback_strings_.size());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 request.headers["content-type"] = "foo"; 479 request.headers["content-type"] = "foo";
420 request.headers["Content-Type"] = "bar"; 480 request.headers["Content-Type"] = "bar";
421 EXPECT_EQ("bar", request.headers["content-type"]); 481 EXPECT_EQ("bar", request.headers["content-type"]);
422 } 482 }
423 483
424 INSTANTIATE_TEST_CASE_P(ServiceWorkerCacheTest, 484 INSTANTIATE_TEST_CASE_P(ServiceWorkerCacheTest,
425 ServiceWorkerCacheTestP, 485 ServiceWorkerCacheTestP,
426 ::testing::Values(false, true)); 486 ::testing::Values(false, true));
427 487
428 } // namespace content 488 } // namespace content
OLDNEW
« 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