Chromium Code Reviews| 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/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/macros.h" | 7 #include "base/macros.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 "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/login/login_handler.h" | 14 #include "chrome/browser/ui/login/login_handler.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 16 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
| 17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
| 19 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
| 20 #include "content/public/browser/notification_details.h" | 20 #include "content/public/browser/notification_details.h" |
| 21 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
| 22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/browser/web_contents_observer.h" | 23 #include "content/public/browser/web_contents_observer.h" |
| 24 #include "content/public/common/content_switches.h" | |
|
hush (inactive)
2016/09/09 22:24:16
Except for this line, are the changes in the file
Nate Fischer
2016/09/09 22:55:31
Whoops! I think that was generated by "clang-forma
| |
| 24 #include "content/public/test/browser_test_utils.h" | 25 #include "content/public/test/browser_test_utils.h" |
| 25 #include "net/test/embedded_test_server/embedded_test_server.h" | 26 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 26 #include "net/test/spawned_test_server/spawned_test_server.h" | 27 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 27 #include "net/test/test_data_directory.h" | 28 #include "net/test/test_data_directory.h" |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 // PAC script that sends all requests to an invalid proxy server. | 32 // PAC script that sends all requests to an invalid proxy server. |
| 32 const base::FilePath::CharType kPACScript[] = FILE_PATH_LITERAL( | 33 const base::FilePath::CharType kPACScript[] = |
| 33 "bad_server.pac"); | 34 FILE_PATH_LITERAL("bad_server.pac"); |
| 34 | 35 |
| 35 // Verify kPACScript is installed as the PAC script. | 36 // Verify kPACScript is installed as the PAC script. |
| 36 void VerifyProxyScript(Browser* browser) { | 37 void VerifyProxyScript(Browser* browser) { |
| 37 ui_test_utils::NavigateToURL(browser, GURL("http://google.com")); | 38 ui_test_utils::NavigateToURL(browser, GURL("http://google.com")); |
| 38 | 39 |
| 39 // Verify we get the ERR_PROXY_CONNECTION_FAILED screen. | 40 // Verify we get the ERR_PROXY_CONNECTION_FAILED screen. |
| 40 bool result = false; | 41 bool result = false; |
| 41 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 42 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 42 browser->tab_strip_model()->GetActiveWebContents(), | 43 browser->tab_strip_model()->GetActiveWebContents(), |
| 43 "var textContent = document.body.textContent;" | 44 "var textContent = document.body.textContent;" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 74 bool auth_handled_; | 75 bool auth_handled_; |
| 75 | 76 |
| 76 DISALLOW_COPY_AND_ASSIGN(LoginPromptObserver); | 77 DISALLOW_COPY_AND_ASSIGN(LoginPromptObserver); |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 class ProxyBrowserTest : public InProcessBrowserTest { | 80 class ProxyBrowserTest : public InProcessBrowserTest { |
| 80 public: | 81 public: |
| 81 ProxyBrowserTest() | 82 ProxyBrowserTest() |
| 82 : proxy_server_(net::SpawnedTestServer::TYPE_BASIC_AUTH_PROXY, | 83 : proxy_server_(net::SpawnedTestServer::TYPE_BASIC_AUTH_PROXY, |
| 83 net::SpawnedTestServer::kLocalhost, | 84 net::SpawnedTestServer::kLocalhost, |
| 84 base::FilePath()) { | 85 base::FilePath()) {} |
| 85 } | |
| 86 | 86 |
| 87 void SetUp() override { | 87 void SetUp() override { |
| 88 ASSERT_TRUE(proxy_server_.Start()); | 88 ASSERT_TRUE(proxy_server_.Start()); |
| 89 InProcessBrowserTest::SetUp(); | 89 InProcessBrowserTest::SetUp(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void SetUpCommandLine(base::CommandLine* command_line) override { | 92 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 93 command_line->AppendSwitchASCII(switches::kProxyServer, | 93 command_line->AppendSwitchASCII(switches::kProxyServer, |
| 94 proxy_server_.host_port_pair().ToString()); | 94 proxy_server_.host_port_pair().ToString()); |
| 95 } | 95 } |
| 96 | 96 |
| 97 protected: | 97 protected: |
| 98 net::SpawnedTestServer proxy_server_; | 98 net::SpawnedTestServer proxy_server_; |
| 99 | 99 |
| 100 private: | 100 private: |
| 101 | |
| 102 DISALLOW_COPY_AND_ASSIGN(ProxyBrowserTest); | 101 DISALLOW_COPY_AND_ASSIGN(ProxyBrowserTest); |
| 103 }; | 102 }; |
| 104 | 103 |
| 105 #if defined(OS_CHROMEOS) | 104 #if defined(OS_CHROMEOS) |
| 106 // We bypass manually installed proxy for localhost on chromeos. | 105 // We bypass manually installed proxy for localhost on chromeos. |
| 107 #define MAYBE_BasicAuthWSConnect DISABLED_BasicAuthWSConnect | 106 #define MAYBE_BasicAuthWSConnect DISABLED_BasicAuthWSConnect |
| 108 #else | 107 #else |
| 109 #define MAYBE_BasicAuthWSConnect BasicAuthWSConnect | 108 #define MAYBE_BasicAuthWSConnect BasicAuthWSConnect |
| 110 #endif | 109 #endif |
| 111 // Test that the browser can establish a WebSocket connection via a proxy | 110 // Test that the browser can establish a WebSocket connection via a proxy |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 } | 151 } |
| 153 ~HttpProxyScriptBrowserTest() override {} | 152 ~HttpProxyScriptBrowserTest() override {} |
| 154 | 153 |
| 155 void SetUp() override { | 154 void SetUp() override { |
| 156 ASSERT_TRUE(http_server_.Start()); | 155 ASSERT_TRUE(http_server_.Start()); |
| 157 InProcessBrowserTest::SetUp(); | 156 InProcessBrowserTest::SetUp(); |
| 158 } | 157 } |
| 159 | 158 |
| 160 void SetUpCommandLine(base::CommandLine* command_line) override { | 159 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 161 base::FilePath pac_script_path(FILE_PATH_LITERAL("/")); | 160 base::FilePath pac_script_path(FILE_PATH_LITERAL("/")); |
| 162 command_line->AppendSwitchASCII(switches::kProxyPacUrl, http_server_.GetURL( | 161 command_line->AppendSwitchASCII( |
| 163 pac_script_path.Append(kPACScript).MaybeAsASCII()).spec()); | 162 switches::kProxyPacUrl, |
| 163 http_server_.GetURL(pac_script_path.Append(kPACScript).MaybeAsASCII()) | |
| 164 .spec()); | |
| 164 } | 165 } |
| 165 | 166 |
| 166 private: | 167 private: |
| 167 net::EmbeddedTestServer http_server_; | 168 net::EmbeddedTestServer http_server_; |
| 168 | 169 |
| 169 DISALLOW_COPY_AND_ASSIGN(HttpProxyScriptBrowserTest); | 170 DISALLOW_COPY_AND_ASSIGN(HttpProxyScriptBrowserTest); |
| 170 }; | 171 }; |
| 171 | 172 |
| 172 IN_PROC_BROWSER_TEST_F(HttpProxyScriptBrowserTest, Verify) { | 173 IN_PROC_BROWSER_TEST_F(HttpProxyScriptBrowserTest, Verify) { |
| 173 VerifyProxyScript(browser()); | 174 VerifyProxyScript(browser()); |
| 174 } | 175 } |
| 175 | 176 |
| 176 // Fetch PAC script via a file:// URL. | 177 // Fetch PAC script via a file:// URL. |
| 177 class FileProxyScriptBrowserTest : public InProcessBrowserTest { | 178 class FileProxyScriptBrowserTest : public InProcessBrowserTest { |
| 178 public: | 179 public: |
| 179 FileProxyScriptBrowserTest() {} | 180 FileProxyScriptBrowserTest() {} |
| 180 ~FileProxyScriptBrowserTest() override {} | 181 ~FileProxyScriptBrowserTest() override {} |
| 181 | 182 |
| 182 void SetUpCommandLine(base::CommandLine* command_line) override { | 183 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 183 command_line->AppendSwitchASCII(switches::kProxyPacUrl, | 184 command_line->AppendSwitchASCII( |
| 185 switches::kProxyPacUrl, | |
| 184 ui_test_utils::GetTestUrl( | 186 ui_test_utils::GetTestUrl( |
| 185 base::FilePath(base::FilePath::kCurrentDirectory), | 187 base::FilePath(base::FilePath::kCurrentDirectory), |
| 186 base::FilePath(kPACScript)).spec()); | 188 base::FilePath(kPACScript)) |
| 189 .spec()); | |
| 187 } | 190 } |
| 188 | 191 |
| 189 private: | 192 private: |
| 190 DISALLOW_COPY_AND_ASSIGN(FileProxyScriptBrowserTest); | 193 DISALLOW_COPY_AND_ASSIGN(FileProxyScriptBrowserTest); |
| 191 }; | 194 }; |
| 192 | 195 |
| 193 IN_PROC_BROWSER_TEST_F(FileProxyScriptBrowserTest, Verify) { | 196 IN_PROC_BROWSER_TEST_F(FileProxyScriptBrowserTest, Verify) { |
| 194 VerifyProxyScript(browser()); | 197 VerifyProxyScript(browser()); |
| 195 } | 198 } |
| 196 | 199 |
| 197 // Fetch PAC script via an ftp:// URL. | 200 // Fetch PAC script via an ftp:// URL. |
| 198 class FtpProxyScriptBrowserTest : public InProcessBrowserTest { | 201 class FtpProxyScriptBrowserTest : public InProcessBrowserTest { |
| 199 public: | 202 public: |
| 200 FtpProxyScriptBrowserTest() | 203 FtpProxyScriptBrowserTest() |
| 201 : ftp_server_(net::SpawnedTestServer::TYPE_FTP, | 204 : ftp_server_(net::SpawnedTestServer::TYPE_FTP, |
| 202 net::SpawnedTestServer::kLocalhost, | 205 net::SpawnedTestServer::kLocalhost, |
| 203 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))) { | 206 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))) {} |
| 204 } | |
| 205 ~FtpProxyScriptBrowserTest() override {} | 207 ~FtpProxyScriptBrowserTest() override {} |
| 206 | 208 |
| 207 void SetUp() override { | 209 void SetUp() override { |
| 208 ASSERT_TRUE(ftp_server_.Start()); | 210 ASSERT_TRUE(ftp_server_.Start()); |
| 209 InProcessBrowserTest::SetUp(); | 211 InProcessBrowserTest::SetUp(); |
| 210 } | 212 } |
| 211 | 213 |
| 212 void SetUpCommandLine(base::CommandLine* command_line) override { | 214 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 213 base::FilePath pac_script_path(kPACScript); | 215 base::FilePath pac_script_path(kPACScript); |
| 214 command_line->AppendSwitchASCII( | 216 command_line->AppendSwitchASCII( |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 228 | 230 |
| 229 // Fetch PAC script via a data: URL. | 231 // Fetch PAC script via a data: URL. |
| 230 class DataProxyScriptBrowserTest : public InProcessBrowserTest { | 232 class DataProxyScriptBrowserTest : public InProcessBrowserTest { |
| 231 public: | 233 public: |
| 232 DataProxyScriptBrowserTest() {} | 234 DataProxyScriptBrowserTest() {} |
| 233 ~DataProxyScriptBrowserTest() override {} | 235 ~DataProxyScriptBrowserTest() override {} |
| 234 | 236 |
| 235 void SetUpCommandLine(base::CommandLine* command_line) override { | 237 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 236 std::string contents; | 238 std::string contents; |
| 237 // Read in kPACScript contents. | 239 // Read in kPACScript contents. |
| 238 ASSERT_TRUE(base::ReadFileToString(ui_test_utils::GetTestFilePath( | 240 ASSERT_TRUE(base::ReadFileToString( |
| 239 base::FilePath(base::FilePath::kCurrentDirectory), | 241 ui_test_utils::GetTestFilePath( |
| 240 base::FilePath(kPACScript)), | 242 base::FilePath(base::FilePath::kCurrentDirectory), |
| 243 base::FilePath(kPACScript)), | |
| 241 &contents)); | 244 &contents)); |
| 242 command_line->AppendSwitchASCII(switches::kProxyPacUrl, | 245 command_line->AppendSwitchASCII(switches::kProxyPacUrl, |
| 243 std::string("data:,") + contents); | 246 std::string("data:,") + contents); |
| 244 } | 247 } |
| 245 | 248 |
| 246 private: | 249 private: |
| 247 DISALLOW_COPY_AND_ASSIGN(DataProxyScriptBrowserTest); | 250 DISALLOW_COPY_AND_ASSIGN(DataProxyScriptBrowserTest); |
| 248 }; | 251 }; |
| 249 | 252 |
| 250 IN_PROC_BROWSER_TEST_F(DataProxyScriptBrowserTest, Verify) { | 253 IN_PROC_BROWSER_TEST_F(DataProxyScriptBrowserTest, Verify) { |
| 251 VerifyProxyScript(browser()); | 254 VerifyProxyScript(browser()); |
| 252 } | 255 } |
| 253 | 256 |
| 254 // Fetch PAC script via a data: URL and run out-of-process using Mojo. | 257 // Fetch PAC script via a data: URL and run out-of-process using Mojo. |
| 255 class OutOfProcessProxyResolverBrowserTest : public InProcessBrowserTest { | 258 class OutOfProcessProxyResolverBrowserTest : public InProcessBrowserTest { |
| 256 public: | 259 public: |
| 257 OutOfProcessProxyResolverBrowserTest() {} | 260 OutOfProcessProxyResolverBrowserTest() {} |
| 258 ~OutOfProcessProxyResolverBrowserTest() override {} | 261 ~OutOfProcessProxyResolverBrowserTest() override {} |
| 259 | 262 |
| 260 void SetUpCommandLine(base::CommandLine* command_line) override { | 263 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 261 std::string contents; | 264 std::string contents; |
| 262 // Read in kPACScript contents. | 265 // Read in kPACScript contents. |
| 263 ASSERT_TRUE(base::ReadFileToString(ui_test_utils::GetTestFilePath( | 266 ASSERT_TRUE(base::ReadFileToString( |
| 264 base::FilePath(base::FilePath::kCurrentDirectory), | 267 ui_test_utils::GetTestFilePath( |
| 265 base::FilePath(kPACScript)), | 268 base::FilePath(base::FilePath::kCurrentDirectory), |
| 269 base::FilePath(kPACScript)), | |
| 266 &contents)); | 270 &contents)); |
| 267 command_line->AppendSwitchASCII( | 271 command_line->AppendSwitchASCII(switches::kProxyPacUrl, |
| 268 switches::kProxyPacUrl, "data:," + contents); | 272 "data:," + contents); |
| 269 command_line->AppendSwitch(switches::kV8PacMojoOutOfProcess); | 273 command_line->AppendSwitch(switches::kV8PacMojoOutOfProcess); |
| 270 } | 274 } |
| 271 | 275 |
| 272 private: | 276 private: |
| 273 DISALLOW_COPY_AND_ASSIGN(OutOfProcessProxyResolverBrowserTest); | 277 DISALLOW_COPY_AND_ASSIGN(OutOfProcessProxyResolverBrowserTest); |
| 274 }; | 278 }; |
| 275 | 279 |
| 276 IN_PROC_BROWSER_TEST_F(OutOfProcessProxyResolverBrowserTest, Verify) { | 280 IN_PROC_BROWSER_TEST_F(OutOfProcessProxyResolverBrowserTest, Verify) { |
| 277 VerifyProxyScript(browser()); | 281 VerifyProxyScript(browser()); |
| 278 } | 282 } |
| 279 | 283 |
| 280 } // namespace | 284 } // namespace |
| OLD | NEW |