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 const GURL pattern("http://www.example.com/"); | 81 const GURL pattern("http://www.example.com/"); |
82 registration_ = new ServiceWorkerRegistration( | 82 registration_ = new ServiceWorkerRegistration( |
83 pattern, | 83 pattern, |
84 1L, | 84 1L, |
85 helper_->context()->AsWeakPtr()); | 85 helper_->context()->AsWeakPtr()); |
86 version_ = new ServiceWorkerVersion( | 86 version_ = new ServiceWorkerVersion( |
87 registration_.get(), | 87 registration_.get(), |
88 GURL("http://www.example.com/service_worker.js"), | 88 GURL("http://www.example.com/service_worker.js"), |
89 1L, | 89 1L, |
90 helper_->context()->AsWeakPtr()); | 90 helper_->context()->AsWeakPtr()); |
| 91 std::vector<ServiceWorkerDatabase::ResourceRecord> records; |
| 92 records.push_back( |
| 93 ServiceWorkerDatabase::ResourceRecord(10, version_->script_url(), 100)); |
| 94 version_->script_cache_map()->SetResources(records); |
91 | 95 |
92 // Make the registration findable via storage functions. | 96 // Make the registration findable via storage functions. |
93 helper_->context()->storage()->LazyInitialize(base::Bind(&base::DoNothing)); | 97 helper_->context()->storage()->LazyInitialize(base::Bind(&base::DoNothing)); |
94 base::RunLoop().RunUntilIdle(); | 98 base::RunLoop().RunUntilIdle(); |
95 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; | 99 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; |
96 helper_->context()->storage()->StoreRegistration( | 100 helper_->context()->storage()->StoreRegistration( |
97 registration_.get(), | 101 registration_.get(), |
98 version_.get(), | 102 version_.get(), |
99 CreateReceiverOnCurrentThread(&status)); | 103 CreateReceiverOnCurrentThread(&status)); |
100 base::RunLoop().RunUntilIdle(); | 104 base::RunLoop().RunUntilIdle(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // 3. SendMessageToWorker (to send InstallEvent), and | 168 // 3. SendMessageToWorker (to send InstallEvent), and |
165 EXPECT_EQ(EmbeddedWorkerContextMsg_MessageToWorker::ID, | 169 EXPECT_EQ(EmbeddedWorkerContextMsg_MessageToWorker::ID, |
166 ipc_sink()->GetMessageAt(2)->type()); | 170 ipc_sink()->GetMessageAt(2)->type()); |
167 // 4. StateChanged (state == Installed). | 171 // 4. StateChanged (state == Installed). |
168 VerifyStateChangedMessage(handle->handle_id(), | 172 VerifyStateChangedMessage(handle->handle_id(), |
169 blink::WebServiceWorkerStateInstalled, | 173 blink::WebServiceWorkerStateInstalled, |
170 ipc_sink()->GetMessageAt(3)); | 174 ipc_sink()->GetMessageAt(3)); |
171 } | 175 } |
172 | 176 |
173 } // namespace content | 177 } // namespace content |
OLD | NEW |