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

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

Issue 2627543002: ServiceWorker: Returns true for IsMojoForServiceWorkerEnabled (Closed)
Patch Set: Created 3 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 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"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 private: 148 private:
149 TestBrowserThreadBundle thread_bundle_; 149 TestBrowserThreadBundle thread_bundle_;
150 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; 150 std::unique_ptr<EmbeddedWorkerTestHelper> helper_;
151 net::TestURLRequestContext request_context_; 151 net::TestURLRequestContext request_context_;
152 net::TestDelegate request_delegate_; 152 net::TestDelegate request_delegate_;
153 MockResourceContext resource_context_; 153 MockResourceContext resource_context_;
154 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; 154 base::WeakPtr<ServiceWorkerProviderHost> provider_host_;
155 storage::BlobStorageContext blob_storage_context_; 155 storage::BlobStorageContext blob_storage_context_;
156 }; 156 };
157 157
158 class LinkHeaderServiceWorkerTestP 158 TEST_F(LinkHeaderServiceWorkerTest, InstallServiceWorker_Basic) {
159 : public MojoServiceWorkerTestP<LinkHeaderServiceWorkerTest> {};
160
161 TEST_P(LinkHeaderServiceWorkerTestP, InstallServiceWorker_Basic) {
162 ProcessLinkHeaderForRequest( 159 ProcessLinkHeaderForRequest(
163 CreateSubresourceRequest(GURL("https://example.com/foo/bar/")).get(), 160 CreateSubresourceRequest(GURL("https://example.com/foo/bar/")).get(),
164 "<../foo.js>; rel=serviceworker", context_wrapper()); 161 "<../foo.js>; rel=serviceworker", context_wrapper());
165 base::RunLoop().RunUntilIdle(); 162 base::RunLoop().RunUntilIdle();
166 163
167 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); 164 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations();
168 ASSERT_EQ(1u, registrations.size()); 165 ASSERT_EQ(1u, registrations.size());
169 EXPECT_EQ(GURL("https://example.com/foo/"), registrations[0].pattern); 166 EXPECT_EQ(GURL("https://example.com/foo/"), registrations[0].pattern);
170 EXPECT_EQ(GURL("https://example.com/foo/foo.js"), 167 EXPECT_EQ(GURL("https://example.com/foo/foo.js"),
171 registrations[0].active_version.script_url); 168 registrations[0].active_version.script_url);
172 } 169 }
173 170
174 TEST_P(LinkHeaderServiceWorkerTestP, InstallServiceWorker_ScopeWithFragment) { 171 TEST_F(LinkHeaderServiceWorkerTest, InstallServiceWorker_ScopeWithFragment) {
175 ProcessLinkHeaderForRequest( 172 ProcessLinkHeaderForRequest(
176 CreateSubresourceRequest(GURL("https://example.com/foo/bar/")).get(), 173 CreateSubresourceRequest(GURL("https://example.com/foo/bar/")).get(),
177 "<../bar.js>; rel=serviceworker; scope=\"scope#ref\"", context_wrapper()); 174 "<../bar.js>; rel=serviceworker; scope=\"scope#ref\"", context_wrapper());
178 base::RunLoop().RunUntilIdle(); 175 base::RunLoop().RunUntilIdle();
179 176
180 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); 177 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations();
181 ASSERT_EQ(1u, registrations.size()); 178 ASSERT_EQ(1u, registrations.size());
182 EXPECT_EQ(GURL("https://example.com/foo/bar/scope"), 179 EXPECT_EQ(GURL("https://example.com/foo/bar/scope"),
183 registrations[0].pattern); 180 registrations[0].pattern);
184 EXPECT_EQ(GURL("https://example.com/foo/bar.js"), 181 EXPECT_EQ(GURL("https://example.com/foo/bar.js"),
185 registrations[0].active_version.script_url); 182 registrations[0].active_version.script_url);
186 } 183 }
187 184
188 TEST_P(LinkHeaderServiceWorkerTestP, InstallServiceWorker_ScopeAbsoluteUrl) { 185 TEST_F(LinkHeaderServiceWorkerTest, InstallServiceWorker_ScopeAbsoluteUrl) {
189 ProcessLinkHeaderForRequest( 186 ProcessLinkHeaderForRequest(
190 CreateSubresourceRequest(GURL("https://example.com/foo/bar/")).get(), 187 CreateSubresourceRequest(GURL("https://example.com/foo/bar/")).get(),
191 "<bar.js>; rel=serviceworker; " 188 "<bar.js>; rel=serviceworker; "
192 "scope=\"https://example.com:443/foo/bar/scope\"", 189 "scope=\"https://example.com:443/foo/bar/scope\"",
193 context_wrapper()); 190 context_wrapper());
194 base::RunLoop().RunUntilIdle(); 191 base::RunLoop().RunUntilIdle();
195 192
196 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); 193 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations();
197 ASSERT_EQ(1u, registrations.size()); 194 ASSERT_EQ(1u, registrations.size());
198 EXPECT_EQ(GURL("https://example.com/foo/bar/scope"), 195 EXPECT_EQ(GURL("https://example.com/foo/bar/scope"),
199 registrations[0].pattern); 196 registrations[0].pattern);
200 EXPECT_EQ(GURL("https://example.com/foo/bar/bar.js"), 197 EXPECT_EQ(GURL("https://example.com/foo/bar/bar.js"),
201 registrations[0].active_version.script_url); 198 registrations[0].active_version.script_url);
202 } 199 }
203 200
204 TEST_P(LinkHeaderServiceWorkerTestP, 201 TEST_F(LinkHeaderServiceWorkerTest, InstallServiceWorker_ScopeDifferentOrigin) {
205 InstallServiceWorker_ScopeDifferentOrigin) {
206 ProcessLinkHeaderForRequest( 202 ProcessLinkHeaderForRequest(
207 CreateSubresourceRequest(GURL("https://example.com/foobar/")).get(), 203 CreateSubresourceRequest(GURL("https://example.com/foobar/")).get(),
208 "<bar.js>; rel=serviceworker; scope=\"https://google.com/scope\"", 204 "<bar.js>; rel=serviceworker; scope=\"https://google.com/scope\"",
209 context_wrapper()); 205 context_wrapper());
210 base::RunLoop().RunUntilIdle(); 206 base::RunLoop().RunUntilIdle();
211 207
212 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); 208 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations();
213 ASSERT_EQ(0u, registrations.size()); 209 ASSERT_EQ(0u, registrations.size());
214 } 210 }
215 211
216 TEST_P(LinkHeaderServiceWorkerTestP, 212 TEST_F(LinkHeaderServiceWorkerTest, InstallServiceWorker_ScopeUrlEncodedSlash) {
217 InstallServiceWorker_ScopeUrlEncodedSlash) {
218 ProcessLinkHeaderForRequest( 213 ProcessLinkHeaderForRequest(
219 CreateSubresourceRequest(GURL("https://example.com/foobar/")).get(), 214 CreateSubresourceRequest(GURL("https://example.com/foobar/")).get(),
220 "<bar.js>; rel=serviceworker; scope=\"./foo%2Fbar\"", context_wrapper()); 215 "<bar.js>; rel=serviceworker; scope=\"./foo%2Fbar\"", context_wrapper());
221 base::RunLoop().RunUntilIdle(); 216 base::RunLoop().RunUntilIdle();
222 217
223 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); 218 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations();
224 ASSERT_EQ(0u, registrations.size()); 219 ASSERT_EQ(0u, registrations.size());
225 } 220 }
226 221
227 TEST_P(LinkHeaderServiceWorkerTestP, 222 TEST_F(LinkHeaderServiceWorkerTest,
228 InstallServiceWorker_ScriptUrlEncodedSlash) { 223 InstallServiceWorker_ScriptUrlEncodedSlash) {
229 ProcessLinkHeaderForRequest( 224 ProcessLinkHeaderForRequest(
230 CreateSubresourceRequest(GURL("https://example.com/foobar/")).get(), 225 CreateSubresourceRequest(GURL("https://example.com/foobar/")).get(),
231 "<foo%2Fbar.js>; rel=serviceworker", context_wrapper()); 226 "<foo%2Fbar.js>; rel=serviceworker", context_wrapper());
232 base::RunLoop().RunUntilIdle(); 227 base::RunLoop().RunUntilIdle();
233 228
234 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); 229 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations();
235 ASSERT_EQ(0u, registrations.size()); 230 ASSERT_EQ(0u, registrations.size());
236 } 231 }
237 232
238 TEST_P(LinkHeaderServiceWorkerTestP, InstallServiceWorker_ScriptAbsoluteUrl) { 233 TEST_F(LinkHeaderServiceWorkerTest, InstallServiceWorker_ScriptAbsoluteUrl) {
239 ProcessLinkHeaderForRequest( 234 ProcessLinkHeaderForRequest(
240 CreateSubresourceRequest(GURL("https://example.com/foobar/")).get(), 235 CreateSubresourceRequest(GURL("https://example.com/foobar/")).get(),
241 "<https://example.com/bar.js>; rel=serviceworker; scope=foo", 236 "<https://example.com/bar.js>; rel=serviceworker; scope=foo",
242 context_wrapper()); 237 context_wrapper());
243 base::RunLoop().RunUntilIdle(); 238 base::RunLoop().RunUntilIdle();
244 239
245 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); 240 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations();
246 ASSERT_EQ(1u, registrations.size()); 241 ASSERT_EQ(1u, registrations.size());
247 EXPECT_EQ(GURL("https://example.com/foobar/foo"), registrations[0].pattern); 242 EXPECT_EQ(GURL("https://example.com/foobar/foo"), registrations[0].pattern);
248 EXPECT_EQ(GURL("https://example.com/bar.js"), 243 EXPECT_EQ(GURL("https://example.com/bar.js"),
249 registrations[0].active_version.script_url); 244 registrations[0].active_version.script_url);
250 } 245 }
251 246
252 TEST_P(LinkHeaderServiceWorkerTestP, 247 TEST_F(LinkHeaderServiceWorkerTest,
253 InstallServiceWorker_ScriptDifferentOrigin) { 248 InstallServiceWorker_ScriptDifferentOrigin) {
254 ProcessLinkHeaderForRequest( 249 ProcessLinkHeaderForRequest(
255 CreateSubresourceRequest(GURL("https://example.com/foobar/")).get(), 250 CreateSubresourceRequest(GURL("https://example.com/foobar/")).get(),
256 "<https://google.com/bar.js>; rel=serviceworker; scope=foo", 251 "<https://google.com/bar.js>; rel=serviceworker; scope=foo",
257 context_wrapper()); 252 context_wrapper());
258 base::RunLoop().RunUntilIdle(); 253 base::RunLoop().RunUntilIdle();
259 254
260 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); 255 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations();
261 ASSERT_EQ(0u, registrations.size()); 256 ASSERT_EQ(0u, registrations.size());
262 } 257 }
263 258
264 TEST_P(LinkHeaderServiceWorkerTestP, InstallServiceWorker_MultipleWorkers) { 259 TEST_F(LinkHeaderServiceWorkerTest, InstallServiceWorker_MultipleWorkers) {
265 ProcessLinkHeaderForRequest( 260 ProcessLinkHeaderForRequest(
266 CreateSubresourceRequest(GURL("https://example.com/foobar/")).get(), 261 CreateSubresourceRequest(GURL("https://example.com/foobar/")).get(),
267 "<bar.js>; rel=serviceworker; scope=foo, <baz.js>; " 262 "<bar.js>; rel=serviceworker; scope=foo, <baz.js>; "
268 "rel=serviceworker; scope=scope", 263 "rel=serviceworker; scope=scope",
269 context_wrapper()); 264 context_wrapper());
270 base::RunLoop().RunUntilIdle(); 265 base::RunLoop().RunUntilIdle();
271 266
272 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); 267 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations();
273 ASSERT_EQ(2u, registrations.size()); 268 ASSERT_EQ(2u, registrations.size());
274 EXPECT_EQ(GURL("https://example.com/foobar/foo"), registrations[0].pattern); 269 EXPECT_EQ(GURL("https://example.com/foobar/foo"), registrations[0].pattern);
275 EXPECT_EQ(GURL("https://example.com/foobar/bar.js"), 270 EXPECT_EQ(GURL("https://example.com/foobar/bar.js"),
276 registrations[0].active_version.script_url); 271 registrations[0].active_version.script_url);
277 EXPECT_EQ(GURL("https://example.com/foobar/scope"), registrations[1].pattern); 272 EXPECT_EQ(GURL("https://example.com/foobar/scope"), registrations[1].pattern);
278 EXPECT_EQ(GURL("https://example.com/foobar/baz.js"), 273 EXPECT_EQ(GURL("https://example.com/foobar/baz.js"),
279 registrations[1].active_version.script_url); 274 registrations[1].active_version.script_url);
280 } 275 }
281 276
282 TEST_P(LinkHeaderServiceWorkerTestP, 277 TEST_F(LinkHeaderServiceWorkerTest,
283 InstallServiceWorker_ValidAndInvalidValues) { 278 InstallServiceWorker_ValidAndInvalidValues) {
284 ProcessLinkHeaderForRequest( 279 ProcessLinkHeaderForRequest(
285 CreateSubresourceRequest(GURL("https://example.com/foobar/")).get(), 280 CreateSubresourceRequest(GURL("https://example.com/foobar/")).get(),
286 "<https://google.com/bar.js>; rel=serviceworker; scope=foo, <baz.js>; " 281 "<https://google.com/bar.js>; rel=serviceworker; scope=foo, <baz.js>; "
287 "rel=serviceworker; scope=scope", 282 "rel=serviceworker; scope=scope",
288 context_wrapper()); 283 context_wrapper());
289 base::RunLoop().RunUntilIdle(); 284 base::RunLoop().RunUntilIdle();
290 285
291 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); 286 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations();
292 ASSERT_EQ(1u, registrations.size()); 287 ASSERT_EQ(1u, registrations.size());
293 EXPECT_EQ(GURL("https://example.com/foobar/scope"), registrations[0].pattern); 288 EXPECT_EQ(GURL("https://example.com/foobar/scope"), registrations[0].pattern);
294 EXPECT_EQ(GURL("https://example.com/foobar/baz.js"), 289 EXPECT_EQ(GURL("https://example.com/foobar/baz.js"),
295 registrations[0].active_version.script_url); 290 registrations[0].active_version.script_url);
296 } 291 }
297 292
298 TEST_P(LinkHeaderServiceWorkerTestP, InstallServiceWorker_InsecureContext) { 293 TEST_F(LinkHeaderServiceWorkerTest, InstallServiceWorker_InsecureContext) {
299 std::unique_ptr<net::URLRequest> request = 294 std::unique_ptr<net::URLRequest> request =
300 CreateSubresourceRequest(GURL("https://example.com/foo/bar/")); 295 CreateSubresourceRequest(GURL("https://example.com/foo/bar/"));
301 ResourceRequestInfoImpl::ForRequest(request.get()) 296 ResourceRequestInfoImpl::ForRequest(request.get())
302 ->set_initiated_in_secure_context_for_testing(false); 297 ->set_initiated_in_secure_context_for_testing(false);
303 ProcessLinkHeaderForRequest(request.get(), "<../foo.js>; rel=serviceworker", 298 ProcessLinkHeaderForRequest(request.get(), "<../foo.js>; rel=serviceworker",
304 context_wrapper()); 299 context_wrapper());
305 base::RunLoop().RunUntilIdle(); 300 base::RunLoop().RunUntilIdle();
306 301
307 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); 302 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations();
308 ASSERT_EQ(0u, registrations.size()); 303 ASSERT_EQ(0u, registrations.size());
309 } 304 }
310 305
311 TEST_P(LinkHeaderServiceWorkerTestP, 306 TEST_F(LinkHeaderServiceWorkerTest,
312 InstallServiceWorker_NavigationFromInsecureContextToSecureContext) { 307 InstallServiceWorker_NavigationFromInsecureContextToSecureContext) {
313 std::unique_ptr<net::URLRequest> request = CreateRequest( 308 std::unique_ptr<net::URLRequest> request = CreateRequest(
314 GURL("https://example.com/foo/bar/"), RESOURCE_TYPE_MAIN_FRAME); 309 GURL("https://example.com/foo/bar/"), RESOURCE_TYPE_MAIN_FRAME);
315 ResourceRequestInfoImpl::ForRequest(request.get()) 310 ResourceRequestInfoImpl::ForRequest(request.get())
316 ->set_initiated_in_secure_context_for_testing(false); 311 ->set_initiated_in_secure_context_for_testing(false);
317 312
318 provider_host()->SetDocumentUrl(GURL("https://example.com/foo/bar/")); 313 provider_host()->SetDocumentUrl(GURL("https://example.com/foo/bar/"));
319 provider_host()->set_parent_frame_secure(true); 314 provider_host()->set_parent_frame_secure(true);
320 315
321 ProcessLinkHeaderForRequest(request.get(), "<../foo.js>; rel=serviceworker", 316 ProcessLinkHeaderForRequest(request.get(), "<../foo.js>; rel=serviceworker",
322 context_wrapper()); 317 context_wrapper());
323 base::RunLoop().RunUntilIdle(); 318 base::RunLoop().RunUntilIdle();
324 319
325 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); 320 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations();
326 ASSERT_EQ(1u, registrations.size()); 321 ASSERT_EQ(1u, registrations.size());
327 EXPECT_EQ(GURL("https://example.com/foo/"), registrations[0].pattern); 322 EXPECT_EQ(GURL("https://example.com/foo/"), registrations[0].pattern);
328 EXPECT_EQ(GURL("https://example.com/foo/foo.js"), 323 EXPECT_EQ(GURL("https://example.com/foo/foo.js"),
329 registrations[0].active_version.script_url); 324 registrations[0].active_version.script_url);
330 } 325 }
331 326
332 TEST_P(LinkHeaderServiceWorkerTestP, 327 TEST_F(LinkHeaderServiceWorkerTest,
333 InstallServiceWorker_NavigationToInsecureContext) { 328 InstallServiceWorker_NavigationToInsecureContext) {
334 provider_host()->SetDocumentUrl(GURL("http://example.com/foo/bar/")); 329 provider_host()->SetDocumentUrl(GURL("http://example.com/foo/bar/"));
335 provider_host()->set_parent_frame_secure(true); 330 provider_host()->set_parent_frame_secure(true);
336 ProcessLinkHeaderForRequest(CreateRequest(GURL("http://example.com/foo/bar/"), 331 ProcessLinkHeaderForRequest(CreateRequest(GURL("http://example.com/foo/bar/"),
337 RESOURCE_TYPE_MAIN_FRAME) 332 RESOURCE_TYPE_MAIN_FRAME)
338 .get(), 333 .get(),
339 "<../foo.js>; rel=serviceworker", 334 "<../foo.js>; rel=serviceworker",
340 context_wrapper()); 335 context_wrapper());
341 base::RunLoop().RunUntilIdle(); 336 base::RunLoop().RunUntilIdle();
342 337
343 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); 338 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations();
344 ASSERT_EQ(0u, registrations.size()); 339 ASSERT_EQ(0u, registrations.size());
345 } 340 }
346 341
347 TEST_P(LinkHeaderServiceWorkerTestP, 342 TEST_F(LinkHeaderServiceWorkerTest,
348 InstallServiceWorker_NavigationToInsecureHttpsContext) { 343 InstallServiceWorker_NavigationToInsecureHttpsContext) {
349 provider_host()->SetDocumentUrl(GURL("https://example.com/foo/bar/")); 344 provider_host()->SetDocumentUrl(GURL("https://example.com/foo/bar/"));
350 provider_host()->set_parent_frame_secure(false); 345 provider_host()->set_parent_frame_secure(false);
351 ProcessLinkHeaderForRequest( 346 ProcessLinkHeaderForRequest(
352 CreateRequest(GURL("https://example.com/foo/bar/"), 347 CreateRequest(GURL("https://example.com/foo/bar/"),
353 RESOURCE_TYPE_MAIN_FRAME) 348 RESOURCE_TYPE_MAIN_FRAME)
354 .get(), 349 .get(),
355 "<../foo.js>; rel=serviceworker", context_wrapper()); 350 "<../foo.js>; rel=serviceworker", context_wrapper());
356 base::RunLoop().RunUntilIdle(); 351 base::RunLoop().RunUntilIdle();
357 352
358 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); 353 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations();
359 ASSERT_EQ(0u, registrations.size()); 354 ASSERT_EQ(0u, registrations.size());
360 } 355 }
361 356
362 TEST_P(LinkHeaderServiceWorkerTestP, 357 TEST_F(LinkHeaderServiceWorkerTest,
363 InstallServiceWorker_FromWorkerWithoutControllees) { 358 InstallServiceWorker_FromWorkerWithoutControllees) {
364 CreateServiceWorkerProviderHost(); 359 CreateServiceWorkerProviderHost();
365 ProcessLinkHeaderForRequest( 360 ProcessLinkHeaderForRequest(
366 CreateSubresourceRequest(GURL("https://example.com/foo/bar/")).get(), 361 CreateSubresourceRequest(GURL("https://example.com/foo/bar/")).get(),
367 "<../foo.js>; rel=serviceworker", context_wrapper()); 362 "<../foo.js>; rel=serviceworker", context_wrapper());
368 base::RunLoop().RunUntilIdle(); 363 base::RunLoop().RunUntilIdle();
369 364
370 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); 365 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations();
371 ASSERT_EQ(0u, registrations.size()); 366 ASSERT_EQ(0u, registrations.size());
372 } 367 }
373 368
374 TEST_P(LinkHeaderServiceWorkerTestP, 369 TEST_F(LinkHeaderServiceWorkerTest,
375 InstallServiceWorker_FromWorkerWithControllees) { 370 InstallServiceWorker_FromWorkerWithControllees) {
376 CreateServiceWorkerProviderHost(); 371 CreateServiceWorkerProviderHost();
377 372
378 std::unique_ptr<ServiceWorkerProviderHost> controllee( 373 std::unique_ptr<ServiceWorkerProviderHost> controllee(
379 new ServiceWorkerProviderHost( 374 new ServiceWorkerProviderHost(
380 render_process_id(), MSG_ROUTING_NONE, kMockProviderId, 375 render_process_id(), MSG_ROUTING_NONE, kMockProviderId,
381 SERVICE_WORKER_PROVIDER_FOR_WINDOW, 376 SERVICE_WORKER_PROVIDER_FOR_WINDOW,
382 ServiceWorkerProviderHost::FrameSecurityLevel::UNINITIALIZED, 377 ServiceWorkerProviderHost::FrameSecurityLevel::UNINITIALIZED,
383 context()->AsWeakPtr(), nullptr)); 378 context()->AsWeakPtr(), nullptr));
384 provider_host()->running_hosted_version()->AddControllee(controllee.get()); 379 provider_host()->running_hosted_version()->AddControllee(controllee.get());
385 380
386 ProcessLinkHeaderForRequest( 381 ProcessLinkHeaderForRequest(
387 CreateSubresourceRequest(GURL("https://example.com/foo/bar/")).get(), 382 CreateSubresourceRequest(GURL("https://example.com/foo/bar/")).get(),
388 "<../foo.js>; rel=serviceworker", context_wrapper()); 383 "<../foo.js>; rel=serviceworker", context_wrapper());
389 base::RunLoop().RunUntilIdle(); 384 base::RunLoop().RunUntilIdle();
390 385
391 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); 386 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations();
392 ASSERT_EQ(1u, registrations.size()); 387 ASSERT_EQ(1u, registrations.size());
393 } 388 }
394 389
395 INSTANTIATE_TEST_CASE_P(LinkHeaderServiceWorkerTest,
396 LinkHeaderServiceWorkerTestP,
397 testing::Bool());
398
399 } // namespace content 390 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698