| 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_storage.h" | 5 #include "content/browser/service_worker/service_worker_storage.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 | 582 |
| 583 // Next available ids should be invalid. | 583 // Next available ids should be invalid. |
| 584 EXPECT_EQ(kInvalidServiceWorkerRegistrationId, | 584 EXPECT_EQ(kInvalidServiceWorkerRegistrationId, |
| 585 storage()->NewRegistrationId()); | 585 storage()->NewRegistrationId()); |
| 586 EXPECT_EQ(kInvalidServiceWorkerVersionId, storage()->NewVersionId()); | 586 EXPECT_EQ(kInvalidServiceWorkerVersionId, storage()->NewVersionId()); |
| 587 EXPECT_EQ(kInvalidServiceWorkerResourceId, storage()->NewRegistrationId()); | 587 EXPECT_EQ(kInvalidServiceWorkerResourceId, storage()->NewRegistrationId()); |
| 588 } | 588 } |
| 589 | 589 |
| 590 TEST_F(ServiceWorkerStorageTest, StoreFindUpdateDeleteRegistration) { | 590 TEST_F(ServiceWorkerStorageTest, StoreFindUpdateDeleteRegistration) { |
| 591 const GURL kScope("http://www.test.not/scope/"); | 591 const GURL kScope("http://www.test.not/scope/"); |
| 592 const GURL kScript("http://www.test.not/script.js"); | |
| 593 const GURL kDocumentUrl("http://www.test.not/scope/document.html"); | 592 const GURL kDocumentUrl("http://www.test.not/scope/document.html"); |
| 594 const GURL kResource1("http://www.test.not/scope/resource1.js"); | 593 const GURL kResource1("http://www.test.not/scope/resource1.js"); |
| 595 const int64_t kResource1Size = 1591234; | 594 const int64_t kResource1Size = 1591234; |
| 596 const GURL kResource2("http://www.test.not/scope/resource2.js"); | 595 const GURL kResource2("http://www.test.not/scope/resource2.js"); |
| 597 const int64_t kResource2Size = 51; | 596 const int64_t kResource2Size = 51; |
| 598 const int64_t kRegistrationId = 0; | 597 const int64_t kRegistrationId = 0; |
| 599 const int64_t kVersionId = 0; | 598 const int64_t kVersionId = 0; |
| 600 const GURL kForeignFetchScope("http://www.test.not/scope/ff/"); | 599 const GURL kForeignFetchScope("http://www.test.not/scope/ff/"); |
| 601 const url::Origin kForeignFetchOrigin(GURL("https://example.com/")); | 600 const url::Origin kForeignFetchOrigin(GURL("https://example.com/")); |
| 602 const base::Time kToday = base::Time::Now(); | 601 const base::Time kToday = base::Time::Now(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 622 resources.push_back( | 621 resources.push_back( |
| 623 ServiceWorkerDatabase::ResourceRecord(1, kResource1, kResource1Size)); | 622 ServiceWorkerDatabase::ResourceRecord(1, kResource1, kResource1Size)); |
| 624 resources.push_back( | 623 resources.push_back( |
| 625 ServiceWorkerDatabase::ResourceRecord(2, kResource2, kResource2Size)); | 624 ServiceWorkerDatabase::ResourceRecord(2, kResource2, kResource2Size)); |
| 626 | 625 |
| 627 // Store something. | 626 // Store something. |
| 628 scoped_refptr<ServiceWorkerRegistration> live_registration = | 627 scoped_refptr<ServiceWorkerRegistration> live_registration = |
| 629 new ServiceWorkerRegistration(kScope, kRegistrationId, | 628 new ServiceWorkerRegistration(kScope, kRegistrationId, |
| 630 context()->AsWeakPtr()); | 629 context()->AsWeakPtr()); |
| 631 scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion( | 630 scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion( |
| 632 live_registration.get(), kScript, kVersionId, context()->AsWeakPtr()); | 631 live_registration.get(), kResource1, kVersionId, context()->AsWeakPtr()); |
| 633 live_version->set_fetch_handler_existence( | 632 live_version->set_fetch_handler_existence( |
| 634 ServiceWorkerVersion::FetchHandlerExistence::EXISTS); | 633 ServiceWorkerVersion::FetchHandlerExistence::EXISTS); |
| 635 live_version->SetStatus(ServiceWorkerVersion::INSTALLED); | 634 live_version->SetStatus(ServiceWorkerVersion::INSTALLED); |
| 636 live_version->script_cache_map()->SetResources(resources); | 635 live_version->script_cache_map()->SetResources(resources); |
| 637 live_version->set_foreign_fetch_scopes( | 636 live_version->set_foreign_fetch_scopes( |
| 638 std::vector<GURL>(1, kForeignFetchScope)); | 637 std::vector<GURL>(1, kForeignFetchScope)); |
| 639 live_version->set_foreign_fetch_origins( | 638 live_version->set_foreign_fetch_origins( |
| 640 std::vector<url::Origin>(1, kForeignFetchOrigin)); | 639 std::vector<url::Origin>(1, kForeignFetchOrigin)); |
| 641 live_registration->SetWaitingVersion(live_version); | 640 live_registration->SetWaitingVersion(live_version); |
| 642 live_registration->set_last_update_check(kYesterday); | 641 live_registration->set_last_update_check(kYesterday); |
| (...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1757 // Remove other registration at first origin. | 1756 // Remove other registration at first origin. |
| 1758 EXPECT_EQ(SERVICE_WORKER_OK, | 1757 EXPECT_EQ(SERVICE_WORKER_OK, |
| 1759 DeleteRegistration(kRegistrationId2, kScope2.GetOrigin())); | 1758 DeleteRegistration(kRegistrationId2, kScope2.GetOrigin())); |
| 1760 | 1759 |
| 1761 // No foreign fetch registrations remain. | 1760 // No foreign fetch registrations remain. |
| 1762 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin1)); | 1761 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin1)); |
| 1763 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin2)); | 1762 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin2)); |
| 1764 } | 1763 } |
| 1765 | 1764 |
| 1766 } // namespace content | 1765 } // namespace content |
| OLD | NEW |