OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/link_header_support.h" | 5 #include "content/browser/service_worker/link_header_support.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/browser/loader/resource_request_info_impl.h" | 10 #include "content/browser/loader/resource_request_info_impl.h" |
11 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 11 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
12 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 12 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
13 #include "content/browser/service_worker/service_worker_registration.h" | 13 #include "content/browser/service_worker/service_worker_registration.h" |
14 #include "content/browser/service_worker/service_worker_request_handler.h" | 14 #include "content/browser/service_worker/service_worker_request_handler.h" |
15 #include "content/browser/service_worker/service_worker_test_utils.h" | 15 #include "content/browser/service_worker/service_worker_test_utils.h" |
16 #include "content/common/service_worker/service_worker_utils.h" | 16 #include "content/common/service_worker/service_worker_utils.h" |
17 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
| 18 #include "content/public/common/previews_state.h" |
18 #include "content/public/test/mock_resource_context.h" | 19 #include "content/public/test/mock_resource_context.h" |
19 #include "content/public/test/test_browser_thread_bundle.h" | 20 #include "content/public/test/test_browser_thread_bundle.h" |
20 #include "net/http/http_response_headers.h" | 21 #include "net/http/http_response_headers.h" |
21 #include "net/url_request/url_request_test_job.h" | 22 #include "net/url_request/url_request_test_job.h" |
22 #include "net/url_request/url_request_test_util.h" | 23 #include "net/url_request/url_request_test_util.h" |
23 #include "storage/browser/blob/blob_storage_context.h" | 24 #include "storage/browser/blob/blob_storage_context.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 | 26 |
26 namespace content { | 27 namespace content { |
27 | 28 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 109 |
109 std::unique_ptr<net::URLRequest> CreateRequest(const GURL& request_url, | 110 std::unique_ptr<net::URLRequest> CreateRequest(const GURL& request_url, |
110 ResourceType resource_type) { | 111 ResourceType resource_type) { |
111 std::unique_ptr<net::URLRequest> request = request_context_.CreateRequest( | 112 std::unique_ptr<net::URLRequest> request = request_context_.CreateRequest( |
112 request_url, net::DEFAULT_PRIORITY, &request_delegate_); | 113 request_url, net::DEFAULT_PRIORITY, &request_delegate_); |
113 ResourceRequestInfo::AllocateForTesting( | 114 ResourceRequestInfo::AllocateForTesting( |
114 request.get(), resource_type, &resource_context_, | 115 request.get(), resource_type, &resource_context_, |
115 -1 /* render_process_id */, -1 /* render_view_id */, | 116 -1 /* render_process_id */, -1 /* render_view_id */, |
116 -1 /* render_frame_id */, resource_type == RESOURCE_TYPE_MAIN_FRAME, | 117 -1 /* render_frame_id */, resource_type == RESOURCE_TYPE_MAIN_FRAME, |
117 false /* parent_is_main_frame */, true /* allow_download */, | 118 false /* parent_is_main_frame */, true /* allow_download */, |
118 true /* is_async */, false /* is_using_lofi */); | 119 true /* is_async */, PREVIEWS_OFF /* previews_state */); |
119 ResourceRequestInfoImpl::ForRequest(request.get()) | 120 ResourceRequestInfoImpl::ForRequest(request.get()) |
120 ->set_initiated_in_secure_context_for_testing(true); | 121 ->set_initiated_in_secure_context_for_testing(true); |
121 | 122 |
122 ServiceWorkerRequestHandler::InitializeHandler( | 123 ServiceWorkerRequestHandler::InitializeHandler( |
123 request.get(), context_wrapper(), &blob_storage_context_, | 124 request.get(), context_wrapper(), &blob_storage_context_, |
124 render_process_id(), kMockProviderId, false /* skip_service_worker */, | 125 render_process_id(), kMockProviderId, false /* skip_service_worker */, |
125 FETCH_REQUEST_MODE_NO_CORS, FETCH_CREDENTIALS_MODE_OMIT, | 126 FETCH_REQUEST_MODE_NO_CORS, FETCH_CREDENTIALS_MODE_OMIT, |
126 FetchRedirectMode::FOLLOW_MODE, resource_type, | 127 FetchRedirectMode::FOLLOW_MODE, resource_type, |
127 REQUEST_CONTEXT_TYPE_HYPERLINK, REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL, | 128 REQUEST_CONTEXT_TYPE_HYPERLINK, REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL, |
128 nullptr); | 129 nullptr); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 | 391 |
391 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); | 392 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); |
392 ASSERT_EQ(1u, registrations.size()); | 393 ASSERT_EQ(1u, registrations.size()); |
393 } | 394 } |
394 | 395 |
395 INSTANTIATE_TEST_CASE_P(LinkHeaderServiceWorkerTest, | 396 INSTANTIATE_TEST_CASE_P(LinkHeaderServiceWorkerTest, |
396 LinkHeaderServiceWorkerTestP, | 397 LinkHeaderServiceWorkerTestP, |
397 testing::Bool()); | 398 testing::Bool()); |
398 | 399 |
399 } // namespace content | 400 } // namespace content |
OLD | NEW |