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

Side by Side Diff: content/browser/service_worker/service_worker_cache_unittest.cc

Issue 862053002: Fix referrer policy handling in service workers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates Created 5 years, 11 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
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"
11 #include "content/browser/fileapi/chrome_blob_storage_context.h" 11 #include "content/browser/fileapi/chrome_blob_storage_context.h"
12 #include "content/browser/fileapi/mock_url_request_delegate.h" 12 #include "content/browser/fileapi/mock_url_request_delegate.h"
13 #include "content/browser/quota/mock_quota_manager_proxy.h" 13 #include "content/browser/quota/mock_quota_manager_proxy.h"
14 #include "content/common/service_worker/service_worker_types.h" 14 #include "content/common/service_worker/service_worker_types.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/common/referrer.h"
16 #include "content/public/test/test_browser_context.h" 17 #include "content/public/test/test_browser_context.h"
17 #include "content/public/test/test_browser_thread_bundle.h" 18 #include "content/public/test/test_browser_thread_bundle.h"
18 #include "net/url_request/url_request_context.h" 19 #include "net/url_request/url_request_context.h"
19 #include "net/url_request/url_request_context_getter.h" 20 #include "net/url_request/url_request_context_getter.h"
20 #include "net/url_request/url_request_job_factory_impl.h" 21 #include "net/url_request/url_request_job_factory_impl.h"
21 #include "storage/browser/blob/blob_data_handle.h" 22 #include "storage/browser/blob/blob_data_handle.h"
22 #include "storage/browser/blob/blob_storage_context.h" 23 #include "storage/browser/blob/blob_storage_context.h"
23 #include "storage/browser/blob/blob_url_request_job_factory.h" 24 #include "storage/browser/blob/blob_url_request_job_factory.h"
24 #include "storage/browser/quota/quota_manager_proxy.h" 25 #include "storage/browser/quota/quota_manager_proxy.h"
25 #include "storage/common/blob/blob_data.h" 26 #include "storage/common/blob/blob_data.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 208
208 void TearDown() override { 209 void TearDown() override {
209 quota_manager_proxy_->SimulateQuotaManagerDestroyed(); 210 quota_manager_proxy_->SimulateQuotaManagerDestroyed();
210 base::RunLoop().RunUntilIdle(); 211 base::RunLoop().RunUntilIdle();
211 } 212 }
212 213
213 void CreateRequests(ChromeBlobStorageContext* blob_storage_context) { 214 void CreateRequests(ChromeBlobStorageContext* blob_storage_context) {
214 ServiceWorkerHeaderMap headers; 215 ServiceWorkerHeaderMap headers;
215 headers.insert(std::make_pair("a", "a")); 216 headers.insert(std::make_pair("a", "a"));
216 headers.insert(std::make_pair("b", "b")); 217 headers.insert(std::make_pair("b", "b"));
217 body_request_ = ServiceWorkerFetchRequest( 218 body_request_ =
218 GURL("http://example.com/body.html"), "GET", headers, GURL(), false); 219 ServiceWorkerFetchRequest(GURL("http://example.com/body.html"), "GET",
220 headers, Referrer(), false);
219 no_body_request_ = 221 no_body_request_ =
220 ServiceWorkerFetchRequest(GURL("http://example.com/no_body.html"), 222 ServiceWorkerFetchRequest(GURL("http://example.com/no_body.html"),
221 "GET", 223 "GET",
222 headers, 224 headers,
223 GURL(), 225 Referrer(),
224 false); 226 false);
225 227
226 std::string expected_response; 228 std::string expected_response;
227 for (int i = 0; i < 100; ++i) 229 for (int i = 0; i < 100; ++i)
228 expected_blob_data_ += kTestData; 230 expected_blob_data_ += kTestData;
229 231
230 scoped_refptr<storage::BlobData> blob_data( 232 scoped_refptr<storage::BlobData> blob_data(
231 new storage::BlobData("blob-id:myblob")); 233 new storage::BlobData("blob-id:myblob"));
232 blob_data->AppendData(expected_blob_data_); 234 blob_data->AppendData(expected_blob_data_);
233 235
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 response.headers["Content-Type"] = "bar"; 714 response.headers["Content-Type"] = "bar";
713 EXPECT_EQ("bar", response.headers["content-type"]); 715 EXPECT_EQ("bar", response.headers["content-type"]);
714 } 716 }
715 717
716 TEST_F(ServiceWorkerCacheTest, CaselessServiceWorkerFetchRequestHeaders) { 718 TEST_F(ServiceWorkerCacheTest, CaselessServiceWorkerFetchRequestHeaders) {
717 // ServiceWorkerCache depends on ServiceWorkerFetchRequest having caseless 719 // ServiceWorkerCache depends on ServiceWorkerFetchRequest having caseless
718 // headers so that it can quickly lookup vary headers. 720 // headers so that it can quickly lookup vary headers.
719 ServiceWorkerFetchRequest request(GURL("http://www.example.com"), 721 ServiceWorkerFetchRequest request(GURL("http://www.example.com"),
720 "GET", 722 "GET",
721 ServiceWorkerHeaderMap(), 723 ServiceWorkerHeaderMap(),
722 GURL(), 724 Referrer(),
723 false); 725 false);
724 request.headers["content-type"] = "foo"; 726 request.headers["content-type"] = "foo";
725 request.headers["Content-Type"] = "bar"; 727 request.headers["Content-Type"] = "bar";
726 EXPECT_EQ("bar", request.headers["content-type"]); 728 EXPECT_EQ("bar", request.headers["content-type"]);
727 } 729 }
728 730
729 TEST_P(ServiceWorkerCacheTestP, QuotaManagerModified) { 731 TEST_P(ServiceWorkerCacheTestP, QuotaManagerModified) {
730 EXPECT_EQ(0, quota_manager_proxy_->notify_storage_modified_count()); 732 EXPECT_EQ(0, quota_manager_proxy_->notify_storage_modified_count());
731 733
732 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); 734 EXPECT_TRUE(Put(no_body_request_, no_body_response_));
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 EXPECT_TRUE(callback_closed_); 908 EXPECT_TRUE(callback_closed_);
907 909
908 VerifyAllOpsFail(); 910 VerifyAllOpsFail();
909 } 911 }
910 912
911 INSTANTIATE_TEST_CASE_P(ServiceWorkerCacheTest, 913 INSTANTIATE_TEST_CASE_P(ServiceWorkerCacheTest,
912 ServiceWorkerCacheTestP, 914 ServiceWorkerCacheTestP,
913 ::testing::Values(false, true)); 915 ::testing::Values(false, true));
914 916
915 } // namespace content 917 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698