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 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 104 |
105 IN_PROC_BROWSER_TEST_F(WorkerTest, SingleWorker) { | 105 IN_PROC_BROWSER_TEST_F(WorkerTest, SingleWorker) { |
106 RunTest("single_worker.html", std::string()); | 106 RunTest("single_worker.html", std::string()); |
107 } | 107 } |
108 | 108 |
109 IN_PROC_BROWSER_TEST_F(WorkerTest, MultipleWorkers) { | 109 IN_PROC_BROWSER_TEST_F(WorkerTest, MultipleWorkers) { |
110 RunTest("multi_worker.html", std::string()); | 110 RunTest("multi_worker.html", std::string()); |
111 } | 111 } |
112 | 112 |
113 IN_PROC_BROWSER_TEST_F(WorkerTest, SingleSharedWorker) { | 113 IN_PROC_BROWSER_TEST_F(WorkerTest, SingleSharedWorker) { |
| 114 if (!SupportsSharedWorker()) |
| 115 return; |
| 116 |
114 RunTest("single_worker.html", "shared=true"); | 117 RunTest("single_worker.html", "shared=true"); |
115 } | 118 } |
116 | 119 |
117 // http://crbug.com/96435 | 120 // http://crbug.com/96435 |
118 IN_PROC_BROWSER_TEST_F(WorkerTest, MultipleSharedWorkers) { | 121 IN_PROC_BROWSER_TEST_F(WorkerTest, MultipleSharedWorkers) { |
| 122 if (!SupportsSharedWorker()) |
| 123 return; |
| 124 |
119 RunTest("multi_worker.html", "shared=true"); | 125 RunTest("multi_worker.html", "shared=true"); |
120 } | 126 } |
121 | 127 |
122 // Incognito windows should not share workers with non-incognito windows | 128 // Incognito windows should not share workers with non-incognito windows |
123 // http://crbug.com/30021 | 129 // http://crbug.com/30021 |
124 IN_PROC_BROWSER_TEST_F(WorkerTest, IncognitoSharedWorkers) { | 130 IN_PROC_BROWSER_TEST_F(WorkerTest, IncognitoSharedWorkers) { |
| 131 if (!SupportsSharedWorker()) |
| 132 return; |
| 133 |
125 // Load a non-incognito tab and have it create a shared worker | 134 // Load a non-incognito tab and have it create a shared worker |
126 RunTest("incognito_worker.html", std::string()); | 135 RunTest("incognito_worker.html", std::string()); |
127 | 136 |
128 // Incognito worker should not share with non-incognito | 137 // Incognito worker should not share with non-incognito |
129 RunTest(CreateOffTheRecordBrowser(), "incognito_worker.html", std::string()); | 138 RunTest(CreateOffTheRecordBrowser(), "incognito_worker.html", std::string()); |
130 } | 139 } |
131 | 140 |
132 // Make sure that auth dialog is displayed from worker context. | 141 // Make sure that auth dialog is displayed from worker context. |
133 // http://crbug.com/33344 | 142 // http://crbug.com/33344 |
134 IN_PROC_BROWSER_TEST_F(WorkerTest, WorkerHttpAuth) { | 143 IN_PROC_BROWSER_TEST_F(WorkerTest, WorkerHttpAuth) { |
135 ASSERT_TRUE(test_server()->Start()); | 144 ASSERT_TRUE(test_server()->Start()); |
136 GURL url = test_server()->GetURL("files/workers/worker_auth.html"); | 145 GURL url = test_server()->GetURL("files/workers/worker_auth.html"); |
137 | 146 |
138 NavigateAndWaitForAuth(url); | 147 NavigateAndWaitForAuth(url); |
139 } | 148 } |
140 | 149 |
141 // Make sure that HTTP auth dialog is displayed from shared worker context. | 150 // Make sure that HTTP auth dialog is displayed from shared worker context. |
142 // http://crbug.com/33344 | 151 // http://crbug.com/33344 |
143 // | 152 // |
144 // TODO(davidben): HTTP auth dialogs are no longer displayed on shared workers, | 153 // TODO(davidben): HTTP auth dialogs are no longer displayed on shared workers, |
145 // but this test only tests that the delegate is called. Move handling the | 154 // but this test only tests that the delegate is called. Move handling the |
146 // WebContentsless case from chrome/ to content/ and adjust the test | 155 // WebContentsless case from chrome/ to content/ and adjust the test |
147 // accordingly. | 156 // accordingly. |
148 IN_PROC_BROWSER_TEST_F(WorkerTest, SharedWorkerHttpAuth) { | 157 IN_PROC_BROWSER_TEST_F(WorkerTest, SharedWorkerHttpAuth) { |
| 158 if (!SupportsSharedWorker()) |
| 159 return; |
| 160 |
149 ASSERT_TRUE(test_server()->Start()); | 161 ASSERT_TRUE(test_server()->Start()); |
150 GURL url = test_server()->GetURL("files/workers/shared_worker_auth.html"); | 162 GURL url = test_server()->GetURL("files/workers/shared_worker_auth.html"); |
151 NavigateAndWaitForAuth(url); | 163 NavigateAndWaitForAuth(url); |
152 } | 164 } |
153 | 165 |
154 // Tests that TLS client auth prompts for normal workers. | 166 // Tests that TLS client auth prompts for normal workers. |
155 IN_PROC_BROWSER_TEST_F(WorkerTest, WorkerTlsClientAuth) { | 167 IN_PROC_BROWSER_TEST_F(WorkerTest, WorkerTlsClientAuth) { |
156 // Launch HTTPS server. | 168 // Launch HTTPS server. |
157 net::SpawnedTestServer::SSLOptions ssl_options; | 169 net::SpawnedTestServer::SSLOptions ssl_options; |
158 ssl_options.request_client_certificate = true; | 170 ssl_options.request_client_certificate = true; |
(...skipping 22 matching lines...) Expand all Loading... |
181 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); | 193 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); |
182 ASSERT_TRUE(https_server.Start()); | 194 ASSERT_TRUE(https_server.Start()); |
183 | 195 |
184 RunTest("worker_tls_client_auth.html", | 196 RunTest("worker_tls_client_auth.html", |
185 "shared=true&url=" + | 197 "shared=true&url=" + |
186 net::EscapeQueryParamValue(https_server.GetURL("").spec(), true)); | 198 net::EscapeQueryParamValue(https_server.GetURL("").spec(), true)); |
187 EXPECT_EQ(0, select_certificate_count()); | 199 EXPECT_EQ(0, select_certificate_count()); |
188 } | 200 } |
189 | 201 |
190 IN_PROC_BROWSER_TEST_F(WorkerTest, WebSocketSharedWorker) { | 202 IN_PROC_BROWSER_TEST_F(WorkerTest, WebSocketSharedWorker) { |
| 203 if (!SupportsSharedWorker()) |
| 204 return; |
| 205 |
191 // Launch WebSocket server. | 206 // Launch WebSocket server. |
192 net::SpawnedTestServer ws_server(net::SpawnedTestServer::TYPE_WS, | 207 net::SpawnedTestServer ws_server(net::SpawnedTestServer::TYPE_WS, |
193 net::SpawnedTestServer::kLocalhost, | 208 net::SpawnedTestServer::kLocalhost, |
194 net::GetWebSocketTestDataDirectory()); | 209 net::GetWebSocketTestDataDirectory()); |
195 ASSERT_TRUE(ws_server.Start()); | 210 ASSERT_TRUE(ws_server.Start()); |
196 | 211 |
197 // Generate test URL. | 212 // Generate test URL. |
198 GURL::Replacements replacements; | 213 GURL::Replacements replacements; |
199 replacements.SetSchemeStr("http"); | 214 replacements.SetSchemeStr("http"); |
200 GURL url = ws_server.GetURL( | 215 GURL url = ws_server.GetURL( |
201 "websocket_shared_worker.html").ReplaceComponents(replacements); | 216 "websocket_shared_worker.html").ReplaceComponents(replacements); |
202 | 217 |
203 // Run test. | 218 // Run test. |
204 Shell* window = shell(); | 219 Shell* window = shell(); |
205 const base::string16 expected_title = base::ASCIIToUTF16("OK"); | 220 const base::string16 expected_title = base::ASCIIToUTF16("OK"); |
206 TitleWatcher title_watcher(window->web_contents(), expected_title); | 221 TitleWatcher title_watcher(window->web_contents(), expected_title); |
207 NavigateToURL(window, url); | 222 NavigateToURL(window, url); |
208 base::string16 final_title = title_watcher.WaitAndGetTitle(); | 223 base::string16 final_title = title_watcher.WaitAndGetTitle(); |
209 EXPECT_EQ(expected_title, final_title); | 224 EXPECT_EQ(expected_title, final_title); |
210 } | 225 } |
211 | 226 |
212 IN_PROC_BROWSER_TEST_F(WorkerTest, PassMessagePortToSharedWorker) { | 227 IN_PROC_BROWSER_TEST_F(WorkerTest, PassMessagePortToSharedWorker) { |
| 228 if (!SupportsSharedWorker()) |
| 229 return; |
| 230 |
213 RunTest("pass_messageport_to_sharedworker.html", ""); | 231 RunTest("pass_messageport_to_sharedworker.html", ""); |
214 } | 232 } |
215 | 233 |
216 IN_PROC_BROWSER_TEST_F(WorkerTest, | 234 IN_PROC_BROWSER_TEST_F(WorkerTest, |
217 PassMessagePortToSharedWorkerDontWaitForConnect) { | 235 PassMessagePortToSharedWorkerDontWaitForConnect) { |
| 236 if (!SupportsSharedWorker()) |
| 237 return; |
| 238 |
218 RunTest("pass_messageport_to_sharedworker_dont_wait_for_connect.html", ""); | 239 RunTest("pass_messageport_to_sharedworker_dont_wait_for_connect.html", ""); |
219 } | 240 } |
220 | 241 |
221 } // namespace content | 242 } // namespace content |
OLD | NEW |