Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Unified Diff: content/browser/service_worker/service_worker_storage_unittest.cc

Issue 377153003: Service Worker: set active worker to REDUNDANT when unregistered (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: version purges the resources Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 2d7e7eec6d567b70baae02f6f780423218b12153..46acc289eb9aeba4d5f4ca38107fb12e75b0fe15 100644
--- a/content/browser/service_worker/service_worker_storage_unittest.cc
+++ b/content/browser/service_worker/service_worker_storage_unittest.cc
@@ -577,6 +577,37 @@ class ServiceWorkerResourceStorageDiskTest
base::ScopedTempDir user_data_directory_;
};
+TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_NoLiveVersion) {
+ bool was_called = false;
+ ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED;
+ std::set<int64> verify_ids;
+
+ registration_->SetWaitingVersion(NULL);
michaeln 2014/07/11 01:16:05 maybe drop the registration_ altogether by setting
falken 2014/07/11 12:08:12 Done.
+
+ // Deleting the registration should result in the resources being added to the
+ // purgeable list and then doomed in the disk cache and removed from that
+ // list.
+ storage()->DeleteRegistration(
+ registration_->id(),
+ scope_.GetOrigin(),
+ base::Bind(&VerifyPurgeableListStatusCallback,
+ base::Unretained(storage()->database_.get()),
+ &verify_ids,
+ &was_called,
+ &result));
+ base::RunLoop().RunUntilIdle();
+ ASSERT_TRUE(was_called);
+ EXPECT_EQ(SERVICE_WORKER_OK, result);
+ EXPECT_EQ(2u, verify_ids.size());
+ verify_ids.clear();
+ EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK,
+ storage()->database_->GetPurgeableResourceIds(&verify_ids));
+ EXPECT_TRUE(verify_ids.empty());
+
+ EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false));
+ EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false));
+}
+
TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_WaitingVersion) {
bool was_called = false;
ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED;
@@ -600,6 +631,19 @@ TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_WaitingVersion) {
verify_ids.clear();
EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK,
storage()->database_->GetPurgeableResourceIds(&verify_ids));
+ EXPECT_EQ(2u, verify_ids.size());
+
+ EXPECT_TRUE(VerifyBasicResponse(storage(), resource_id1_, false));
+ EXPECT_TRUE(VerifyBasicResponse(storage(), resource_id2_, false));
+
+ // Doom the version, now it happens.
+ registration_->waiting_version()->Doom();
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(SERVICE_WORKER_OK, result);
+ EXPECT_EQ(2u, verify_ids.size());
+ verify_ids.clear();
+ EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK,
+ storage()->database_->GetPurgeableResourceIds(&verify_ids));
EXPECT_TRUE(verify_ids.empty());
EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false));
@@ -632,6 +676,7 @@ TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) {
&verify_ids,
&was_called,
&result));
+ registration_->active_version()->Doom();
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(was_called);
EXPECT_EQ(SERVICE_WORKER_OK, result);
@@ -781,6 +826,7 @@ TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) {
&verify_ids,
&was_called,
&result));
+ registration_->active_version()->Doom();
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(was_called);
EXPECT_EQ(SERVICE_WORKER_OK, result);

Powered by Google App Engine
This is Rietveld 408576698