OLD | NEW |
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/browser/service_worker/service_worker_dispatcher_host.h" | 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 ServiceWorkerMsg_ServiceWorkerRegistered::ID); | 205 ServiceWorkerMsg_ServiceWorkerRegistered::ID); |
206 } | 206 } |
207 | 207 |
208 TEST_F(ServiceWorkerDispatcherHostTest, Register_InvalidScopeShouldFail) { | 208 TEST_F(ServiceWorkerDispatcherHostTest, Register_InvalidScopeShouldFail) { |
209 const int64 kProviderId = 99; // Dummy value | 209 const int64 kProviderId = 99; // Dummy value |
210 scoped_ptr<ServiceWorkerProviderHost> host( | 210 scoped_ptr<ServiceWorkerProviderHost> host( |
211 CreateServiceWorkerProviderHost(kProviderId)); | 211 CreateServiceWorkerProviderHost(kProviderId)); |
212 host->SetDocumentUrl(GURL("https://www.example.com/foo")); | 212 host->SetDocumentUrl(GURL("https://www.example.com/foo")); |
213 context()->AddProviderHost(host.Pass()); | 213 context()->AddProviderHost(host.Pass()); |
214 | 214 |
215 SendRegister( | 215 SendRegister(kProviderId, GURL(""), |
216 kProviderId, GURL(""), GURL("https://www.example.com/bar/hoge.js")); | 216 GURL("https://www.example.com/bar/hoge.js")); |
217 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); | 217 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); |
218 } | 218 } |
219 | 219 |
220 TEST_F(ServiceWorkerDispatcherHostTest, Register_InvalidScriptShouldFail) { | 220 TEST_F(ServiceWorkerDispatcherHostTest, Register_InvalidScriptShouldFail) { |
221 const int64 kProviderId = 99; // Dummy value | 221 const int64 kProviderId = 99; // Dummy value |
222 scoped_ptr<ServiceWorkerProviderHost> host( | 222 scoped_ptr<ServiceWorkerProviderHost> host( |
223 CreateServiceWorkerProviderHost(kProviderId)); | 223 CreateServiceWorkerProviderHost(kProviderId)); |
224 host->SetDocumentUrl(GURL("https://www.example.com/foo")); | 224 host->SetDocumentUrl(GURL("https://www.example.com/foo")); |
225 context()->AddProviderHost(host.Pass()); | 225 context()->AddProviderHost(host.Pass()); |
226 | 226 |
227 SendRegister(kProviderId, GURL("https://www.example.com/bar/"), GURL("")); | 227 SendRegister(kProviderId, GURL("https://www.example.com/bar/"), GURL("")); |
228 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); | 228 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); |
229 } | 229 } |
230 | 230 |
231 TEST_F(ServiceWorkerDispatcherHostTest, Register_NonSecureOriginShouldFail) { | 231 TEST_F(ServiceWorkerDispatcherHostTest, Register_NonSecureOriginShouldFail) { |
232 const int64 kProviderId = 99; // Dummy value | 232 const int64 kProviderId = 99; // Dummy value |
233 scoped_ptr<ServiceWorkerProviderHost> host( | 233 scoped_ptr<ServiceWorkerProviderHost> host( |
234 CreateServiceWorkerProviderHost(kProviderId)); | 234 CreateServiceWorkerProviderHost(kProviderId)); |
235 host->SetDocumentUrl(GURL("http://www.example.com/foo")); | 235 host->SetDocumentUrl(GURL("http://www.example.com/foo")); |
236 context()->AddProviderHost(host.Pass()); | 236 context()->AddProviderHost(host.Pass()); |
237 | 237 |
238 Register(kProviderId, | 238 SendRegister(kProviderId, |
239 GURL("http://www.example.com/"), | 239 GURL("http://www.example.com/"), |
240 GURL("http://www.example.com/bar"), | 240 GURL("http://www.example.com/bar")); |
241 ServiceWorkerMsg_ServiceWorkerRegistrationError::ID); | 241 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); |
242 } | 242 } |
243 | 243 |
244 TEST_F(ServiceWorkerDispatcherHostTest, Register_CrossOriginShouldFail) { | 244 TEST_F(ServiceWorkerDispatcherHostTest, Register_CrossOriginShouldFail) { |
245 const int64 kProviderId = 99; // Dummy value | 245 const int64 kProviderId = 99; // Dummy value |
246 scoped_ptr<ServiceWorkerProviderHost> host( | 246 scoped_ptr<ServiceWorkerProviderHost> host( |
247 CreateServiceWorkerProviderHost(kProviderId)); | 247 CreateServiceWorkerProviderHost(kProviderId)); |
248 host->SetDocumentUrl(GURL("https://www.example.com/foo")); | 248 host->SetDocumentUrl(GURL("https://www.example.com/foo")); |
249 context()->AddProviderHost(host.Pass()); | 249 context()->AddProviderHost(host.Pass()); |
250 | 250 |
251 // Script has a different host | 251 // Script has a different host |
252 Register(kProviderId, | 252 SendRegister(kProviderId, |
253 GURL("https://www.example.com/"), | 253 GURL("https://www.example.com/"), |
254 GURL("https://foo.example.com/bar"), | 254 GURL("https://foo.example.com/bar")); |
255 ServiceWorkerMsg_ServiceWorkerRegistrationError::ID); | 255 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); |
256 | 256 |
257 // Scope has a different host | 257 // Scope has a different host |
258 Register(kProviderId, | 258 SendRegister(kProviderId, |
259 GURL("https://foo.example.com/"), | 259 GURL("https://foo.example.com/"), |
260 GURL("https://www.example.com/bar"), | 260 GURL("https://www.example.com/bar")); |
261 ServiceWorkerMsg_ServiceWorkerRegistrationError::ID); | 261 EXPECT_EQ(2, dispatcher_host_->bad_messages_received_count_); |
262 | 262 |
263 // Script has a different port | 263 // Script has a different port |
264 Register(kProviderId, | 264 SendRegister(kProviderId, |
265 GURL("https://www.example.com/"), | 265 GURL("https://www.example.com/"), |
266 GURL("https://www.example.com:8080/bar"), | 266 GURL("https://www.example.com:8080/bar")); |
267 ServiceWorkerMsg_ServiceWorkerRegistrationError::ID); | 267 EXPECT_EQ(3, dispatcher_host_->bad_messages_received_count_); |
268 | 268 |
269 // Scope has a different transport | 269 // Scope has a different transport |
270 Register(kProviderId, | 270 SendRegister(kProviderId, |
271 GURL("wss://www.example.com/"), | 271 GURL("wss://www.example.com/"), |
272 GURL("https://www.example.com/bar"), | 272 GURL("https://www.example.com/bar")); |
273 ServiceWorkerMsg_ServiceWorkerRegistrationError::ID); | 273 EXPECT_EQ(4, dispatcher_host_->bad_messages_received_count_); |
274 | 274 |
275 // Script and scope have a different host but match each other | 275 // Script and scope have a different host but match each other |
276 Register(kProviderId, | 276 SendRegister(kProviderId, |
277 GURL("https://foo.example.com/"), | 277 GURL("https://foo.example.com/"), |
278 GURL("https://foo.example.com/bar"), | 278 GURL("https://foo.example.com/bar")); |
279 ServiceWorkerMsg_ServiceWorkerRegistrationError::ID); | 279 EXPECT_EQ(5, dispatcher_host_->bad_messages_received_count_); |
280 | 280 |
281 // Script and scope URLs are invalid | 281 // Script and scope URLs are invalid |
282 SendRegister(kProviderId, | 282 SendRegister(kProviderId, |
283 GURL(), | 283 GURL(), |
284 GURL("h@ttps://@")); | 284 GURL("h@ttps://@")); |
285 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); | 285 EXPECT_EQ(6, dispatcher_host_->bad_messages_received_count_); |
286 } | 286 } |
287 | 287 |
288 TEST_F(ServiceWorkerDispatcherHostTest, | 288 TEST_F(ServiceWorkerDispatcherHostTest, |
289 Register_FileSystemDocumentShouldFail) { | 289 Register_FileSystemDocumentShouldFail) { |
290 const int64 kProviderId = 99; // Dummy value | 290 const int64 kProviderId = 99; // Dummy value |
291 scoped_ptr<ServiceWorkerProviderHost> host( | 291 scoped_ptr<ServiceWorkerProviderHost> host( |
292 CreateServiceWorkerProviderHost(kProviderId)); | 292 CreateServiceWorkerProviderHost(kProviderId)); |
293 host->SetDocumentUrl(GURL("filesystem:https://www.example.com/temporary/a")); | 293 host->SetDocumentUrl(GURL("filesystem:https://www.example.com/temporary/a")); |
294 context()->AddProviderHost(host.Pass()); | 294 context()->AddProviderHost(host.Pass()); |
295 | 295 |
296 Register(kProviderId, | 296 SendRegister(kProviderId, |
297 GURL("filesystem:https://www.example.com/temporary/"), | 297 GURL("filesystem:https://www.example.com/temporary/"), |
298 GURL("https://www.example.com/temporary/bar"), | 298 GURL("https://www.example.com/temporary/bar")); |
299 ServiceWorkerMsg_ServiceWorkerRegistrationError::ID); | 299 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); |
300 | 300 |
301 Register(kProviderId, | 301 SendRegister(kProviderId, |
302 GURL("https://www.example.com/temporary/"), | 302 GURL("https://www.example.com/temporary/"), |
303 GURL("filesystem:https://www.example.com/temporary/bar"), | 303 GURL("filesystem:https://www.example.com/temporary/bar")); |
304 ServiceWorkerMsg_ServiceWorkerRegistrationError::ID); | 304 EXPECT_EQ(2, dispatcher_host_->bad_messages_received_count_); |
305 | 305 |
306 Register(kProviderId, | 306 SendRegister(kProviderId, |
307 GURL("filesystem:https://www.example.com/temporary/"), | 307 GURL("filesystem:https://www.example.com/temporary/"), |
308 GURL("filesystem:https://www.example.com/temporary/bar"), | 308 GURL("filesystem:https://www.example.com/temporary/bar")); |
309 ServiceWorkerMsg_ServiceWorkerRegistrationError::ID); | 309 EXPECT_EQ(3, dispatcher_host_->bad_messages_received_count_); |
310 } | 310 } |
311 | 311 |
312 TEST_F(ServiceWorkerDispatcherHostTest, | 312 TEST_F(ServiceWorkerDispatcherHostTest, |
313 Register_FileSystemScriptOrScopeShouldFail) { | 313 Register_FileSystemScriptOrScopeShouldFail) { |
314 const int64 kProviderId = 99; // Dummy value | 314 const int64 kProviderId = 99; // Dummy value |
315 scoped_ptr<ServiceWorkerProviderHost> host( | 315 scoped_ptr<ServiceWorkerProviderHost> host( |
316 CreateServiceWorkerProviderHost(kProviderId)); | 316 CreateServiceWorkerProviderHost(kProviderId)); |
317 host->SetDocumentUrl(GURL("https://www.example.com/temporary/")); | 317 host->SetDocumentUrl(GURL("https://www.example.com/temporary/")); |
318 context()->AddProviderHost(host.Pass()); | 318 context()->AddProviderHost(host.Pass()); |
319 | 319 |
320 Register(kProviderId, | 320 SendRegister(kProviderId, |
321 GURL("filesystem:https://www.example.com/temporary/"), | 321 GURL("filesystem:https://www.example.com/temporary/"), |
322 GURL("https://www.example.com/temporary/bar"), | 322 GURL("https://www.example.com/temporary/bar")); |
323 ServiceWorkerMsg_ServiceWorkerRegistrationError::ID); | 323 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); |
324 | 324 |
325 Register(kProviderId, | 325 SendRegister(kProviderId, |
326 GURL("https://www.example.com/temporary/"), | 326 GURL("https://www.example.com/temporary/"), |
327 GURL("filesystem:https://www.example.com/temporary/bar"), | 327 GURL("filesystem:https://www.example.com/temporary/bar")); |
328 ServiceWorkerMsg_ServiceWorkerRegistrationError::ID); | 328 EXPECT_EQ(2, dispatcher_host_->bad_messages_received_count_); |
329 | 329 |
330 Register(kProviderId, | 330 SendRegister(kProviderId, |
331 GURL("filesystem:https://www.example.com/temporary/"), | 331 GURL("filesystem:https://www.example.com/temporary/"), |
332 GURL("filesystem:https://www.example.com/temporary/bar"), | 332 GURL("filesystem:https://www.example.com/temporary/bar")); |
333 ServiceWorkerMsg_ServiceWorkerRegistrationError::ID); | 333 EXPECT_EQ(3, dispatcher_host_->bad_messages_received_count_); |
334 } | 334 } |
335 | 335 |
336 TEST_F(ServiceWorkerDispatcherHostTest, Unregister_HTTPS) { | 336 TEST_F(ServiceWorkerDispatcherHostTest, Unregister_HTTPS) { |
337 const int64 kProviderId = 99; // Dummy value | 337 const int64 kProviderId = 99; // Dummy value |
338 scoped_ptr<ServiceWorkerProviderHost> host( | 338 scoped_ptr<ServiceWorkerProviderHost> host( |
339 CreateServiceWorkerProviderHost(kProviderId)); | 339 CreateServiceWorkerProviderHost(kProviderId)); |
340 host->SetDocumentUrl(GURL("https://www.example.com/foo")); | 340 host->SetDocumentUrl(GURL("https://www.example.com/foo")); |
341 context()->AddProviderHost(host.Pass()); | 341 context()->AddProviderHost(host.Pass()); |
342 | 342 |
343 Unregister(kProviderId, | 343 Unregister(kProviderId, |
344 GURL("https://www.example.com/"), | 344 GURL("https://www.example.com/"), |
345 ServiceWorkerMsg_ServiceWorkerUnregistered::ID); | 345 ServiceWorkerMsg_ServiceWorkerUnregistered::ID); |
346 } | 346 } |
347 | 347 |
348 TEST_F(ServiceWorkerDispatcherHostTest, | 348 TEST_F(ServiceWorkerDispatcherHostTest, |
349 Unregister_NonSecureTransportLocalhost) { | 349 Unregister_NotSecureTransportLocalhost) { |
350 const int64 kProviderId = 99; // Dummy value | 350 const int64 kProviderId = 99; // Dummy value |
351 scoped_ptr<ServiceWorkerProviderHost> host( | 351 scoped_ptr<ServiceWorkerProviderHost> host( |
352 CreateServiceWorkerProviderHost(kProviderId)); | 352 CreateServiceWorkerProviderHost(kProviderId)); |
353 host->SetDocumentUrl(GURL("http://localhost/foo")); | 353 host->SetDocumentUrl(GURL("http://localhost/foo")); |
354 context()->AddProviderHost(host.Pass()); | 354 context()->AddProviderHost(host.Pass()); |
355 | 355 |
356 Unregister(kProviderId, | 356 Unregister(kProviderId, |
357 GURL("http://localhost/"), | 357 GURL("http://localhost/"), |
358 ServiceWorkerMsg_ServiceWorkerUnregistered::ID); | 358 ServiceWorkerMsg_ServiceWorkerUnregistered::ID); |
359 } | 359 } |
360 | 360 |
361 TEST_F(ServiceWorkerDispatcherHostTest, Unregister_CrossOriginShouldFail) { | 361 TEST_F(ServiceWorkerDispatcherHostTest, Unregister_CrossOriginShouldFail) { |
362 const int64 kProviderId = 99; // Dummy value | 362 const int64 kProviderId = 99; // Dummy value |
363 scoped_ptr<ServiceWorkerProviderHost> host( | 363 scoped_ptr<ServiceWorkerProviderHost> host( |
364 CreateServiceWorkerProviderHost(kProviderId)); | 364 CreateServiceWorkerProviderHost(kProviderId)); |
365 host->SetDocumentUrl(GURL("https://www.example.com/foo")); | 365 host->SetDocumentUrl(GURL("https://www.example.com/foo")); |
366 context()->AddProviderHost(host.Pass()); | 366 context()->AddProviderHost(host.Pass()); |
367 | 367 |
368 Unregister(kProviderId, | 368 SendUnregister(kProviderId, GURL("https://foo.example.com/")); |
369 GURL("https://foo.example.com/"), | 369 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); |
370 ServiceWorkerMsg_ServiceWorkerUnregistrationError::ID); | |
371 } | 370 } |
372 | 371 |
373 TEST_F(ServiceWorkerDispatcherHostTest, Unregister_InvalidScopeShouldFail) { | 372 TEST_F(ServiceWorkerDispatcherHostTest, Unregister_InvalidScopeShouldFail) { |
374 const int64 kProviderId = 99; // Dummy value | 373 const int64 kProviderId = 99; // Dummy value |
375 scoped_ptr<ServiceWorkerProviderHost> host( | 374 scoped_ptr<ServiceWorkerProviderHost> host( |
376 CreateServiceWorkerProviderHost(kProviderId)); | 375 CreateServiceWorkerProviderHost(kProviderId)); |
377 host->SetDocumentUrl(GURL("https://www.example.com/foo")); | 376 host->SetDocumentUrl(GURL("https://www.example.com/foo")); |
378 context()->AddProviderHost(host.Pass()); | 377 context()->AddProviderHost(host.Pass()); |
379 | 378 |
380 SendUnregister(kProviderId, GURL("")); | 379 SendUnregister(kProviderId, GURL("")); |
381 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); | 380 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); |
382 } | 381 } |
383 | 382 |
384 TEST_F(ServiceWorkerDispatcherHostTest, Unregister_NonSecureOriginShouldFail) { | 383 TEST_F(ServiceWorkerDispatcherHostTest, Unregister_NonSecureOriginShouldFail) { |
385 const int64 kProviderId = 99; // Dummy value | 384 const int64 kProviderId = 99; // Dummy value |
386 scoped_ptr<ServiceWorkerProviderHost> host( | 385 scoped_ptr<ServiceWorkerProviderHost> host( |
387 CreateServiceWorkerProviderHost(kProviderId)); | 386 CreateServiceWorkerProviderHost(kProviderId)); |
388 host->SetDocumentUrl(GURL("http://www.example.com/foo")); | 387 host->SetDocumentUrl(GURL("http://www.example.com/foo")); |
389 context()->AddProviderHost(host.Pass()); | 388 context()->AddProviderHost(host.Pass()); |
390 | 389 |
391 Unregister(kProviderId, | 390 SendUnregister(kProviderId, GURL("http://www.example.com/")); |
392 GURL("http://www.example.com/"), | 391 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); |
393 ServiceWorkerMsg_ServiceWorkerUnregistrationError::ID); | |
394 } | 392 } |
395 | 393 |
396 TEST_F(ServiceWorkerDispatcherHostTest, EarlyContextDeletion) { | 394 TEST_F(ServiceWorkerDispatcherHostTest, EarlyContextDeletion) { |
397 helper_->ShutdownContext(); | 395 helper_->ShutdownContext(); |
398 | 396 |
399 // Let the shutdown reach the simulated IO thread. | 397 // Let the shutdown reach the simulated IO thread. |
400 base::RunLoop().RunUntilIdle(); | 398 base::RunLoop().RunUntilIdle(); |
401 | 399 |
402 Register(-1, | 400 Register(-1, |
403 GURL(), | 401 GURL(), |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 ServiceWorkerMsg_DidGetRegistration::ID); | 446 ServiceWorkerMsg_DidGetRegistration::ID); |
449 } | 447 } |
450 | 448 |
451 TEST_F(ServiceWorkerDispatcherHostTest, GetRegistration_CrossOriginShouldFail) { | 449 TEST_F(ServiceWorkerDispatcherHostTest, GetRegistration_CrossOriginShouldFail) { |
452 const int64 kProviderId = 99; // Dummy value | 450 const int64 kProviderId = 99; // Dummy value |
453 scoped_ptr<ServiceWorkerProviderHost> host( | 451 scoped_ptr<ServiceWorkerProviderHost> host( |
454 CreateServiceWorkerProviderHost(kProviderId)); | 452 CreateServiceWorkerProviderHost(kProviderId)); |
455 host->SetDocumentUrl(GURL("https://www.example.com/foo")); | 453 host->SetDocumentUrl(GURL("https://www.example.com/foo")); |
456 context()->AddProviderHost(host.Pass()); | 454 context()->AddProviderHost(host.Pass()); |
457 | 455 |
458 GetRegistration(kProviderId, | 456 SendGetRegistration(kProviderId, GURL("https://foo.example.com/")); |
459 GURL("https://foo.example.com/"), | 457 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); |
460 ServiceWorkerMsg_ServiceWorkerGetRegistrationError::ID); | |
461 } | 458 } |
462 | 459 |
463 TEST_F(ServiceWorkerDispatcherHostTest, | 460 TEST_F(ServiceWorkerDispatcherHostTest, |
464 GetRegistration_InvalidScopeShouldFail) { | 461 GetRegistration_InvalidScopeShouldFail) { |
465 const int64 kProviderId = 99; // Dummy value | 462 const int64 kProviderId = 99; // Dummy value |
466 scoped_ptr<ServiceWorkerProviderHost> host( | 463 scoped_ptr<ServiceWorkerProviderHost> host( |
467 CreateServiceWorkerProviderHost(kProviderId)); | 464 CreateServiceWorkerProviderHost(kProviderId)); |
468 host->SetDocumentUrl(GURL("https://www.example.com/foo")); | 465 host->SetDocumentUrl(GURL("https://www.example.com/foo")); |
469 context()->AddProviderHost(host.Pass()); | 466 context()->AddProviderHost(host.Pass()); |
470 | 467 |
471 SendGetRegistration(kProviderId, GURL("")); | 468 SendGetRegistration(kProviderId, GURL("")); |
472 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); | 469 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); |
473 } | 470 } |
474 | 471 |
475 TEST_F(ServiceWorkerDispatcherHostTest, | 472 TEST_F(ServiceWorkerDispatcherHostTest, |
476 GetRegistration_NotSecureOriginShouldFail) { | 473 GetRegistration_NonSecureOriginShouldFail) { |
477 const int64 kProviderId = 99; // Dummy value | 474 const int64 kProviderId = 99; // Dummy value |
478 scoped_ptr<ServiceWorkerProviderHost> host( | 475 scoped_ptr<ServiceWorkerProviderHost> host( |
479 CreateServiceWorkerProviderHost(kProviderId)); | 476 CreateServiceWorkerProviderHost(kProviderId)); |
480 host->SetDocumentUrl(GURL("http://www.example.com/foo")); | 477 host->SetDocumentUrl(GURL("http://www.example.com/foo")); |
481 context()->AddProviderHost(host.Pass()); | 478 context()->AddProviderHost(host.Pass()); |
482 | 479 |
483 GetRegistration(kProviderId, | 480 SendGetRegistration(kProviderId, GURL("http://www.example.com/")); |
484 GURL("http://www.example.com/"), | 481 EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_); |
485 ServiceWorkerMsg_ServiceWorkerGetRegistrationError::ID); | |
486 } | 482 } |
487 | 483 |
488 TEST_F(ServiceWorkerDispatcherHostTest, GetRegistration_EarlyContextDeletion) { | 484 TEST_F(ServiceWorkerDispatcherHostTest, GetRegistration_EarlyContextDeletion) { |
489 helper_->ShutdownContext(); | 485 helper_->ShutdownContext(); |
490 | 486 |
491 // Let the shutdown reach the simulated IO thread. | 487 // Let the shutdown reach the simulated IO thread. |
492 base::RunLoop().RunUntilIdle(); | 488 base::RunLoop().RunUntilIdle(); |
493 | 489 |
494 GetRegistration(-1, | 490 GetRegistration(-1, |
495 GURL(), | 491 GURL(), |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 | 540 |
545 // To show the new dispatcher can operate, simulate provider creation. Since | 541 // To show the new dispatcher can operate, simulate provider creation. Since |
546 // the old dispatcher cleaned up the old provider host, the new one won't | 542 // the old dispatcher cleaned up the old provider host, the new one won't |
547 // complain. | 543 // complain. |
548 new_dispatcher_host->OnMessageReceived( | 544 new_dispatcher_host->OnMessageReceived( |
549 ServiceWorkerHostMsg_ProviderCreated(kProviderId, MSG_ROUTING_NONE)); | 545 ServiceWorkerHostMsg_ProviderCreated(kProviderId, MSG_ROUTING_NONE)); |
550 EXPECT_EQ(0, new_dispatcher_host->bad_messages_received_count_); | 546 EXPECT_EQ(0, new_dispatcher_host->bad_messages_received_count_); |
551 } | 547 } |
552 | 548 |
553 } // namespace content | 549 } // namespace content |
OLD | NEW |