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

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

Issue 761923004: Keep alive ServiceWorkers when devtools is attached (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ASSERT_TRUE -> DCHECK :( 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 ASSERT_EQ(ServiceWorkerVersion::ACTIVATING, statuses[2]); 356 ASSERT_EQ(ServiceWorkerVersion::ACTIVATING, statuses[2]);
357 ASSERT_EQ(ServiceWorkerVersion::ACTIVATED, statuses[3]); 357 ASSERT_EQ(ServiceWorkerVersion::ACTIVATED, statuses[3]);
358 ASSERT_EQ(ServiceWorkerVersion::REDUNDANT, statuses[4]); 358 ASSERT_EQ(ServiceWorkerVersion::REDUNDANT, statuses[4]);
359 } 359 }
360 360
361 TEST_F(ServiceWorkerVersionTest, ScheduleStopWorker) { 361 TEST_F(ServiceWorkerVersionTest, ScheduleStopWorker) {
362 // Verify the timer is not running when version initializes its status. 362 // Verify the timer is not running when version initializes its status.
363 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); 363 version_->SetStatus(ServiceWorkerVersion::ACTIVATED);
364 EXPECT_FALSE(version_->stop_worker_timer_.IsRunning()); 364 EXPECT_FALSE(version_->stop_worker_timer_.IsRunning());
365 365
366 // Verify the timer is running when version status changes frome ACTIVATING 366 // Verify the timer is running after the worker is started.
367 // to ACTIVATED.
368 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; 367 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED;
369 version_->StartWorker(CreateReceiverOnCurrentThread(&status)); 368 version_->StartWorker(CreateReceiverOnCurrentThread(&status));
370 base::RunLoop().RunUntilIdle(); 369 base::RunLoop().RunUntilIdle();
371 EXPECT_EQ(SERVICE_WORKER_OK, status); 370 EXPECT_EQ(SERVICE_WORKER_OK, status);
372 version_->SetStatus(ServiceWorkerVersion::ACTIVATING);
373 version_->SetStatus(ServiceWorkerVersion::ACTIVATED);
374 EXPECT_TRUE(version_->stop_worker_timer_.IsRunning()); 371 EXPECT_TRUE(version_->stop_worker_timer_.IsRunning());
375 372
376 // The timer should be running if the worker is restarted without controllee. 373 // The timer should be running if the worker is restarted without controllee.
377 status = SERVICE_WORKER_ERROR_FAILED; 374 status = SERVICE_WORKER_ERROR_FAILED;
378 version_->StopWorker(CreateReceiverOnCurrentThread(&status)); 375 version_->StopWorker(CreateReceiverOnCurrentThread(&status));
379 base::RunLoop().RunUntilIdle(); 376 base::RunLoop().RunUntilIdle();
380 EXPECT_EQ(SERVICE_WORKER_OK, status); 377 EXPECT_EQ(SERVICE_WORKER_OK, status);
381 status = SERVICE_WORKER_ERROR_FAILED; 378 status = SERVICE_WORKER_ERROR_FAILED;
382 version_->StartWorker(CreateReceiverOnCurrentThread(&status)); 379 version_->StartWorker(CreateReceiverOnCurrentThread(&status));
383 base::RunLoop().RunUntilIdle(); 380 base::RunLoop().RunUntilIdle();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 helper_->context()->embedded_worker_registry()->RemoveChildProcessSender( 440 helper_->context()->embedded_worker_registry()->RemoveChildProcessSender(
444 process_id); 441 process_id);
445 base::RunLoop().RunUntilIdle(); 442 base::RunLoop().RunUntilIdle();
446 443
447 // Callback completed. 444 // Callback completed.
448 EXPECT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status); 445 EXPECT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status);
449 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); 446 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status());
450 } 447 }
451 448
452 } // namespace content 449 } // 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