Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: content/browser/shared_worker/worker_browsertest.cc

Issue 1411073005: Migrating tests to use EmbeddedTestServer (/content) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/sys_info.h" 11 #include "base/sys_info.h"
12 #include "base/test/test_timeouts.h" 12 #include "base/test/test_timeouts.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/client_certificate_delegate.h" 14 #include "content/public/browser/client_certificate_delegate.h"
15 #include "content/public/common/content_paths.h" 15 #include "content/public/common/content_paths.h"
16 #include "content/public/test/browser_test_utils.h" 16 #include "content/public/test/browser_test_utils.h"
17 #include "content/public/test/content_browser_test.h" 17 #include "content/public/test/content_browser_test.h"
18 #include "content/public/test/content_browser_test_utils.h" 18 #include "content/public/test/content_browser_test_utils.h"
19 #include "content/public/test/test_utils.h" 19 #include "content/public/test/test_utils.h"
20 #include "content/shell/browser/shell.h" 20 #include "content/shell/browser/shell.h"
21 #include "content/shell/browser/shell_content_browser_client.h" 21 #include "content/shell/browser/shell_content_browser_client.h"
22 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" 22 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h"
23 #include "net/base/escape.h" 23 #include "net/base/escape.h"
24 #include "net/base/test_data_directory.h" 24 #include "net/base/test_data_directory.h"
25 #include "net/ssl/ssl_server_config.h"
26 #include "net/test/embedded_test_server/embedded_test_server.h"
25 #include "net/test/spawned_test_server/spawned_test_server.h" 27 #include "net/test/spawned_test_server/spawned_test_server.h"
26 #include "url/gurl.h" 28 #include "url/gurl.h"
27 29
28 namespace content { 30 namespace content {
29 31
30 namespace { 32 namespace {
31 33
32 bool SupportsSharedWorker() { 34 bool SupportsSharedWorker() {
33 #if defined(OS_ANDROID) 35 #if defined(OS_ANDROID)
34 // SharedWorkers are not enabled on Android. https://crbug.com/154571 36 // SharedWorkers are not enabled on Android. https://crbug.com/154571
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // Load a non-incognito tab and have it create a shared worker 136 // Load a non-incognito tab and have it create a shared worker
135 RunTest("incognito_worker.html", std::string()); 137 RunTest("incognito_worker.html", std::string());
136 138
137 // Incognito worker should not share with non-incognito 139 // Incognito worker should not share with non-incognito
138 RunTest(CreateOffTheRecordBrowser(), "incognito_worker.html", std::string()); 140 RunTest(CreateOffTheRecordBrowser(), "incognito_worker.html", std::string());
139 } 141 }
140 142
141 // Make sure that auth dialog is displayed from worker context. 143 // Make sure that auth dialog is displayed from worker context.
142 // http://crbug.com/33344 144 // http://crbug.com/33344
143 IN_PROC_BROWSER_TEST_F(WorkerTest, WorkerHttpAuth) { 145 IN_PROC_BROWSER_TEST_F(WorkerTest, WorkerHttpAuth) {
144 ASSERT_TRUE(test_server()->Start()); 146 ASSERT_TRUE(embedded_test_server()->Start());
145 GURL url = test_server()->GetURL("files/workers/worker_auth.html"); 147 GURL url = embedded_test_server()->GetURL("/workers/worker_auth.html");
146 148
147 NavigateAndWaitForAuth(url); 149 NavigateAndWaitForAuth(url);
148 } 150 }
149 151
150 // Make sure that HTTP auth dialog is displayed from shared worker context. 152 // Make sure that HTTP auth dialog is displayed from shared worker context.
151 // http://crbug.com/33344 153 // http://crbug.com/33344
152 // 154 //
153 // TODO(davidben): HTTP auth dialogs are no longer displayed on shared workers, 155 // TODO(davidben): HTTP auth dialogs are no longer displayed on shared workers,
154 // but this test only tests that the delegate is called. Move handling the 156 // but this test only tests that the delegate is called. Move handling the
155 // WebContentsless case from chrome/ to content/ and adjust the test 157 // WebContentsless case from chrome/ to content/ and adjust the test
156 // accordingly. 158 // accordingly.
157 IN_PROC_BROWSER_TEST_F(WorkerTest, SharedWorkerHttpAuth) { 159 IN_PROC_BROWSER_TEST_F(WorkerTest, SharedWorkerHttpAuth) {
158 if (!SupportsSharedWorker()) 160 if (!SupportsSharedWorker())
159 return; 161 return;
160 162
161 ASSERT_TRUE(test_server()->Start()); 163 ASSERT_TRUE(embedded_test_server()->Start());
162 GURL url = test_server()->GetURL("files/workers/shared_worker_auth.html"); 164 GURL url = embedded_test_server()->GetURL("/workers/shared_worker_auth.html");
163 NavigateAndWaitForAuth(url); 165 NavigateAndWaitForAuth(url);
164 } 166 }
165 167
166 // Tests that TLS client auth prompts for normal workers. 168 // Tests that TLS client auth prompts for normal workers.
167 IN_PROC_BROWSER_TEST_F(WorkerTest, WorkerTlsClientAuth) { 169 IN_PROC_BROWSER_TEST_F(WorkerTest, WorkerTlsClientAuth) {
168 // Launch HTTPS server. 170 // Launch HTTPS server.
169 net::SpawnedTestServer::SSLOptions ssl_options; 171 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
170 ssl_options.request_client_certificate = true; 172 https_server.ServeFilesFromSourceDirectory("content/test/data");
171 net::SpawnedTestServer https_server( 173 net::SSLServerConfig ssl_config;
172 net::SpawnedTestServer::TYPE_HTTPS, ssl_options, 174 ssl_config.require_client_cert = true;
173 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); 175 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_OK, ssl_config);
174 ASSERT_TRUE(https_server.Start()); 176 ASSERT_TRUE(https_server.Start());
175 177
176 RunTest("worker_tls_client_auth.html", 178 RunTest("worker_tls_client_auth.html",
177 "url=" + 179 "url=" + net::EscapeQueryParamValue(https_server.GetURL("/").spec(),
178 net::EscapeQueryParamValue(https_server.GetURL("").spec(), true)); 180 true));
179 EXPECT_EQ(1, select_certificate_count()); 181 EXPECT_EQ(1, select_certificate_count());
180 } 182 }
181 183
182 // Tests that TLS client auth does not prompt for a shared worker; shared 184 // Tests that TLS client auth does not prompt for a shared worker; shared
183 // workers are not associated with a WebContents. 185 // workers are not associated with a WebContents.
184 IN_PROC_BROWSER_TEST_F(WorkerTest, SharedWorkerTlsClientAuth) { 186 IN_PROC_BROWSER_TEST_F(WorkerTest, SharedWorkerTlsClientAuth) {
185 if (!SupportsSharedWorker()) 187 if (!SupportsSharedWorker())
186 return; 188 return;
187 189
188 // Launch HTTPS server. 190 // Launch HTTPS server.
189 net::SpawnedTestServer::SSLOptions ssl_options; 191 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
190 ssl_options.request_client_certificate = true; 192 https_server.ServeFilesFromSourceDirectory("content/test/data");
191 net::SpawnedTestServer https_server( 193 net::SSLServerConfig ssl_config;
192 net::SpawnedTestServer::TYPE_HTTPS, ssl_options, 194 ssl_config.require_client_cert = true;
193 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); 195 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_OK, ssl_config);
194 ASSERT_TRUE(https_server.Start()); 196 ASSERT_TRUE(https_server.Start());
195 197
196 RunTest("worker_tls_client_auth.html", 198 RunTest("worker_tls_client_auth.html",
197 "shared=true&url=" + 199 "shared=true&url=" + net::EscapeQueryParamValue(
198 net::EscapeQueryParamValue(https_server.GetURL("").spec(), true)); 200 https_server.GetURL("/").spec(), true));
199 EXPECT_EQ(0, select_certificate_count()); 201 EXPECT_EQ(0, select_certificate_count());
200 } 202 }
201 203
202 IN_PROC_BROWSER_TEST_F(WorkerTest, WebSocketSharedWorker) { 204 IN_PROC_BROWSER_TEST_F(WorkerTest, WebSocketSharedWorker) {
203 if (!SupportsSharedWorker()) 205 if (!SupportsSharedWorker())
204 return; 206 return;
205 207
206 // Launch WebSocket server. 208 // Launch WebSocket server.
207 net::SpawnedTestServer ws_server(net::SpawnedTestServer::TYPE_WS, 209 net::SpawnedTestServer ws_server(net::SpawnedTestServer::TYPE_WS,
208 net::SpawnedTestServer::kLocalhost, 210 net::SpawnedTestServer::kLocalhost,
(...skipping 24 matching lines...) Expand all
233 235
234 IN_PROC_BROWSER_TEST_F(WorkerTest, 236 IN_PROC_BROWSER_TEST_F(WorkerTest,
235 PassMessagePortToSharedWorkerDontWaitForConnect) { 237 PassMessagePortToSharedWorkerDontWaitForConnect) {
236 if (!SupportsSharedWorker()) 238 if (!SupportsSharedWorker())
237 return; 239 return;
238 240
239 RunTest("pass_messageport_to_sharedworker_dont_wait_for_connect.html", ""); 241 RunTest("pass_messageport_to_sharedworker_dont_wait_for_connect.html", "");
240 } 242 }
241 243
242 } // namespace content 244 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/session_history_browsertest.cc ('k') | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698