Chromium Code Reviews| 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..8f31e7dae58a345d884b4378a7bb9d091ab7e5a1 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_LE(CountRenderProcessHosts(), 1) << "Unregistering doesn't stop the " |
|
dominicc (has gone to gerrit)
2014/05/20 02:01:18
Isn't it expected, actual?
Jeffrey Yasskin
2014/05/20 05:20:10
For EQ and NE, yes. For the inequalities, https://
kinuko
2014/05/20 06:30:03
Ah yes, that might be the case.
|
| + "workers eagerly, so their RPHs " |
| + "can still be running."; |
| // Should not be able to find it. |
| { |