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"); |
52 | 54 |
53 embedded_test_server()->ServeFilesFromDirectory(service_worker_dir_.path()); | 55 embedded_test_server()->ServeFilesFromDirectory(service_worker_dir_.path()); |
54 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 56 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
55 | 57 |
56 content::ServiceWorkerContext* sw_context = | 58 content::ServiceWorkerContext* sw_context = |
57 content::BrowserContext::GetDefaultStoragePartition(browser()->profile()) | 59 content::BrowserContext::GetDefaultStoragePartition(browser()->profile()) |
58 ->GetServiceWorkerContext(); | 60 ->GetServiceWorkerContext(); |
59 | 61 |
60 base::RunLoop run_loop; | 62 base::RunLoop run_loop; |
61 sw_context->RegisterServiceWorker( | 63 sw_context->RegisterServiceWorker( |
62 embedded_test_server()->GetURL("/*"), | 64 embedded_test_server()->GetURL("/*"), |
63 embedded_test_server()->GetURL("/service_worker.js"), | 65 embedded_test_server()->GetURL("/service_worker.js"), |
64 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure())); | 66 base::Bind(&ExpectResultAndRun, true, run_loop.QuitClosure())); |
65 run_loop.Run(); | 67 run_loop.Run(); |
66 | 68 |
67 // Leave the Service Worker registered, and make sure that the browser can | 69 // Leave the Service Worker registered, and make sure that the browser can |
68 // shut down without DCHECK'ing. It'd be nice to check here that the SW is | 70 // shut down without DCHECK'ing. It'd be nice to check here that the SW is |
69 // actually occupying a process, but we don't yet have the public interface to | 71 // actually occupying a process, but we don't yet have the public interface to |
70 // do that. | 72 // do that. |
71 } | 73 } |
72 | 74 |
73 } // namespace | 75 } // namespace |
OLD | NEW |