| OLD | NEW |
| 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "content/browser/service_worker/embedded_worker_registry.h" | 7 #include "content/browser/service_worker/embedded_worker_registry.h" |
| 8 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 8 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
| 9 #include "content/browser/service_worker/service_worker_context_core.h" | 9 #include "content/browser/service_worker/service_worker_context_core.h" |
| 10 #include "content/browser/service_worker/service_worker_registration.h" | 10 #include "content/browser/service_worker/service_worker_registration.h" |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 helper_->context()->RemoveAllProviderHostsForProcess(process_id); | 443 helper_->context()->RemoveAllProviderHostsForProcess(process_id); |
| 444 helper_->context()->embedded_worker_registry()->RemoveChildProcessSender( | 444 helper_->context()->embedded_worker_registry()->RemoveChildProcessSender( |
| 445 process_id); | 445 process_id); |
| 446 base::RunLoop().RunUntilIdle(); | 446 base::RunLoop().RunUntilIdle(); |
| 447 | 447 |
| 448 // Callback completed. | 448 // Callback completed. |
| 449 EXPECT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status); | 449 EXPECT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status); |
| 450 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); | 450 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); |
| 451 } | 451 } |
| 452 | 452 |
| 453 TEST_F(ServiceWorkerFailToStartTest, Timeout) { |
| 454 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_NETWORK; // dummy value |
| 455 |
| 456 // We could just call StartWorker but make it interesting and test |
| 457 // starting the worker as part of dispatching an event. |
| 458 version_->SetStatus(ServiceWorkerVersion::ACTIVATING); |
| 459 version_->DispatchActivateEvent(CreateReceiverOnCurrentThread(&status)); |
| 460 base::RunLoop().RunUntilIdle(); |
| 461 |
| 462 // Callback has not completed yet. |
| 463 EXPECT_EQ(SERVICE_WORKER_ERROR_NETWORK, status); |
| 464 EXPECT_EQ(ServiceWorkerVersion::STARTING, version_->running_status()); |
| 465 |
| 466 // Simulate timeout. |
| 467 EXPECT_TRUE(version_->start_worker_timeout_timer_.IsRunning()); |
| 468 version_->start_worker_timeout_timer_.user_task().Run(); |
| 469 base::RunLoop().RunUntilIdle(); |
| 470 EXPECT_EQ(SERVICE_WORKER_ERROR_TIMEOUT, status); |
| 471 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); |
| 472 } |
| 473 |
| 453 } // namespace content | 474 } // namespace content |
| OLD | NEW |