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

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

Issue 633273002: Added quota client for serviceworker. Enables 'clear past <time> data'. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Logic to Core Created 6 years, 2 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_context_unittest.cc
diff --git a/content/browser/service_worker/service_worker_context_unittest.cc b/content/browser/service_worker/service_worker_context_unittest.cc
index d9331ee2468ccd2bda40f549ab51bad51ead961a..502cb9cc9605d7f1086ba235c3fca59780aec56e 100644
--- a/content/browser/service_worker/service_worker_context_unittest.cc
+++ b/content/browser/service_worker/service_worker_context_unittest.cc
@@ -273,6 +273,91 @@ TEST_F(ServiceWorkerContextTest, Unregister) {
base::RunLoop().RunUntilIdle();
}
+// Make sure registrations are cleaned up when they are unregistered in bulk.
+TEST_F(ServiceWorkerContextTest, UnregisterMultiple) {
+ GURL origin1_p1("http://www.example.com/test");
+ GURL origin1_p2("http://www.example.com/hello");
+ GURL origin1_p3("http://www.example.com:8080/again");
jsbell 2014/10/13 20:54:25 http://example.com and http://example.com:8080 are
dmurph 2014/10/14 00:16:31 Done.
+ GURL origin2_p1("http://www.other.com/");
+ GURL origin1 = origin1_p1.GetOrigin();
+ GURL origin2 = origin2_p1.GetOrigin();
+
+ bool called = false;
+ int64 registration_id1 = kInvalidServiceWorkerRegistrationId;
+ int64 registration_id2 = kInvalidServiceWorkerRegistrationId;
+ int64 registration_id3 = kInvalidServiceWorkerRegistrationId;
+ int64 registration_id4 = kInvalidServiceWorkerRegistrationId;
+ context()->RegisterServiceWorker(
+ origin1_p1,
+ GURL("http://www.example.com/service_worker.js"),
+ NULL,
+ MakeRegisteredCallback(&called, &registration_id1));
+ context()->RegisterServiceWorker(
+ origin1_p2,
+ GURL("http://www.example.com/service_worker2.js"),
+ NULL,
+ MakeRegisteredCallback(&called, &registration_id2));
+ context()->RegisterServiceWorker(
+ origin1_p3,
+ GURL("http://www.example.com:8080/service_worker3.js"),
+ NULL,
+ MakeRegisteredCallback(&called, &registration_id3));
+ context()->RegisterServiceWorker(
+ origin2_p1,
+ GURL("http://www.other.com/service_worker4.js"),
+ NULL,
+ MakeRegisteredCallback(&called, &registration_id4));
+
+ ASSERT_FALSE(called);
+ base::RunLoop().RunUntilIdle();
+ ASSERT_TRUE(called);
+
+ EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id1);
+ EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id2);
+ EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id3);
+ EXPECT_NE(kInvalidServiceWorkerRegistrationId, registration_id4);
+
+ called = false;
+ context()->UnregisterServiceWorkers(origin1,
+ MakeUnregisteredCallback(&called));
+
+ ASSERT_FALSE(called);
+ base::RunLoop().RunUntilIdle();
+ ASSERT_TRUE(called);
+
+ context()->storage()->FindRegistrationForId(
+ registration_id1,
+ origin1,
+ base::Bind(&ExpectRegisteredWorkers,
+ SERVICE_WORKER_ERROR_NOT_FOUND,
+ false /* expect_waiting */,
+ false /* expect_active */));
+ context()->storage()->FindRegistrationForId(
+ registration_id2,
+ origin1,
+ base::Bind(&ExpectRegisteredWorkers,
+ SERVICE_WORKER_ERROR_NOT_FOUND,
+ false /* expect_waiting */,
+ false /* expect_active */));
+ context()->storage()->FindRegistrationForId(
+ registration_id3,
+ origin1,
jsbell 2014/10/13 20:54:25 I believe this is only succeeding because registra
dmurph 2014/10/14 00:16:31 Done.
+ base::Bind(&ExpectRegisteredWorkers,
+ SERVICE_WORKER_ERROR_NOT_FOUND,
+ false /* expect_waiting */,
+ false /* expect_active */));
+
+ context()->storage()->FindRegistrationForId(
+ registration_id4,
+ origin2,
+ base::Bind(&ExpectRegisteredWorkers,
+ SERVICE_WORKER_OK,
+ false /* expect_waiting */,
+ true /* expect_active */));
+
+ base::RunLoop().RunUntilIdle();
+}
+
// Make sure registering a new script shares an existing registration.
TEST_F(ServiceWorkerContextTest, RegisterNewScript) {
GURL pattern("http://www.example.com/");

Powered by Google App Engine
This is Rietveld 408576698