diff options
author | falken <falken@chromium.org> | 2016-03-24 16:35:38 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-24 23:36:57 +0000 |
commit | cb65da13abc71994dbad796aaef9a3b6f5e1ec02 (patch) | |
tree | 8a17869c95d5c2fe1ec3a2715760a70942935b93 /content/browser/service_worker/service_worker_version_unittest.cc | |
parent | cb3880246bcb734401a374ca9c15af5a815196d9 (diff) | |
download | chromium_src-cb65da13abc71994dbad796aaef9a3b6f5e1ec02.zip chromium_src-cb65da13abc71994dbad796aaef9a3b6f5e1ec02.tar.gz chromium_src-cb65da13abc71994dbad796aaef9a3b6f5e1ec02.tar.bz2 |
service worker: Revert the self-disabling mechanism
Beta channel shows 0.1% of users have a disabled service worker, which still
seems too aggressive. This feature isn't ready for Stable. I intend to merge
this patch to M50.
It's now looking like a simple timeout is not a good heuristic for a broken
service worker, since even main frame navigation without SW can take over
10 seconds to begin a URLRequestJob (crbug.com/448722).
The mechanism to force creating a renderer process remains, to help service
worker escape stuck renderer processes.
BUG=559001
TBR=jwd
Review URL: https://codereview.chromium.org/1829623002
Cr-Commit-Position: refs/heads/master@{#383188}
Diffstat (limited to 'content/browser/service_worker/service_worker_version_unittest.cc')
-rw-r--r-- | content/browser/service_worker/service_worker_version_unittest.cc | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/content/browser/service_worker/service_worker_version_unittest.cc b/content/browser/service_worker/service_worker_version_unittest.cc index 06bb32b..88660df 100644 --- a/content/browser/service_worker/service_worker_version_unittest.cc +++ b/content/browser/service_worker/service_worker_version_unittest.cc @@ -1279,71 +1279,62 @@ TEST_F(ServiceWorkerVersionTest, DispatchEvent) { EXPECT_TRUE(version_->FinishRequest(request_id, true)); } -TEST_F(ServiceWorkerFailToStartTest, FailingWorkerIsDisabled) { +TEST_F(ServiceWorkerFailToStartTest, FailingWorkerUsesNewRendererProcess) { ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_MAX_VALUE; helper_->SimulateAddProcessToPattern(pattern_, helper_->new_render_process_id()); - - // (1) Fail twice and then succeed. The failure count should be reset. ServiceWorkerContextCore* context = helper_->context(); int64_t id = version_->version_id(); - set_start_mode(MessageReceiverDisallowStart::StartMode::FAIL); - // Fail once. - version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN, - CreateReceiverOnCurrentThread(&status)); - base::RunLoop().RunUntilIdle(); - EXPECT_EQ(1, context->GetVersionFailureCount(id)); - // Fail again. - version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN, - CreateReceiverOnCurrentThread(&status)); - base::RunLoop().RunUntilIdle(); - EXPECT_EQ(2, context->GetVersionFailureCount(id)); - // Succeed. It should choose the "new process". + + // Start once. It should choose the "existing process". set_start_mode(MessageReceiverDisallowStart::StartMode::SUCCEED); version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN, CreateReceiverOnCurrentThread(&status)); base::RunLoop().RunUntilIdle(); - EXPECT_EQ(helper_->new_render_process_id(), + EXPECT_EQ(SERVICE_WORKER_OK, status); + EXPECT_EQ(helper_->mock_render_process_id(), version_->embedded_worker()->process_id()); - EXPECT_EQ(0, context->GetVersionFailureCount(id)); version_->StopWorker(CreateReceiverOnCurrentThread(&status)); base::RunLoop().RunUntilIdle(); - // (2) Fail three times. The worker should be disabled. - set_start_mode(MessageReceiverDisallowStart::StartMode::FAIL); // Fail once. + set_start_mode(MessageReceiverDisallowStart::StartMode::FAIL); version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN, CreateReceiverOnCurrentThread(&status)); base::RunLoop().RunUntilIdle(); + EXPECT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status); EXPECT_EQ(1, context->GetVersionFailureCount(id)); + // Fail again. version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN, CreateReceiverOnCurrentThread(&status)); base::RunLoop().RunUntilIdle(); + EXPECT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status); EXPECT_EQ(2, context->GetVersionFailureCount(id)); - // Fail again. + + // Succeed. It should choose the "new process". + set_start_mode(MessageReceiverDisallowStart::StartMode::SUCCEED); version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN, CreateReceiverOnCurrentThread(&status)); base::RunLoop().RunUntilIdle(); - EXPECT_EQ(3, context->GetVersionFailureCount(id)); + EXPECT_EQ(SERVICE_WORKER_OK, status); + EXPECT_EQ(helper_->new_render_process_id(), + version_->embedded_worker()->process_id()); + EXPECT_EQ(0, context->GetVersionFailureCount(id)); + version_->StopWorker(CreateReceiverOnCurrentThread(&status)); + base::RunLoop().RunUntilIdle(); - // The worker should be disabled. - EXPECT_TRUE(version_->IsDisabled()); - set_start_mode(MessageReceiverDisallowStart::StartMode::SUCCEED); + // Start again. It should choose the "existing process" again as we no longer + // force creation of a new process. version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN, CreateReceiverOnCurrentThread(&status)); base::RunLoop().RunUntilIdle(); - EXPECT_EQ(SERVICE_WORKER_ERROR_DISABLED_WORKER, status); - EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); - - // (3) The worker is re-enabled when the failure counts expire. - EXPECT_TRUE(version_->IsDisabled()); - base::Time yesterday = GetYesterday(); - context->failure_counts_expiration_time_ = yesterday; - EXPECT_EQ(0, context->GetVersionFailureCount(id)); - EXPECT_LT(yesterday, context->failure_counts_expiration_time_); - EXPECT_FALSE(version_->IsDisabled()); + EXPECT_EQ(SERVICE_WORKER_OK, status); + EXPECT_EQ(helper_->mock_render_process_id(), + version_->embedded_worker()->process_id()); + version_->StopWorker(CreateReceiverOnCurrentThread(&status)); + base::RunLoop().RunUntilIdle(); } TEST_F(ServiceWorkerVersionTest, DispatchConcurrentEvent) { |