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

Unified Diff: content/child/service_worker/service_worker_dispatcher_unittest.cc

Issue 1478103002: [WIP] [service worker] Fix detach controller and fallback to network mechanism (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: return null in Create/Adopt Created 5 years 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/child/service_worker/service_worker_dispatcher_unittest.cc
diff --git a/content/child/service_worker/service_worker_dispatcher_unittest.cc b/content/child/service_worker/service_worker_dispatcher_unittest.cc
index a62b8461c06e35277c496accf5ae47c8efcd2839..5df0501c326148a3faa3dfbb91b51e537c35f918 100644
--- a/content/child/service_worker/service_worker_dispatcher_unittest.cc
+++ b/content/child/service_worker/service_worker_dispatcher_unittest.cc
@@ -330,6 +330,35 @@ TEST_F(ServiceWorkerDispatcherTest, OnSetControllerServiceWorker) {
ipc_sink()->GetMessageAt(1)->type());
}
+// Test that clearing the controller by sending a kInvalidServiceWorkerHandle
+// results in the provider context having a null controller.
+TEST_F(ServiceWorkerDispatcherTest, OnSetControllerServiceWorker_Null) {
+ const int kProviderId = 10;
+ bool should_notify_controllerchange = true;
+
+ ServiceWorkerRegistrationObjectInfo info;
+ ServiceWorkerVersionAttributes attrs;
+ CreateObjectInfoAndVersionAttributes(&info, &attrs);
+
+ scoped_ptr<MockWebServiceWorkerProviderClientImpl> provider_client(
+ new MockWebServiceWorkerProviderClientImpl(kProviderId, dispatcher()));
+ scoped_refptr<ServiceWorkerProviderContext> provider_context(
+ new ServiceWorkerProviderContext(kProviderId,
+ SERVICE_WORKER_PROVIDER_FOR_WINDOW,
+ thread_safe_sender()));
+
+ OnAssociateRegistration(kDocumentMainThreadId, kProviderId, info, attrs);
+
+ // Set the controller to kInvalidServiceWorkerHandle.
+ OnSetControllerServiceWorker(kDocumentMainThreadId, kProviderId,
+ ServiceWorkerObjectInfo(),
+ should_notify_controllerchange);
+
+ // Check that it became null.
+ EXPECT_EQ(nullptr, provider_context->controller());
+ EXPECT_TRUE(provider_client->is_set_controlled_called());
+}
+
TEST_F(ServiceWorkerDispatcherTest, OnPostMessage) {
const int kProviderId = 10;

Powered by Google App Engine
This is Rietveld 408576698