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/public/browser/service_worker_context.h" | 5 #include "content/public/browser/service_worker_context.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 EXPECT_TRUE(registration->waiting_version()); | 72 EXPECT_TRUE(registration->waiting_version()); |
73 } else { | 73 } else { |
74 EXPECT_FALSE(registration->waiting_version()); | 74 EXPECT_FALSE(registration->waiting_version()); |
75 } | 75 } |
76 | 76 |
77 if (expect_active) { | 77 if (expect_active) { |
78 EXPECT_TRUE(registration->active_version()); | 78 EXPECT_TRUE(registration->active_version()); |
79 } else { | 79 } else { |
80 EXPECT_FALSE(registration->active_version()); | 80 EXPECT_FALSE(registration->active_version()); |
81 } | 81 } |
| 82 |
| 83 EXPECT_FALSE(registration->use_cache()); |
82 } | 84 } |
83 | 85 |
84 class RejectInstallTestHelper : public EmbeddedWorkerTestHelper { | 86 class RejectInstallTestHelper : public EmbeddedWorkerTestHelper { |
85 public: | 87 public: |
86 RejectInstallTestHelper() : EmbeddedWorkerTestHelper(base::FilePath()) {} | 88 RejectInstallTestHelper() : EmbeddedWorkerTestHelper(base::FilePath()) {} |
87 | 89 |
88 void OnInstallEvent(int embedded_worker_id, | 90 void OnInstallEvent(int embedded_worker_id, |
89 int request_id) override { | 91 int request_id) override { |
90 SimulateSend(new ServiceWorkerHostMsg_InstallEventFinished( | 92 SimulateSend(new ServiceWorkerHostMsg_InstallEventFinished( |
91 embedded_worker_id, request_id, | 93 embedded_worker_id, request_id, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 GURL pattern("http://www.example.com/"); | 203 GURL pattern("http://www.example.com/"); |
202 GURL script_url("http://www.example.com/service_worker.js"); | 204 GURL script_url("http://www.example.com/service_worker.js"); |
203 | 205 |
204 RecordableEmbeddedWorkerInstanceClient* client = nullptr; | 206 RecordableEmbeddedWorkerInstanceClient* client = nullptr; |
205 client = helper_->CreateAndRegisterMockInstanceClient< | 207 client = helper_->CreateAndRegisterMockInstanceClient< |
206 RecordableEmbeddedWorkerInstanceClient>(helper_->AsWeakPtr()); | 208 RecordableEmbeddedWorkerInstanceClient>(helper_->AsWeakPtr()); |
207 | 209 |
208 int64_t registration_id = kInvalidServiceWorkerRegistrationId; | 210 int64_t registration_id = kInvalidServiceWorkerRegistrationId; |
209 bool called = false; | 211 bool called = false; |
210 context()->RegisterServiceWorker( | 212 context()->RegisterServiceWorker( |
211 pattern, | 213 script_url, ServiceWorkerRegistrationOptions(pattern), NULL, |
212 script_url, | |
213 NULL, | |
214 MakeRegisteredCallback(&called, ®istration_id)); | 214 MakeRegisteredCallback(&called, ®istration_id)); |
215 | 215 |
216 ASSERT_FALSE(called); | 216 ASSERT_FALSE(called); |
217 base::RunLoop().RunUntilIdle(); | 217 base::RunLoop().RunUntilIdle(); |
218 EXPECT_TRUE(called); | 218 EXPECT_TRUE(called); |
219 | 219 |
220 EXPECT_EQ(1UL, helper_->ipc_sink()->message_count()); | 220 EXPECT_EQ(1UL, helper_->ipc_sink()->message_count()); |
221 ASSERT_EQ(1UL, helper_->dispatched_events()->size()); | 221 ASSERT_EQ(1UL, helper_->dispatched_events()->size()); |
222 ASSERT_EQ(2UL, client->events().size()); | 222 ASSERT_EQ(2UL, client->events().size()); |
223 EXPECT_EQ(RecordableEmbeddedWorkerInstanceClient::Message::StartWorker, | 223 EXPECT_EQ(RecordableEmbeddedWorkerInstanceClient::Message::StartWorker, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 helper_.reset(new RejectInstallTestHelper); | 257 helper_.reset(new RejectInstallTestHelper); |
258 helper_->context_wrapper()->AddObserver(this); | 258 helper_->context_wrapper()->AddObserver(this); |
259 | 259 |
260 RecordableEmbeddedWorkerInstanceClient* client = nullptr; | 260 RecordableEmbeddedWorkerInstanceClient* client = nullptr; |
261 client = helper_->CreateAndRegisterMockInstanceClient< | 261 client = helper_->CreateAndRegisterMockInstanceClient< |
262 RecordableEmbeddedWorkerInstanceClient>(helper_->AsWeakPtr()); | 262 RecordableEmbeddedWorkerInstanceClient>(helper_->AsWeakPtr()); |
263 | 263 |
264 int64_t registration_id = kInvalidServiceWorkerRegistrationId; | 264 int64_t registration_id = kInvalidServiceWorkerRegistrationId; |
265 bool called = false; | 265 bool called = false; |
266 context()->RegisterServiceWorker( | 266 context()->RegisterServiceWorker( |
267 pattern, | 267 script_url, ServiceWorkerRegistrationOptions(pattern), NULL, |
268 script_url, | |
269 NULL, | |
270 MakeRegisteredCallback(&called, ®istration_id)); | 268 MakeRegisteredCallback(&called, ®istration_id)); |
271 | 269 |
272 ASSERT_FALSE(called); | 270 ASSERT_FALSE(called); |
273 base::RunLoop().RunUntilIdle(); | 271 base::RunLoop().RunUntilIdle(); |
274 EXPECT_TRUE(called); | 272 EXPECT_TRUE(called); |
275 | 273 |
276 EXPECT_EQ(1UL, helper_->ipc_sink()->message_count()); | 274 EXPECT_EQ(1UL, helper_->ipc_sink()->message_count()); |
277 EXPECT_EQ(0UL, helper_->dispatched_events()->size()); | 275 EXPECT_EQ(0UL, helper_->dispatched_events()->size()); |
278 ASSERT_EQ(2UL, client->events().size()); | 276 ASSERT_EQ(2UL, client->events().size()); |
279 EXPECT_EQ(RecordableEmbeddedWorkerInstanceClient::Message::StartWorker, | 277 EXPECT_EQ(RecordableEmbeddedWorkerInstanceClient::Message::StartWorker, |
(...skipping 30 matching lines...) Expand all Loading... |
310 helper_.reset(new RejectActivateTestHelper); | 308 helper_.reset(new RejectActivateTestHelper); |
311 helper_->context_wrapper()->AddObserver(this); | 309 helper_->context_wrapper()->AddObserver(this); |
312 | 310 |
313 RecordableEmbeddedWorkerInstanceClient* client = nullptr; | 311 RecordableEmbeddedWorkerInstanceClient* client = nullptr; |
314 client = helper_->CreateAndRegisterMockInstanceClient< | 312 client = helper_->CreateAndRegisterMockInstanceClient< |
315 RecordableEmbeddedWorkerInstanceClient>(helper_->AsWeakPtr()); | 313 RecordableEmbeddedWorkerInstanceClient>(helper_->AsWeakPtr()); |
316 | 314 |
317 int64_t registration_id = kInvalidServiceWorkerRegistrationId; | 315 int64_t registration_id = kInvalidServiceWorkerRegistrationId; |
318 bool called = false; | 316 bool called = false; |
319 context()->RegisterServiceWorker( | 317 context()->RegisterServiceWorker( |
320 pattern, script_url, NULL, | 318 script_url, ServiceWorkerRegistrationOptions(pattern), NULL, |
321 MakeRegisteredCallback(&called, ®istration_id)); | 319 MakeRegisteredCallback(&called, ®istration_id)); |
322 | 320 |
323 ASSERT_FALSE(called); | 321 ASSERT_FALSE(called); |
324 base::RunLoop().RunUntilIdle(); | 322 base::RunLoop().RunUntilIdle(); |
325 EXPECT_TRUE(called); | 323 EXPECT_TRUE(called); |
326 | 324 |
327 EXPECT_EQ(1UL, helper_->ipc_sink()->message_count()); | 325 EXPECT_EQ(1UL, helper_->ipc_sink()->message_count()); |
328 ASSERT_EQ(1UL, helper_->dispatched_events()->size()); | 326 ASSERT_EQ(1UL, helper_->dispatched_events()->size()); |
329 ASSERT_EQ(2UL, client->events().size()); | 327 ASSERT_EQ(2UL, client->events().size()); |
330 EXPECT_EQ(RecordableEmbeddedWorkerInstanceClient::Message::StartWorker, | 328 EXPECT_EQ(RecordableEmbeddedWorkerInstanceClient::Message::StartWorker, |
(...skipping 19 matching lines...) Expand all Loading... |
350 base::RunLoop().RunUntilIdle(); | 348 base::RunLoop().RunUntilIdle(); |
351 } | 349 } |
352 | 350 |
353 // Make sure registrations are cleaned up when they are unregistered. | 351 // Make sure registrations are cleaned up when they are unregistered. |
354 TEST_F(ServiceWorkerContextTest, Unregister) { | 352 TEST_F(ServiceWorkerContextTest, Unregister) { |
355 GURL pattern("http://www.example.com/"); | 353 GURL pattern("http://www.example.com/"); |
356 | 354 |
357 bool called = false; | 355 bool called = false; |
358 int64_t registration_id = kInvalidServiceWorkerRegistrationId; | 356 int64_t registration_id = kInvalidServiceWorkerRegistrationId; |
359 context()->RegisterServiceWorker( | 357 context()->RegisterServiceWorker( |
360 pattern, | |
361 GURL("http://www.example.com/service_worker.js"), | 358 GURL("http://www.example.com/service_worker.js"), |
362 NULL, | 359 ServiceWorkerRegistrationOptions(pattern), NULL, |
363 MakeRegisteredCallback(&called, ®istration_id)); | 360 MakeRegisteredCallback(&called, ®istration_id)); |
364 | 361 |
365 ASSERT_FALSE(called); | 362 ASSERT_FALSE(called); |
366 base::RunLoop().RunUntilIdle(); | 363 base::RunLoop().RunUntilIdle(); |
367 ASSERT_TRUE(called); | 364 ASSERT_TRUE(called); |
368 EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id); | 365 EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id); |
369 | 366 |
370 called = false; | 367 called = false; |
371 context()->UnregisterServiceWorker(pattern, | 368 context()->UnregisterServiceWorker(pattern, |
372 MakeUnregisteredCallback(&called)); | 369 MakeUnregisteredCallback(&called)); |
(...skipping 26 matching lines...) Expand all Loading... |
399 GURL origin1_p2("http://www.example.com/hello"); | 396 GURL origin1_p2("http://www.example.com/hello"); |
400 GURL origin2_p1("http://www.example.com:8080/again"); | 397 GURL origin2_p1("http://www.example.com:8080/again"); |
401 GURL origin3_p1("http://www.other.com/"); | 398 GURL origin3_p1("http://www.other.com/"); |
402 | 399 |
403 bool called = false; | 400 bool called = false; |
404 int64_t registration_id1 = kInvalidServiceWorkerRegistrationId; | 401 int64_t registration_id1 = kInvalidServiceWorkerRegistrationId; |
405 int64_t registration_id2 = kInvalidServiceWorkerRegistrationId; | 402 int64_t registration_id2 = kInvalidServiceWorkerRegistrationId; |
406 int64_t registration_id3 = kInvalidServiceWorkerRegistrationId; | 403 int64_t registration_id3 = kInvalidServiceWorkerRegistrationId; |
407 int64_t registration_id4 = kInvalidServiceWorkerRegistrationId; | 404 int64_t registration_id4 = kInvalidServiceWorkerRegistrationId; |
408 context()->RegisterServiceWorker( | 405 context()->RegisterServiceWorker( |
409 origin1_p1, | |
410 GURL("http://www.example.com/service_worker.js"), | 406 GURL("http://www.example.com/service_worker.js"), |
411 NULL, | 407 ServiceWorkerRegistrationOptions(origin1_p1), NULL, |
412 MakeRegisteredCallback(&called, ®istration_id1)); | 408 MakeRegisteredCallback(&called, ®istration_id1)); |
413 context()->RegisterServiceWorker( | 409 context()->RegisterServiceWorker( |
414 origin1_p2, | |
415 GURL("http://www.example.com/service_worker2.js"), | 410 GURL("http://www.example.com/service_worker2.js"), |
416 NULL, | 411 ServiceWorkerRegistrationOptions(origin1_p2), NULL, |
417 MakeRegisteredCallback(&called, ®istration_id2)); | 412 MakeRegisteredCallback(&called, ®istration_id2)); |
418 context()->RegisterServiceWorker( | 413 context()->RegisterServiceWorker( |
419 origin2_p1, | |
420 GURL("http://www.example.com:8080/service_worker3.js"), | 414 GURL("http://www.example.com:8080/service_worker3.js"), |
421 NULL, | 415 ServiceWorkerRegistrationOptions(origin2_p1), NULL, |
422 MakeRegisteredCallback(&called, ®istration_id3)); | 416 MakeRegisteredCallback(&called, ®istration_id3)); |
423 context()->RegisterServiceWorker( | 417 context()->RegisterServiceWorker( |
424 origin3_p1, | |
425 GURL("http://www.other.com/service_worker4.js"), | 418 GURL("http://www.other.com/service_worker4.js"), |
426 NULL, | 419 ServiceWorkerRegistrationOptions(origin3_p1), NULL, |
427 MakeRegisteredCallback(&called, ®istration_id4)); | 420 MakeRegisteredCallback(&called, ®istration_id4)); |
428 | 421 |
429 ASSERT_FALSE(called); | 422 ASSERT_FALSE(called); |
430 base::RunLoop().RunUntilIdle(); | 423 base::RunLoop().RunUntilIdle(); |
431 ASSERT_TRUE(called); | 424 ASSERT_TRUE(called); |
432 | 425 |
433 EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id1); | 426 EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id1); |
434 EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id2); | 427 EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id2); |
435 EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id3); | 428 EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id3); |
436 EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id4); | 429 EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id4); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 EXPECT_EQ(registration_id1, notifications_[5].registration_id); | 489 EXPECT_EQ(registration_id1, notifications_[5].registration_id); |
497 } | 490 } |
498 | 491 |
499 // Make sure registering a new script shares an existing registration. | 492 // Make sure registering a new script shares an existing registration. |
500 TEST_F(ServiceWorkerContextTest, RegisterNewScript) { | 493 TEST_F(ServiceWorkerContextTest, RegisterNewScript) { |
501 GURL pattern("http://www.example.com/"); | 494 GURL pattern("http://www.example.com/"); |
502 | 495 |
503 bool called = false; | 496 bool called = false; |
504 int64_t old_registration_id = kInvalidServiceWorkerRegistrationId; | 497 int64_t old_registration_id = kInvalidServiceWorkerRegistrationId; |
505 context()->RegisterServiceWorker( | 498 context()->RegisterServiceWorker( |
506 pattern, | |
507 GURL("http://www.example.com/service_worker.js"), | 499 GURL("http://www.example.com/service_worker.js"), |
508 NULL, | 500 ServiceWorkerRegistrationOptions(pattern), NULL, |
509 MakeRegisteredCallback(&called, &old_registration_id)); | 501 MakeRegisteredCallback(&called, &old_registration_id)); |
510 | 502 |
511 ASSERT_FALSE(called); | 503 ASSERT_FALSE(called); |
512 base::RunLoop().RunUntilIdle(); | 504 base::RunLoop().RunUntilIdle(); |
513 ASSERT_TRUE(called); | 505 ASSERT_TRUE(called); |
514 EXPECT_NE(kInvalidServiceWorkerRegistrationId, old_registration_id); | 506 EXPECT_NE(kInvalidServiceWorkerRegistrationId, old_registration_id); |
515 | 507 |
516 called = false; | 508 called = false; |
517 int64_t new_registration_id = kInvalidServiceWorkerRegistrationId; | 509 int64_t new_registration_id = kInvalidServiceWorkerRegistrationId; |
518 context()->RegisterServiceWorker( | 510 context()->RegisterServiceWorker( |
519 pattern, | |
520 GURL("http://www.example.com/service_worker_new.js"), | 511 GURL("http://www.example.com/service_worker_new.js"), |
521 NULL, | 512 ServiceWorkerRegistrationOptions(pattern), NULL, |
522 MakeRegisteredCallback(&called, &new_registration_id)); | 513 MakeRegisteredCallback(&called, &new_registration_id)); |
523 | 514 |
524 ASSERT_FALSE(called); | 515 ASSERT_FALSE(called); |
525 base::RunLoop().RunUntilIdle(); | 516 base::RunLoop().RunUntilIdle(); |
526 ASSERT_TRUE(called); | 517 ASSERT_TRUE(called); |
527 | 518 |
528 EXPECT_NE(kInvalidServiceWorkerRegistrationId, new_registration_id); | 519 EXPECT_NE(kInvalidServiceWorkerRegistrationId, new_registration_id); |
529 EXPECT_EQ(old_registration_id, new_registration_id); | 520 EXPECT_EQ(old_registration_id, new_registration_id); |
530 | 521 |
531 ASSERT_EQ(2u, notifications_.size()); | 522 ASSERT_EQ(2u, notifications_.size()); |
532 EXPECT_EQ(REGISTRATION_STORED, notifications_[0].type); | 523 EXPECT_EQ(REGISTRATION_STORED, notifications_[0].type); |
533 EXPECT_EQ(pattern, notifications_[0].pattern); | 524 EXPECT_EQ(pattern, notifications_[0].pattern); |
534 EXPECT_EQ(old_registration_id, notifications_[0].registration_id); | 525 EXPECT_EQ(old_registration_id, notifications_[0].registration_id); |
535 EXPECT_EQ(REGISTRATION_STORED, notifications_[1].type); | 526 EXPECT_EQ(REGISTRATION_STORED, notifications_[1].type); |
536 EXPECT_EQ(pattern, notifications_[1].pattern); | 527 EXPECT_EQ(pattern, notifications_[1].pattern); |
537 EXPECT_EQ(new_registration_id, notifications_[1].registration_id); | 528 EXPECT_EQ(new_registration_id, notifications_[1].registration_id); |
538 } | 529 } |
539 | 530 |
540 // Make sure that when registering a duplicate pattern+script_url | 531 // Make sure that when registering a duplicate pattern+script_url |
541 // combination, that the same registration is used. | 532 // combination, that the same registration is used. |
542 TEST_F(ServiceWorkerContextTest, RegisterDuplicateScript) { | 533 TEST_F(ServiceWorkerContextTest, RegisterDuplicateScript) { |
543 GURL pattern("http://www.example.com/"); | 534 GURL pattern("http://www.example.com/"); |
544 GURL script_url("http://www.example.com/service_worker.js"); | 535 GURL script_url("http://www.example.com/service_worker.js"); |
545 | 536 |
546 bool called = false; | 537 bool called = false; |
547 int64_t old_registration_id = kInvalidServiceWorkerRegistrationId; | 538 int64_t old_registration_id = kInvalidServiceWorkerRegistrationId; |
548 context()->RegisterServiceWorker( | 539 context()->RegisterServiceWorker( |
549 pattern, | 540 script_url, ServiceWorkerRegistrationOptions(pattern), NULL, |
550 script_url, | |
551 NULL, | |
552 MakeRegisteredCallback(&called, &old_registration_id)); | 541 MakeRegisteredCallback(&called, &old_registration_id)); |
553 | 542 |
554 ASSERT_FALSE(called); | 543 ASSERT_FALSE(called); |
555 base::RunLoop().RunUntilIdle(); | 544 base::RunLoop().RunUntilIdle(); |
556 ASSERT_TRUE(called); | 545 ASSERT_TRUE(called); |
557 EXPECT_NE(kInvalidServiceWorkerRegistrationId, old_registration_id); | 546 EXPECT_NE(kInvalidServiceWorkerRegistrationId, old_registration_id); |
558 | 547 |
559 called = false; | 548 called = false; |
560 int64_t new_registration_id = kInvalidServiceWorkerRegistrationId; | 549 int64_t new_registration_id = kInvalidServiceWorkerRegistrationId; |
561 context()->RegisterServiceWorker( | 550 context()->RegisterServiceWorker( |
562 pattern, | 551 script_url, ServiceWorkerRegistrationOptions(pattern), NULL, |
563 script_url, | |
564 NULL, | |
565 MakeRegisteredCallback(&called, &new_registration_id)); | 552 MakeRegisteredCallback(&called, &new_registration_id)); |
566 | 553 |
567 ASSERT_FALSE(called); | 554 ASSERT_FALSE(called); |
568 base::RunLoop().RunUntilIdle(); | 555 base::RunLoop().RunUntilIdle(); |
569 ASSERT_TRUE(called); | 556 ASSERT_TRUE(called); |
570 EXPECT_EQ(old_registration_id, new_registration_id); | 557 EXPECT_EQ(old_registration_id, new_registration_id); |
571 | 558 |
572 ASSERT_EQ(2u, notifications_.size()); | 559 ASSERT_EQ(2u, notifications_.size()); |
573 EXPECT_EQ(REGISTRATION_STORED, notifications_[0].type); | 560 EXPECT_EQ(REGISTRATION_STORED, notifications_[0].type); |
574 EXPECT_EQ(pattern, notifications_[0].pattern); | 561 EXPECT_EQ(pattern, notifications_[0].pattern); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 // Reinitialize the helper to test on-disk storage. | 666 // Reinitialize the helper to test on-disk storage. |
680 base::ScopedTempDir user_data_directory; | 667 base::ScopedTempDir user_data_directory; |
681 ASSERT_TRUE(user_data_directory.CreateUniqueTempDir()); | 668 ASSERT_TRUE(user_data_directory.CreateUniqueTempDir()); |
682 helper_.reset(new EmbeddedWorkerTestHelper(user_data_directory.GetPath())); | 669 helper_.reset(new EmbeddedWorkerTestHelper(user_data_directory.GetPath())); |
683 helper_->context_wrapper()->AddObserver(this); | 670 helper_->context_wrapper()->AddObserver(this); |
684 } | 671 } |
685 | 672 |
686 int64_t registration_id = kInvalidServiceWorkerRegistrationId; | 673 int64_t registration_id = kInvalidServiceWorkerRegistrationId; |
687 bool called = false; | 674 bool called = false; |
688 context()->RegisterServiceWorker( | 675 context()->RegisterServiceWorker( |
689 pattern, | 676 script_url, ServiceWorkerRegistrationOptions(pattern), NULL, |
690 script_url, | |
691 NULL, | |
692 MakeRegisteredCallback(&called, ®istration_id)); | 677 MakeRegisteredCallback(&called, ®istration_id)); |
693 | 678 |
694 ASSERT_FALSE(called); | 679 ASSERT_FALSE(called); |
695 base::RunLoop().RunUntilIdle(); | 680 base::RunLoop().RunUntilIdle(); |
696 EXPECT_TRUE(called); | 681 EXPECT_TRUE(called); |
697 | 682 |
698 context()->storage()->FindRegistrationForId( | 683 context()->storage()->FindRegistrationForId( |
699 registration_id, | 684 registration_id, |
700 pattern.GetOrigin(), | 685 pattern.GetOrigin(), |
701 base::Bind(&ExpectRegisteredWorkers, | 686 base::Bind(&ExpectRegisteredWorkers, |
(...skipping 22 matching lines...) Expand all Loading... |
724 registration_id, | 709 registration_id, |
725 pattern.GetOrigin(), | 710 pattern.GetOrigin(), |
726 base::Bind(&ExpectRegisteredWorkers, | 711 base::Bind(&ExpectRegisteredWorkers, |
727 SERVICE_WORKER_ERROR_NOT_FOUND, | 712 SERVICE_WORKER_ERROR_NOT_FOUND, |
728 false /* expect_waiting */, | 713 false /* expect_waiting */, |
729 true /* expect_active */)); | 714 true /* expect_active */)); |
730 base::RunLoop().RunUntilIdle(); | 715 base::RunLoop().RunUntilIdle(); |
731 | 716 |
732 called = false; | 717 called = false; |
733 context()->RegisterServiceWorker( | 718 context()->RegisterServiceWorker( |
734 pattern, | 719 script_url, ServiceWorkerRegistrationOptions(pattern), NULL, |
735 script_url, | |
736 NULL, | |
737 MakeRegisteredCallback(&called, ®istration_id)); | 720 MakeRegisteredCallback(&called, ®istration_id)); |
738 | 721 |
739 ASSERT_FALSE(called); | 722 ASSERT_FALSE(called); |
740 base::RunLoop().RunUntilIdle(); | 723 base::RunLoop().RunUntilIdle(); |
741 EXPECT_TRUE(called); | 724 EXPECT_TRUE(called); |
742 | 725 |
743 context()->storage()->FindRegistrationForId( | 726 context()->storage()->FindRegistrationForId( |
744 registration_id, | 727 registration_id, |
745 pattern.GetOrigin(), | 728 pattern.GetOrigin(), |
746 base::Bind(&ExpectRegisteredWorkers, | 729 base::Bind(&ExpectRegisteredWorkers, |
(...skipping 14 matching lines...) Expand all Loading... |
761 EXPECT_EQ(REGISTRATION_STORED, notifications_[2].type); | 744 EXPECT_EQ(REGISTRATION_STORED, notifications_[2].type); |
762 EXPECT_EQ(pattern, notifications_[2].pattern); | 745 EXPECT_EQ(pattern, notifications_[2].pattern); |
763 EXPECT_EQ(registration_id, notifications_[2].registration_id); | 746 EXPECT_EQ(registration_id, notifications_[2].registration_id); |
764 } | 747 } |
765 | 748 |
766 INSTANTIATE_TEST_CASE_P(ServiceWorkerContextRecoveryTest, | 749 INSTANTIATE_TEST_CASE_P(ServiceWorkerContextRecoveryTest, |
767 ServiceWorkerContextRecoveryTest, | 750 ServiceWorkerContextRecoveryTest, |
768 testing::Bool()); | 751 testing::Bool()); |
769 | 752 |
770 } // namespace content | 753 } // namespace content |
OLD | NEW |