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