Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: chrome/browser/ssl/ssl_browser_tests.cc

Issue 887223005: Skip interstitials and don't block requests for localhost SSL errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweaked flag placement and added histograms.xml entry Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..d2326bda1769c946af7a263ee58a7df61d691725 100644
--- a/chrome/browser/ssl/ssl_browser_tests.cc
+++ b/chrome/browser/ssl/ssl_browser_tests.cc
@@ -380,6 +380,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 +544,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).
+ 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) {

Powered by Google App Engine
This is Rietveld 408576698