| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 bool auth_handled_; | 53 bool auth_handled_; |
| 54 | 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(LoginPromptObserver); | 55 DISALLOW_COPY_AND_ASSIGN(LoginPromptObserver); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 class ProxyBrowserTest : public InProcessBrowserTest { | 58 class ProxyBrowserTest : public InProcessBrowserTest { |
| 59 public: | 59 public: |
| 60 ProxyBrowserTest() | 60 ProxyBrowserTest() |
| 61 : proxy_server_(net::TestServer::TYPE_BASIC_AUTH_PROXY, | 61 : proxy_server_(net::TestServer::TYPE_BASIC_AUTH_PROXY, |
| 62 net::TestServer::kLocalhost, | 62 net::TestServer::kLocalhost, |
| 63 base::FilePath()) { | 63 net::TestServer::GetSourcePath()) { |
| 64 } | 64 } |
| 65 | 65 |
| 66 virtual void SetUp() OVERRIDE { | 66 virtual void SetUp() OVERRIDE { |
| 67 ASSERT_TRUE(proxy_server_.Start()); | 67 ASSERT_TRUE(proxy_server_.Start()); |
| 68 InProcessBrowserTest::SetUp(); | 68 InProcessBrowserTest::SetUp(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 71 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 72 command_line->AppendSwitchASCII(switches::kProxyServer, | 72 command_line->AppendSwitchASCII(switches::kProxyServer, |
| 73 proxy_server_.host_port_pair().ToString()); | 73 proxy_server_.host_port_pair().ToString()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 86 #define MAYBE_BasicAuthWSConnect DISABLED_BasicAuthWSConnect | 86 #define MAYBE_BasicAuthWSConnect DISABLED_BasicAuthWSConnect |
| 87 #else | 87 #else |
| 88 #define MAYBE_BasicAuthWSConnect BasicAuthWSConnect | 88 #define MAYBE_BasicAuthWSConnect BasicAuthWSConnect |
| 89 #endif | 89 #endif |
| 90 // Test that the browser can establish a WebSocket connection via a proxy | 90 // Test that the browser can establish a WebSocket connection via a proxy |
| 91 // that requires basic authentication. | 91 // that requires basic authentication. |
| 92 IN_PROC_BROWSER_TEST_F(ProxyBrowserTest, MAYBE_BasicAuthWSConnect) { | 92 IN_PROC_BROWSER_TEST_F(ProxyBrowserTest, MAYBE_BasicAuthWSConnect) { |
| 93 // Launch WebSocket server. | 93 // Launch WebSocket server. |
| 94 net::TestServer ws_server(net::TestServer::TYPE_WS, | 94 net::TestServer ws_server(net::TestServer::TYPE_WS, |
| 95 net::TestServer::kLocalhost, | 95 net::TestServer::kLocalhost, |
| 96 net::GetWebSocketTestDataDirectory()); | 96 net::TestServer::GetSourceRelativePath( |
| 97 net::GetWebSocketTestDataDirectory())); |
| 97 ASSERT_TRUE(ws_server.Start()); | 98 ASSERT_TRUE(ws_server.Start()); |
| 98 | 99 |
| 99 content::WebContents* tab = | 100 content::WebContents* tab = |
| 100 browser()->tab_strip_model()->GetActiveWebContents(); | 101 browser()->tab_strip_model()->GetActiveWebContents(); |
| 101 content::NavigationController* controller = &tab->GetController(); | 102 content::NavigationController* controller = &tab->GetController(); |
| 102 content::NotificationRegistrar registrar; | 103 content::NotificationRegistrar registrar; |
| 103 // The proxy server will request basic authentication. | 104 // The proxy server will request basic authentication. |
| 104 // |observer| supplies the credential. | 105 // |observer| supplies the credential. |
| 105 LoginPromptObserver observer; | 106 LoginPromptObserver observer; |
| 106 registrar.Add(&observer, chrome::NOTIFICATION_AUTH_NEEDED, | 107 registrar.Add(&observer, chrome::NOTIFICATION_AUTH_NEEDED, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 117 ui_test_utils::NavigateToURL( | 118 ui_test_utils::NavigateToURL( |
| 118 browser(), | 119 browser(), |
| 119 ws_server.GetURL("connect_check.html").ReplaceComponents(replacements)); | 120 ws_server.GetURL("connect_check.html").ReplaceComponents(replacements)); |
| 120 | 121 |
| 121 const string16 result = watcher.WaitAndGetTitle(); | 122 const string16 result = watcher.WaitAndGetTitle(); |
| 122 EXPECT_TRUE(EqualsASCII(result, "PASS")); | 123 EXPECT_TRUE(EqualsASCII(result, "PASS")); |
| 123 EXPECT_TRUE(observer.auth_handled()); | 124 EXPECT_TRUE(observer.auth_handled()); |
| 124 } | 125 } |
| 125 | 126 |
| 126 } // namespace | 127 } // namespace |
| OLD | NEW |