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 #include <tuple> | 6 #include <tuple> |
7 | 7 |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 void RunUnregisterJob( | 166 void RunUnregisterJob( |
167 const GURL& pattern, | 167 const GURL& pattern, |
168 ServiceWorkerStatusCode expected_status = SERVICE_WORKER_OK); | 168 ServiceWorkerStatusCode expected_status = SERVICE_WORKER_OK); |
169 scoped_refptr<ServiceWorkerRegistration> FindRegistrationForPattern( | 169 scoped_refptr<ServiceWorkerRegistration> FindRegistrationForPattern( |
170 const GURL& pattern, | 170 const GURL& pattern, |
171 ServiceWorkerStatusCode expected_status = SERVICE_WORKER_OK); | 171 ServiceWorkerStatusCode expected_status = SERVICE_WORKER_OK); |
172 std::unique_ptr<ServiceWorkerProviderHost> CreateControllee(); | 172 std::unique_ptr<ServiceWorkerProviderHost> CreateControllee(); |
173 | 173 |
174 TestBrowserThreadBundle browser_thread_bundle_; | 174 TestBrowserThreadBundle browser_thread_bundle_; |
175 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; | 175 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; |
| 176 std::vector<ServiceWorkerRemoteProviderEndpoint> remote_endpoints_; |
176 }; | 177 }; |
177 | 178 |
178 scoped_refptr<ServiceWorkerRegistration> ServiceWorkerJobTest::RunRegisterJob( | 179 scoped_refptr<ServiceWorkerRegistration> ServiceWorkerJobTest::RunRegisterJob( |
179 const GURL& pattern, | 180 const GURL& pattern, |
180 const GURL& script_url, | 181 const GURL& script_url, |
181 ServiceWorkerStatusCode expected_status) { | 182 ServiceWorkerStatusCode expected_status) { |
182 scoped_refptr<ServiceWorkerRegistration> registration; | 183 scoped_refptr<ServiceWorkerRegistration> registration; |
183 bool called; | 184 bool called; |
184 job_coordinator()->Register( | 185 job_coordinator()->Register( |
185 pattern, script_url, NULL, | 186 pattern, script_url, NULL, |
(...skipping 26 matching lines...) Expand all Loading... |
212 SaveFoundRegistration(expected_status, &called, ®istration)); | 213 SaveFoundRegistration(expected_status, &called, ®istration)); |
213 | 214 |
214 EXPECT_FALSE(called); | 215 EXPECT_FALSE(called); |
215 base::RunLoop().RunUntilIdle(); | 216 base::RunLoop().RunUntilIdle(); |
216 EXPECT_TRUE(called); | 217 EXPECT_TRUE(called); |
217 return registration; | 218 return registration; |
218 } | 219 } |
219 | 220 |
220 std::unique_ptr<ServiceWorkerProviderHost> | 221 std::unique_ptr<ServiceWorkerProviderHost> |
221 ServiceWorkerJobTest::CreateControllee() { | 222 ServiceWorkerJobTest::CreateControllee() { |
| 223 remote_endpoints_.emplace_back(); |
222 std::unique_ptr<ServiceWorkerProviderHost> host = CreateProviderHostForWindow( | 224 std::unique_ptr<ServiceWorkerProviderHost> host = CreateProviderHostForWindow( |
223 33 /* dummy render process id */, 1 /* dummy provider_id */, | 225 33 /* dummy render process id */, 1 /* dummy provider_id */, |
224 true /* is_parent_frame_secure */, helper_->context()->AsWeakPtr()); | 226 true /* is_parent_frame_secure */, helper_->context()->AsWeakPtr(), |
| 227 &remote_endpoints_.back()); |
225 return host; | 228 return host; |
226 } | 229 } |
227 | 230 |
228 TEST_F(ServiceWorkerJobTest, SameDocumentSameRegistration) { | 231 TEST_F(ServiceWorkerJobTest, SameDocumentSameRegistration) { |
229 scoped_refptr<ServiceWorkerRegistration> original_registration = | 232 scoped_refptr<ServiceWorkerRegistration> original_registration = |
230 RunRegisterJob(GURL("http://www.example.com/"), | 233 RunRegisterJob(GURL("http://www.example.com/"), |
231 GURL("http://www.example.com/service_worker.js")); | 234 GURL("http://www.example.com/service_worker.js")); |
232 bool called; | 235 bool called; |
233 scoped_refptr<ServiceWorkerRegistration> registration1; | 236 scoped_refptr<ServiceWorkerRegistration> registration1; |
234 storage()->FindRegistrationForDocument( | 237 storage()->FindRegistrationForDocument( |
(...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 // should not be promoted to ACTIVATED because failure occur | 1804 // should not be promoted to ACTIVATED because failure occur |
1802 // during shutdown. | 1805 // during shutdown. |
1803 runner->RunUntilIdle(); | 1806 runner->RunUntilIdle(); |
1804 base::RunLoop().RunUntilIdle(); | 1807 base::RunLoop().RunUntilIdle(); |
1805 EXPECT_EQ(new_version.get(), registration->active_version()); | 1808 EXPECT_EQ(new_version.get(), registration->active_version()); |
1806 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); | 1809 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); |
1807 registration->RemoveListener(update_helper); | 1810 registration->RemoveListener(update_helper); |
1808 } | 1811 } |
1809 | 1812 |
1810 } // namespace content | 1813 } // namespace content |
OLD | NEW |