| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 scoped_refptr<ServiceWorkerRegistration> registration1; | 141 scoped_refptr<ServiceWorkerRegistration> registration1; |
| 142 storage()->FindRegistrationForDocument( | 142 storage()->FindRegistrationForDocument( |
| 143 GURL("http://www.example.com/"), | 143 GURL("http://www.example.com/"), |
| 144 SaveFoundRegistration(SERVICE_WORKER_OK, &called, ®istration1)); | 144 SaveFoundRegistration(SERVICE_WORKER_OK, &called, ®istration1)); |
| 145 scoped_refptr<ServiceWorkerRegistration> registration2; | 145 scoped_refptr<ServiceWorkerRegistration> registration2; |
| 146 storage()->FindRegistrationForDocument( | 146 storage()->FindRegistrationForDocument( |
| 147 GURL("http://www.example.com/"), | 147 GURL("http://www.example.com/"), |
| 148 SaveFoundRegistration(SERVICE_WORKER_OK, &called, ®istration2)); | 148 SaveFoundRegistration(SERVICE_WORKER_OK, &called, ®istration2)); |
| 149 base::RunLoop().RunUntilIdle(); | 149 base::RunLoop().RunUntilIdle(); |
| 150 EXPECT_TRUE(called); | 150 EXPECT_TRUE(called); |
| 151 ASSERT_TRUE(registration1); | 151 ASSERT_TRUE(registration1.get()); |
| 152 ASSERT_EQ(registration1, original_registration); | 152 ASSERT_EQ(registration1, original_registration); |
| 153 ASSERT_EQ(registration1, registration2); | 153 ASSERT_EQ(registration1, registration2); |
| 154 } | 154 } |
| 155 | 155 |
| 156 TEST_F(ServiceWorkerJobTest, SameMatchSameRegistration) { | 156 TEST_F(ServiceWorkerJobTest, SameMatchSameRegistration) { |
| 157 bool called; | 157 bool called; |
| 158 scoped_refptr<ServiceWorkerRegistration> original_registration; | 158 scoped_refptr<ServiceWorkerRegistration> original_registration; |
| 159 job_coordinator()->Register( | 159 job_coordinator()->Register( |
| 160 GURL("http://www.example.com/"), | 160 GURL("http://www.example.com/"), |
| 161 GURL("http://www.example.com/service_worker.js"), | 161 GURL("http://www.example.com/service_worker.js"), |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 366 |
| 367 scoped_refptr<ServiceWorkerRegistration> old_registration_by_pattern; | 367 scoped_refptr<ServiceWorkerRegistration> old_registration_by_pattern; |
| 368 storage()->FindRegistrationForPattern( | 368 storage()->FindRegistrationForPattern( |
| 369 pattern, | 369 pattern, |
| 370 SaveFoundRegistration( | 370 SaveFoundRegistration( |
| 371 SERVICE_WORKER_OK, &called, &old_registration_by_pattern)); | 371 SERVICE_WORKER_OK, &called, &old_registration_by_pattern)); |
| 372 ASSERT_FALSE(called); | 372 ASSERT_FALSE(called); |
| 373 base::RunLoop().RunUntilIdle(); | 373 base::RunLoop().RunUntilIdle(); |
| 374 ASSERT_TRUE(called); | 374 ASSERT_TRUE(called); |
| 375 | 375 |
| 376 ASSERT_TRUE(old_registration_by_pattern); | 376 ASSERT_TRUE(old_registration_by_pattern.get()); |
| 377 | 377 |
| 378 scoped_refptr<ServiceWorkerRegistration> new_registration; | 378 scoped_refptr<ServiceWorkerRegistration> new_registration; |
| 379 job_coordinator()->Register( | 379 job_coordinator()->Register( |
| 380 pattern, | 380 pattern, |
| 381 script_url, | 381 script_url, |
| 382 render_process_id_, | 382 render_process_id_, |
| 383 SaveRegistration(SERVICE_WORKER_OK, &called, &new_registration)); | 383 SaveRegistration(SERVICE_WORKER_OK, &called, &new_registration)); |
| 384 | 384 |
| 385 ASSERT_FALSE(called); | 385 ASSERT_FALSE(called); |
| 386 base::RunLoop().RunUntilIdle(); | 386 base::RunLoop().RunUntilIdle(); |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 job_coordinator()->Register( | 718 job_coordinator()->Register( |
| 719 GURL("http://www.example.com/"), | 719 GURL("http://www.example.com/"), |
| 720 GURL("http://www.example.com/service_worker.js"), | 720 GURL("http://www.example.com/service_worker.js"), |
| 721 render_process_id_, | 721 render_process_id_, |
| 722 SaveRegistration(SERVICE_WORKER_OK, &called, ®istration)); | 722 SaveRegistration(SERVICE_WORKER_OK, &called, ®istration)); |
| 723 base::RunLoop().RunUntilIdle(); | 723 base::RunLoop().RunUntilIdle(); |
| 724 ASSERT_TRUE(called); | 724 ASSERT_TRUE(called); |
| 725 ASSERT_TRUE(registration); | 725 ASSERT_TRUE(registration.get()); |
| 726 | 726 |
| 727 // Manually create the waiting worker since there is no way to become a | 727 // Manually create the waiting worker since there is no way to become a |
| 728 // waiting worker until Update is implemented. | 728 // waiting worker until Update is implemented. |
| 729 scoped_refptr<ServiceWorkerVersion> version = new ServiceWorkerVersion( | 729 scoped_refptr<ServiceWorkerVersion> version = new ServiceWorkerVersion( |
| 730 registration, 1L, helper_->context()->AsWeakPtr()); | 730 registration.get(), 1L, helper_->context()->AsWeakPtr()); |
| 731 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; | 731 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; |
| 732 version->StartWorker(CreateReceiverOnCurrentThread(&status)); | 732 version->StartWorker(CreateReceiverOnCurrentThread(&status)); |
| 733 base::RunLoop().RunUntilIdle(); | 733 base::RunLoop().RunUntilIdle(); |
| 734 ASSERT_EQ(SERVICE_WORKER_OK, status); | 734 ASSERT_EQ(SERVICE_WORKER_OK, status); |
| 735 | 735 |
| 736 version->SetStatus(ServiceWorkerVersion::INSTALLED); | 736 version->SetStatus(ServiceWorkerVersion::INSTALLED); |
| 737 registration->SetWaitingVersion(version); | 737 registration->SetWaitingVersion(version.get()); |
| 738 EXPECT_EQ(ServiceWorkerVersion::RUNNING, | 738 EXPECT_EQ(ServiceWorkerVersion::RUNNING, |
| 739 version->running_status()); | 739 version->running_status()); |
| 740 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, version->status()); | 740 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, version->status()); |
| 741 | 741 |
| 742 called = false; | 742 called = false; |
| 743 job_coordinator()->Unregister(GURL("http://www.example.com/"), | 743 job_coordinator()->Unregister(GURL("http://www.example.com/"), |
| 744 SaveUnregistration(SERVICE_WORKER_OK, &called)); | 744 SaveUnregistration(SERVICE_WORKER_OK, &called)); |
| 745 base::RunLoop().RunUntilIdle(); | 745 base::RunLoop().RunUntilIdle(); |
| 746 ASSERT_TRUE(called); | 746 ASSERT_TRUE(called); |
| 747 | 747 |
| 748 // The version should be stopped since there is no controllee after | 748 // The version should be stopped since there is no controllee after |
| 749 // unregistration. | 749 // unregistration. |
| 750 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version->running_status()); | 750 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version->running_status()); |
| 751 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version->status()); | 751 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version->status()); |
| 752 } | 752 } |
| 753 | 753 |
| 754 // Tests that the active worker enters the 'redundant' state upon | 754 // Tests that the active worker enters the 'redundant' state upon |
| 755 // unregistration. | 755 // unregistration. |
| 756 TEST_F(ServiceWorkerJobTest, UnregisterActiveSetsRedundant) { | 756 TEST_F(ServiceWorkerJobTest, UnregisterActiveSetsRedundant) { |
| 757 scoped_refptr<ServiceWorkerRegistration> registration; | 757 scoped_refptr<ServiceWorkerRegistration> registration; |
| 758 bool called = false; | 758 bool called = false; |
| 759 job_coordinator()->Register( | 759 job_coordinator()->Register( |
| 760 GURL("http://www.example.com/"), | 760 GURL("http://www.example.com/"), |
| 761 GURL("http://www.example.com/service_worker.js"), | 761 GURL("http://www.example.com/service_worker.js"), |
| 762 render_process_id_, | 762 render_process_id_, |
| 763 SaveRegistration(SERVICE_WORKER_OK, &called, ®istration)); | 763 SaveRegistration(SERVICE_WORKER_OK, &called, ®istration)); |
| 764 base::RunLoop().RunUntilIdle(); | 764 base::RunLoop().RunUntilIdle(); |
| 765 ASSERT_TRUE(called); | 765 ASSERT_TRUE(called); |
| 766 ASSERT_TRUE(registration); | 766 ASSERT_TRUE(registration.get()); |
| 767 | 767 |
| 768 scoped_refptr<ServiceWorkerVersion> version = registration->active_version(); | 768 scoped_refptr<ServiceWorkerVersion> version = registration->active_version(); |
| 769 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version->running_status()); | 769 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version->running_status()); |
| 770 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, version->status()); | 770 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, version->status()); |
| 771 | 771 |
| 772 called = false; | 772 called = false; |
| 773 job_coordinator()->Unregister(GURL("http://www.example.com/"), | 773 job_coordinator()->Unregister(GURL("http://www.example.com/"), |
| 774 SaveUnregistration(SERVICE_WORKER_OK, &called)); | 774 SaveUnregistration(SERVICE_WORKER_OK, &called)); |
| 775 base::RunLoop().RunUntilIdle(); | 775 base::RunLoop().RunUntilIdle(); |
| 776 ASSERT_TRUE(called); | 776 ASSERT_TRUE(called); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 787 UnregisterActiveSetsRedundant_WaitForNoControllee) { | 787 UnregisterActiveSetsRedundant_WaitForNoControllee) { |
| 788 scoped_refptr<ServiceWorkerRegistration> registration; | 788 scoped_refptr<ServiceWorkerRegistration> registration; |
| 789 bool called = false; | 789 bool called = false; |
| 790 job_coordinator()->Register( | 790 job_coordinator()->Register( |
| 791 GURL("http://www.example.com/"), | 791 GURL("http://www.example.com/"), |
| 792 GURL("http://www.example.com/service_worker.js"), | 792 GURL("http://www.example.com/service_worker.js"), |
| 793 render_process_id_, | 793 render_process_id_, |
| 794 SaveRegistration(SERVICE_WORKER_OK, &called, ®istration)); | 794 SaveRegistration(SERVICE_WORKER_OK, &called, ®istration)); |
| 795 base::RunLoop().RunUntilIdle(); | 795 base::RunLoop().RunUntilIdle(); |
| 796 ASSERT_TRUE(called); | 796 ASSERT_TRUE(called); |
| 797 ASSERT_TRUE(registration); | 797 ASSERT_TRUE(registration.get()); |
| 798 | 798 |
| 799 scoped_ptr<ServiceWorkerProviderHost> host( | 799 scoped_ptr<ServiceWorkerProviderHost> host( |
| 800 new ServiceWorkerProviderHost(33 /* dummy render process id */, | 800 new ServiceWorkerProviderHost(33 /* dummy render process id */, |
| 801 1 /* dummy provider_id */, | 801 1 /* dummy provider_id */, |
| 802 context()->AsWeakPtr(), | 802 context()->AsWeakPtr(), |
| 803 NULL)); | 803 NULL)); |
| 804 registration->active_version()->AddControllee(host.get()); | 804 registration->active_version()->AddControllee(host.get()); |
| 805 | 805 |
| 806 scoped_refptr<ServiceWorkerVersion> version = registration->active_version(); | 806 scoped_refptr<ServiceWorkerVersion> version = registration->active_version(); |
| 807 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version->running_status()); | 807 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version->running_status()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 | 851 |
| 852 scoped_ptr<net::HttpResponseInfo> info(new net::HttpResponseInfo); | 852 scoped_ptr<net::HttpResponseInfo> info(new net::HttpResponseInfo); |
| 853 info->request_time = base::Time::Now(); | 853 info->request_time = base::Time::Now(); |
| 854 info->response_time = base::Time::Now(); | 854 info->response_time = base::Time::Now(); |
| 855 info->was_cached = false; | 855 info->was_cached = false; |
| 856 info->headers = new net::HttpResponseHeaders(headers); | 856 info->headers = new net::HttpResponseHeaders(headers); |
| 857 scoped_refptr<HttpResponseInfoIOBuffer> info_buffer = | 857 scoped_refptr<HttpResponseInfoIOBuffer> info_buffer = |
| 858 new HttpResponseInfoIOBuffer(info.release()); | 858 new HttpResponseInfoIOBuffer(info.release()); |
| 859 | 859 |
| 860 int rv = -1234; | 860 int rv = -1234; |
| 861 writer->WriteInfo(info_buffer, base::Bind(&OnIOComplete, &rv)); | 861 writer->WriteInfo(info_buffer.get(), base::Bind(&OnIOComplete, &rv)); |
| 862 RunNestedUntilIdle(); | 862 RunNestedUntilIdle(); |
| 863 EXPECT_LT(0, rv); | 863 EXPECT_LT(0, rv); |
| 864 | 864 |
| 865 rv = -1234; | 865 rv = -1234; |
| 866 writer->WriteData(body, length, | 866 writer->WriteData(body, length, |
| 867 base::Bind(&OnIOComplete, &rv)); | 867 base::Bind(&OnIOComplete, &rv)); |
| 868 RunNestedUntilIdle(); | 868 RunNestedUntilIdle(); |
| 869 EXPECT_EQ(length, rv); | 869 EXPECT_EQ(length, rv); |
| 870 } | 870 } |
| 871 | 871 |
| 872 void WriteStringResponse( | 872 void WriteStringResponse( |
| 873 ServiceWorkerStorage* storage, int64 id, | 873 ServiceWorkerStorage* storage, int64 id, |
| 874 const std::string& body) { | 874 const std::string& body) { |
| 875 scoped_refptr<IOBuffer> body_buffer(new WrappedIOBuffer(body.data())); | 875 scoped_refptr<IOBuffer> body_buffer(new WrappedIOBuffer(body.data())); |
| 876 const char kHttpHeaders[] = "HTTP/1.0 200 HONKYDORY\0\0"; | 876 const char kHttpHeaders[] = "HTTP/1.0 200 HONKYDORY\0\0"; |
| 877 std::string headers(kHttpHeaders, arraysize(kHttpHeaders)); | 877 std::string headers(kHttpHeaders, arraysize(kHttpHeaders)); |
| 878 WriteResponse(storage, id, headers, body_buffer, body.length()); | 878 WriteResponse(storage, id, headers, body_buffer.get(), body.length()); |
| 879 } | 879 } |
| 880 | 880 |
| 881 class UpdateJobTestHelper | 881 class UpdateJobTestHelper |
| 882 : public EmbeddedWorkerTestHelper, | 882 : public EmbeddedWorkerTestHelper, |
| 883 public ServiceWorkerRegistration::Listener, | 883 public ServiceWorkerRegistration::Listener, |
| 884 public ServiceWorkerVersion::Listener { | 884 public ServiceWorkerVersion::Listener { |
| 885 public: | 885 public: |
| 886 struct AttributeChangeLogEntry { | 886 struct AttributeChangeLogEntry { |
| 887 int64 registration_id; | 887 int64 registration_id; |
| 888 ChangedVersionAttributesMask mask; | 888 ChangedVersionAttributesMask mask; |
| 889 ServiceWorkerRegistrationInfo info; | 889 ServiceWorkerRegistrationInfo info; |
| 890 }; | 890 }; |
| 891 | 891 |
| 892 struct StateChangeLogEntry { | 892 struct StateChangeLogEntry { |
| 893 int64 version_id; | 893 int64 version_id; |
| 894 ServiceWorkerVersion::Status status; | 894 ServiceWorkerVersion::Status status; |
| 895 }; | 895 }; |
| 896 | 896 |
| 897 UpdateJobTestHelper(int mock_render_process_id) | 897 UpdateJobTestHelper(int mock_render_process_id) |
| 898 : EmbeddedWorkerTestHelper(mock_render_process_id) {} | 898 : EmbeddedWorkerTestHelper(mock_render_process_id) {} |
| 899 virtual ~UpdateJobTestHelper() { | 899 virtual ~UpdateJobTestHelper() { |
| 900 if (registration_) | 900 if (registration_.get()) |
| 901 registration_->RemoveListener(this); | 901 registration_->RemoveListener(this); |
| 902 } | 902 } |
| 903 | 903 |
| 904 ServiceWorkerStorage* storage() { return context()->storage(); } | 904 ServiceWorkerStorage* storage() { return context()->storage(); } |
| 905 ServiceWorkerJobCoordinator* job_coordinator() { | 905 ServiceWorkerJobCoordinator* job_coordinator() { |
| 906 return context()->job_coordinator(); | 906 return context()->job_coordinator(); |
| 907 } | 907 } |
| 908 | 908 |
| 909 scoped_refptr<ServiceWorkerRegistration> SetupInitialRegistration( | 909 scoped_refptr<ServiceWorkerRegistration> SetupInitialRegistration( |
| 910 const GURL& test_origin) { | 910 const GURL& test_origin) { |
| 911 scoped_refptr<ServiceWorkerRegistration> registration; | 911 scoped_refptr<ServiceWorkerRegistration> registration; |
| 912 bool called = false; | 912 bool called = false; |
| 913 job_coordinator()->Register( | 913 job_coordinator()->Register( |
| 914 test_origin.Resolve(kScope), | 914 test_origin.Resolve(kScope), |
| 915 test_origin.Resolve(kScript), | 915 test_origin.Resolve(kScript), |
| 916 mock_render_process_id(), | 916 mock_render_process_id(), |
| 917 SaveRegistration(SERVICE_WORKER_OK, &called, ®istration)); | 917 SaveRegistration(SERVICE_WORKER_OK, &called, ®istration)); |
| 918 base::RunLoop().RunUntilIdle(); | 918 base::RunLoop().RunUntilIdle(); |
| 919 EXPECT_TRUE(called); | 919 EXPECT_TRUE(called); |
| 920 EXPECT_TRUE(registration); | 920 EXPECT_TRUE(registration.get()); |
| 921 EXPECT_TRUE(registration->active_version()); | 921 EXPECT_TRUE(registration->active_version()); |
| 922 EXPECT_FALSE(registration->installing_version()); | 922 EXPECT_FALSE(registration->installing_version()); |
| 923 EXPECT_FALSE(registration->waiting_version()); | 923 EXPECT_FALSE(registration->waiting_version()); |
| 924 registration_ = registration; | 924 registration_ = registration; |
| 925 return registration; | 925 return registration; |
| 926 } | 926 } |
| 927 | 927 |
| 928 // EmbeddedWorkerTestHelper overrides | 928 // EmbeddedWorkerTestHelper overrides |
| 929 virtual void OnStartWorker(int embedded_worker_id, | 929 virtual void OnStartWorker(int embedded_worker_id, |
| 930 int64 version_id, | 930 int64 version_id, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 }; | 988 }; |
| 989 | 989 |
| 990 } // namespace | 990 } // namespace |
| 991 | 991 |
| 992 TEST_F(ServiceWorkerJobTest, Update_NoChange) { | 992 TEST_F(ServiceWorkerJobTest, Update_NoChange) { |
| 993 UpdateJobTestHelper* update_helper = | 993 UpdateJobTestHelper* update_helper = |
| 994 new UpdateJobTestHelper(render_process_id_); | 994 new UpdateJobTestHelper(render_process_id_); |
| 995 helper_.reset(update_helper); | 995 helper_.reset(update_helper); |
| 996 scoped_refptr<ServiceWorkerRegistration> registration = | 996 scoped_refptr<ServiceWorkerRegistration> registration = |
| 997 update_helper->SetupInitialRegistration(kNoChangeOrigin); | 997 update_helper->SetupInitialRegistration(kNoChangeOrigin); |
| 998 ASSERT_TRUE(registration); | 998 ASSERT_TRUE(registration.get()); |
| 999 ASSERT_EQ(4u, update_helper->state_change_log_.size()); | 999 ASSERT_EQ(4u, update_helper->state_change_log_.size()); |
| 1000 EXPECT_EQ(ServiceWorkerVersion::INSTALLING, | 1000 EXPECT_EQ(ServiceWorkerVersion::INSTALLING, |
| 1001 update_helper->state_change_log_[0].status); | 1001 update_helper->state_change_log_[0].status); |
| 1002 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, | 1002 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, |
| 1003 update_helper->state_change_log_[1].status); | 1003 update_helper->state_change_log_[1].status); |
| 1004 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, | 1004 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, |
| 1005 update_helper->state_change_log_[2].status); | 1005 update_helper->state_change_log_[2].status); |
| 1006 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, | 1006 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, |
| 1007 update_helper->state_change_log_[3].status); | 1007 update_helper->state_change_log_[3].status); |
| 1008 update_helper->state_change_log_.clear(); | 1008 update_helper->state_change_log_.clear(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1026 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, | 1026 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, |
| 1027 update_helper->state_change_log_[0].status); | 1027 update_helper->state_change_log_[0].status); |
| 1028 } | 1028 } |
| 1029 | 1029 |
| 1030 TEST_F(ServiceWorkerJobTest, Update_NewVersion) { | 1030 TEST_F(ServiceWorkerJobTest, Update_NewVersion) { |
| 1031 UpdateJobTestHelper* update_helper = | 1031 UpdateJobTestHelper* update_helper = |
| 1032 new UpdateJobTestHelper(render_process_id_); | 1032 new UpdateJobTestHelper(render_process_id_); |
| 1033 helper_.reset(update_helper); | 1033 helper_.reset(update_helper); |
| 1034 scoped_refptr<ServiceWorkerRegistration> registration = | 1034 scoped_refptr<ServiceWorkerRegistration> registration = |
| 1035 update_helper->SetupInitialRegistration(kNewVersionOrigin); | 1035 update_helper->SetupInitialRegistration(kNewVersionOrigin); |
| 1036 ASSERT_TRUE(registration); | 1036 ASSERT_TRUE(registration.get()); |
| 1037 update_helper->state_change_log_.clear(); | 1037 update_helper->state_change_log_.clear(); |
| 1038 | 1038 |
| 1039 // Run the update job. | 1039 // Run the update job. |
| 1040 registration->AddListener(update_helper); | 1040 registration->AddListener(update_helper); |
| 1041 scoped_refptr<ServiceWorkerVersion> first_version = | 1041 scoped_refptr<ServiceWorkerVersion> first_version = |
| 1042 registration->active_version(); | 1042 registration->active_version(); |
| 1043 first_version->StartUpdate(); | 1043 first_version->StartUpdate(); |
| 1044 base::RunLoop().RunUntilIdle(); | 1044 base::RunLoop().RunUntilIdle(); |
| 1045 | 1045 |
| 1046 // Verify results. | 1046 // Verify results. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, | 1101 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, |
| 1102 update_helper->state_change_log_[3].status); | 1102 update_helper->state_change_log_[3].status); |
| 1103 | 1103 |
| 1104 EXPECT_EQ(registration->active_version()->version_id(), | 1104 EXPECT_EQ(registration->active_version()->version_id(), |
| 1105 update_helper->state_change_log_[4].version_id); | 1105 update_helper->state_change_log_[4].version_id); |
| 1106 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, | 1106 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, |
| 1107 update_helper->state_change_log_[4].status); | 1107 update_helper->state_change_log_[4].status); |
| 1108 } | 1108 } |
| 1109 | 1109 |
| 1110 } // namespace content | 1110 } // namespace content |
| OLD | NEW |