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

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

Issue 1149383004: [3/5 chromium] Shows the clients which are controlled by ServiceWorker in DevTools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 version_->StartWorker(CreateReceiverOnCurrentThread(&status)); 453 version_->StartWorker(CreateReceiverOnCurrentThread(&status));
454 base::RunLoop().RunUntilIdle(); 454 base::RunLoop().RunUntilIdle();
455 EXPECT_EQ(SERVICE_WORKER_OK, status); 455 EXPECT_EQ(SERVICE_WORKER_OK, status);
456 EXPECT_TRUE(version_->timeout_timer_.IsRunning()); 456 EXPECT_TRUE(version_->timeout_timer_.IsRunning());
457 EXPECT_LT(idle_time, version_->idle_time_); 457 EXPECT_LT(idle_time, version_->idle_time_);
458 458
459 // Adding a controllee resets the idle time. 459 // Adding a controllee resets the idle time.
460 version_->idle_time_ -= kOneSecond; 460 version_->idle_time_ -= kOneSecond;
461 idle_time = version_->idle_time_; 461 idle_time = version_->idle_time_;
462 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( 462 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost(
463 33 /* dummy render process id */, MSG_ROUTING_NONE /* render_frame_id */, 463 33 /* dummy render process id */, 1 /* dummy render_frame_id */,
464 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, 464 MSG_ROUTING_NONE /* shared_worker_route_id */, 1 /* dummy provider_id */,
465 helper_->context()->AsWeakPtr(), NULL)); 465 helper_->context()->AsWeakPtr(), NULL));
466 version_->AddControllee(host.get()); 466 version_->AddControllee(host.get());
467 EXPECT_TRUE(version_->timeout_timer_.IsRunning()); 467 EXPECT_TRUE(version_->timeout_timer_.IsRunning());
468 EXPECT_LT(idle_time, version_->idle_time_); 468 EXPECT_LT(idle_time, version_->idle_time_);
469 469
470 // Completing an event resets the idle time. 470 // Completing an event resets the idle time.
471 status = SERVICE_WORKER_ERROR_FAILED; 471 status = SERVICE_WORKER_ERROR_FAILED;
472 version_->idle_time_ -= kOneSecond; 472 version_->idle_time_ -= kOneSecond;
473 idle_time = version_->idle_time_; 473 idle_time = version_->idle_time_;
474 version_->DispatchFetchEvent(ServiceWorkerFetchRequest(), 474 version_->DispatchFetchEvent(ServiceWorkerFetchRequest(),
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 base::TimeTicks::Now() - 591 base::TimeTicks::Now() -
592 base::TimeDelta::FromMinutes( 592 base::TimeDelta::FromMinutes(
593 ServiceWorkerVersion::kStartWorkerTimeoutMinutes + 1); 593 ServiceWorkerVersion::kStartWorkerTimeoutMinutes + 1);
594 version_->timeout_timer_.user_task().Run(); 594 version_->timeout_timer_.user_task().Run();
595 base::RunLoop().RunUntilIdle(); 595 base::RunLoop().RunUntilIdle();
596 EXPECT_EQ(SERVICE_WORKER_ERROR_TIMEOUT, status); 596 EXPECT_EQ(SERVICE_WORKER_ERROR_TIMEOUT, status);
597 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); 597 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status());
598 } 598 }
599 599
600 } // namespace content 600 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698