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

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

Issue 1271733002: [2/3 chromium] Support redirect option of Request and "opaqueredirect" response type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add _MODE to avoid compile error at Windows. Created 5 years, 4 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 "base/files/scoped_temp_dir.h" 5 #include "base/files/scoped_temp_dir.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "content/browser/browser_thread_impl.h" 8 #include "content/browser/browser_thread_impl.h"
9 #include "content/browser/fileapi/mock_url_request_delegate.h" 9 #include "content/browser/fileapi/mock_url_request_delegate.h"
10 #include "content/browser/service_worker/embedded_worker_test_helper.h" 10 #include "content/browser/service_worker/embedded_worker_test_helper.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 version_.get(), 116 version_.get(),
117 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 117 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
118 base::RunLoop().RunUntilIdle(); 118 base::RunLoop().RunUntilIdle();
119 119
120 // Conduct a main resource load. 120 // Conduct a main resource load.
121 const GURL kDocUrl("http://host/scope/doc"); 121 const GURL kDocUrl("http://host/scope/doc");
122 scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( 122 scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest(
123 kDocUrl, net::DEFAULT_PRIORITY, &url_request_delegate_); 123 kDocUrl, net::DEFAULT_PRIORITY, &url_request_delegate_);
124 scoped_ptr<ServiceWorkerControlleeRequestHandler> handler( 124 scoped_ptr<ServiceWorkerControlleeRequestHandler> handler(
125 new ServiceWorkerControlleeRequestHandler( 125 new ServiceWorkerControlleeRequestHandler(
126 context()->AsWeakPtr(), 126 context()->AsWeakPtr(), provider_host_,
127 provider_host_,
128 base::WeakPtr<storage::BlobStorageContext>(), 127 base::WeakPtr<storage::BlobStorageContext>(),
129 FETCH_REQUEST_MODE_NO_CORS, 128 FETCH_REQUEST_MODE_NO_CORS, FETCH_CREDENTIALS_MODE_OMIT,
130 FETCH_CREDENTIALS_MODE_OMIT, 129 FetchRedirectMode::FOLLOW_MODE, RESOURCE_TYPE_MAIN_FRAME,
131 RESOURCE_TYPE_MAIN_FRAME, 130 REQUEST_CONTEXT_TYPE_HYPERLINK, REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL,
132 REQUEST_CONTEXT_TYPE_HYPERLINK,
133 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL,
134 scoped_refptr<ResourceRequestBody>())); 131 scoped_refptr<ResourceRequestBody>()));
135 scoped_refptr<net::URLRequestJob> job = 132 scoped_refptr<net::URLRequestJob> job =
136 handler->MaybeCreateJob(request.get(), NULL, &mock_resource_context_); 133 handler->MaybeCreateJob(request.get(), NULL, &mock_resource_context_);
137 ServiceWorkerURLRequestJob* sw_job = 134 ServiceWorkerURLRequestJob* sw_job =
138 static_cast<ServiceWorkerURLRequestJob*>(job.get()); 135 static_cast<ServiceWorkerURLRequestJob*>(job.get());
139 136
140 EXPECT_FALSE(sw_job->ShouldFallbackToNetwork()); 137 EXPECT_FALSE(sw_job->ShouldFallbackToNetwork());
141 EXPECT_FALSE(sw_job->ShouldForwardToServiceWorker()); 138 EXPECT_FALSE(sw_job->ShouldForwardToServiceWorker());
142 EXPECT_FALSE(version_->HasControllee()); 139 EXPECT_FALSE(version_->HasControllee());
143 base::RunLoop().RunUntilIdle(); 140 base::RunLoop().RunUntilIdle();
(...skipping 15 matching lines...) Expand all
159 version_.get(), 156 version_.get(),
160 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 157 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
161 base::RunLoop().RunUntilIdle(); 158 base::RunLoop().RunUntilIdle();
162 159
163 // Conduct a main resource load. 160 // Conduct a main resource load.
164 const GURL kDocUrl("http://host/scope/doc"); 161 const GURL kDocUrl("http://host/scope/doc");
165 scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( 162 scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest(
166 kDocUrl, net::DEFAULT_PRIORITY, &url_request_delegate_); 163 kDocUrl, net::DEFAULT_PRIORITY, &url_request_delegate_);
167 scoped_ptr<ServiceWorkerControlleeRequestHandler> handler( 164 scoped_ptr<ServiceWorkerControlleeRequestHandler> handler(
168 new ServiceWorkerControlleeRequestHandler( 165 new ServiceWorkerControlleeRequestHandler(
169 context()->AsWeakPtr(), 166 context()->AsWeakPtr(), provider_host_,
170 provider_host_,
171 base::WeakPtr<storage::BlobStorageContext>(), 167 base::WeakPtr<storage::BlobStorageContext>(),
172 FETCH_REQUEST_MODE_NO_CORS, 168 FETCH_REQUEST_MODE_NO_CORS, FETCH_CREDENTIALS_MODE_OMIT,
173 FETCH_CREDENTIALS_MODE_OMIT, 169 FetchRedirectMode::FOLLOW_MODE, RESOURCE_TYPE_MAIN_FRAME,
174 RESOURCE_TYPE_MAIN_FRAME, 170 REQUEST_CONTEXT_TYPE_HYPERLINK, REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL,
175 REQUEST_CONTEXT_TYPE_HYPERLINK,
176 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL,
177 scoped_refptr<ResourceRequestBody>())); 171 scoped_refptr<ResourceRequestBody>()));
178 scoped_refptr<net::URLRequestJob> job = 172 scoped_refptr<net::URLRequestJob> job =
179 handler->MaybeCreateJob(request.get(), NULL, &mock_resource_context_); 173 handler->MaybeCreateJob(request.get(), NULL, &mock_resource_context_);
180 ServiceWorkerURLRequestJob* sw_job = 174 ServiceWorkerURLRequestJob* sw_job =
181 static_cast<ServiceWorkerURLRequestJob*>(job.get()); 175 static_cast<ServiceWorkerURLRequestJob*>(job.get());
182 176
183 EXPECT_FALSE(sw_job->ShouldFallbackToNetwork()); 177 EXPECT_FALSE(sw_job->ShouldFallbackToNetwork());
184 EXPECT_FALSE(sw_job->ShouldForwardToServiceWorker()); 178 EXPECT_FALSE(sw_job->ShouldForwardToServiceWorker());
185 EXPECT_FALSE(version_->HasControllee()); 179 EXPECT_FALSE(version_->HasControllee());
186 180
(...skipping 23 matching lines...) Expand all
210 base::RunLoop().RunUntilIdle(); 204 base::RunLoop().RunUntilIdle();
211 version_ = NULL; 205 version_ = NULL;
212 registration_ = NULL; 206 registration_ = NULL;
213 207
214 // Conduct a main resource load. 208 // Conduct a main resource load.
215 const GURL kDocUrl("http://host/scope/doc"); 209 const GURL kDocUrl("http://host/scope/doc");
216 scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( 210 scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest(
217 kDocUrl, net::DEFAULT_PRIORITY, &url_request_delegate_); 211 kDocUrl, net::DEFAULT_PRIORITY, &url_request_delegate_);
218 scoped_ptr<ServiceWorkerControlleeRequestHandler> handler( 212 scoped_ptr<ServiceWorkerControlleeRequestHandler> handler(
219 new ServiceWorkerControlleeRequestHandler( 213 new ServiceWorkerControlleeRequestHandler(
220 context()->AsWeakPtr(), 214 context()->AsWeakPtr(), provider_host_,
221 provider_host_,
222 base::WeakPtr<storage::BlobStorageContext>(), 215 base::WeakPtr<storage::BlobStorageContext>(),
223 FETCH_REQUEST_MODE_NO_CORS, 216 FETCH_REQUEST_MODE_NO_CORS, FETCH_CREDENTIALS_MODE_OMIT,
224 FETCH_CREDENTIALS_MODE_OMIT, 217 FetchRedirectMode::FOLLOW_MODE, RESOURCE_TYPE_MAIN_FRAME,
225 RESOURCE_TYPE_MAIN_FRAME, 218 REQUEST_CONTEXT_TYPE_HYPERLINK, REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL,
226 REQUEST_CONTEXT_TYPE_HYPERLINK,
227 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL,
228 scoped_refptr<ResourceRequestBody>())); 219 scoped_refptr<ResourceRequestBody>()));
229 scoped_refptr<net::URLRequestJob> job = 220 scoped_refptr<net::URLRequestJob> job =
230 handler->MaybeCreateJob(request.get(), NULL, &mock_resource_context_); 221 handler->MaybeCreateJob(request.get(), NULL, &mock_resource_context_);
231 ServiceWorkerURLRequestJob* sw_job = 222 ServiceWorkerURLRequestJob* sw_job =
232 static_cast<ServiceWorkerURLRequestJob*>(job.get()); 223 static_cast<ServiceWorkerURLRequestJob*>(job.get());
233 224
234 EXPECT_FALSE(sw_job->ShouldFallbackToNetwork()); 225 EXPECT_FALSE(sw_job->ShouldFallbackToNetwork());
235 EXPECT_FALSE(sw_job->ShouldForwardToServiceWorker()); 226 EXPECT_FALSE(sw_job->ShouldForwardToServiceWorker());
236 227
237 // Shouldn't crash if the ProviderHost is deleted prior to completion of 228 // Shouldn't crash if the ProviderHost is deleted prior to completion of
238 // the database lookup. 229 // the database lookup.
239 context()->RemoveProviderHost(kMockRenderProcessId, kMockProviderId); 230 context()->RemoveProviderHost(kMockRenderProcessId, kMockProviderId);
240 EXPECT_FALSE(provider_host_.get()); 231 EXPECT_FALSE(provider_host_.get());
241 base::RunLoop().RunUntilIdle(); 232 base::RunLoop().RunUntilIdle();
242 EXPECT_TRUE(sw_job->ShouldFallbackToNetwork()); 233 EXPECT_TRUE(sw_job->ShouldFallbackToNetwork());
243 EXPECT_FALSE(sw_job->ShouldForwardToServiceWorker()); 234 EXPECT_FALSE(sw_job->ShouldForwardToServiceWorker());
244 } 235 }
245 236
246 } // namespace content 237 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698