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

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

Issue 345583002: ServiceWorker: Add a function to abort all pending jobs in SWJobCoordinator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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_job_unittest.cc
diff --git a/content/browser/service_worker/service_worker_job_unittest.cc b/content/browser/service_worker/service_worker_job_unittest.cc
index 885793763ac36db1b83083833b158eb65f89031c..f403d894feaeb22eda23239099df728e0cb796bc 100644
--- a/content/browser/service_worker/service_worker_job_unittest.cc
+++ b/content/browser/service_worker/service_worker_job_unittest.cc
@@ -584,4 +584,43 @@ TEST_F(ServiceWorkerJobTest, ParallelUnreg) {
ASSERT_EQ(scoped_refptr<ServiceWorkerRegistration>(), registration);
}
+TEST_F(ServiceWorkerJobTest, AbortAll) {
+ GURL pattern("http://www.example.com/*");
+ GURL script_url("http://www.example.com/service_worker.js");
+
+ bool registration_called = false;
+ scoped_refptr<ServiceWorkerRegistration> registration;
+ job_coordinator()->Register(
+ pattern,
+ script_url,
+ render_process_id_,
+ SaveRegistration(SERVICE_WORKER_ERROR_ABORT,
+ &registration_called, &registration));
+
+ bool unregistration_called = false;
+ job_coordinator()->Unregister(
+ pattern,
+ SaveUnregistration(SERVICE_WORKER_ERROR_ABORT,
+ &unregistration_called));
+
+ ASSERT_FALSE(registration_called);
+ ASSERT_FALSE(unregistration_called);
+ job_coordinator()->AbortAll();
+
+ base::RunLoop().RunUntilIdle();
+ ASSERT_TRUE(registration_called);
+ ASSERT_TRUE(unregistration_called);
+
+ bool find_called = false;
+ storage()->FindRegistrationForPattern(
+ pattern,
+ SaveFoundRegistration(
+ SERVICE_WORKER_ERROR_NOT_FOUND, &find_called, &registration));
+
+ base::RunLoop().RunUntilIdle();
+ ASSERT_TRUE(find_called);
+ ASSERT_EQ(scoped_refptr<ServiceWorkerRegistration>(), registration);
+}
+
+
falken 2014/06/19 03:45:55 extra newline?
nhiroki 2014/06/19 05:53:09 Done.
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698