| 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" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 : ws_server_(net::SpawnedTestServer::TYPE_WS, | 31 : ws_server_(net::SpawnedTestServer::TYPE_WS, |
| 32 net::SpawnedTestServer::kLocalhost, | 32 net::SpawnedTestServer::kLocalhost, |
| 33 net::GetWebSocketTestDataDirectory()), | 33 net::GetWebSocketTestDataDirectory()), |
| 34 wss_server_(net::SpawnedTestServer::TYPE_WSS, | 34 wss_server_(net::SpawnedTestServer::TYPE_WSS, |
| 35 SSLOptions(SSLOptions::CERT_OK), | 35 SSLOptions(SSLOptions::CERT_OK), |
| 36 net::GetWebSocketTestDataDirectory()) {} | 36 net::GetWebSocketTestDataDirectory()) {} |
| 37 | 37 |
| 38 protected: | 38 protected: |
| 39 void NavigateToHTTP(const std::string& path) { | 39 void NavigateToHTTP(const std::string& path) { |
| 40 // Visit a HTTP page for testing. | 40 // Visit a HTTP page for testing. |
| 41 std::string scheme("http"); | |
| 42 GURL::Replacements replacements; | 41 GURL::Replacements replacements; |
| 43 replacements.SetSchemeStr(scheme); | 42 replacements.SetSchemeStr("http"); |
| 44 ui_test_utils::NavigateToURL( | 43 ui_test_utils::NavigateToURL( |
| 45 browser(), ws_server_.GetURL(path).ReplaceComponents(replacements)); | 44 browser(), ws_server_.GetURL(path).ReplaceComponents(replacements)); |
| 46 } | 45 } |
| 47 | 46 |
| 48 void NavigateToHTTPS(const std::string& path) { | 47 void NavigateToHTTPS(const std::string& path) { |
| 49 // Visit a HTTPS page for testing. | 48 // Visit a HTTPS page for testing. |
| 50 std::string scheme("https"); | |
| 51 GURL::Replacements replacements; | 49 GURL::Replacements replacements; |
| 52 replacements.SetSchemeStr(scheme); | 50 replacements.SetSchemeStr("https"); |
| 53 ui_test_utils::NavigateToURL( | 51 ui_test_utils::NavigateToURL( |
| 54 browser(), wss_server_.GetURL(path).ReplaceComponents(replacements)); | 52 browser(), wss_server_.GetURL(path).ReplaceComponents(replacements)); |
| 55 } | 53 } |
| 56 | 54 |
| 57 // Prepare the title watcher. | 55 // Prepare the title watcher. |
| 58 void SetUpOnMainThread() override { | 56 void SetUpOnMainThread() override { |
| 59 watcher_.reset(new content::TitleWatcher( | 57 watcher_.reset(new content::TitleWatcher( |
| 60 browser()->tab_strip_model()->GetActiveWebContents(), | 58 browser()->tab_strip_model()->GetActiveWebContents(), |
| 61 base::ASCIIToUTF16("PASS"))); | 59 base::ASCIIToUTF16("PASS"))); |
| 62 watcher_->AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); | 60 watcher_->AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 NavigateToHTTP("count_connection.html"); | 195 NavigateToHTTP("count_connection.html"); |
| 198 EXPECT_EQ("PASS", WaitAndGetTitle()); | 196 EXPECT_EQ("PASS", WaitAndGetTitle()); |
| 199 } | 197 } |
| 200 | 198 |
| 201 IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, WebSocketBasicAuthInHTTPURL) { | 199 IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, WebSocketBasicAuthInHTTPURL) { |
| 202 // Launch a basic-auth-protected WebSocket server. | 200 // Launch a basic-auth-protected WebSocket server. |
| 203 ws_server_.set_websocket_basic_auth(true); | 201 ws_server_.set_websocket_basic_auth(true); |
| 204 ASSERT_TRUE(ws_server_.Start()); | 202 ASSERT_TRUE(ws_server_.Start()); |
| 205 | 203 |
| 206 // Open connect_check.html via HTTP with credentials in the URL. | 204 // Open connect_check.html via HTTP with credentials in the URL. |
| 207 std::string scheme("http"); | |
| 208 GURL::Replacements replacements; | 205 GURL::Replacements replacements; |
| 209 replacements.SetSchemeStr(scheme); | 206 replacements.SetSchemeStr("http"); |
| 210 ui_test_utils::NavigateToURL( | 207 ui_test_utils::NavigateToURL( |
| 211 browser(), | 208 browser(), |
| 212 ws_server_.GetURLWithUserAndPassword("connect_check.html", "test", "test") | 209 ws_server_.GetURLWithUserAndPassword("connect_check.html", "test", "test") |
| 213 .ReplaceComponents(replacements)); | 210 .ReplaceComponents(replacements)); |
| 214 | 211 |
| 215 EXPECT_EQ("PASS", WaitAndGetTitle()); | 212 EXPECT_EQ("PASS", WaitAndGetTitle()); |
| 216 } | 213 } |
| 217 | 214 |
| 218 IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, WebSocketBasicAuthInHTTPSURL) { | 215 IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, WebSocketBasicAuthInHTTPSURL) { |
| 219 // Launch a basic-auth-protected secure WebSocket server. | 216 // Launch a basic-auth-protected secure WebSocket server. |
| 220 wss_server_.set_websocket_basic_auth(true); | 217 wss_server_.set_websocket_basic_auth(true); |
| 221 ASSERT_TRUE(wss_server_.Start()); | 218 ASSERT_TRUE(wss_server_.Start()); |
| 222 | 219 |
| 223 // Open connect_check.html via HTTPS with credentials in the URL. | 220 // Open connect_check.html via HTTPS with credentials in the URL. |
| 224 std::string scheme("https"); | |
| 225 GURL::Replacements replacements; | 221 GURL::Replacements replacements; |
| 226 replacements.SetSchemeStr(scheme); | 222 replacements.SetSchemeStr("https"); |
| 227 ui_test_utils::NavigateToURL( | 223 ui_test_utils::NavigateToURL( |
| 228 browser(), | 224 browser(), |
| 229 wss_server_.GetURLWithUserAndPassword( | 225 wss_server_.GetURLWithUserAndPassword( |
| 230 "connect_check.html", "test", "test") | 226 "connect_check.html", "test", "test") |
| 231 .ReplaceComponents(replacements)); | 227 .ReplaceComponents(replacements)); |
| 232 | 228 |
| 233 EXPECT_EQ("PASS", WaitAndGetTitle()); | 229 EXPECT_EQ("PASS", WaitAndGetTitle()); |
| 234 } | 230 } |
| 235 | 231 |
| 236 // This test verifies that login details entered by the user into the login | 232 // This test verifies that login details entered by the user into the login |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 // Blink layout tests, and browser tests are expensive to run. | 290 // Blink layout tests, and browser tests are expensive to run. |
| 295 IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, SSLConnectionLimit) { | 291 IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, SSLConnectionLimit) { |
| 296 ASSERT_TRUE(wss_server_.Start()); | 292 ASSERT_TRUE(wss_server_.Start()); |
| 297 | 293 |
| 298 NavigateToHTTPS("multiple-connections.html"); | 294 NavigateToHTTPS("multiple-connections.html"); |
| 299 | 295 |
| 300 EXPECT_EQ("PASS", WaitAndGetTitle()); | 296 EXPECT_EQ("PASS", WaitAndGetTitle()); |
| 301 } | 297 } |
| 302 | 298 |
| 303 } // namespace | 299 } // namespace |
| OLD | NEW |