Chromium Code Reviews| Index: chrome/browser/ssl/ssl_browser_tests.cc |
| diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc |
| index 4d1ffdc5f137b86284d4beedce12b95dfd010d37..aaf0213085b5d558be92c854d5caa6e12e652fad 100644 |
| --- a/chrome/browser/ssl/ssl_browser_tests.cc |
| +++ b/chrome/browser/ssl/ssl_browser_tests.cc |
| @@ -36,6 +36,7 @@ |
| #include "content/public/browser/render_widget_host_view.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/browser/web_contents_observer.h" |
| +#include "content/public/common/content_switches.h" |
| #include "content/public/common/security_style.h" |
| #include "content/public/common/ssl_status.h" |
| #include "content/public/test/browser_test_utils.h" |
| @@ -380,6 +381,16 @@ class SSLUITestIgnoreCertErrors : public SSLUITest { |
| } |
| }; |
| +class SSLUITestIgnoreLocalhostCertErrors : public SSLUITest { |
| + public: |
| + SSLUITestIgnoreLocalhostCertErrors() : SSLUITest() {} |
| + |
| + void SetUpCommandLine(base::CommandLine* command_line) override { |
| + // Browser will ignore certificate errors on localhost. |
| + command_line->AppendSwitch(switches::kAllowInsecureLocalhost); |
| + } |
| +}; |
| + |
| // Visits a regular page over http. |
| IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTP) { |
| ASSERT_TRUE(test_server()->Start()); |
| @@ -534,6 +545,36 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestHTTPSExpiredCertAndDontProceed) { |
| CheckUnauthenticatedState(tab, AuthState::NONE); |
| } |
| +// Test that localhost pages don't show an interstitial. |
| +IN_PROC_BROWSER_TEST_F(SSLUITestIgnoreLocalhostCertErrors, |
| + TestNoInterstitialOnLocalhost) { |
| + ASSERT_TRUE(https_server_.Start()); |
| + |
| + WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| + |
| + // Navigate to a localhost page. |
| + GURL url = https_server_.GetURL("files/ssl/page_with_subresource.html"); |
| + GURL::Replacements replacements; |
| + std::string new_host("localhost"); |
| + replacements.SetHostStr(new_host); |
| + url = url.ReplaceComponents(replacements); |
| + |
| + ui_test_utils::NavigateToURL(browser(), url); |
| + |
| + // We should see no interstitial, but we should have an error |
| + // (red-crossed-out-https) in the URL bar. |
| + CheckAuthenticationBrokenState(tab, |
| + net::CERT_STATUS_COMMON_NAME_INVALID, |
| + AuthState::NONE); |
| + |
| + // We should see that the script tag in the page loaded and ran (and |
| + // wasn't blocked by the certificate error). |
|
Ryan Sleevi
2015/02/09 19:31:34
Prevailing code pattern wins here (meaning no chan
estark
2015/02/09 20:48:40
Interesting thread! This is going to be a tough ha
|
| + base::string16 title; |
| + base::string16 expected_title = base::ASCIIToUTF16("This script has loaded"); |
| + ui_test_utils::GetCurrentTabTitle(browser(), &title); |
| + EXPECT_EQ(title, expected_title); |
| +} |
| + |
| // Visits a page with https error and then goes back using Browser::GoBack. |
| IN_PROC_BROWSER_TEST_F(SSLUITest, |
| TestHTTPSExpiredCertAndGoBackViaButton) { |