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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1125 update_helper->state_change_log_[3].status); | 1125 update_helper->state_change_log_[3].status); |
1126 | 1126 |
1127 EXPECT_EQ(registration->active_version()->version_id(), | 1127 EXPECT_EQ(registration->active_version()->version_id(), |
1128 update_helper->state_change_log_[4].version_id); | 1128 update_helper->state_change_log_[4].version_id); |
1129 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, | 1129 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, |
1130 update_helper->state_change_log_[4].status); | 1130 update_helper->state_change_log_[4].status); |
1131 | 1131 |
1132 EXPECT_TRUE(update_helper->update_found_); | 1132 EXPECT_TRUE(update_helper->update_found_); |
1133 } | 1133 } |
1134 | 1134 |
1135 TEST_F(ServiceWorkerJobTest, Update_NewestVersionChanged) { | 1135 TEST_F(ServiceWorkerJobTest, Update_NewestVersionChanged) { |
nhiroki
2016/04/28 05:51:46
Can you add a comment about what we want to check
falken
2016/04/28 06:25:17
Done.
| |
1136 scoped_refptr<ServiceWorkerRegistration> registration = | 1136 scoped_refptr<ServiceWorkerRegistration> registration = |
1137 RunRegisterJob(GURL("http://www.example.com/one/"), | 1137 RunRegisterJob(GURL("http://www.example.com/one/"), |
1138 GURL("http://www.example.com/service_worker.js")); | 1138 GURL("http://www.example.com/service_worker.js")); |
1139 | 1139 |
1140 ServiceWorkerVersion* active_version = registration->active_version(); | 1140 // Queue an Update. When this runs, it will use the waiting version's script. |
1141 | |
1142 // Queue an Update, it should abort when it starts and sees the new version. | |
1143 job_coordinator()->Update(registration.get(), false); | 1141 job_coordinator()->Update(registration.get(), false); |
1144 | 1142 |
1145 // Add a waiting version with new script. | 1143 // Add a waiting version with new script. |
1146 scoped_refptr<ServiceWorkerVersion> version = | 1144 const char* new_script = "http://www.example.com/new_worker.js"; |
1147 new ServiceWorkerVersion(registration.get(), | 1145 scoped_refptr<ServiceWorkerVersion> version = new ServiceWorkerVersion( |
1148 GURL("http://www.example.com/new_worker.js"), | 1146 registration.get(), GURL(new_script), 2L /* dummy version id */, |
1149 2L /* dummy version id */, | 1147 helper_->context()->AsWeakPtr()); |
1150 helper_->context()->AsWeakPtr()); | |
1151 registration->SetWaitingVersion(version); | 1148 registration->SetWaitingVersion(version); |
1152 | 1149 |
1153 base::RunLoop().RunUntilIdle(); | 1150 base::RunLoop().RunUntilIdle(); |
1154 | 1151 |
1155 // Verify the registration was not modified by the Update. | 1152 EXPECT_EQ(new_script, registration->active_version()->script_url().spec()); |
1156 EXPECT_EQ(active_version, registration->active_version()); | 1153 EXPECT_EQ(nullptr, registration->waiting_version()); |
1157 EXPECT_EQ(version.get(), registration->waiting_version()); | 1154 EXPECT_EQ(nullptr, registration->installing_version()); |
1158 EXPECT_EQ(NULL, registration->installing_version()); | |
1159 } | 1155 } |
1160 | 1156 |
1161 // Test that update succeeds if the incumbent worker was evicted | 1157 // Test that update succeeds if the incumbent worker was evicted |
1162 // during the update job (this can happen on disk cache failure). | 1158 // during the update job (this can happen on disk cache failure). |
1163 TEST_F(ServiceWorkerJobTest, Update_EvictedIncumbent) { | 1159 TEST_F(ServiceWorkerJobTest, Update_EvictedIncumbent) { |
1164 EvictIncumbentVersionHelper* update_helper = new EvictIncumbentVersionHelper; | 1160 EvictIncumbentVersionHelper* update_helper = new EvictIncumbentVersionHelper; |
1165 helper_.reset(update_helper); | 1161 helper_.reset(update_helper); |
1166 scoped_refptr<ServiceWorkerRegistration> registration = | 1162 scoped_refptr<ServiceWorkerRegistration> registration = |
1167 update_helper->SetupInitialRegistration(kNewVersionOrigin); | 1163 update_helper->SetupInitialRegistration(kNewVersionOrigin); |
1168 ASSERT_TRUE(registration.get()); | 1164 ASSERT_TRUE(registration.get()); |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1579 ASSERT_TRUE(start_msg); | 1575 ASSERT_TRUE(start_msg); |
1580 EmbeddedWorkerMsg_StartWorker::Param param; | 1576 EmbeddedWorkerMsg_StartWorker::Param param; |
1581 EmbeddedWorkerMsg_StartWorker::Read(start_msg, ¶m); | 1577 EmbeddedWorkerMsg_StartWorker::Read(start_msg, ¶m); |
1582 EmbeddedWorkerMsg_StartWorker_Params start_params = base::get<0>(param); | 1578 EmbeddedWorkerMsg_StartWorker_Params start_params = base::get<0>(param); |
1583 EXPECT_TRUE(start_params.pause_after_download); | 1579 EXPECT_TRUE(start_params.pause_after_download); |
1584 sink->ClearMessages(); | 1580 sink->ClearMessages(); |
1585 } | 1581 } |
1586 } | 1582 } |
1587 | 1583 |
1588 } // namespace content | 1584 } // namespace content |
OLD | NEW |