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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 pattern, | 173 pattern, |
174 SaveFoundRegistration(expected_status, &called, ®istration)); | 174 SaveFoundRegistration(expected_status, &called, ®istration)); |
175 | 175 |
176 EXPECT_FALSE(called); | 176 EXPECT_FALSE(called); |
177 base::RunLoop().RunUntilIdle(); | 177 base::RunLoop().RunUntilIdle(); |
178 EXPECT_TRUE(called); | 178 EXPECT_TRUE(called); |
179 return registration; | 179 return registration; |
180 } | 180 } |
181 | 181 |
182 scoped_ptr<ServiceWorkerProviderHost> ServiceWorkerJobTest::CreateControllee() { | 182 scoped_ptr<ServiceWorkerProviderHost> ServiceWorkerJobTest::CreateControllee() { |
183 return scoped_ptr<ServiceWorkerProviderHost>( | 183 return scoped_ptr<ServiceWorkerProviderHost>(new ServiceWorkerProviderHost( |
184 new ServiceWorkerProviderHost(33 /* dummy render_process id */, | 184 33 /* dummy render_process id */, MSG_ROUTING_NONE /* render_frame_id */, |
185 MSG_ROUTING_NONE /* render_frame_id */, | 185 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, |
186 1 /* dummy provider_id */, | 186 helper_->context()->AsWeakPtr(), NULL)); |
187 SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE, | |
188 helper_->context()->AsWeakPtr(), | |
189 NULL)); | |
190 } | 187 } |
191 | 188 |
192 TEST_F(ServiceWorkerJobTest, SameDocumentSameRegistration) { | 189 TEST_F(ServiceWorkerJobTest, SameDocumentSameRegistration) { |
193 scoped_refptr<ServiceWorkerRegistration> original_registration = | 190 scoped_refptr<ServiceWorkerRegistration> original_registration = |
194 RunRegisterJob(GURL("http://www.example.com/"), | 191 RunRegisterJob(GURL("http://www.example.com/"), |
195 GURL("http://www.example.com/service_worker.js")); | 192 GURL("http://www.example.com/service_worker.js")); |
196 bool called; | 193 bool called; |
197 scoped_refptr<ServiceWorkerRegistration> registration1; | 194 scoped_refptr<ServiceWorkerRegistration> registration1; |
198 storage()->FindRegistrationForDocument( | 195 storage()->FindRegistrationForDocument( |
199 GURL("http://www.example.com/"), | 196 GURL("http://www.example.com/"), |
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 EXPECT_FALSE(registration->is_uninstalling()); | 1394 EXPECT_FALSE(registration->is_uninstalling()); |
1398 EXPECT_TRUE(registration->is_uninstalled()); | 1395 EXPECT_TRUE(registration->is_uninstalled()); |
1399 | 1396 |
1400 EXPECT_EQ(ServiceWorkerVersion::STOPPED, old_version->running_status()); | 1397 EXPECT_EQ(ServiceWorkerVersion::STOPPED, old_version->running_status()); |
1401 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, old_version->status()); | 1398 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, old_version->status()); |
1402 | 1399 |
1403 FindRegistrationForPattern(pattern, SERVICE_WORKER_ERROR_NOT_FOUND); | 1400 FindRegistrationForPattern(pattern, SERVICE_WORKER_ERROR_NOT_FOUND); |
1404 } | 1401 } |
1405 | 1402 |
1406 } // namespace content | 1403 } // namespace content |
OLD | NEW |