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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "content/browser/service_worker/embedded_worker_registry.h" | 7 #include "content/browser/service_worker/embedded_worker_registry.h" |
8 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 8 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
9 #include "content/browser/service_worker/service_worker_context_core.h" | 9 #include "content/browser/service_worker/service_worker_context_core.h" |
10 #include "content/browser/service_worker/service_worker_dispatcher_host.h" | 10 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 registration_ = new ServiceWorkerRegistration( | 81 registration_ = new ServiceWorkerRegistration( |
82 pattern, | 82 pattern, |
83 1L, | 83 1L, |
84 helper_->context()->AsWeakPtr()); | 84 helper_->context()->AsWeakPtr()); |
85 version_ = new ServiceWorkerVersion( | 85 version_ = new ServiceWorkerVersion( |
86 registration_.get(), | 86 registration_.get(), |
87 GURL("http://www.example.com/service_worker.js"), | 87 GURL("http://www.example.com/service_worker.js"), |
88 1L, | 88 1L, |
89 helper_->context()->AsWeakPtr()); | 89 helper_->context()->AsWeakPtr()); |
90 | 90 |
| 91 // Make the registration findable via storage functions. |
| 92 helper_->context()->storage()->LazyInitialize(base::Bind(&base::DoNothing)); |
| 93 base::RunLoop().RunUntilIdle(); |
| 94 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; |
| 95 helper_->context()->storage()->StoreRegistration( |
| 96 registration_.get(), |
| 97 version_.get(), |
| 98 CreateReceiverOnCurrentThread(&status)); |
| 99 base::RunLoop().RunUntilIdle(); |
| 100 ASSERT_EQ(SERVICE_WORKER_OK, status); |
| 101 |
91 provider_host_.reset(new ServiceWorkerProviderHost( | 102 provider_host_.reset(new ServiceWorkerProviderHost( |
92 kRenderProcessId, kRenderFrameId, 1, | 103 kRenderProcessId, kRenderFrameId, 1, |
93 SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE, | 104 SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE, |
94 helper_->context()->AsWeakPtr(), dispatcher_host_.get())); | 105 helper_->context()->AsWeakPtr(), dispatcher_host_.get())); |
95 | 106 |
96 helper_->SimulateAddProcessToPattern(pattern, kRenderProcessId); | 107 helper_->SimulateAddProcessToPattern(pattern, kRenderProcessId); |
97 } | 108 } |
98 | 109 |
99 void TearDown() override { | 110 void TearDown() override { |
100 dispatcher_host_ = NULL; | 111 dispatcher_host_ = NULL; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // 3. SendMessageToWorker (to send InstallEvent), and | 164 // 3. SendMessageToWorker (to send InstallEvent), and |
154 EXPECT_EQ(EmbeddedWorkerContextMsg_MessageToWorker::ID, | 165 EXPECT_EQ(EmbeddedWorkerContextMsg_MessageToWorker::ID, |
155 ipc_sink()->GetMessageAt(2)->type()); | 166 ipc_sink()->GetMessageAt(2)->type()); |
156 // 4. StateChanged (state == Installed). | 167 // 4. StateChanged (state == Installed). |
157 VerifyStateChangedMessage(handle->handle_id(), | 168 VerifyStateChangedMessage(handle->handle_id(), |
158 blink::WebServiceWorkerStateInstalled, | 169 blink::WebServiceWorkerStateInstalled, |
159 ipc_sink()->GetMessageAt(3)); | 170 ipc_sink()->GetMessageAt(3)); |
160 } | 171 } |
161 | 172 |
162 } // namespace content | 173 } // namespace content |
OLD | NEW |