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

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

Issue 1042933002: ServiceWorker: Support non-window clients in Clients.matchAll (1/2 chromium) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 status = SERVICE_WORKER_ERROR_FAILED; 439 status = SERVICE_WORKER_ERROR_FAILED;
440 version_->StartWorker(CreateReceiverOnCurrentThread(&status)); 440 version_->StartWorker(CreateReceiverOnCurrentThread(&status));
441 base::RunLoop().RunUntilIdle(); 441 base::RunLoop().RunUntilIdle();
442 EXPECT_EQ(SERVICE_WORKER_OK, status); 442 EXPECT_EQ(SERVICE_WORKER_OK, status);
443 EXPECT_TRUE(version_->timeout_timer_.IsRunning()); 443 EXPECT_TRUE(version_->timeout_timer_.IsRunning());
444 EXPECT_LT(idle_time, version_->idle_time_); 444 EXPECT_LT(idle_time, version_->idle_time_);
445 445
446 // Adding a controllee resets the idle time. 446 // Adding a controllee resets the idle time.
447 version_->idle_time_ -= kOneSecond; 447 version_->idle_time_ -= kOneSecond;
448 idle_time = version_->idle_time_; 448 idle_time = version_->idle_time_;
449 scoped_ptr<ServiceWorkerProviderHost> host( 449 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost(
450 new ServiceWorkerProviderHost(33 /* dummy render process id */, 450 33 /* dummy render process id */, MSG_ROUTING_NONE /* render_frame_id */,
451 MSG_ROUTING_NONE /* render_frame_id */, 451 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW,
452 1 /* dummy provider_id */, 452 helper_->context()->AsWeakPtr(), NULL));
453 SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE,
454 helper_->context()->AsWeakPtr(),
455 NULL));
456 version_->AddControllee(host.get()); 453 version_->AddControllee(host.get());
457 EXPECT_TRUE(version_->timeout_timer_.IsRunning()); 454 EXPECT_TRUE(version_->timeout_timer_.IsRunning());
458 EXPECT_LT(idle_time, version_->idle_time_); 455 EXPECT_LT(idle_time, version_->idle_time_);
459 456
460 // Completing an event resets the idle time. 457 // Completing an event resets the idle time.
461 status = SERVICE_WORKER_ERROR_FAILED; 458 status = SERVICE_WORKER_ERROR_FAILED;
462 version_->idle_time_ -= kOneSecond; 459 version_->idle_time_ -= kOneSecond;
463 idle_time = version_->idle_time_; 460 idle_time = version_->idle_time_;
464 version_->DispatchFetchEvent(ServiceWorkerFetchRequest(), 461 version_->DispatchFetchEvent(ServiceWorkerFetchRequest(),
465 base::Bind(&base::DoNothing), 462 base::Bind(&base::DoNothing),
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 base::TimeTicks::Now() - 564 base::TimeTicks::Now() -
568 base::TimeDelta::FromMinutes( 565 base::TimeDelta::FromMinutes(
569 ServiceWorkerVersion::kStartWorkerTimeoutMinutes + 1); 566 ServiceWorkerVersion::kStartWorkerTimeoutMinutes + 1);
570 version_->timeout_timer_.user_task().Run(); 567 version_->timeout_timer_.user_task().Run();
571 base::RunLoop().RunUntilIdle(); 568 base::RunLoop().RunUntilIdle();
572 EXPECT_EQ(SERVICE_WORKER_ERROR_TIMEOUT, status); 569 EXPECT_EQ(SERVICE_WORKER_ERROR_TIMEOUT, status);
573 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); 570 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status());
574 } 571 }
575 572
576 } // namespace content 573 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698