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

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

Issue 1181973004: ServiceWorker: Route unregister() through WebServiceWorkerRegistration for refactoring (2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minimize ifdef Created 5 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_dispatcher_host_unittest.cc
diff --git a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
index e2f2f7f602237e0447fe51b93dd838680db12403..bb4021ea145ee18a4e33790d31ea777df23f727e 100644
--- a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
+++ b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
@@ -99,9 +99,10 @@ class ServiceWorkerDispatcherHostTest : public testing::Test {
dispatcher_host_->ipc_sink()->ClearMessages();
}
+#ifdef CRBUG_500404
void SendUnregister(int64 provider_id, GURL pattern) {
dispatcher_host_->OnMessageReceived(
- ServiceWorkerHostMsg_UnregisterServiceWorker(
+ ServiceWorkerHostMsg_DeprecatedUnregisterServiceWorker(
-1, -1, provider_id, pattern));
base::RunLoop().RunUntilIdle();
}
@@ -112,6 +113,23 @@ class ServiceWorkerDispatcherHostTest : public testing::Test {
expected_message));
dispatcher_host_->ipc_sink()->ClearMessages();
}
+#else
+ void SendUnregister(int64 provider_id, int64 registration_id) {
+ dispatcher_host_->OnMessageReceived(
+ ServiceWorkerHostMsg_UnregisterServiceWorker(-1, -1, provider_id,
+ registration_id));
+ base::RunLoop().RunUntilIdle();
+ }
+
+ void Unregister(int64 provider_id,
+ int64 registration_id,
+ uint32 expected_message) {
+ SendUnregister(provider_id, registration_id);
+ EXPECT_TRUE(dispatcher_host_->ipc_sink()->GetUniqueMessageMatching(
+ expected_message));
+ dispatcher_host_->ipc_sink()->ClearMessages();
+ }
+#endif // CRBUG_500404
void SendGetRegistration(int64 provider_id, GURL document_url) {
dispatcher_host_->OnMessageReceived(
@@ -184,14 +202,24 @@ TEST_F(ServiceWorkerDispatcherHostTest,
GURL("https://www.example.com/"),
GURL("https://www.example.com/bar"),
ServiceWorkerMsg_ServiceWorkerRegistrationError::ID);
- Unregister(kProviderId,
- GURL("https://www.example.com/"),
- ServiceWorkerMsg_ServiceWorkerUnregistrationError::ID);
GetRegistration(kProviderId,
GURL("https://www.example.com/"),
ServiceWorkerMsg_ServiceWorkerGetRegistrationError::ID);
GetRegistrations(kProviderId,
ServiceWorkerMsg_ServiceWorkerGetRegistrationsError::ID);
+#ifdef CRBUG_500404
kinuko 2015/06/17 17:44:56 I don't really understand why we still need these
nhiroki 2015/06/17 23:23:48 #define was already landed in the 1st patch and wi
+ Unregister(kProviderId, GURL("https://www.example.com/"),
+ ServiceWorkerMsg_ServiceWorkerUnregistrationError::ID);
+#else
+ // Add a registration into a live registration map so that Unregister() can
+ // find it.
+ const int64 kRegistrationId = 999; // Dummy value
+ scoped_refptr<ServiceWorkerRegistration> registration(
+ new ServiceWorkerRegistration(GURL("https://www.example.com/"),
+ kRegistrationId, context()->AsWeakPtr()));
+ Unregister(kProviderId, kRegistrationId,
+ ServiceWorkerMsg_ServiceWorkerUnregistrationError::ID);
+#endif // CRBUG_500404
SetBrowserClientForTesting(old_browser_client);
}
@@ -350,6 +378,8 @@ TEST_F(ServiceWorkerDispatcherHostTest,
EXPECT_EQ(3, dispatcher_host_->bad_messages_received_count_);
}
+// TODO(nhiroki): Remove these tests after http://crbug.com/500404 is fixed.
+#ifdef CRBUG_500404
TEST_F(ServiceWorkerDispatcherHostTest, Unregister_HTTPS) {
const int64 kProviderId = 99; // Dummy value
scoped_ptr<ServiceWorkerProviderHost> host(
@@ -407,6 +437,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, Unregister_NonSecureOriginShouldFail) {
SendUnregister(kProviderId, GURL("http://www.example.com/"));
EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_);
}
+#endif // CRBUG_500404
TEST_F(ServiceWorkerDispatcherHostTest, EarlyContextDeletion) {
helper_->ShutdownContext();

Powered by Google App Engine
This is Rietveld 408576698