Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Side by Side Diff: content/browser/service_worker/service_worker_context_unittest.cc

Issue 238043002: Teach EmbeddedWorkerInstance to create a process when it needs one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle 2 places where context_ could be NULL. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/public/browser/service_worker_context.h" 5 #include "content/public/browser/service_worker_context.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/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "content/browser/browser_thread_impl.h" 10 #include "content/browser/browser_thread_impl.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 EXPECT_TRUE(registration->active_version()); 76 EXPECT_TRUE(registration->active_version());
77 EXPECT_EQ(expect_version_id, 77 EXPECT_EQ(expect_version_id,
78 registration->active_version()->version_id()); 78 registration->active_version()->version_id());
79 } else { 79 } else {
80 EXPECT_FALSE(registration->active_version()); 80 EXPECT_FALSE(registration->active_version());
81 } 81 }
82 } 82 }
83 83
84 class RejectInstallTestHelper : public EmbeddedWorkerTestHelper { 84 class RejectInstallTestHelper : public EmbeddedWorkerTestHelper {
85 public: 85 public:
86 RejectInstallTestHelper(ServiceWorkerContextCore* context, 86 RejectInstallTestHelper(int mock_render_process_id)
87 int mock_render_process_id) 87 : EmbeddedWorkerTestHelper(mock_render_process_id) {}
88 : EmbeddedWorkerTestHelper(context, mock_render_process_id) {}
89 88
90 virtual void OnInstallEvent(int embedded_worker_id, 89 virtual void OnInstallEvent(int embedded_worker_id,
91 int request_id, 90 int request_id,
92 int active_version_id) OVERRIDE { 91 int active_version_id) OVERRIDE {
93 SimulateSend( 92 SimulateSend(
94 new ServiceWorkerHostMsg_InstallEventFinished( 93 new ServiceWorkerHostMsg_InstallEventFinished(
95 embedded_worker_id, request_id, 94 embedded_worker_id, request_id,
96 blink::WebServiceWorkerEventResultRejected)); 95 blink::WebServiceWorkerEventResultRejected));
97 } 96 }
98 }; 97 };
99 98
100 class RejectActivateTestHelper : public EmbeddedWorkerTestHelper { 99 class RejectActivateTestHelper : public EmbeddedWorkerTestHelper {
101 public: 100 public:
102 RejectActivateTestHelper(ServiceWorkerContextCore* context, 101 RejectActivateTestHelper(int mock_render_process_id)
103 int mock_render_process_id) 102 : EmbeddedWorkerTestHelper(mock_render_process_id) {}
104 : EmbeddedWorkerTestHelper(context, mock_render_process_id) {}
105 103
106 virtual void OnActivateEvent(int embedded_worker_id, 104 virtual void OnActivateEvent(int embedded_worker_id,
107 int request_id) OVERRIDE { 105 int request_id) OVERRIDE {
108 SimulateSend( 106 SimulateSend(
109 new ServiceWorkerHostMsg_ActivateEventFinished( 107 new ServiceWorkerHostMsg_ActivateEventFinished(
110 embedded_worker_id, request_id, 108 embedded_worker_id, request_id,
111 blink::WebServiceWorkerEventResultRejected)); 109 blink::WebServiceWorkerEventResultRejected));
112 } 110 }
113 }; 111 };
114 112
115 } // namespace 113 } // namespace
116 114
117 class ServiceWorkerContextTest : public testing::Test { 115 class ServiceWorkerContextTest : public testing::Test {
118 public: 116 public:
119 ServiceWorkerContextTest() 117 ServiceWorkerContextTest()
120 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP), 118 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP),
121 render_process_id_(99) {} 119 render_process_id_(99) {}
122 120
123 virtual void SetUp() OVERRIDE { 121 virtual void SetUp() OVERRIDE {
124 context_.reset(new ServiceWorkerContextCore(base::FilePath(), NULL, NULL)); 122 helper_.reset(new EmbeddedWorkerTestHelper(render_process_id_));
125 helper_.reset(new EmbeddedWorkerTestHelper(
126 context_.get(), render_process_id_));
127 } 123 }
128 124
129 virtual void TearDown() OVERRIDE { 125 virtual void TearDown() OVERRIDE {
130 helper_.reset(); 126 helper_.reset();
131 context_.reset();
132 } 127 }
133 128
129 ServiceWorkerContextCore* context() { return helper_->context(); }
130
134 protected: 131 protected:
135 TestBrowserThreadBundle browser_thread_bundle_; 132 TestBrowserThreadBundle browser_thread_bundle_;
136 scoped_ptr<ServiceWorkerContextCore> context_;
137 scoped_ptr<EmbeddedWorkerTestHelper> helper_; 133 scoped_ptr<EmbeddedWorkerTestHelper> helper_;
138 const int render_process_id_; 134 const int render_process_id_;
139 }; 135 };
140 136
141 // Make sure basic registration is working. 137 // Make sure basic registration is working.
142 TEST_F(ServiceWorkerContextTest, Register) { 138 TEST_F(ServiceWorkerContextTest, Register) {
143 int64 registration_id = kInvalidServiceWorkerRegistrationId; 139 int64 registration_id = kInvalidServiceWorkerRegistrationId;
144 int64 version_id = kInvalidServiceWorkerVersionId; 140 int64 version_id = kInvalidServiceWorkerVersionId;
145 bool called = false; 141 bool called = false;
146 context_->RegisterServiceWorker( 142 context()->RegisterServiceWorker(
147 GURL("http://www.example.com/*"), 143 GURL("http://www.example.com/*"),
148 GURL("http://www.example.com/service_worker.js"), 144 GURL("http://www.example.com/service_worker.js"),
149 render_process_id_, 145 render_process_id_,
150 NULL, 146 NULL,
151 MakeRegisteredCallback(&called, &registration_id, &version_id)); 147 MakeRegisteredCallback(&called, &registration_id, &version_id));
152 148
153 ASSERT_FALSE(called); 149 ASSERT_FALSE(called);
154 base::RunLoop().RunUntilIdle(); 150 base::RunLoop().RunUntilIdle();
155 EXPECT_TRUE(called); 151 EXPECT_TRUE(called);
156 152
157 EXPECT_EQ(3UL, helper_->ipc_sink()->message_count()); 153 EXPECT_EQ(3UL, helper_->ipc_sink()->message_count());
158 EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching( 154 EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
159 ServiceWorkerMsg_InstallEvent::ID)); 155 ServiceWorkerMsg_InstallEvent::ID));
160 EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching( 156 EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
161 ServiceWorkerMsg_ActivateEvent::ID)); 157 ServiceWorkerMsg_ActivateEvent::ID));
162 EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id); 158 EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id);
163 EXPECT_NE(kInvalidServiceWorkerVersionId, version_id); 159 EXPECT_NE(kInvalidServiceWorkerVersionId, version_id);
164 160
165 context_->storage()->FindRegistrationForId( 161 context()->storage()->FindRegistrationForId(
166 registration_id, 162 registration_id,
167 base::Bind(&ExpectRegisteredWorkers, 163 base::Bind(&ExpectRegisteredWorkers,
168 SERVICE_WORKER_OK, 164 SERVICE_WORKER_OK,
169 version_id, 165 version_id,
170 false /* expect_pending */, 166 false /* expect_pending */,
171 true /* expect_active */)); 167 true /* expect_active */));
172 base::RunLoop().RunUntilIdle(); 168 base::RunLoop().RunUntilIdle();
173 } 169 }
174 170
175 // Test registration when the service worker rejects the install event. The 171 // Test registration when the service worker rejects the install event. The
176 // registration callback should indicate success, but there should be no pending 172 // registration callback should indicate success, but there should be no pending
177 // or active worker in the registration. 173 // or active worker in the registration.
178 TEST_F(ServiceWorkerContextTest, Register_RejectInstall) { 174 TEST_F(ServiceWorkerContextTest, Register_RejectInstall) {
179 helper_.reset( 175 helper_.reset(); // Make sure the process lookups stay overridden.
180 new RejectInstallTestHelper(context_.get(), render_process_id_)); 176 helper_.reset(new RejectInstallTestHelper(render_process_id_));
181 int64 registration_id = kInvalidServiceWorkerRegistrationId; 177 int64 registration_id = kInvalidServiceWorkerRegistrationId;
182 int64 version_id = kInvalidServiceWorkerVersionId; 178 int64 version_id = kInvalidServiceWorkerVersionId;
183 bool called = false; 179 bool called = false;
184 context_->RegisterServiceWorker( 180 context()->RegisterServiceWorker(
185 GURL("http://www.example.com/*"), 181 GURL("http://www.example.com/*"),
186 GURL("http://www.example.com/service_worker.js"), 182 GURL("http://www.example.com/service_worker.js"),
187 render_process_id_, 183 render_process_id_,
188 NULL, 184 NULL,
189 MakeRegisteredCallback(&called, &registration_id, &version_id)); 185 MakeRegisteredCallback(&called, &registration_id, &version_id));
190 186
191 ASSERT_FALSE(called); 187 ASSERT_FALSE(called);
192 base::RunLoop().RunUntilIdle(); 188 base::RunLoop().RunUntilIdle();
193 EXPECT_TRUE(called); 189 EXPECT_TRUE(called);
194 190
195 EXPECT_EQ(2UL, helper_->ipc_sink()->message_count()); 191 EXPECT_EQ(2UL, helper_->ipc_sink()->message_count());
196 EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching( 192 EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
197 ServiceWorkerMsg_InstallEvent::ID)); 193 ServiceWorkerMsg_InstallEvent::ID));
198 EXPECT_FALSE(helper_->inner_ipc_sink()->GetUniqueMessageMatching( 194 EXPECT_FALSE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
199 ServiceWorkerMsg_ActivateEvent::ID)); 195 ServiceWorkerMsg_ActivateEvent::ID));
200 EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id); 196 EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id);
201 EXPECT_NE(kInvalidServiceWorkerVersionId, version_id); 197 EXPECT_NE(kInvalidServiceWorkerVersionId, version_id);
202 198
203 context_->storage()->FindRegistrationForId( 199 context()->storage()->FindRegistrationForId(
204 registration_id, 200 registration_id,
205 base::Bind(&ExpectRegisteredWorkers, 201 base::Bind(&ExpectRegisteredWorkers,
206 SERVICE_WORKER_ERROR_NOT_FOUND, 202 SERVICE_WORKER_ERROR_NOT_FOUND,
207 kInvalidServiceWorkerVersionId, 203 kInvalidServiceWorkerVersionId,
208 false /* expect_pending */, 204 false /* expect_pending */,
209 false /* expect_active */)); 205 false /* expect_active */));
210 base::RunLoop().RunUntilIdle(); 206 base::RunLoop().RunUntilIdle();
211 } 207 }
212 208
213 // Test registration when the service worker rejects the activate event. The 209 // Test registration when the service worker rejects the activate event. The
214 // registration callback should indicate success, but there should be no pending 210 // registration callback should indicate success, but there should be no pending
215 // or active worker in the registration. 211 // or active worker in the registration.
216 TEST_F(ServiceWorkerContextTest, Register_RejectActivate) { 212 TEST_F(ServiceWorkerContextTest, Register_RejectActivate) {
217 helper_.reset( 213 helper_.reset(); // Make sure the process lookups stay overridden.
218 new RejectActivateTestHelper(context_.get(), render_process_id_)); 214 helper_.reset(new RejectActivateTestHelper(render_process_id_));
219 int64 registration_id = kInvalidServiceWorkerRegistrationId; 215 int64 registration_id = kInvalidServiceWorkerRegistrationId;
220 int64 version_id = kInvalidServiceWorkerVersionId; 216 int64 version_id = kInvalidServiceWorkerVersionId;
221 bool called = false; 217 bool called = false;
222 context_->RegisterServiceWorker( 218 context()->RegisterServiceWorker(
223 GURL("http://www.example.com/*"), 219 GURL("http://www.example.com/*"),
224 GURL("http://www.example.com/service_worker.js"), 220 GURL("http://www.example.com/service_worker.js"),
225 render_process_id_, 221 render_process_id_,
226 NULL, 222 NULL,
227 MakeRegisteredCallback(&called, &registration_id, &version_id)); 223 MakeRegisteredCallback(&called, &registration_id, &version_id));
228 224
229 ASSERT_FALSE(called); 225 ASSERT_FALSE(called);
230 base::RunLoop().RunUntilIdle(); 226 base::RunLoop().RunUntilIdle();
231 EXPECT_TRUE(called); 227 EXPECT_TRUE(called);
232 228
233 EXPECT_EQ(3UL, helper_->ipc_sink()->message_count()); 229 EXPECT_EQ(3UL, helper_->ipc_sink()->message_count());
234 EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching( 230 EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
235 ServiceWorkerMsg_InstallEvent::ID)); 231 ServiceWorkerMsg_InstallEvent::ID));
236 EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching( 232 EXPECT_TRUE(helper_->inner_ipc_sink()->GetUniqueMessageMatching(
237 ServiceWorkerMsg_ActivateEvent::ID)); 233 ServiceWorkerMsg_ActivateEvent::ID));
238 EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id); 234 EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id);
239 EXPECT_NE(kInvalidServiceWorkerVersionId, version_id); 235 EXPECT_NE(kInvalidServiceWorkerVersionId, version_id);
240 236
241 context_->storage()->FindRegistrationForId( 237 context()->storage()->FindRegistrationForId(
242 registration_id, 238 registration_id,
243 base::Bind(&ExpectRegisteredWorkers, 239 base::Bind(&ExpectRegisteredWorkers,
244 SERVICE_WORKER_ERROR_NOT_FOUND, 240 SERVICE_WORKER_ERROR_NOT_FOUND,
245 kInvalidServiceWorkerVersionId, 241 kInvalidServiceWorkerVersionId,
246 false /* expect_pending */, 242 false /* expect_pending */,
247 false /* expect_active */)); 243 false /* expect_active */));
248 base::RunLoop().RunUntilIdle(); 244 base::RunLoop().RunUntilIdle();
249 } 245 }
250 246
251 // Make sure registrations are cleaned up when they are unregistered. 247 // Make sure registrations are cleaned up when they are unregistered.
252 TEST_F(ServiceWorkerContextTest, Unregister) { 248 TEST_F(ServiceWorkerContextTest, Unregister) {
253 GURL pattern("http://www.example.com/*"); 249 GURL pattern("http://www.example.com/*");
254 250
255 bool called = false; 251 bool called = false;
256 int64 registration_id = kInvalidServiceWorkerRegistrationId; 252 int64 registration_id = kInvalidServiceWorkerRegistrationId;
257 int64 version_id = kInvalidServiceWorkerVersionId; 253 int64 version_id = kInvalidServiceWorkerVersionId;
258 context_->RegisterServiceWorker( 254 context()->RegisterServiceWorker(
259 pattern, 255 pattern,
260 GURL("http://www.example.com/service_worker.js"), 256 GURL("http://www.example.com/service_worker.js"),
261 render_process_id_, 257 render_process_id_,
262 NULL, 258 NULL,
263 MakeRegisteredCallback(&called, &registration_id, &version_id)); 259 MakeRegisteredCallback(&called, &registration_id, &version_id));
264 260
265 ASSERT_FALSE(called); 261 ASSERT_FALSE(called);
266 base::RunLoop().RunUntilIdle(); 262 base::RunLoop().RunUntilIdle();
267 ASSERT_TRUE(called); 263 ASSERT_TRUE(called);
268 EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id); 264 EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id);
269 EXPECT_NE(kInvalidServiceWorkerVersionId, version_id); 265 EXPECT_NE(kInvalidServiceWorkerVersionId, version_id);
270 266
271 called = false; 267 called = false;
272 context_->UnregisterServiceWorker( 268 context()->UnregisterServiceWorker(
273 pattern, render_process_id_, NULL, MakeUnregisteredCallback(&called)); 269 pattern, render_process_id_, NULL, MakeUnregisteredCallback(&called));
274 270
275 ASSERT_FALSE(called); 271 ASSERT_FALSE(called);
276 base::RunLoop().RunUntilIdle(); 272 base::RunLoop().RunUntilIdle();
277 ASSERT_TRUE(called); 273 ASSERT_TRUE(called);
278 274
279 context_->storage()->FindRegistrationForId( 275 context()->storage()->FindRegistrationForId(
280 registration_id, 276 registration_id,
281 base::Bind(&ExpectRegisteredWorkers, 277 base::Bind(&ExpectRegisteredWorkers,
282 SERVICE_WORKER_ERROR_NOT_FOUND, 278 SERVICE_WORKER_ERROR_NOT_FOUND,
283 kInvalidServiceWorkerVersionId, 279 kInvalidServiceWorkerVersionId,
284 false /* expect_pending */, 280 false /* expect_pending */,
285 false /* expect_active */)); 281 false /* expect_active */));
286 base::RunLoop().RunUntilIdle(); 282 base::RunLoop().RunUntilIdle();
287 } 283 }
288 284
289 // Make sure that when a new registration replaces an existing 285 // Make sure that when a new registration replaces an existing
290 // registration, that the old one is cleaned up. 286 // registration, that the old one is cleaned up.
291 TEST_F(ServiceWorkerContextTest, RegisterNewScript) { 287 TEST_F(ServiceWorkerContextTest, RegisterNewScript) {
292 GURL pattern("http://www.example.com/*"); 288 GURL pattern("http://www.example.com/*");
293 289
294 bool called = false; 290 bool called = false;
295 int64 old_registration_id = kInvalidServiceWorkerRegistrationId; 291 int64 old_registration_id = kInvalidServiceWorkerRegistrationId;
296 int64 old_version_id = kInvalidServiceWorkerVersionId; 292 int64 old_version_id = kInvalidServiceWorkerVersionId;
297 context_->RegisterServiceWorker( 293 context()->RegisterServiceWorker(
298 pattern, 294 pattern,
299 GURL("http://www.example.com/service_worker.js"), 295 GURL("http://www.example.com/service_worker.js"),
300 render_process_id_, 296 render_process_id_,
301 NULL, 297 NULL,
302 MakeRegisteredCallback(&called, &old_registration_id, &old_version_id)); 298 MakeRegisteredCallback(&called, &old_registration_id, &old_version_id));
303 299
304 ASSERT_FALSE(called); 300 ASSERT_FALSE(called);
305 base::RunLoop().RunUntilIdle(); 301 base::RunLoop().RunUntilIdle();
306 ASSERT_TRUE(called); 302 ASSERT_TRUE(called);
307 EXPECT_NE(kInvalidServiceWorkerRegistrationId, old_registration_id); 303 EXPECT_NE(kInvalidServiceWorkerRegistrationId, old_registration_id);
308 EXPECT_NE(kInvalidServiceWorkerVersionId, old_version_id); 304 EXPECT_NE(kInvalidServiceWorkerVersionId, old_version_id);
309 305
310 called = false; 306 called = false;
311 int64 new_registration_id = kInvalidServiceWorkerRegistrationId; 307 int64 new_registration_id = kInvalidServiceWorkerRegistrationId;
312 int64 new_version_id = kInvalidServiceWorkerVersionId; 308 int64 new_version_id = kInvalidServiceWorkerVersionId;
313 context_->RegisterServiceWorker( 309 context()->RegisterServiceWorker(
314 pattern, 310 pattern,
315 GURL("http://www.example.com/service_worker_new.js"), 311 GURL("http://www.example.com/service_worker_new.js"),
316 render_process_id_, 312 render_process_id_,
317 NULL, 313 NULL,
318 MakeRegisteredCallback(&called, &new_registration_id, &new_version_id)); 314 MakeRegisteredCallback(&called, &new_registration_id, &new_version_id));
319 315
320 ASSERT_FALSE(called); 316 ASSERT_FALSE(called);
321 base::RunLoop().RunUntilIdle(); 317 base::RunLoop().RunUntilIdle();
322 ASSERT_TRUE(called); 318 ASSERT_TRUE(called);
323 319
324 // Returned IDs should be valid, and should differ from the values 320 // Returned IDs should be valid, and should differ from the values
325 // returned for the previous registration. 321 // returned for the previous registration.
326 EXPECT_NE(kInvalidServiceWorkerRegistrationId, new_registration_id); 322 EXPECT_NE(kInvalidServiceWorkerRegistrationId, new_registration_id);
327 EXPECT_NE(kInvalidServiceWorkerVersionId, new_version_id); 323 EXPECT_NE(kInvalidServiceWorkerVersionId, new_version_id);
328 EXPECT_NE(old_registration_id, new_registration_id); 324 EXPECT_NE(old_registration_id, new_registration_id);
329 EXPECT_NE(old_version_id, new_version_id); 325 EXPECT_NE(old_version_id, new_version_id);
330 } 326 }
331 327
332 // Make sure that when registering a duplicate pattern+script_url 328 // Make sure that when registering a duplicate pattern+script_url
333 // combination, that the same registration is used. 329 // combination, that the same registration is used.
334 TEST_F(ServiceWorkerContextTest, RegisterDuplicateScript) { 330 TEST_F(ServiceWorkerContextTest, RegisterDuplicateScript) {
335 GURL pattern("http://www.example.com/*"); 331 GURL pattern("http://www.example.com/*");
336 GURL script_url("http://www.example.com/service_worker.js"); 332 GURL script_url("http://www.example.com/service_worker.js");
337 333
338 bool called = false; 334 bool called = false;
339 int64 old_registration_id = kInvalidServiceWorkerRegistrationId; 335 int64 old_registration_id = kInvalidServiceWorkerRegistrationId;
340 int64 old_version_id = kInvalidServiceWorkerVersionId; 336 int64 old_version_id = kInvalidServiceWorkerVersionId;
341 context_->RegisterServiceWorker( 337 context()->RegisterServiceWorker(
342 pattern, 338 pattern,
343 script_url, 339 script_url,
344 render_process_id_, 340 render_process_id_,
345 NULL, 341 NULL,
346 MakeRegisteredCallback(&called, &old_registration_id, &old_version_id)); 342 MakeRegisteredCallback(&called, &old_registration_id, &old_version_id));
347 343
348 ASSERT_FALSE(called); 344 ASSERT_FALSE(called);
349 base::RunLoop().RunUntilIdle(); 345 base::RunLoop().RunUntilIdle();
350 ASSERT_TRUE(called); 346 ASSERT_TRUE(called);
351 EXPECT_NE(kInvalidServiceWorkerRegistrationId, old_registration_id); 347 EXPECT_NE(kInvalidServiceWorkerRegistrationId, old_registration_id);
352 EXPECT_NE(kInvalidServiceWorkerVersionId, old_version_id); 348 EXPECT_NE(kInvalidServiceWorkerVersionId, old_version_id);
353 349
354 called = false; 350 called = false;
355 int64 new_registration_id = kInvalidServiceWorkerRegistrationId; 351 int64 new_registration_id = kInvalidServiceWorkerRegistrationId;
356 int64 new_version_id = kInvalidServiceWorkerVersionId; 352 int64 new_version_id = kInvalidServiceWorkerVersionId;
357 context_->RegisterServiceWorker( 353 context()->RegisterServiceWorker(
358 pattern, 354 pattern,
359 script_url, 355 script_url,
360 render_process_id_, 356 render_process_id_,
361 NULL, 357 NULL,
362 MakeRegisteredCallback(&called, &new_registration_id, &new_version_id)); 358 MakeRegisteredCallback(&called, &new_registration_id, &new_version_id));
363 359
364 ASSERT_FALSE(called); 360 ASSERT_FALSE(called);
365 base::RunLoop().RunUntilIdle(); 361 base::RunLoop().RunUntilIdle();
366 ASSERT_TRUE(called); 362 ASSERT_TRUE(called);
367 EXPECT_EQ(old_registration_id, new_registration_id); 363 EXPECT_EQ(old_registration_id, new_registration_id);
368 EXPECT_EQ(old_version_id, new_version_id); 364 EXPECT_EQ(old_version_id, new_version_id);
369 } 365 }
370 366
371 } // namespace content 367 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698