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 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 | 1335 |
1336 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false)); | 1336 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false)); |
1337 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false)); | 1337 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false)); |
1338 } | 1338 } |
1339 | 1339 |
1340 TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) { | 1340 TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) { |
1341 // Promote the worker to active and add a controllee. | 1341 // Promote the worker to active and add a controllee. |
1342 registration_->SetActiveVersion(registration_->waiting_version()); | 1342 registration_->SetActiveVersion(registration_->waiting_version()); |
1343 storage()->UpdateToActiveState( | 1343 storage()->UpdateToActiveState( |
1344 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1344 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
1345 std::unique_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( | 1345 std::unique_ptr<ServiceWorkerProviderHost> host = |
1346 33 /* dummy render process id */, MSG_ROUTING_NONE, | 1346 ServiceWorkerProviderHost::CreateForTesting( |
1347 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, | 1347 33 /* dummy render process id */, 1 /* dummy provider_id */, |
1348 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE, | 1348 SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr()); |
1349 context()->AsWeakPtr(), NULL)); | 1349 host->set_parent_frame_secure(true); |
1350 registration_->active_version()->AddControllee(host.get()); | 1350 registration_->active_version()->AddControllee(host.get()); |
1351 | 1351 |
1352 bool was_called = false; | 1352 bool was_called = false; |
1353 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; | 1353 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; |
1354 std::set<int64_t> verify_ids; | 1354 std::set<int64_t> verify_ids; |
1355 | 1355 |
1356 // Deleting the registration should move the resources to the purgeable list | 1356 // Deleting the registration should move the resources to the purgeable list |
1357 // but keep them available. | 1357 // but keep them available. |
1358 storage()->DeleteRegistration( | 1358 storage()->DeleteRegistration( |
1359 registration_->id(), | 1359 registration_->id(), |
(...skipping 27 matching lines...) Expand all Loading... |
1387 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false)); | 1387 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false)); |
1388 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false)); | 1388 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false)); |
1389 } | 1389 } |
1390 | 1390 |
1391 TEST_F(ServiceWorkerResourceStorageDiskTest, CleanupOnRestart) { | 1391 TEST_F(ServiceWorkerResourceStorageDiskTest, CleanupOnRestart) { |
1392 // Promote the worker to active and add a controllee. | 1392 // Promote the worker to active and add a controllee. |
1393 registration_->SetActiveVersion(registration_->waiting_version()); | 1393 registration_->SetActiveVersion(registration_->waiting_version()); |
1394 registration_->SetWaitingVersion(NULL); | 1394 registration_->SetWaitingVersion(NULL); |
1395 storage()->UpdateToActiveState( | 1395 storage()->UpdateToActiveState( |
1396 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1396 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
1397 std::unique_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( | 1397 std::unique_ptr<ServiceWorkerProviderHost> host = |
1398 33 /* dummy render process id */, MSG_ROUTING_NONE, | 1398 ServiceWorkerProviderHost::CreateForTesting( |
1399 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, | 1399 33 /* dummy render process id */, 1 /* dummy provider_id */, |
1400 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE, | 1400 SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr()); |
1401 context()->AsWeakPtr(), NULL)); | 1401 host->set_parent_frame_secure(true); |
1402 registration_->active_version()->AddControllee(host.get()); | 1402 registration_->active_version()->AddControllee(host.get()); |
1403 | 1403 |
1404 bool was_called = false; | 1404 bool was_called = false; |
1405 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; | 1405 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; |
1406 std::set<int64_t> verify_ids; | 1406 std::set<int64_t> verify_ids; |
1407 | 1407 |
1408 // Deleting the registration should move the resources to the purgeable list | 1408 // Deleting the registration should move the resources to the purgeable list |
1409 // but keep them available. | 1409 // but keep them available. |
1410 storage()->DeleteRegistration( | 1410 storage()->DeleteRegistration( |
1411 registration_->id(), | 1411 registration_->id(), |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 EXPECT_FALSE(base::DirectoryExists(storage()->GetDiskCachePath())); | 1547 EXPECT_FALSE(base::DirectoryExists(storage()->GetDiskCachePath())); |
1548 EXPECT_FALSE(base::DirectoryExists(storage()->GetDatabasePath())); | 1548 EXPECT_FALSE(base::DirectoryExists(storage()->GetDatabasePath())); |
1549 #endif | 1549 #endif |
1550 } | 1550 } |
1551 | 1551 |
1552 TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) { | 1552 TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) { |
1553 // Promote the worker to active worker and add a controllee. | 1553 // Promote the worker to active worker and add a controllee. |
1554 registration_->SetActiveVersion(registration_->waiting_version()); | 1554 registration_->SetActiveVersion(registration_->waiting_version()); |
1555 storage()->UpdateToActiveState( | 1555 storage()->UpdateToActiveState( |
1556 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1556 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
1557 std::unique_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( | 1557 std::unique_ptr<ServiceWorkerProviderHost> host = |
1558 33 /* dummy render process id */, MSG_ROUTING_NONE, | 1558 ServiceWorkerProviderHost::CreateForTesting( |
1559 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, | 1559 33 /* dummy render process id */, 1 /* dummy provider_id */, |
1560 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE, | 1560 SERVICE_WORKER_PROVIDER_FOR_WINDOW, helper_->context()->AsWeakPtr()); |
1561 context()->AsWeakPtr(), NULL)); | 1561 host->set_parent_frame_secure(true); |
1562 registration_->active_version()->AddControllee(host.get()); | 1562 registration_->active_version()->AddControllee(host.get()); |
1563 | 1563 |
1564 bool was_called = false; | 1564 bool was_called = false; |
1565 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; | 1565 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; |
1566 std::set<int64_t> verify_ids; | 1566 std::set<int64_t> verify_ids; |
1567 | 1567 |
1568 // Make an updated registration. | 1568 // Make an updated registration. |
1569 scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion( | 1569 scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion( |
1570 registration_.get(), script_, storage()->NewVersionId(), | 1570 registration_.get(), script_, storage()->NewVersionId(), |
1571 context()->AsWeakPtr()); | 1571 context()->AsWeakPtr()); |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2128 EXPECT_TRUE(registration_state.enabled); | 2128 EXPECT_TRUE(registration_state.enabled); |
2129 EXPECT_EQ(kHeaderValue, registration_state.header); | 2129 EXPECT_EQ(kHeaderValue, registration_state.header); |
2130 ASSERT_TRUE(found_registration->active_version()); | 2130 ASSERT_TRUE(found_registration->active_version()); |
2131 const NavigationPreloadState& state = | 2131 const NavigationPreloadState& state = |
2132 found_registration->active_version()->navigation_preload_state(); | 2132 found_registration->active_version()->navigation_preload_state(); |
2133 EXPECT_TRUE(state.enabled); | 2133 EXPECT_TRUE(state.enabled); |
2134 EXPECT_EQ(kHeaderValue, state.header); | 2134 EXPECT_EQ(kHeaderValue, state.header); |
2135 } | 2135 } |
2136 | 2136 |
2137 } // namespace content | 2137 } // namespace content |
OLD | NEW |