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

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

Issue 996123002: ServiceWorker: Ensure live registration during starting worker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 5 years, 9 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
« 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 registration_ = new ServiceWorkerRegistration( 123 registration_ = new ServiceWorkerRegistration(
124 pattern_, 124 pattern_,
125 1L, 125 1L,
126 helper_->context()->AsWeakPtr()); 126 helper_->context()->AsWeakPtr());
127 version_ = new ServiceWorkerVersion( 127 version_ = new ServiceWorkerVersion(
128 registration_.get(), 128 registration_.get(),
129 GURL("http://www.example.com/service_worker.js"), 129 GURL("http://www.example.com/service_worker.js"),
130 1L, 130 1L,
131 helper_->context()->AsWeakPtr()); 131 helper_->context()->AsWeakPtr());
132 132
133 // Make the registration findable via storage functions.
134 helper_->context()->storage()->LazyInitialize(base::Bind(&base::DoNothing));
135 base::RunLoop().RunUntilIdle();
136 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED;
137 helper_->context()->storage()->StoreRegistration(
138 registration_.get(),
139 version_.get(),
140 CreateReceiverOnCurrentThread(&status));
141 base::RunLoop().RunUntilIdle();
142 ASSERT_EQ(SERVICE_WORKER_OK, status);
143
133 // Simulate adding one process to the pattern. 144 // Simulate adding one process to the pattern.
134 helper_->SimulateAddProcessToPattern(pattern_, kRenderProcessId); 145 helper_->SimulateAddProcessToPattern(pattern_, kRenderProcessId);
135 ASSERT_TRUE(helper_->context()->process_manager() 146 ASSERT_TRUE(helper_->context()->process_manager()
136 ->PatternHasProcessToRun(pattern_)); 147 ->PatternHasProcessToRun(pattern_));
137 } 148 }
138 149
139 virtual scoped_ptr<MessageReceiver> GetMessageReceiver() { 150 virtual scoped_ptr<MessageReceiver> GetMessageReceiver() {
140 return make_scoped_ptr(new MessageReceiver()); 151 return make_scoped_ptr(new MessageReceiver());
141 } 152 }
142 153
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 base::TimeTicks::Now() - 480 base::TimeTicks::Now() -
470 base::TimeDelta::FromMinutes( 481 base::TimeDelta::FromMinutes(
471 ServiceWorkerVersion::kStartWorkerTimeoutMinutes + 1); 482 ServiceWorkerVersion::kStartWorkerTimeoutMinutes + 1);
472 version_->timeout_timer_.user_task().Run(); 483 version_->timeout_timer_.user_task().Run();
473 base::RunLoop().RunUntilIdle(); 484 base::RunLoop().RunUntilIdle();
474 EXPECT_EQ(SERVICE_WORKER_ERROR_TIMEOUT, status); 485 EXPECT_EQ(SERVICE_WORKER_ERROR_TIMEOUT, status);
475 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); 486 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status());
476 } 487 }
477 488
478 } // namespace content 489 } // 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