OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/login/login_prompt.h" | 11 #include "chrome/browser/ui/login/login_prompt.h" |
| 12 #include "chrome/browser/ui/login/login_prompt_test_utils.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
13 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
15 #include "content/public/browser/navigation_controller.h" | 16 #include "content/public/browser/navigation_controller.h" |
16 #include "content/public/browser/notification_details.h" | 17 #include "content/public/browser/notification_details.h" |
17 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
18 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
20 #include "content/public/test/browser_test_utils.h" | 21 #include "content/public/test/browser_test_utils.h" |
21 #include "net/base/test_data_directory.h" | 22 #include "net/base/test_data_directory.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 wss_server_.GetURLWithUserAndPassword( | 229 wss_server_.GetURLWithUserAndPassword( |
229 "connect_check.html", "test", "test") | 230 "connect_check.html", "test", "test") |
230 .ReplaceComponents(replacements)); | 231 .ReplaceComponents(replacements)); |
231 | 232 |
232 EXPECT_EQ("PASS", WaitAndGetTitle()); | 233 EXPECT_EQ("PASS", WaitAndGetTitle()); |
233 } | 234 } |
234 | 235 |
235 // This test verifies that login details entered by the user into the login | 236 // This test verifies that login details entered by the user into the login |
236 // prompt to authenticate the main page are re-used for WebSockets from the same | 237 // prompt to authenticate the main page are re-used for WebSockets from the same |
237 // origin. | 238 // origin. |
238 IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, WebSocketBasicAuthPrompt) { | 239 IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, |
| 240 ReuseMainPageBasicAuthCredentialsForWebSocket) { |
239 // Launch a basic-auth-protected WebSocket server. | 241 // Launch a basic-auth-protected WebSocket server. |
240 ws_server_.set_websocket_basic_auth(true); | 242 ws_server_.set_websocket_basic_auth(true); |
241 ASSERT_TRUE(ws_server_.Start()); | 243 ASSERT_TRUE(ws_server_.Start()); |
242 | 244 |
243 content::NavigationController* navigation_controller = | 245 content::NavigationController* navigation_controller = |
244 &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); | 246 &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); |
245 AutoLogin auto_login("test", "test", navigation_controller); | 247 AutoLogin auto_login("test", "test", navigation_controller); |
246 | 248 |
| 249 WindowedAuthNeededObserver auth_needed_waiter(navigation_controller); |
247 NavigateToHTTP("connect_check.html"); | 250 NavigateToHTTP("connect_check.html"); |
| 251 auth_needed_waiter.Wait(); |
248 | 252 |
249 EXPECT_TRUE(auto_login.logged_in()); | 253 EXPECT_TRUE(auto_login.logged_in()); |
250 EXPECT_EQ("PASS", WaitAndGetTitle()); | 254 EXPECT_EQ("PASS", WaitAndGetTitle()); |
251 } | 255 } |
252 | 256 |
253 IN_PROC_BROWSER_TEST_F(WebSocketBrowserConnectToTest, | 257 IN_PROC_BROWSER_TEST_F(WebSocketBrowserConnectToTest, |
254 WebSocketBasicAuthInWSURL) { | 258 WebSocketBasicAuthInWSURL) { |
255 // Launch a basic-auth-protected WebSocket server. | 259 // Launch a basic-auth-protected WebSocket server. |
256 ws_server_.set_websocket_basic_auth(true); | 260 ws_server_.set_websocket_basic_auth(true); |
257 ASSERT_TRUE(ws_server_.Start()); | 261 ASSERT_TRUE(ws_server_.Start()); |
(...skipping 21 matching lines...) Expand all Loading... |
279 // Launch a basic-auth-protected WebSocket server. | 283 // Launch a basic-auth-protected WebSocket server. |
280 ws_server_.set_websocket_basic_auth(true); | 284 ws_server_.set_websocket_basic_auth(true); |
281 ASSERT_TRUE(ws_server_.Start()); | 285 ASSERT_TRUE(ws_server_.Start()); |
282 | 286 |
283 ConnectTo(ws_server_.GetURL("echo-with-no-extension")); | 287 ConnectTo(ws_server_.GetURL("echo-with-no-extension")); |
284 | 288 |
285 EXPECT_EQ("FAIL", WaitAndGetTitle()); | 289 EXPECT_EQ("FAIL", WaitAndGetTitle()); |
286 } | 290 } |
287 | 291 |
288 } // namespace | 292 } // namespace |
OLD | NEW |