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

Side by Side Diff: content/browser/service_worker/service_worker_version_unittest.cc

Issue 805083006: Schedule the stop-worker-timer even if the ServiceWorker is controlling pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 unified diff | Download patch
« no previous file with comments | « content/browser/service_worker/service_worker_version.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "content/browser/service_worker/embedded_worker_registry.h" 7 #include "content/browser/service_worker/embedded_worker_registry.h"
8 #include "content/browser/service_worker/embedded_worker_test_helper.h" 8 #include "content/browser/service_worker/embedded_worker_test_helper.h"
9 #include "content/browser/service_worker/service_worker_context_core.h" 9 #include "content/browser/service_worker/service_worker_context_core.h"
10 #include "content/browser/service_worker/service_worker_registration.h" 10 #include "content/browser/service_worker/service_worker_registration.h"
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 status = SERVICE_WORKER_ERROR_FAILED; 374 status = SERVICE_WORKER_ERROR_FAILED;
375 version_->StopWorker(CreateReceiverOnCurrentThread(&status)); 375 version_->StopWorker(CreateReceiverOnCurrentThread(&status));
376 base::RunLoop().RunUntilIdle(); 376 base::RunLoop().RunUntilIdle();
377 EXPECT_EQ(SERVICE_WORKER_OK, status); 377 EXPECT_EQ(SERVICE_WORKER_OK, status);
378 status = SERVICE_WORKER_ERROR_FAILED; 378 status = SERVICE_WORKER_ERROR_FAILED;
379 version_->StartWorker(CreateReceiverOnCurrentThread(&status)); 379 version_->StartWorker(CreateReceiverOnCurrentThread(&status));
380 base::RunLoop().RunUntilIdle(); 380 base::RunLoop().RunUntilIdle();
381 EXPECT_EQ(SERVICE_WORKER_OK, status); 381 EXPECT_EQ(SERVICE_WORKER_OK, status);
382 EXPECT_TRUE(version_->stop_worker_timer_.IsRunning()); 382 EXPECT_TRUE(version_->stop_worker_timer_.IsRunning());
383 383
384 // The timer should not be running if a controllee is added. 384 // Adding controllee doesn't stop the stop-worker-timer.
385 scoped_ptr<ServiceWorkerProviderHost> host( 385 scoped_ptr<ServiceWorkerProviderHost> host(
386 new ServiceWorkerProviderHost(33 /* dummy render process id */, 386 new ServiceWorkerProviderHost(33 /* dummy render process id */,
387 MSG_ROUTING_NONE /* render_frame_id */, 387 MSG_ROUTING_NONE /* render_frame_id */,
388 1 /* dummy provider_id */, 388 1 /* dummy provider_id */,
389 helper_->context()->AsWeakPtr(), 389 helper_->context()->AsWeakPtr(),
390 NULL)); 390 NULL));
391 version_->AddControllee(host.get()); 391 version_->AddControllee(host.get());
392 EXPECT_FALSE(version_->stop_worker_timer_.IsRunning());
393
394 // The timer should be running if the controllee is removed.
395 version_->RemoveControllee(host.get());
396 EXPECT_TRUE(version_->stop_worker_timer_.IsRunning()); 392 EXPECT_TRUE(version_->stop_worker_timer_.IsRunning());
397 } 393 }
398 394
399 TEST_F(ServiceWorkerVersionTest, ListenerAvailability) { 395 TEST_F(ServiceWorkerVersionTest, ListenerAvailability) {
400 // Initially the worker is not running. There should be no cache_listener_. 396 // Initially the worker is not running. There should be no cache_listener_.
401 EXPECT_FALSE(version_->cache_listener_.get()); 397 EXPECT_FALSE(version_->cache_listener_.get());
402 398
403 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; 399 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED;
404 version_->StartWorker( 400 version_->StartWorker(
405 CreateReceiverOnCurrentThread(&status)); 401 CreateReceiverOnCurrentThread(&status));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 helper_->context()->embedded_worker_registry()->RemoveChildProcessSender( 436 helper_->context()->embedded_worker_registry()->RemoveChildProcessSender(
441 process_id); 437 process_id);
442 base::RunLoop().RunUntilIdle(); 438 base::RunLoop().RunUntilIdle();
443 439
444 // Callback completed. 440 // Callback completed.
445 EXPECT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status); 441 EXPECT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status);
446 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); 442 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status());
447 } 443 }
448 444
449 } // namespace content 445 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_version.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698