| Index: content/browser/service_worker/service_worker_browsertest.cc
|
| diff --git a/content/browser/service_worker/service_worker_browsertest.cc b/content/browser/service_worker/service_worker_browsertest.cc
|
| index 9b32308834d8ab6af7025470268d24cf63fe0136..7c1d60765ec4c0d9976214bf4f04588fb73489eb 100644
|
| --- a/content/browser/service_worker/service_worker_browsertest.cc
|
| +++ b/content/browser/service_worker/service_worker_browsertest.cc
|
| @@ -550,10 +550,6 @@ class ServiceWorkerBlackBoxBrowserTest : public ServiceWorkerBrowserTest {
|
| continuation.Run();
|
| }
|
|
|
| - int RenderProcessID() {
|
| - return shell()->web_contents()->GetRenderProcessHost()->GetID();
|
| - }
|
| -
|
| void FindRegistrationOnIO(const GURL& document_url,
|
| ServiceWorkerStatusCode* status,
|
| GURL* script_url,
|
| @@ -583,7 +579,21 @@ class ServiceWorkerBlackBoxBrowserTest : public ServiceWorkerBrowserTest {
|
| }
|
| };
|
|
|
| +static int CountRenderProcessHosts() {
|
| + int result = 0;
|
| + for (RenderProcessHost::iterator iter(RenderProcessHost::AllHostsIterator());
|
| + !iter.IsAtEnd();
|
| + iter.Advance()) {
|
| + result++;
|
| + }
|
| + return result;
|
| +}
|
| +
|
| IN_PROC_BROWSER_TEST_F(ServiceWorkerBlackBoxBrowserTest, Registration) {
|
| + // Close the only window to be sure we're not re-using its RenderProcessHost.
|
| + shell()->Close();
|
| + EXPECT_EQ(0, CountRenderProcessHosts());
|
| +
|
| const std::string kWorkerUrl = "/service_worker/fetch_event.js";
|
|
|
| // Unregistering nothing should return true.
|
| @@ -597,6 +607,19 @@ IN_PROC_BROWSER_TEST_F(ServiceWorkerBlackBoxBrowserTest, Registration) {
|
| run_loop.Run();
|
| }
|
|
|
| + // If we use a worker URL that doesn't exist, registration fails.
|
| + {
|
| + base::RunLoop run_loop;
|
| + public_context()->RegisterServiceWorker(
|
| + embedded_test_server()->GetURL("/*"),
|
| + embedded_test_server()->GetURL("/does/not/exist"),
|
| + base::Bind(&ServiceWorkerBlackBoxBrowserTest::ExpectResultAndRun,
|
| + false,
|
| + run_loop.QuitClosure()));
|
| + run_loop.Run();
|
| + }
|
| + EXPECT_EQ(0, CountRenderProcessHosts());
|
| +
|
| // Register returns when the promise would be resolved.
|
| {
|
| base::RunLoop run_loop;
|
| @@ -608,6 +631,7 @@ IN_PROC_BROWSER_TEST_F(ServiceWorkerBlackBoxBrowserTest, Registration) {
|
| run_loop.QuitClosure()));
|
| run_loop.Run();
|
| }
|
| + EXPECT_EQ(1, CountRenderProcessHosts());
|
|
|
| // Registering again should succeed, although the algo still
|
| // might not be complete.
|
| @@ -636,6 +660,9 @@ IN_PROC_BROWSER_TEST_F(ServiceWorkerBlackBoxBrowserTest, Registration) {
|
| run_loop.QuitClosure()));
|
| run_loop.Run();
|
| }
|
| + EXPECT_GE(1, CountRenderProcessHosts()) << "Unregistering doesn't stop the "
|
| + "workers eagerly, so their RPHs "
|
| + "can still be running.";
|
|
|
| // Should not be able to find it.
|
| {
|
|
|