| Index: content/browser/service_worker/service_worker_storage_unittest.cc
|
| diff --git a/content/browser/service_worker/service_worker_storage_unittest.cc b/content/browser/service_worker/service_worker_storage_unittest.cc
|
| index 93fee33bda2359bca799b05ccdf67a86a35c9b17..4bbfc83cbeacd9ea343167010df7d4e304a31fa8 100644
|
| --- a/content/browser/service_worker/service_worker_storage_unittest.cc
|
| +++ b/content/browser/service_worker/service_worker_storage_unittest.cc
|
| @@ -600,13 +600,18 @@ TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_WaitingVersion) {
|
| storage()->database_->GetPurgeableResourceIds(&verify_ids));
|
| EXPECT_TRUE(verify_ids.empty());
|
|
|
| + EXPECT_EQ(ServiceWorkerVersion::REDUNDANT,
|
| + registration_->waiting_version()->status());
|
| +
|
| EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false));
|
| EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false));
|
| }
|
|
|
| TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) {
|
| // Promote the worker to active and add a controllee.
|
| - registration_->SetActiveVersion(registration_->waiting_version());
|
| + ServiceWorkerVersion* version = registration_->waiting_version();
|
| + version->SetStatus(ServiceWorkerVersion::ACTIVATED);
|
| + registration_->SetActiveVersion(version);
|
| storage()->UpdateToActiveState(
|
| registration_, base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
|
| scoped_ptr<ServiceWorkerProviderHost> host(
|
| @@ -614,7 +619,7 @@ TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) {
|
| 1 /* dummy provider_id */,
|
| context_->AsWeakPtr(),
|
| NULL));
|
| - registration_->active_version()->AddControllee(host.get());
|
| + version->AddControllee(host.get());
|
|
|
| bool was_called = false;
|
| ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED;
|
| @@ -642,8 +647,11 @@ TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) {
|
| EXPECT_TRUE(VerifyBasicResponse(storage(), resource_id1_, true));
|
| EXPECT_TRUE(VerifyBasicResponse(storage(), resource_id2_, true));
|
|
|
| + // The live version should still be activated.
|
| + EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, version->status());
|
| +
|
| // Removing the controllee should cause the resources to be deleted.
|
| - registration_->active_version()->RemoveControllee(host.get());
|
| + version->RemoveControllee(host.get());
|
| base::RunLoop().RunUntilIdle();
|
| verify_ids.clear();
|
| EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK,
|
| @@ -652,6 +660,9 @@ TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) {
|
|
|
| EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false));
|
| EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false));
|
| +
|
| + // The live version should now be redundant.
|
| + EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version->status());
|
| }
|
|
|
| // Android has flaky IO error: http://crbug.com/387045
|
| @@ -723,7 +734,9 @@ TEST_F(ServiceWorkerResourceStorageDiskTest, MAYBE_CleanupOnRestart) {
|
|
|
| TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) {
|
| // Promote the worker to active worker and add a controllee.
|
| - registration_->SetActiveVersion(registration_->waiting_version());
|
| + ServiceWorkerVersion* version = registration_->waiting_version();
|
| + version->SetStatus(ServiceWorkerVersion::ACTIVATED);
|
| + registration_->SetActiveVersion(version);
|
| storage()->UpdateToActiveState(
|
| registration_, base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
|
| scoped_ptr<ServiceWorkerProviderHost> host(
|
| @@ -731,17 +744,17 @@ TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) {
|
| 1 /* dummy provider_id */,
|
| context_->AsWeakPtr(),
|
| NULL));
|
| - registration_->active_version()->AddControllee(host.get());
|
| + version->AddControllee(host.get());
|
|
|
| bool was_called = false;
|
| ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED;
|
| std::set<int64> verify_ids;
|
|
|
| // Make an updated registration.
|
| - scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion(
|
| + scoped_refptr<ServiceWorkerVersion> new_version = new ServiceWorkerVersion(
|
| registration_, storage()->NewVersionId(), context_ptr_);
|
| - live_version->SetStatus(ServiceWorkerVersion::NEW);
|
| - registration_->SetWaitingVersion(live_version);
|
| + new_version->SetStatus(ServiceWorkerVersion::NEW);
|
| + registration_->SetWaitingVersion(new_version);
|
|
|
| // Writing the registration should move the old version's resources to the
|
| // purgeable list but keep them available.
|
| @@ -765,9 +778,11 @@ TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) {
|
| EXPECT_TRUE(VerifyBasicResponse(storage(), resource_id1_, false));
|
| EXPECT_TRUE(VerifyBasicResponse(storage(), resource_id2_, false));
|
|
|
| + EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, version->status());
|
| +
|
| // Removing the controllee should cause the old version's resources to be
|
| // deleted.
|
| - registration_->active_version()->RemoveControllee(host.get());
|
| + version->RemoveControllee(host.get());
|
| base::RunLoop().RunUntilIdle();
|
| verify_ids.clear();
|
| EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK,
|
| @@ -776,6 +791,8 @@ TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) {
|
|
|
| EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false));
|
| EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false));
|
| +
|
| + EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version->status());
|
| }
|
|
|
| TEST_F(ServiceWorkerStorageTest, FindRegistration_LongestScopeMatch) {
|
|
|