| 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 "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 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 | 518 |
| 519 ASSERT_EQ(2u, notifications_.size()); | 519 ASSERT_EQ(2u, notifications_.size()); |
| 520 EXPECT_EQ(REGISTRATION_STORED, notifications_[0].type); | 520 EXPECT_EQ(REGISTRATION_STORED, notifications_[0].type); |
| 521 EXPECT_EQ(pattern, notifications_[0].pattern); | 521 EXPECT_EQ(pattern, notifications_[0].pattern); |
| 522 EXPECT_EQ(old_registration_id, notifications_[0].registration_id); | 522 EXPECT_EQ(old_registration_id, notifications_[0].registration_id); |
| 523 EXPECT_EQ(REGISTRATION_STORED, notifications_[1].type); | 523 EXPECT_EQ(REGISTRATION_STORED, notifications_[1].type); |
| 524 EXPECT_EQ(pattern, notifications_[1].pattern); | 524 EXPECT_EQ(pattern, notifications_[1].pattern); |
| 525 EXPECT_EQ(old_registration_id, notifications_[1].registration_id); | 525 EXPECT_EQ(old_registration_id, notifications_[1].registration_id); |
| 526 } | 526 } |
| 527 | 527 |
| 528 TEST_F(ServiceWorkerContextTest, HasWindowProviderHost) { | |
| 529 const int kRenderProcessId = 1; | |
| 530 const GURL kOrigin = GURL("http://www.example.com/"); | |
| 531 const GURL kOriginOther = GURL("https://www.example.com/"); | |
| 532 int provider_id = 1; | |
| 533 | |
| 534 ServiceWorkerProviderHost* host_window(new ServiceWorkerProviderHost( | |
| 535 kRenderProcessId, MSG_ROUTING_NONE, provider_id++, | |
| 536 SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(), nullptr)); | |
| 537 host_window->SetDocumentUrl(kOrigin); | |
| 538 | |
| 539 // Host2 (provider_id=2): process_id=2, origin2. | |
| 540 ServiceWorkerProviderHost* host_worker(new ServiceWorkerProviderHost( | |
| 541 kRenderProcessId, MSG_ROUTING_NONE, provider_id++, | |
| 542 SERVICE_WORKER_PROVIDER_FOR_WORKER, context()->AsWeakPtr(), nullptr)); | |
| 543 host_worker->SetDocumentUrl(kOrigin); | |
| 544 | |
| 545 EXPECT_FALSE(context()->HasWindowProviderHost(kOrigin)); | |
| 546 context()->AddProviderHost(make_scoped_ptr(host_worker)); | |
| 547 EXPECT_FALSE(context()->HasWindowProviderHost(kOrigin)); | |
| 548 context()->AddProviderHost(make_scoped_ptr(host_window)); | |
| 549 EXPECT_TRUE(context()->HasWindowProviderHost(kOrigin)); | |
| 550 EXPECT_FALSE(context()->HasWindowProviderHost(kOriginOther)); | |
| 551 } | |
| 552 | |
| 553 TEST_F(ServiceWorkerContextTest, ProviderHostIterator) { | 528 TEST_F(ServiceWorkerContextTest, ProviderHostIterator) { |
| 554 const int kRenderProcessId1 = 1; | 529 const int kRenderProcessId1 = 1; |
| 555 const int kRenderProcessId2 = 2; | 530 const int kRenderProcessId2 = 2; |
| 556 const GURL kOrigin1 = GURL("http://www.example.com/"); | 531 const GURL kOrigin1 = GURL("http://www.example.com/"); |
| 557 const GURL kOrigin2 = GURL("https://www.example.com/"); | 532 const GURL kOrigin2 = GURL("https://www.example.com/"); |
| 558 int provider_id = 1; | 533 int provider_id = 1; |
| 559 | 534 |
| 560 // Host1 (provider_id=1): process_id=1, origin1. | 535 // Host1 (provider_id=1): process_id=1, origin1. |
| 561 ServiceWorkerProviderHost* host1(new ServiceWorkerProviderHost( | 536 ServiceWorkerProviderHost* host1(new ServiceWorkerProviderHost( |
| 562 kRenderProcessId1, MSG_ROUTING_NONE, provider_id++, | 537 kRenderProcessId1, MSG_ROUTING_NONE, provider_id++, |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 EXPECT_EQ(pattern, notifications_[0].pattern); | 700 EXPECT_EQ(pattern, notifications_[0].pattern); |
| 726 EXPECT_EQ(registration_id, notifications_[0].registration_id); | 701 EXPECT_EQ(registration_id, notifications_[0].registration_id); |
| 727 EXPECT_EQ(STORAGE_RECOVERED, notifications_[1].type); | 702 EXPECT_EQ(STORAGE_RECOVERED, notifications_[1].type); |
| 728 EXPECT_EQ(REGISTRATION_STORED, notifications_[2].type); | 703 EXPECT_EQ(REGISTRATION_STORED, notifications_[2].type); |
| 729 EXPECT_EQ(pattern, notifications_[2].pattern); | 704 EXPECT_EQ(pattern, notifications_[2].pattern); |
| 730 EXPECT_EQ(registration_id, notifications_[2].registration_id); | 705 EXPECT_EQ(registration_id, notifications_[2].registration_id); |
| 731 } | 706 } |
| 732 | 707 |
| 733 | 708 |
| 734 } // namespace content | 709 } // namespace content |
| OLD | NEW |