| OLD | NEW |
| 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 // This file tests that Service Workers (a Content feature) work in the Chromium | 5 // This file tests that Service Workers (a Content feature) work in the Chromium |
| 6 // embedder. | 6 // embedder. |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 const base::Closure& continuation, | 42 const base::Closure& continuation, |
| 43 bool actual) { | 43 bool actual) { |
| 44 EXPECT_EQ(expected, actual); | 44 EXPECT_EQ(expected, actual); |
| 45 continuation.Run(); | 45 continuation.Run(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 // http://crbug.com/368570 | 48 // http://crbug.com/368570 |
| 49 IN_PROC_BROWSER_TEST_F(ChromeServiceWorkerTest, | 49 IN_PROC_BROWSER_TEST_F(ChromeServiceWorkerTest, |
| 50 CanShutDownWithRegisteredServiceWorker) { | 50 CanShutDownWithRegisteredServiceWorker) { |
| 51 WriteFile(FILE_PATH_LITERAL("service_worker.js"), ""); | 51 WriteFile(FILE_PATH_LITERAL("service_worker.js"), ""); |
| 52 WriteFile(FILE_PATH_LITERAL("service_worker.js.mock-http-headers"), | |
| 53 "HTTP/1.1 200 OK\nContent-Type: text/javascript"); | |
| 54 | 52 |
| 55 embedded_test_server()->ServeFilesFromDirectory(service_worker_dir_.path()); | 53 embedded_test_server()->ServeFilesFromDirectory(service_worker_dir_.path()); |
| 56 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 54 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 57 | 55 |
| 58 content::ServiceWorkerContext* sw_context = | 56 content::ServiceWorkerContext* sw_context = |
| 59 content::BrowserContext::GetDefaultStoragePartition(browser()->profile()) | 57 content::BrowserContext::GetDefaultStoragePartition(browser()->profile()) |
| 60 ->GetServiceWorkerContext(); | 58 ->GetServiceWorkerContext(); |
| 61 | 59 |
| 62 base::RunLoop run_loop; | 60 base::RunLoop run_loop; |
| 63 sw_context->RegisterServiceWorker( | 61 sw_context->RegisterServiceWorker( |
| 64 embedded_test_server()->GetURL("/*"), | 62 embedded_test_server()->GetURL("/*"), |
| 65 embedded_test_server()->GetURL("/service_worker.js"), | 63 embedded_test_server()->GetURL("/service_worker.js"), |
| 66 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure())); | 64 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure())); |
| 67 run_loop.Run(); | 65 run_loop.Run(); |
| 68 | 66 |
| 69 // Leave the Service Worker registered, and make sure that the browser can | 67 // Leave the Service Worker registered, and make sure that the browser can |
| 70 // shut down without DCHECK'ing. It'd be nice to check here that the SW is | 68 // shut down without DCHECK'ing. It'd be nice to check here that the SW is |
| 71 // actually occupying a process, but we don't yet have the public interface to | 69 // actually occupying a process, but we don't yet have the public interface to |
| 72 // do that. | 70 // do that. |
| 73 } | 71 } |
| 74 | 72 |
| 75 } // namespace | 73 } // namespace |
| OLD | NEW |