| 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/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/service_worker/embedded_worker_registry.h" | 9 #include "content/browser/service_worker/embedded_worker_registry.h" |
| 10 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 10 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 base::RunLoop().RunUntilIdle(); | 708 base::RunLoop().RunUntilIdle(); |
| 709 ASSERT_TRUE(find_called); | 709 ASSERT_TRUE(find_called); |
| 710 EXPECT_EQ(scoped_refptr<ServiceWorkerRegistration>(), registration); | 710 EXPECT_EQ(scoped_refptr<ServiceWorkerRegistration>(), registration); |
| 711 } | 711 } |
| 712 | 712 |
| 713 // Tests that the waiting worker enters the 'redundant' state upon | 713 // Tests that the waiting worker enters the 'redundant' state upon |
| 714 // unregistration. | 714 // unregistration. |
| 715 TEST_F(ServiceWorkerJobTest, UnregisterWaitingSetsRedundant) { | 715 TEST_F(ServiceWorkerJobTest, UnregisterWaitingSetsRedundant) { |
| 716 scoped_refptr<ServiceWorkerRegistration> registration; | 716 scoped_refptr<ServiceWorkerRegistration> registration; |
| 717 bool called = false; | 717 bool called = false; |
| 718 GURL script_url("http://www.example.com/service_worker.js"); |
| 718 job_coordinator()->Register( | 719 job_coordinator()->Register( |
| 719 GURL("http://www.example.com/"), | 720 GURL("http://www.example.com/"), |
| 720 GURL("http://www.example.com/service_worker.js"), | 721 script_url, |
| 721 render_process_id_, | 722 render_process_id_, |
| 722 SaveRegistration(SERVICE_WORKER_OK, &called, ®istration)); | 723 SaveRegistration(SERVICE_WORKER_OK, &called, ®istration)); |
| 723 base::RunLoop().RunUntilIdle(); | 724 base::RunLoop().RunUntilIdle(); |
| 724 ASSERT_TRUE(called); | 725 ASSERT_TRUE(called); |
| 725 ASSERT_TRUE(registration); | 726 ASSERT_TRUE(registration); |
| 726 | 727 |
| 727 // Manually create the waiting worker since there is no way to become a | 728 // Manually create the waiting worker since there is no way to become a |
| 728 // waiting worker until Update is implemented. | 729 // waiting worker until Update is implemented. |
| 729 scoped_refptr<ServiceWorkerVersion> version = new ServiceWorkerVersion( | 730 scoped_refptr<ServiceWorkerVersion> version = new ServiceWorkerVersion( |
| 730 registration, 1L, helper_->context()->AsWeakPtr()); | 731 registration, script_url, 1L, helper_->context()->AsWeakPtr()); |
| 731 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; | 732 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; |
| 732 version->StartWorker(CreateReceiverOnCurrentThread(&status)); | 733 version->StartWorker(CreateReceiverOnCurrentThread(&status)); |
| 733 base::RunLoop().RunUntilIdle(); | 734 base::RunLoop().RunUntilIdle(); |
| 734 ASSERT_EQ(SERVICE_WORKER_OK, status); | 735 ASSERT_EQ(SERVICE_WORKER_OK, status); |
| 735 | 736 |
| 736 version->SetStatus(ServiceWorkerVersion::INSTALLED); | 737 version->SetStatus(ServiceWorkerVersion::INSTALLED); |
| 737 registration->SetWaitingVersion(version); | 738 registration->SetWaitingVersion(version); |
| 738 EXPECT_EQ(ServiceWorkerVersion::RUNNING, | 739 EXPECT_EQ(ServiceWorkerVersion::RUNNING, |
| 739 version->running_status()); | 740 version->running_status()); |
| 740 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, version->status()); | 741 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, version->status()); |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, | 1102 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, |
| 1102 update_helper->state_change_log_[3].status); | 1103 update_helper->state_change_log_[3].status); |
| 1103 | 1104 |
| 1104 EXPECT_EQ(registration->active_version()->version_id(), | 1105 EXPECT_EQ(registration->active_version()->version_id(), |
| 1105 update_helper->state_change_log_[4].version_id); | 1106 update_helper->state_change_log_[4].version_id); |
| 1106 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, | 1107 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, |
| 1107 update_helper->state_change_log_[4].status); | 1108 update_helper->state_change_log_[4].status); |
| 1108 } | 1109 } |
| 1109 | 1110 |
| 1110 } // namespace content | 1111 } // namespace content |
| OLD | NEW |