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

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

Issue 2431313003: Mojofy unittests related to service workers (Closed)
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_dispatcher_host.h" 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "content/browser/browser_thread_impl.h" 16 #include "content/browser/browser_thread_impl.h"
17 #include "content/browser/message_port_service.h" 17 #include "content/browser/message_port_service.h"
18 #include "content/browser/service_worker/embedded_worker_instance.h" 18 #include "content/browser/service_worker/embedded_worker_instance.h"
19 #include "content/browser/service_worker/embedded_worker_registry.h" 19 #include "content/browser/service_worker/embedded_worker_registry.h"
20 #include "content/browser/service_worker/embedded_worker_status.h" 20 #include "content/browser/service_worker/embedded_worker_status.h"
21 #include "content/browser/service_worker/embedded_worker_test_helper.h" 21 #include "content/browser/service_worker/embedded_worker_test_helper.h"
22 #include "content/browser/service_worker/service_worker_context_core.h" 22 #include "content/browser/service_worker/service_worker_context_core.h"
23 #include "content/browser/service_worker/service_worker_context_wrapper.h" 23 #include "content/browser/service_worker/service_worker_context_wrapper.h"
24 #include "content/browser/service_worker/service_worker_handle.h" 24 #include "content/browser/service_worker/service_worker_handle.h"
25 #include "content/browser/service_worker/service_worker_test_utils.h"
25 #include "content/common/service_worker/embedded_worker_messages.h" 26 #include "content/common/service_worker/embedded_worker_messages.h"
26 #include "content/common/service_worker/service_worker_messages.h" 27 #include "content/common/service_worker/service_worker_messages.h"
27 #include "content/common/service_worker/service_worker_utils.h" 28 #include "content/common/service_worker/service_worker_utils.h"
28 #include "content/public/common/content_switches.h" 29 #include "content/public/common/content_switches.h"
29 #include "content/public/test/mock_resource_context.h" 30 #include "content/public/test/mock_resource_context.h"
30 #include "content/public/test/test_browser_thread_bundle.h" 31 #include "content/public/test/test_browser_thread_bundle.h"
31 #include "content/test/test_content_browser_client.h" 32 #include "content/test/test_content_browser_client.h"
32 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
33 34
34 namespace content { 35 namespace content {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 250
250 TestBrowserThreadBundle browser_thread_bundle_; 251 TestBrowserThreadBundle browser_thread_bundle_;
251 content::MockResourceContext resource_context_; 252 content::MockResourceContext resource_context_;
252 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; 253 std::unique_ptr<EmbeddedWorkerTestHelper> helper_;
253 scoped_refptr<TestingServiceWorkerDispatcherHost> dispatcher_host_; 254 scoped_refptr<TestingServiceWorkerDispatcherHost> dispatcher_host_;
254 scoped_refptr<ServiceWorkerRegistration> registration_; 255 scoped_refptr<ServiceWorkerRegistration> registration_;
255 scoped_refptr<ServiceWorkerVersion> version_; 256 scoped_refptr<ServiceWorkerVersion> version_;
256 ServiceWorkerProviderHost* provider_host_; 257 ServiceWorkerProviderHost* provider_host_;
257 }; 258 };
258 259
260 class ServiceWorkerDispatcherHostTestP
261 : public MojoServiceWorkerTestP<ServiceWorkerDispatcherHostTest> {};
262
259 class ServiceWorkerTestContentBrowserClient : public TestContentBrowserClient { 263 class ServiceWorkerTestContentBrowserClient : public TestContentBrowserClient {
260 public: 264 public:
261 ServiceWorkerTestContentBrowserClient() {} 265 ServiceWorkerTestContentBrowserClient() {}
262 bool AllowServiceWorker(const GURL& scope, 266 bool AllowServiceWorker(const GURL& scope,
263 const GURL& first_party, 267 const GURL& first_party,
264 content::ResourceContext* context, 268 content::ResourceContext* context,
265 int render_process_id, 269 int render_process_id,
266 int render_frame_id) override { 270 int render_frame_id) override {
267 return false; 271 return false;
268 } 272 }
269 }; 273 };
270 274
271 TEST_F(ServiceWorkerDispatcherHostTest, 275 TEST_P(ServiceWorkerDispatcherHostTestP,
272 Register_ContentSettingsDisallowsServiceWorker) { 276 Register_ContentSettingsDisallowsServiceWorker) {
273 ServiceWorkerTestContentBrowserClient test_browser_client; 277 ServiceWorkerTestContentBrowserClient test_browser_client;
274 ContentBrowserClient* old_browser_client = 278 ContentBrowserClient* old_browser_client =
275 SetBrowserClientForTesting(&test_browser_client); 279 SetBrowserClientForTesting(&test_browser_client);
276 280
277 const int64_t kProviderId = 99; // Dummy value 281 const int64_t kProviderId = 99; // Dummy value
278 std::unique_ptr<ServiceWorkerProviderHost> host( 282 std::unique_ptr<ServiceWorkerProviderHost> host(
279 CreateServiceWorkerProviderHost(kProviderId)); 283 CreateServiceWorkerProviderHost(kProviderId));
280 host->SetDocumentUrl(GURL("https://www.example.com/foo")); 284 host->SetDocumentUrl(GURL("https://www.example.com/foo"));
281 context()->AddProviderHost(std::move(host)); 285 context()->AddProviderHost(std::move(host));
(...skipping 13 matching lines...) Expand all
295 const int64_t kRegistrationId = 999; // Dummy value 299 const int64_t kRegistrationId = 999; // Dummy value
296 scoped_refptr<ServiceWorkerRegistration> registration( 300 scoped_refptr<ServiceWorkerRegistration> registration(
297 new ServiceWorkerRegistration(GURL("https://www.example.com/"), 301 new ServiceWorkerRegistration(GURL("https://www.example.com/"),
298 kRegistrationId, context()->AsWeakPtr())); 302 kRegistrationId, context()->AsWeakPtr()));
299 Unregister(kProviderId, kRegistrationId, 303 Unregister(kProviderId, kRegistrationId,
300 ServiceWorkerMsg_ServiceWorkerUnregistrationError::ID); 304 ServiceWorkerMsg_ServiceWorkerUnregistrationError::ID);
301 305
302 SetBrowserClientForTesting(old_browser_client); 306 SetBrowserClientForTesting(old_browser_client);
303 } 307 }
304 308
305 TEST_F(ServiceWorkerDispatcherHostTest, Register_HTTPS) { 309 TEST_P(ServiceWorkerDispatcherHostTestP, Register_HTTPS) {
306 const int64_t kProviderId = 99; // Dummy value 310 const int64_t kProviderId = 99; // Dummy value
307 std::unique_ptr<ServiceWorkerProviderHost> host( 311 std::unique_ptr<ServiceWorkerProviderHost> host(
308 CreateServiceWorkerProviderHost(kProviderId)); 312 CreateServiceWorkerProviderHost(kProviderId));
309 host->SetDocumentUrl(GURL("https://www.example.com/foo")); 313 host->SetDocumentUrl(GURL("https://www.example.com/foo"));
310 context()->AddProviderHost(std::move(host)); 314 context()->AddProviderHost(std::move(host));
311 315
312 Register(kProviderId, 316 Register(kProviderId,
313 GURL("https://www.example.com/"), 317 GURL("https://www.example.com/"),
314 GURL("https://www.example.com/bar"), 318 GURL("https://www.example.com/bar"),
315 ServiceWorkerMsg_ServiceWorkerRegistered::ID); 319 ServiceWorkerMsg_ServiceWorkerRegistered::ID);
316 } 320 }
317 321
318 TEST_F(ServiceWorkerDispatcherHostTest, Register_NonSecureTransportLocalhost) { 322 TEST_P(ServiceWorkerDispatcherHostTestP, Register_NonSecureTransportLocalhost) {
319 const int64_t kProviderId = 99; // Dummy value 323 const int64_t kProviderId = 99; // Dummy value
320 std::unique_ptr<ServiceWorkerProviderHost> host( 324 std::unique_ptr<ServiceWorkerProviderHost> host(
321 CreateServiceWorkerProviderHost(kProviderId)); 325 CreateServiceWorkerProviderHost(kProviderId));
322 host->SetDocumentUrl(GURL("http://127.0.0.3:81/foo")); 326 host->SetDocumentUrl(GURL("http://127.0.0.3:81/foo"));
323 context()->AddProviderHost(std::move(host)); 327 context()->AddProviderHost(std::move(host));
324 328
325 Register(kProviderId, 329 Register(kProviderId,
326 GURL("http://127.0.0.3:81/bar"), 330 GURL("http://127.0.0.3:81/bar"),
327 GURL("http://127.0.0.3:81/baz"), 331 GURL("http://127.0.0.3:81/baz"),
328 ServiceWorkerMsg_ServiceWorkerRegistered::ID); 332 ServiceWorkerMsg_ServiceWorkerRegistered::ID);
329 } 333 }
330 334
331 TEST_F(ServiceWorkerDispatcherHostTest, Register_InvalidScopeShouldFail) { 335 TEST_P(ServiceWorkerDispatcherHostTestP, Register_InvalidScopeShouldFail) {
332 const int64_t kProviderId = 99; // Dummy value 336 const int64_t kProviderId = 99; // Dummy value
333 std::unique_ptr<ServiceWorkerProviderHost> host( 337 std::unique_ptr<ServiceWorkerProviderHost> host(
334 CreateServiceWorkerProviderHost(kProviderId)); 338 CreateServiceWorkerProviderHost(kProviderId));
335 host->SetDocumentUrl(GURL("https://www.example.com/foo")); 339 host->SetDocumentUrl(GURL("https://www.example.com/foo"));
336 context()->AddProviderHost(std::move(host)); 340 context()->AddProviderHost(std::move(host));
337 341
338 SendRegister(kProviderId, GURL(""), 342 SendRegister(kProviderId, GURL(""),
339 GURL("https://www.example.com/bar/hoge.js")); 343 GURL("https://www.example.com/bar/hoge.js"));
340 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); 344 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_);
341 } 345 }
342 346
343 TEST_F(ServiceWorkerDispatcherHostTest, Register_InvalidScriptShouldFail) { 347 TEST_P(ServiceWorkerDispatcherHostTestP, Register_InvalidScriptShouldFail) {
344 const int64_t kProviderId = 99; // Dummy value 348 const int64_t kProviderId = 99; // Dummy value
345 std::unique_ptr<ServiceWorkerProviderHost> host( 349 std::unique_ptr<ServiceWorkerProviderHost> host(
346 CreateServiceWorkerProviderHost(kProviderId)); 350 CreateServiceWorkerProviderHost(kProviderId));
347 host->SetDocumentUrl(GURL("https://www.example.com/foo")); 351 host->SetDocumentUrl(GURL("https://www.example.com/foo"));
348 context()->AddProviderHost(std::move(host)); 352 context()->AddProviderHost(std::move(host));
349 353
350 SendRegister(kProviderId, GURL("https://www.example.com/bar/"), GURL("")); 354 SendRegister(kProviderId, GURL("https://www.example.com/bar/"), GURL(""));
351 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); 355 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_);
352 } 356 }
353 357
354 TEST_F(ServiceWorkerDispatcherHostTest, Register_NonSecureOriginShouldFail) { 358 TEST_P(ServiceWorkerDispatcherHostTestP, Register_NonSecureOriginShouldFail) {
355 const int64_t kProviderId = 99; // Dummy value 359 const int64_t kProviderId = 99; // Dummy value
356 std::unique_ptr<ServiceWorkerProviderHost> host( 360 std::unique_ptr<ServiceWorkerProviderHost> host(
357 CreateServiceWorkerProviderHost(kProviderId)); 361 CreateServiceWorkerProviderHost(kProviderId));
358 host->SetDocumentUrl(GURL("http://www.example.com/foo")); 362 host->SetDocumentUrl(GURL("http://www.example.com/foo"));
359 context()->AddProviderHost(std::move(host)); 363 context()->AddProviderHost(std::move(host));
360 364
361 SendRegister(kProviderId, 365 SendRegister(kProviderId,
362 GURL("http://www.example.com/"), 366 GURL("http://www.example.com/"),
363 GURL("http://www.example.com/bar")); 367 GURL("http://www.example.com/bar"));
364 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); 368 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_);
365 } 369 }
366 370
367 TEST_F(ServiceWorkerDispatcherHostTest, Register_CrossOriginShouldFail) { 371 TEST_P(ServiceWorkerDispatcherHostTestP, Register_CrossOriginShouldFail) {
368 const int64_t kProviderId = 99; // Dummy value 372 const int64_t kProviderId = 99; // Dummy value
369 std::unique_ptr<ServiceWorkerProviderHost> host( 373 std::unique_ptr<ServiceWorkerProviderHost> host(
370 CreateServiceWorkerProviderHost(kProviderId)); 374 CreateServiceWorkerProviderHost(kProviderId));
371 host->SetDocumentUrl(GURL("https://www.example.com/foo")); 375 host->SetDocumentUrl(GURL("https://www.example.com/foo"));
372 context()->AddProviderHost(std::move(host)); 376 context()->AddProviderHost(std::move(host));
373 377
374 // Script has a different host 378 // Script has a different host
375 SendRegister(kProviderId, 379 SendRegister(kProviderId,
376 GURL("https://www.example.com/"), 380 GURL("https://www.example.com/"),
377 GURL("https://foo.example.com/bar")); 381 GURL("https://foo.example.com/bar"));
(...skipping 23 matching lines...) Expand all
401 GURL("https://foo.example.com/bar")); 405 GURL("https://foo.example.com/bar"));
402 EXPECT_EQ(5, dispatcher_host_->bad_messages_received_count_); 406 EXPECT_EQ(5, dispatcher_host_->bad_messages_received_count_);
403 407
404 // Script and scope URLs are invalid 408 // Script and scope URLs are invalid
405 SendRegister(kProviderId, 409 SendRegister(kProviderId,
406 GURL(), 410 GURL(),
407 GURL("h@ttps://@")); 411 GURL("h@ttps://@"));
408 EXPECT_EQ(6, dispatcher_host_->bad_messages_received_count_); 412 EXPECT_EQ(6, dispatcher_host_->bad_messages_received_count_);
409 } 413 }
410 414
411 TEST_F(ServiceWorkerDispatcherHostTest, Register_BadCharactersShouldFail) { 415 TEST_P(ServiceWorkerDispatcherHostTestP, Register_BadCharactersShouldFail) {
412 const int64_t kProviderId = 99; // Dummy value 416 const int64_t kProviderId = 99; // Dummy value
413 std::unique_ptr<ServiceWorkerProviderHost> host( 417 std::unique_ptr<ServiceWorkerProviderHost> host(
414 CreateServiceWorkerProviderHost(kProviderId)); 418 CreateServiceWorkerProviderHost(kProviderId));
415 host->SetDocumentUrl(GURL("https://www.example.com/")); 419 host->SetDocumentUrl(GURL("https://www.example.com/"));
416 context()->AddProviderHost(std::move(host)); 420 context()->AddProviderHost(std::move(host));
417 421
418 SendRegister(kProviderId, GURL("https://www.example.com/%2f"), 422 SendRegister(kProviderId, GURL("https://www.example.com/%2f"),
419 GURL("https://www.example.com/")); 423 GURL("https://www.example.com/"));
420 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); 424 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_);
421 425
(...skipping 11 matching lines...) Expand all
433 437
434 SendRegister(kProviderId, GURL("https://www.example.com/"), 438 SendRegister(kProviderId, GURL("https://www.example.com/"),
435 GURL("https://www.example.com/%5c")); 439 GURL("https://www.example.com/%5c"));
436 EXPECT_EQ(5, dispatcher_host_->bad_messages_received_count_); 440 EXPECT_EQ(5, dispatcher_host_->bad_messages_received_count_);
437 441
438 SendRegister(kProviderId, GURL("https://www.example.com/"), 442 SendRegister(kProviderId, GURL("https://www.example.com/"),
439 GURL("https://www.example.com/%5C")); 443 GURL("https://www.example.com/%5C"));
440 EXPECT_EQ(6, dispatcher_host_->bad_messages_received_count_); 444 EXPECT_EQ(6, dispatcher_host_->bad_messages_received_count_);
441 } 445 }
442 446
443 TEST_F(ServiceWorkerDispatcherHostTest, 447 TEST_P(ServiceWorkerDispatcherHostTestP,
444 Register_FileSystemDocumentShouldFail) { 448 Register_FileSystemDocumentShouldFail) {
445 const int64_t kProviderId = 99; // Dummy value 449 const int64_t kProviderId = 99; // Dummy value
446 std::unique_ptr<ServiceWorkerProviderHost> host( 450 std::unique_ptr<ServiceWorkerProviderHost> host(
447 CreateServiceWorkerProviderHost(kProviderId)); 451 CreateServiceWorkerProviderHost(kProviderId));
448 host->SetDocumentUrl(GURL("filesystem:https://www.example.com/temporary/a")); 452 host->SetDocumentUrl(GURL("filesystem:https://www.example.com/temporary/a"));
449 context()->AddProviderHost(std::move(host)); 453 context()->AddProviderHost(std::move(host));
450 454
451 SendRegister(kProviderId, 455 SendRegister(kProviderId,
452 GURL("filesystem:https://www.example.com/temporary/"), 456 GURL("filesystem:https://www.example.com/temporary/"),
453 GURL("https://www.example.com/temporary/bar")); 457 GURL("https://www.example.com/temporary/bar"));
454 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); 458 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_);
455 459
456 SendRegister(kProviderId, 460 SendRegister(kProviderId,
457 GURL("https://www.example.com/temporary/"), 461 GURL("https://www.example.com/temporary/"),
458 GURL("filesystem:https://www.example.com/temporary/bar")); 462 GURL("filesystem:https://www.example.com/temporary/bar"));
459 EXPECT_EQ(2, dispatcher_host_->bad_messages_received_count_); 463 EXPECT_EQ(2, dispatcher_host_->bad_messages_received_count_);
460 464
461 SendRegister(kProviderId, 465 SendRegister(kProviderId,
462 GURL("filesystem:https://www.example.com/temporary/"), 466 GURL("filesystem:https://www.example.com/temporary/"),
463 GURL("filesystem:https://www.example.com/temporary/bar")); 467 GURL("filesystem:https://www.example.com/temporary/bar"));
464 EXPECT_EQ(3, dispatcher_host_->bad_messages_received_count_); 468 EXPECT_EQ(3, dispatcher_host_->bad_messages_received_count_);
465 } 469 }
466 470
467 TEST_F(ServiceWorkerDispatcherHostTest, 471 TEST_P(ServiceWorkerDispatcherHostTestP,
468 Register_FileSystemScriptOrScopeShouldFail) { 472 Register_FileSystemScriptOrScopeShouldFail) {
469 const int64_t kProviderId = 99; // Dummy value 473 const int64_t kProviderId = 99; // Dummy value
470 std::unique_ptr<ServiceWorkerProviderHost> host( 474 std::unique_ptr<ServiceWorkerProviderHost> host(
471 CreateServiceWorkerProviderHost(kProviderId)); 475 CreateServiceWorkerProviderHost(kProviderId));
472 host->SetDocumentUrl(GURL("https://www.example.com/temporary/")); 476 host->SetDocumentUrl(GURL("https://www.example.com/temporary/"));
473 context()->AddProviderHost(std::move(host)); 477 context()->AddProviderHost(std::move(host));
474 478
475 SendRegister(kProviderId, 479 SendRegister(kProviderId,
476 GURL("filesystem:https://www.example.com/temporary/"), 480 GURL("filesystem:https://www.example.com/temporary/"),
477 GURL("https://www.example.com/temporary/bar")); 481 GURL("https://www.example.com/temporary/bar"));
478 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); 482 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_);
479 483
480 SendRegister(kProviderId, 484 SendRegister(kProviderId,
481 GURL("https://www.example.com/temporary/"), 485 GURL("https://www.example.com/temporary/"),
482 GURL("filesystem:https://www.example.com/temporary/bar")); 486 GURL("filesystem:https://www.example.com/temporary/bar"));
483 EXPECT_EQ(2, dispatcher_host_->bad_messages_received_count_); 487 EXPECT_EQ(2, dispatcher_host_->bad_messages_received_count_);
484 488
485 SendRegister(kProviderId, 489 SendRegister(kProviderId,
486 GURL("filesystem:https://www.example.com/temporary/"), 490 GURL("filesystem:https://www.example.com/temporary/"),
487 GURL("filesystem:https://www.example.com/temporary/bar")); 491 GURL("filesystem:https://www.example.com/temporary/bar"));
488 EXPECT_EQ(3, dispatcher_host_->bad_messages_received_count_); 492 EXPECT_EQ(3, dispatcher_host_->bad_messages_received_count_);
489 } 493 }
490 494
491 TEST_F(ServiceWorkerDispatcherHostTest, EarlyContextDeletion) { 495 TEST_P(ServiceWorkerDispatcherHostTestP, EarlyContextDeletion) {
492 helper_->ShutdownContext(); 496 helper_->ShutdownContext();
493 497
494 // Let the shutdown reach the simulated IO thread. 498 // Let the shutdown reach the simulated IO thread.
495 base::RunLoop().RunUntilIdle(); 499 base::RunLoop().RunUntilIdle();
496 500
497 Register(-1, 501 Register(-1,
498 GURL(), 502 GURL(),
499 GURL(), 503 GURL(),
500 ServiceWorkerMsg_ServiceWorkerRegistrationError::ID); 504 ServiceWorkerMsg_ServiceWorkerRegistrationError::ID);
501 } 505 }
502 506
503 TEST_F(ServiceWorkerDispatcherHostTest, ProviderCreatedAndDestroyed) { 507 TEST_P(ServiceWorkerDispatcherHostTestP, ProviderCreatedAndDestroyed) {
504 const int kProviderId = 1001; 508 const int kProviderId = 1001;
505 int process_id = helper_->mock_render_process_id(); 509 int process_id = helper_->mock_render_process_id();
506 510
507 dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated( 511 dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated(
508 kProviderId, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW, 512 kProviderId, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW,
509 true /* is_parent_frame_secure */)); 513 true /* is_parent_frame_secure */));
510 EXPECT_TRUE(context()->GetProviderHost(process_id, kProviderId)); 514 EXPECT_TRUE(context()->GetProviderHost(process_id, kProviderId));
511 515
512 // Two with the same ID should be seen as a bad message. 516 // Two with the same ID should be seen as a bad message.
513 dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated( 517 dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated(
(...skipping 14 matching lines...) Expand all
528 // process to get deleted as well. 532 // process to get deleted as well.
529 dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated( 533 dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated(
530 kProviderId, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW, 534 kProviderId, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW,
531 true /* is_parent_frame_secure */)); 535 true /* is_parent_frame_secure */));
532 EXPECT_TRUE(context()->GetProviderHost(process_id, kProviderId)); 536 EXPECT_TRUE(context()->GetProviderHost(process_id, kProviderId));
533 EXPECT_TRUE(dispatcher_host_->HasOneRef()); 537 EXPECT_TRUE(dispatcher_host_->HasOneRef());
534 dispatcher_host_ = NULL; 538 dispatcher_host_ = NULL;
535 EXPECT_FALSE(context()->GetProviderHost(process_id, kProviderId)); 539 EXPECT_FALSE(context()->GetProviderHost(process_id, kProviderId));
536 } 540 }
537 541
538 TEST_F(ServiceWorkerDispatcherHostTest, GetRegistration_SameOrigin) { 542 TEST_P(ServiceWorkerDispatcherHostTestP, GetRegistration_SameOrigin) {
539 const int64_t kProviderId = 99; // Dummy value 543 const int64_t kProviderId = 99; // Dummy value
540 std::unique_ptr<ServiceWorkerProviderHost> host( 544 std::unique_ptr<ServiceWorkerProviderHost> host(
541 CreateServiceWorkerProviderHost(kProviderId)); 545 CreateServiceWorkerProviderHost(kProviderId));
542 host->SetDocumentUrl(GURL("https://www.example.com/foo")); 546 host->SetDocumentUrl(GURL("https://www.example.com/foo"));
543 context()->AddProviderHost(std::move(host)); 547 context()->AddProviderHost(std::move(host));
544 548
545 GetRegistration(kProviderId, 549 GetRegistration(kProviderId,
546 GURL("https://www.example.com/"), 550 GURL("https://www.example.com/"),
547 ServiceWorkerMsg_DidGetRegistration::ID); 551 ServiceWorkerMsg_DidGetRegistration::ID);
548 } 552 }
549 553
550 TEST_F(ServiceWorkerDispatcherHostTest, GetRegistration_CrossOriginShouldFail) { 554 TEST_P(ServiceWorkerDispatcherHostTestP,
555 GetRegistration_CrossOriginShouldFail) {
551 const int64_t kProviderId = 99; // Dummy value 556 const int64_t kProviderId = 99; // Dummy value
552 std::unique_ptr<ServiceWorkerProviderHost> host( 557 std::unique_ptr<ServiceWorkerProviderHost> host(
553 CreateServiceWorkerProviderHost(kProviderId)); 558 CreateServiceWorkerProviderHost(kProviderId));
554 host->SetDocumentUrl(GURL("https://www.example.com/foo")); 559 host->SetDocumentUrl(GURL("https://www.example.com/foo"));
555 context()->AddProviderHost(std::move(host)); 560 context()->AddProviderHost(std::move(host));
556 561
557 SendGetRegistration(kProviderId, GURL("https://foo.example.com/")); 562 SendGetRegistration(kProviderId, GURL("https://foo.example.com/"));
558 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); 563 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_);
559 } 564 }
560 565
561 TEST_F(ServiceWorkerDispatcherHostTest, 566 TEST_P(ServiceWorkerDispatcherHostTestP,
562 GetRegistration_InvalidScopeShouldFail) { 567 GetRegistration_InvalidScopeShouldFail) {
563 const int64_t kProviderId = 99; // Dummy value 568 const int64_t kProviderId = 99; // Dummy value
564 std::unique_ptr<ServiceWorkerProviderHost> host( 569 std::unique_ptr<ServiceWorkerProviderHost> host(
565 CreateServiceWorkerProviderHost(kProviderId)); 570 CreateServiceWorkerProviderHost(kProviderId));
566 host->SetDocumentUrl(GURL("https://www.example.com/foo")); 571 host->SetDocumentUrl(GURL("https://www.example.com/foo"));
567 context()->AddProviderHost(std::move(host)); 572 context()->AddProviderHost(std::move(host));
568 573
569 SendGetRegistration(kProviderId, GURL("")); 574 SendGetRegistration(kProviderId, GURL(""));
570 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); 575 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_);
571 } 576 }
572 577
573 TEST_F(ServiceWorkerDispatcherHostTest, 578 TEST_P(ServiceWorkerDispatcherHostTestP,
574 GetRegistration_NonSecureOriginShouldFail) { 579 GetRegistration_NonSecureOriginShouldFail) {
575 const int64_t kProviderId = 99; // Dummy value 580 const int64_t kProviderId = 99; // Dummy value
576 std::unique_ptr<ServiceWorkerProviderHost> host( 581 std::unique_ptr<ServiceWorkerProviderHost> host(
577 CreateServiceWorkerProviderHost(kProviderId)); 582 CreateServiceWorkerProviderHost(kProviderId));
578 host->SetDocumentUrl(GURL("http://www.example.com/foo")); 583 host->SetDocumentUrl(GURL("http://www.example.com/foo"));
579 context()->AddProviderHost(std::move(host)); 584 context()->AddProviderHost(std::move(host));
580 585
581 SendGetRegistration(kProviderId, GURL("http://www.example.com/")); 586 SendGetRegistration(kProviderId, GURL("http://www.example.com/"));
582 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); 587 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_);
583 } 588 }
584 589
585 TEST_F(ServiceWorkerDispatcherHostTest, GetRegistration_EarlyContextDeletion) { 590 TEST_P(ServiceWorkerDispatcherHostTestP, GetRegistration_EarlyContextDeletion) {
586 helper_->ShutdownContext(); 591 helper_->ShutdownContext();
587 592
588 // Let the shutdown reach the simulated IO thread. 593 // Let the shutdown reach the simulated IO thread.
589 base::RunLoop().RunUntilIdle(); 594 base::RunLoop().RunUntilIdle();
590 595
591 GetRegistration(-1, 596 GetRegistration(-1,
592 GURL(), 597 GURL(),
593 ServiceWorkerMsg_ServiceWorkerGetRegistrationError::ID); 598 ServiceWorkerMsg_ServiceWorkerGetRegistrationError::ID);
594 } 599 }
595 600
596 TEST_F(ServiceWorkerDispatcherHostTest, GetRegistrations_SecureOrigin) { 601 TEST_P(ServiceWorkerDispatcherHostTestP, GetRegistrations_SecureOrigin) {
597 const int64_t kProviderId = 99; // Dummy value 602 const int64_t kProviderId = 99; // Dummy value
598 std::unique_ptr<ServiceWorkerProviderHost> host( 603 std::unique_ptr<ServiceWorkerProviderHost> host(
599 CreateServiceWorkerProviderHost(kProviderId)); 604 CreateServiceWorkerProviderHost(kProviderId));
600 host->SetDocumentUrl(GURL("https://www.example.com/foo")); 605 host->SetDocumentUrl(GURL("https://www.example.com/foo"));
601 context()->AddProviderHost(std::move(host)); 606 context()->AddProviderHost(std::move(host));
602 607
603 GetRegistrations(kProviderId, ServiceWorkerMsg_DidGetRegistrations::ID); 608 GetRegistrations(kProviderId, ServiceWorkerMsg_DidGetRegistrations::ID);
604 } 609 }
605 610
606 TEST_F(ServiceWorkerDispatcherHostTest, 611 TEST_P(ServiceWorkerDispatcherHostTestP,
607 GetRegistrations_NonSecureOriginShouldFail) { 612 GetRegistrations_NonSecureOriginShouldFail) {
608 const int64_t kProviderId = 99; // Dummy value 613 const int64_t kProviderId = 99; // Dummy value
609 std::unique_ptr<ServiceWorkerProviderHost> host( 614 std::unique_ptr<ServiceWorkerProviderHost> host(
610 CreateServiceWorkerProviderHost(kProviderId)); 615 CreateServiceWorkerProviderHost(kProviderId));
611 host->SetDocumentUrl(GURL("http://www.example.com/foo")); 616 host->SetDocumentUrl(GURL("http://www.example.com/foo"));
612 context()->AddProviderHost(std::move(host)); 617 context()->AddProviderHost(std::move(host));
613 618
614 SendGetRegistrations(kProviderId); 619 SendGetRegistrations(kProviderId);
615 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); 620 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_);
616 } 621 }
617 622
618 TEST_F(ServiceWorkerDispatcherHostTest, GetRegistrations_EarlyContextDeletion) { 623 TEST_P(ServiceWorkerDispatcherHostTestP,
624 GetRegistrations_EarlyContextDeletion) {
619 helper_->ShutdownContext(); 625 helper_->ShutdownContext();
620 626
621 // Let the shutdown reach the simulated IO thread. 627 // Let the shutdown reach the simulated IO thread.
622 base::RunLoop().RunUntilIdle(); 628 base::RunLoop().RunUntilIdle();
623 629
624 GetRegistrations(-1, ServiceWorkerMsg_ServiceWorkerGetRegistrationsError::ID); 630 GetRegistrations(-1, ServiceWorkerMsg_ServiceWorkerGetRegistrationsError::ID);
625 } 631 }
626 632
627 TEST_F(ServiceWorkerDispatcherHostTest, CleanupOnRendererCrash) { 633 TEST_P(ServiceWorkerDispatcherHostTestP, CleanupOnRendererCrash) {
628 GURL pattern = GURL("http://www.example.com/"); 634 GURL pattern = GURL("http://www.example.com/");
629 GURL script_url = GURL("http://www.example.com/service_worker.js"); 635 GURL script_url = GURL("http://www.example.com/service_worker.js");
630 int process_id = helper_->mock_render_process_id(); 636 int process_id = helper_->mock_render_process_id();
631 637
632 SendProviderCreated(SERVICE_WORKER_PROVIDER_FOR_WINDOW, pattern); 638 SendProviderCreated(SERVICE_WORKER_PROVIDER_FOR_WINDOW, pattern);
633 SetUpRegistration(pattern, script_url); 639 SetUpRegistration(pattern, script_url);
634 int64_t provider_id = provider_host_->provider_id(); 640 int64_t provider_id = provider_host_->provider_id();
635 641
636 // Start up the worker. 642 // Start up the worker.
637 bool called = false; 643 bool called = false;
(...skipping 24 matching lines...) Expand all
662 668
663 // To show the new dispatcher can operate, simulate provider creation. Since 669 // To show the new dispatcher can operate, simulate provider creation. Since
664 // the old dispatcher cleaned up the old provider host, the new one won't 670 // the old dispatcher cleaned up the old provider host, the new one won't
665 // complain. 671 // complain.
666 new_dispatcher_host->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated( 672 new_dispatcher_host->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated(
667 provider_id, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW, 673 provider_id, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW,
668 true /* is_parent_frame_secure */)); 674 true /* is_parent_frame_secure */));
669 EXPECT_EQ(0, new_dispatcher_host->bad_messages_received_count_); 675 EXPECT_EQ(0, new_dispatcher_host->bad_messages_received_count_);
670 } 676 }
671 677
672 TEST_F(ServiceWorkerDispatcherHostTest, DispatchExtendableMessageEvent) { 678 TEST_P(ServiceWorkerDispatcherHostTestP, DispatchExtendableMessageEvent) {
673 GURL pattern = GURL("http://www.example.com/"); 679 GURL pattern = GURL("http://www.example.com/");
674 GURL script_url = GURL("http://www.example.com/service_worker.js"); 680 GURL script_url = GURL("http://www.example.com/service_worker.js");
675 681
676 SendProviderCreated(SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, pattern); 682 SendProviderCreated(SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, pattern);
677 SetUpRegistration(pattern, script_url); 683 SetUpRegistration(pattern, script_url);
678 684
679 // Set the running hosted version so that we can retrieve a valid service 685 // Set the running hosted version so that we can retrieve a valid service
680 // worker object information for the source attribute of the message event. 686 // worker object information for the source attribute of the message event.
681 provider_host_->running_hosted_version_ = version_; 687 provider_host_->running_hosted_version_ = version_;
682 688
(...skipping 19 matching lines...) Expand all
702 EXPECT_TRUE(called); 708 EXPECT_TRUE(called);
703 EXPECT_EQ(SERVICE_WORKER_OK, status); 709 EXPECT_EQ(SERVICE_WORKER_OK, status);
704 710
705 // Messages should be held until ports are created at the destination. 711 // Messages should be held until ports are created at the destination.
706 for (int port : ports) 712 for (int port : ports)
707 EXPECT_TRUE(MessagePortService::GetInstance()->AreMessagesHeld(port)); 713 EXPECT_TRUE(MessagePortService::GetInstance()->AreMessagesHeld(port));
708 714
709 EXPECT_EQ(ref_count + 1, sender_worker_handle->ref_count()); 715 EXPECT_EQ(ref_count + 1, sender_worker_handle->ref_count());
710 } 716 }
711 717
712 TEST_F(ServiceWorkerDispatcherHostTest, DispatchExtendableMessageEvent_Fail) { 718 TEST_P(ServiceWorkerDispatcherHostTestP, DispatchExtendableMessageEvent_Fail) {
713 GURL pattern = GURL("http://www.example.com/"); 719 GURL pattern = GURL("http://www.example.com/");
714 GURL script_url = GURL("http://www.example.com/service_worker.js"); 720 GURL script_url = GURL("http://www.example.com/service_worker.js");
715 721
716 Initialize(base::WrapUnique(new FailToStartWorkerTestHelper)); 722 Initialize(base::WrapUnique(new FailToStartWorkerTestHelper));
717 SendProviderCreated(SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, pattern); 723 SendProviderCreated(SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, pattern);
718 SetUpRegistration(pattern, script_url); 724 SetUpRegistration(pattern, script_url);
719 725
720 // Set the running hosted version so that we can retrieve a valid service 726 // Set the running hosted version so that we can retrieve a valid service
721 // worker object information for the source attribute of the message event. 727 // worker object information for the source attribute of the message event.
722 provider_host_->running_hosted_version_ = version_; 728 provider_host_->running_hosted_version_ = version_;
(...skipping 20 matching lines...) Expand all
743 base::RunLoop().RunUntilIdle(); 749 base::RunLoop().RunUntilIdle();
744 EXPECT_TRUE(called); 750 EXPECT_TRUE(called);
745 EXPECT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status); 751 EXPECT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status);
746 752
747 // The error callback should clean up the ports and handle. 753 // The error callback should clean up the ports and handle.
748 for (int port : ports) 754 for (int port : ports)
749 EXPECT_FALSE(MessagePortService::GetInstance()->AreMessagesHeld(port)); 755 EXPECT_FALSE(MessagePortService::GetInstance()->AreMessagesHeld(port));
750 EXPECT_EQ(ref_count, sender_worker_handle->ref_count()); 756 EXPECT_EQ(ref_count, sender_worker_handle->ref_count());
751 } 757 }
752 758
753 TEST_F(ServiceWorkerDispatcherHostTest, OnSetHostedVersionId) { 759 TEST_P(ServiceWorkerDispatcherHostTestP, OnSetHostedVersionId) {
754 GURL pattern = GURL("http://www.example.com/"); 760 GURL pattern = GURL("http://www.example.com/");
755 GURL script_url = GURL("http://www.example.com/service_worker.js"); 761 GURL script_url = GURL("http://www.example.com/service_worker.js");
756 762
757 Initialize(base::WrapUnique(new FailToStartWorkerTestHelper)); 763 Initialize(base::WrapUnique(new FailToStartWorkerTestHelper));
758 SendProviderCreated(SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, pattern); 764 SendProviderCreated(SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, pattern);
759 SetUpRegistration(pattern, script_url); 765 SetUpRegistration(pattern, script_url);
760 766
761 const int64_t kProviderId = 99; // Dummy value 767 const int64_t kProviderId = 99; // Dummy value
762 bool called; 768 bool called;
763 ServiceWorkerStatusCode status; 769 ServiceWorkerStatusCode status;
764 // StartWorker puts the worker in STARTING state but it will have no 770 // StartWorker puts the worker in STARTING state but it will have no
765 // process id yet. 771 // process id yet.
766 version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN, 772 version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN,
767 base::Bind(&SaveStatusCallback, &called, &status)); 773 base::Bind(&SaveStatusCallback, &called, &status));
768 EXPECT_NE(version_->embedded_worker()->process_id(), 774 EXPECT_NE(version_->embedded_worker()->process_id(),
769 provider_host_->process_id()); 775 provider_host_->process_id());
770 // SendSetHostedVersionId should reject because the provider host process id 776 // SendSetHostedVersionId should reject because the provider host process id
771 // is different. It should call BadMessageReceived because it's not an 777 // is different. It should call BadMessageReceived because it's not an
772 // expected error state. 778 // expected error state.
773 SendSetHostedVersionId(kProviderId, version_->version_id(), 779 SendSetHostedVersionId(kProviderId, version_->version_id(),
774 version_->embedded_worker()->embedded_worker_id()); 780 version_->embedded_worker()->embedded_worker_id());
775 base::RunLoop().RunUntilIdle(); 781 base::RunLoop().RunUntilIdle();
776 EXPECT_FALSE(dispatcher_host_->ipc_sink()->GetUniqueMessageMatching( 782 EXPECT_FALSE(dispatcher_host_->ipc_sink()->GetUniqueMessageMatching(
777 ServiceWorkerMsg_AssociateRegistration::ID)); 783 ServiceWorkerMsg_AssociateRegistration::ID));
778 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); 784 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_);
779 } 785 }
780 786
781 TEST_F(ServiceWorkerDispatcherHostTest, OnSetHostedVersionId_DetachedWorker) { 787 TEST_P(ServiceWorkerDispatcherHostTestP, OnSetHostedVersionId_DetachedWorker) {
782 GURL pattern = GURL("http://www.example.com/"); 788 GURL pattern = GURL("http://www.example.com/");
783 GURL script_url = GURL("http://www.example.com/service_worker.js"); 789 GURL script_url = GURL("http://www.example.com/service_worker.js");
784 790
785 Initialize(base::WrapUnique(new FailToStartWorkerTestHelper)); 791 Initialize(base::WrapUnique(new FailToStartWorkerTestHelper));
786 SendProviderCreated(SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, pattern); 792 SendProviderCreated(SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, pattern);
787 SetUpRegistration(pattern, script_url); 793 SetUpRegistration(pattern, script_url);
788 794
789 const int64_t kProviderId = 99; // Dummy value 795 const int64_t kProviderId = 99; // Dummy value
790 bool called; 796 bool called;
791 ServiceWorkerStatusCode status; 797 ServiceWorkerStatusCode status;
792 // StartWorker puts the worker in STARTING state. 798 // StartWorker puts the worker in STARTING state.
793 version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN, 799 version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN,
794 base::Bind(&SaveStatusCallback, &called, &status)); 800 base::Bind(&SaveStatusCallback, &called, &status));
795 801
796 // SendSetHostedVersionId should bail because the embedded worker is 802 // SendSetHostedVersionId should bail because the embedded worker is
797 // different. It shouldn't call BadMessageReceived because receiving a message 803 // different. It shouldn't call BadMessageReceived because receiving a message
798 // for a detached worker is a legitimite possibility. 804 // for a detached worker is a legitimite possibility.
799 int bad_embedded_worker_id = 805 int bad_embedded_worker_id =
800 version_->embedded_worker()->embedded_worker_id() + 1; 806 version_->embedded_worker()->embedded_worker_id() + 1;
801 SendSetHostedVersionId(kProviderId, version_->version_id(), 807 SendSetHostedVersionId(kProviderId, version_->version_id(),
802 bad_embedded_worker_id); 808 bad_embedded_worker_id);
803 base::RunLoop().RunUntilIdle(); 809 base::RunLoop().RunUntilIdle();
804 EXPECT_FALSE(dispatcher_host_->ipc_sink()->GetUniqueMessageMatching( 810 EXPECT_FALSE(dispatcher_host_->ipc_sink()->GetUniqueMessageMatching(
805 ServiceWorkerMsg_AssociateRegistration::ID)); 811 ServiceWorkerMsg_AssociateRegistration::ID));
806 EXPECT_EQ(0, dispatcher_host_->bad_messages_received_count_); 812 EXPECT_EQ(0, dispatcher_host_->bad_messages_received_count_);
807 } 813 }
808 814
809 TEST_F(ServiceWorkerDispatcherHostTest, ReceivedTimedOutRequestResponse) { 815 TEST_P(ServiceWorkerDispatcherHostTestP, ReceivedTimedOutRequestResponse) {
810 GURL pattern = GURL("https://www.example.com/"); 816 GURL pattern = GURL("https://www.example.com/");
811 GURL script_url = GURL("https://www.example.com/service_worker.js"); 817 GURL script_url = GURL("https://www.example.com/service_worker.js");
812 818
813 SendProviderCreated(SERVICE_WORKER_PROVIDER_FOR_WINDOW, pattern); 819 SendProviderCreated(SERVICE_WORKER_PROVIDER_FOR_WINDOW, pattern);
814 SetUpRegistration(pattern, script_url); 820 SetUpRegistration(pattern, script_url);
815 821
816 version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN, 822 version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN,
817 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 823 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
818 base::RunLoop().RunUntilIdle(); 824 base::RunLoop().RunUntilIdle();
819 825
820 // Set the worker status to STOPPING. 826 // Set the worker status to STOPPING.
821 version_->embedded_worker()->Stop(); 827 version_->embedded_worker()->Stop();
822 EXPECT_EQ(EmbeddedWorkerStatus::STOPPING, version_->running_status()); 828 EXPECT_EQ(EmbeddedWorkerStatus::STOPPING, version_->running_status());
823 829
824 // Receive a response for a timed out request. The bad message count should 830 // Receive a response for a timed out request. The bad message count should
825 // not increase. 831 // not increase.
826 const int kFetchEventId = 91; // Dummy value 832 const int kFetchEventId = 91; // Dummy value
827 dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_FetchEventResponse( 833 dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_FetchEventResponse(
828 version_->embedded_worker()->embedded_worker_id(), kFetchEventId, 834 version_->embedded_worker()->embedded_worker_id(), kFetchEventId,
829 SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK, ServiceWorkerResponse(), 835 SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK, ServiceWorkerResponse(),
830 base::Time::Now())); 836 base::Time::Now()));
831 837
832 base::RunLoop().RunUntilIdle(); 838 base::RunLoop().RunUntilIdle();
833 EXPECT_EQ(0, dispatcher_host_->bad_messages_received_count_); 839 EXPECT_EQ(0, dispatcher_host_->bad_messages_received_count_);
834 } 840 }
835 841
842 INSTANTIATE_TEST_CASE_P(ServiceWorkerDispatcherHostTest,
843 ServiceWorkerDispatcherHostTestP,
844 testing::Bool());
845
836 } // namespace content 846 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698