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

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

Issue 2894523002: (false positive) Revert of Set render_frame_id while fetching from the dedicated worker ... (Closed)
Patch Set: Created 3 years, 7 months 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
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/command_line.h"
7 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
8 #include "base/logging.h" 7 #include "base/logging.h"
9 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
12 #include "base/sys_info.h" 11 #include "base/sys_info.h"
13 #include "base/test/test_timeouts.h" 12 #include "base/test/test_timeouts.h"
14 #include "build/build_config.h" 13 #include "build/build_config.h"
15 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/client_certificate_delegate.h" 15 #include "content/public/browser/client_certificate_delegate.h"
17 #include "content/public/common/content_features.h"
18 #include "content/public/common/content_paths.h" 16 #include "content/public/common/content_paths.h"
19 #include "content/public/common/content_switches.h"
20 #include "content/public/test/browser_test_utils.h" 17 #include "content/public/test/browser_test_utils.h"
21 #include "content/public/test/content_browser_test.h" 18 #include "content/public/test/content_browser_test.h"
22 #include "content/public/test/content_browser_test_utils.h" 19 #include "content/public/test/content_browser_test_utils.h"
23 #include "content/public/test/test_utils.h" 20 #include "content/public/test/test_utils.h"
24 #include "content/shell/browser/shell.h" 21 #include "content/shell/browser/shell.h"
25 #include "content/shell/browser/shell_content_browser_client.h" 22 #include "content/shell/browser/shell_content_browser_client.h"
26 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" 23 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h"
27 #include "net/base/escape.h" 24 #include "net/base/escape.h"
28 #include "net/ssl/ssl_server_config.h" 25 #include "net/ssl/ssl_server_config.h"
29 #include "net/test/embedded_test_server/embedded_test_server.h" 26 #include "net/test/embedded_test_server/embedded_test_server.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 shell()->LoadURL(url); 98 shell()->LoadURL(url);
102 runner->Run(); 99 runner->Run();
103 } 100 }
104 101
105 private: 102 private:
106 void OnSelectClientCertificate() { select_certificate_count_++; } 103 void OnSelectClientCertificate() { select_certificate_count_++; }
107 104
108 int select_certificate_count_; 105 int select_certificate_count_;
109 }; 106 };
110 107
111 class WorkerFetchTest : public testing::WithParamInterface<bool>,
112 public WorkerTest {
113 public:
114 ~WorkerFetchTest() override {}
115 void SetUpCommandLine(base::CommandLine* command_line) override {
116 if (GetParam()) {
117 command_line->AppendSwitchASCII(switches::kEnableFeatures,
118 features::kOffMainThreadFetch.name);
119 } else {
120 command_line->AppendSwitchASCII(switches::kDisableFeatures,
121 features::kOffMainThreadFetch.name);
122 }
123 }
124 };
125
126 IN_PROC_BROWSER_TEST_F(WorkerTest, SingleWorker) { 108 IN_PROC_BROWSER_TEST_F(WorkerTest, SingleWorker) {
127 RunTest("single_worker.html", std::string()); 109 RunTest("single_worker.html", std::string());
128 } 110 }
129 111
130 IN_PROC_BROWSER_TEST_F(WorkerTest, MultipleWorkers) { 112 IN_PROC_BROWSER_TEST_F(WorkerTest, MultipleWorkers) {
131 RunTest("multi_worker.html", std::string()); 113 RunTest("multi_worker.html", std::string());
132 } 114 }
133 115
134 IN_PROC_BROWSER_TEST_F(WorkerTest, SingleSharedWorker) { 116 IN_PROC_BROWSER_TEST_F(WorkerTest, SingleSharedWorker) {
135 if (!SupportsSharedWorker()) 117 if (!SupportsSharedWorker())
(...skipping 18 matching lines...) Expand all
154 136
155 // Load a non-incognito tab and have it create a shared worker 137 // Load a non-incognito tab and have it create a shared worker
156 RunTest("incognito_worker.html", std::string()); 138 RunTest("incognito_worker.html", std::string());
157 139
158 // Incognito worker should not share with non-incognito 140 // Incognito worker should not share with non-incognito
159 RunTest(CreateOffTheRecordBrowser(), "incognito_worker.html", std::string()); 141 RunTest(CreateOffTheRecordBrowser(), "incognito_worker.html", std::string());
160 } 142 }
161 143
162 // Make sure that auth dialog is displayed from worker context. 144 // Make sure that auth dialog is displayed from worker context.
163 // http://crbug.com/33344 145 // http://crbug.com/33344
164 IN_PROC_BROWSER_TEST_P(WorkerFetchTest, WorkerHttpAuth) { 146 IN_PROC_BROWSER_TEST_F(WorkerTest, WorkerHttpAuth) {
165 ASSERT_TRUE(embedded_test_server()->Start()); 147 ASSERT_TRUE(embedded_test_server()->Start());
166 GURL url = embedded_test_server()->GetURL("/workers/worker_auth.html"); 148 GURL url = embedded_test_server()->GetURL("/workers/worker_auth.html");
167 149
168 NavigateAndWaitForAuth(url); 150 NavigateAndWaitForAuth(url);
169 } 151 }
170 152
171 // Make sure that HTTP auth dialog is displayed from shared worker context. 153 // Make sure that HTTP auth dialog is displayed from shared worker context.
172 // http://crbug.com/33344 154 // http://crbug.com/33344
173 // 155 //
174 // TODO(davidben): HTTP auth dialogs are no longer displayed on shared workers, 156 // TODO(davidben): HTTP auth dialogs are no longer displayed on shared workers,
175 // but this test only tests that the delegate is called. Move handling the 157 // but this test only tests that the delegate is called. Move handling the
176 // WebContentsless case from chrome/ to content/ and adjust the test 158 // WebContentsless case from chrome/ to content/ and adjust the test
177 // accordingly. 159 // accordingly.
178 IN_PROC_BROWSER_TEST_P(WorkerFetchTest, SharedWorkerHttpAuth) { 160 IN_PROC_BROWSER_TEST_F(WorkerTest, SharedWorkerHttpAuth) {
179 if (!SupportsSharedWorker()) 161 if (!SupportsSharedWorker())
180 return; 162 return;
181 163
182 ASSERT_TRUE(embedded_test_server()->Start()); 164 ASSERT_TRUE(embedded_test_server()->Start());
183 GURL url = embedded_test_server()->GetURL("/workers/shared_worker_auth.html"); 165 GURL url = embedded_test_server()->GetURL("/workers/shared_worker_auth.html");
184 NavigateAndWaitForAuth(url); 166 NavigateAndWaitForAuth(url);
185 } 167 }
186 168
187 // Tests that TLS client auth prompts for normal workers's importScripts. 169 // Tests that TLS client auth prompts for normal workers.
188 IN_PROC_BROWSER_TEST_P(WorkerFetchTest, WorkerTlsClientAuthImportScripts) { 170 IN_PROC_BROWSER_TEST_F(WorkerTest, WorkerTlsClientAuth) {
189 // Launch HTTPS server. 171 // Launch HTTPS server.
190 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); 172 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
191 https_server.ServeFilesFromSourceDirectory("content/test/data"); 173 https_server.ServeFilesFromSourceDirectory("content/test/data");
192 net::SSLServerConfig ssl_config; 174 net::SSLServerConfig ssl_config;
193 ssl_config.client_cert_type = 175 ssl_config.client_cert_type =
194 net::SSLServerConfig::ClientCertType::REQUIRE_CLIENT_CERT; 176 net::SSLServerConfig::ClientCertType::REQUIRE_CLIENT_CERT;
195 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_OK, ssl_config); 177 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_OK, ssl_config);
196 ASSERT_TRUE(https_server.Start()); 178 ASSERT_TRUE(https_server.Start());
197 179
198 RunTest("worker_tls_client_auth.html", 180 RunTest("worker_tls_client_auth.html",
199 "test=import&url=" + net::EscapeQueryParamValue( 181 "url=" + net::EscapeQueryParamValue(https_server.GetURL("/").spec(),
200 https_server.GetURL("/").spec(), true)); 182 true));
201 EXPECT_EQ(1, select_certificate_count()); 183 EXPECT_EQ(1, select_certificate_count());
202 } 184 }
203 185
204 // Tests that TLS client auth prompts for normal workers's fetch() call. 186 // Tests that TLS client auth does not prompt for a shared worker; shared
205 IN_PROC_BROWSER_TEST_P(WorkerFetchTest, WorkerTlsClientAuthFetch) { 187 // workers are not associated with a WebContents.
188 IN_PROC_BROWSER_TEST_F(WorkerTest, SharedWorkerTlsClientAuth) {
189 if (!SupportsSharedWorker())
190 return;
191
206 // Launch HTTPS server. 192 // Launch HTTPS server.
207 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); 193 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
208 https_server.ServeFilesFromSourceDirectory("content/test/data"); 194 https_server.ServeFilesFromSourceDirectory("content/test/data");
209 net::SSLServerConfig ssl_config; 195 net::SSLServerConfig ssl_config;
210 ssl_config.client_cert_type = 196 ssl_config.client_cert_type =
211 net::SSLServerConfig::ClientCertType::REQUIRE_CLIENT_CERT; 197 net::SSLServerConfig::ClientCertType::REQUIRE_CLIENT_CERT;
212 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_OK, ssl_config); 198 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_OK, ssl_config);
213 ASSERT_TRUE(https_server.Start()); 199 ASSERT_TRUE(https_server.Start());
214 200
215 RunTest("worker_tls_client_auth.html", 201 RunTest("worker_tls_client_auth.html",
216 "test=fetch&url=" + net::EscapeQueryParamValue( 202 "shared=true&url=" + net::EscapeQueryParamValue(
217 https_server.GetURL("/").spec(), true)); 203 https_server.GetURL("/").spec(), true));
218 EXPECT_EQ(1, select_certificate_count());
219 }
220
221 // Tests that TLS client auth does not prompt for a shared worker; shared
222 // workers are not associated with a WebContents.
223 IN_PROC_BROWSER_TEST_P(WorkerFetchTest,
224 SharedWorkerTlsClientAuthImportScripts) {
225 if (!SupportsSharedWorker())
226 return;
227
228 // Launch HTTPS server.
229 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
230 https_server.ServeFilesFromSourceDirectory("content/test/data");
231 net::SSLServerConfig ssl_config;
232 ssl_config.client_cert_type =
233 net::SSLServerConfig::ClientCertType::REQUIRE_CLIENT_CERT;
234 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_OK, ssl_config);
235 ASSERT_TRUE(https_server.Start());
236
237 RunTest(
238 "worker_tls_client_auth.html",
239 "test=import&shared=true&url=" +
240 net::EscapeQueryParamValue(https_server.GetURL("/").spec(), true));
241 EXPECT_EQ(0, select_certificate_count()); 204 EXPECT_EQ(0, select_certificate_count());
242 } 205 }
243 206
244 IN_PROC_BROWSER_TEST_F(WorkerTest, WebSocketSharedWorker) { 207 IN_PROC_BROWSER_TEST_F(WorkerTest, WebSocketSharedWorker) {
245 if (!SupportsSharedWorker()) 208 if (!SupportsSharedWorker())
246 return; 209 return;
247 210
248 // Launch WebSocket server. 211 // Launch WebSocket server.
249 net::SpawnedTestServer ws_server(net::SpawnedTestServer::TYPE_WS, 212 net::SpawnedTestServer ws_server(net::SpawnedTestServer::TYPE_WS,
250 net::SpawnedTestServer::kLocalhost, 213 net::SpawnedTestServer::kLocalhost,
(...skipping 23 matching lines...) Expand all
274 } 237 }
275 238
276 IN_PROC_BROWSER_TEST_F(WorkerTest, 239 IN_PROC_BROWSER_TEST_F(WorkerTest,
277 PassMessagePortToSharedWorkerDontWaitForConnect) { 240 PassMessagePortToSharedWorkerDontWaitForConnect) {
278 if (!SupportsSharedWorker()) 241 if (!SupportsSharedWorker())
279 return; 242 return;
280 243
281 RunTest("pass_messageport_to_sharedworker_dont_wait_for_connect.html", ""); 244 RunTest("pass_messageport_to_sharedworker_dont_wait_for_connect.html", "");
282 } 245 }
283 246
284 INSTANTIATE_TEST_CASE_P(/* no prefix */,
285 WorkerFetchTest,
286 ::testing::Values(true, false));
287
288 } // namespace content 247 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698