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

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

Issue 1063823005: Service Worker: Use more specific errors when StartWorker fails (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update histograms.xml 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/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/fileapi/chrome_blob_storage_context.h" 10 #include "content/browser/fileapi/chrome_blob_storage_context.h"
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 &status)); 687 &status));
688 stop_run_loop.Run(); 688 stop_run_loop.Run();
689 ASSERT_EQ(SERVICE_WORKER_OK, status); 689 ASSERT_EQ(SERVICE_WORKER_OK, status);
690 } 690 }
691 691
692 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, StartNotFound) { 692 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, StartNotFound) {
693 RunOnIOThread(base::Bind(&self::SetUpRegistrationOnIOThread, this, 693 RunOnIOThread(base::Bind(&self::SetUpRegistrationOnIOThread, this,
694 "/service_worker/nonexistent.js")); 694 "/service_worker/nonexistent.js"));
695 695
696 // Start a worker for nonexistent URL. 696 // Start a worker for nonexistent URL.
697 StartWorker(SERVICE_WORKER_ERROR_START_WORKER_FAILED); 697 StartWorker(SERVICE_WORKER_ERROR_NETWORK);
698 } 698 }
699 699
700 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, Install) { 700 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, Install) {
701 InstallTestHelper("/service_worker/worker.js", SERVICE_WORKER_OK); 701 InstallTestHelper("/service_worker/worker.js", SERVICE_WORKER_OK);
702 } 702 }
703 703
704 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, 704 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest,
705 InstallWithWaitUntil_Fulfilled) { 705 InstallWithWaitUntil_Fulfilled) {
706 InstallTestHelper("/service_worker/worker_install_fulfilled.js", 706 InstallTestHelper("/service_worker/worker_install_fulfilled.js",
707 SERVICE_WORKER_OK); 707 SERVICE_WORKER_OK);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 ASSERT_EQ(SERVICE_WORKER_ERROR_FAILED, status); 766 ASSERT_EQ(SERVICE_WORKER_ERROR_FAILED, status);
767 EXPECT_EQ(ServiceWorkerVersion::STARTING, version_->running_status()); 767 EXPECT_EQ(ServiceWorkerVersion::STARTING, version_->running_status());
768 768
769 // Simulate execution timeout. Use a delay to prevent killing the worker 769 // Simulate execution timeout. Use a delay to prevent killing the worker
770 // before it's started execution. 770 // before it's started execution.
771 EXPECT_TRUE(version_->timeout_timer_.IsRunning()); 771 EXPECT_TRUE(version_->timeout_timer_.IsRunning());
772 RunOnIOThreadWithDelay(base::Bind(&self::TimeoutWorkerOnIOThread, this), 772 RunOnIOThreadWithDelay(base::Bind(&self::TimeoutWorkerOnIOThread, this),
773 base::TimeDelta::FromMilliseconds(100)); 773 base::TimeDelta::FromMilliseconds(100));
774 start_run_loop.Run(); 774 start_run_loop.Run();
775 775
776 EXPECT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status); 776 EXPECT_EQ(SERVICE_WORKER_ERROR_TIMEOUT, status);
777 } 777 }
778 778
779 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, TimeoutWorkerInEvent) { 779 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, TimeoutWorkerInEvent) {
780 RunOnIOThread(base::Bind(&self::SetUpRegistrationOnIOThread, this, 780 RunOnIOThread(base::Bind(&self::SetUpRegistrationOnIOThread, this,
781 "/service_worker/while_true_in_install_worker.js")); 781 "/service_worker/while_true_in_install_worker.js"));
782 782
783 // Start a worker. 783 // Start a worker.
784 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; 784 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED;
785 base::RunLoop start_run_loop; 785 base::RunLoop start_run_loop;
786 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 786 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 ASSERT_EQ(SERVICE_WORKER_OK, status); 1204 ASSERT_EQ(SERVICE_WORKER_OK, status);
1205 // Stop the worker. 1205 // Stop the worker.
1206 StopWorker(SERVICE_WORKER_OK); 1206 StopWorker(SERVICE_WORKER_OK);
1207 // Restart the worker. 1207 // Restart the worker.
1208 StartWorker(SERVICE_WORKER_OK); 1208 StartWorker(SERVICE_WORKER_OK);
1209 // Stop the worker. 1209 // Stop the worker.
1210 StopWorker(SERVICE_WORKER_OK); 1210 StopWorker(SERVICE_WORKER_OK);
1211 } 1211 }
1212 1212
1213 } // namespace content 1213 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698