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

Side by Side 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: Added warning in console on localhost SSL errors Created 5 years, 10 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 unified diff | Download patch
OLDNEW
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/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 class SSLUITestIgnoreCertErrors : public SSLUITest { 373 class SSLUITestIgnoreCertErrors : public SSLUITest {
374 public: 374 public:
375 SSLUITestIgnoreCertErrors() : SSLUITest() {} 375 SSLUITestIgnoreCertErrors() : SSLUITest() {}
376 376
377 void SetUpCommandLine(base::CommandLine* command_line) override { 377 void SetUpCommandLine(base::CommandLine* command_line) override {
378 // Browser will ignore certificate errors. 378 // Browser will ignore certificate errors.
379 command_line->AppendSwitch(switches::kIgnoreCertificateErrors); 379 command_line->AppendSwitch(switches::kIgnoreCertificateErrors);
380 } 380 }
381 }; 381 };
382 382
383 class SSLUITestIgnoreLocalhostCertErrors : public SSLUITest {
384 public:
385 SSLUITestIgnoreLocalhostCertErrors() : SSLUITest() {}
386
387 void SetUpCommandLine(base::CommandLine* command_line) override {
388 // Browser will ignore certificate errors on localhost.
389 command_line->AppendSwitch(switches::kAllowInsecureLocalhost);
390 }
391 };
392
383 // Visits a regular page over http. 393 // Visits a regular page over http.
384 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTP) { 394 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTP) {
385 ASSERT_TRUE(test_server()->Start()); 395 ASSERT_TRUE(test_server()->Start());
386 396
387 ui_test_utils::NavigateToURL(browser(), 397 ui_test_utils::NavigateToURL(browser(),
388 test_server()->GetURL("files/ssl/google.html")); 398 test_server()->GetURL("files/ssl/google.html"));
389 399
390 CheckUnauthenticatedState( 400 CheckUnauthenticatedState(
391 browser()->tab_strip_model()->GetActiveWebContents(), AuthState::NONE); 401 browser()->tab_strip_model()->GetActiveWebContents(), AuthState::NONE);
392 } 402 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 537
528 // We should be back to the original good page. 538 // We should be back to the original good page.
529 CheckAuthenticatedState(tab, AuthState::NONE); 539 CheckAuthenticatedState(tab, AuthState::NONE);
530 540
531 // Try to navigate to a new page. (to make sure bug 5800 is fixed). 541 // Try to navigate to a new page. (to make sure bug 5800 is fixed).
532 ui_test_utils::NavigateToURL(browser(), 542 ui_test_utils::NavigateToURL(browser(),
533 test_server()->GetURL("files/ssl/google.html")); 543 test_server()->GetURL("files/ssl/google.html"));
534 CheckUnauthenticatedState(tab, AuthState::NONE); 544 CheckUnauthenticatedState(tab, AuthState::NONE);
535 } 545 }
536 546
547 // Test that localhost pages don't show an interstitial.
548 IN_PROC_BROWSER_TEST_F(SSLUITestIgnoreLocalhostCertErrors,
549 TestNoInterstitialOnLocalhost) {
550 ASSERT_TRUE(https_server_.Start());
551
552 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
553
554 // Navigate to a localhost page.
555 GURL url = https_server_.GetURL("files/ssl/page_with_subresource.html");
556 GURL::Replacements replacements;
557 std::string new_host("localhost");
558 replacements.SetHostStr(new_host);
559 url = url.ReplaceComponents(replacements);
560
561 ui_test_utils::NavigateToURL(browser(), url);
Ryan Sleevi 2015/02/04 19:34:41 Unfortunately, I think this test is going to be on
estark 2015/02/05 03:02:38 Is there any chance that using 127.0.0.1 instead o
562
563 // We should see no interstitial, but we should have an error
564 // (red-crossed-out-https) in the URL bar.
565 CheckAuthenticationBrokenState(tab,
566 net::CERT_STATUS_COMMON_NAME_INVALID,
567 AuthState::NONE);
568
569 // We should see that the script tag in the page loaded and ran (and
570 // wasn't blocked by the certificate error).
571 base::string16 title;
572 base::string16 expected_title = base::ASCIIToUTF16("This script has loaded");
573 ui_test_utils::GetCurrentTabTitle(browser(), &title);
574 EXPECT_EQ(title, expected_title);
575 }
576
537 // Visits a page with https error and then goes back using Browser::GoBack. 577 // Visits a page with https error and then goes back using Browser::GoBack.
538 IN_PROC_BROWSER_TEST_F(SSLUITest, 578 IN_PROC_BROWSER_TEST_F(SSLUITest,
539 TestHTTPSExpiredCertAndGoBackViaButton) { 579 TestHTTPSExpiredCertAndGoBackViaButton) {
540 ASSERT_TRUE(test_server()->Start()); 580 ASSERT_TRUE(test_server()->Start());
541 ASSERT_TRUE(https_server_expired_.Start()); 581 ASSERT_TRUE(https_server_expired_.Start());
542 582
543 // First navigate to an HTTP page. 583 // First navigate to an HTTP page.
544 ui_test_utils::NavigateToURL(browser(), 584 ui_test_utils::NavigateToURL(browser(),
545 test_server()->GetURL("files/ssl/google.html")); 585 test_server()->GetURL("files/ssl/google.html"));
546 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 586 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1880 1920
1881 // Visit a page over https that contains a frame with a redirect. 1921 // Visit a page over https that contains a frame with a redirect.
1882 1922
1883 // XMLHttpRequest insecure content in synchronous mode. 1923 // XMLHttpRequest insecure content in synchronous mode.
1884 1924
1885 // XMLHttpRequest insecure content in asynchronous mode. 1925 // XMLHttpRequest insecure content in asynchronous mode.
1886 1926
1887 // XMLHttpRequest over bad ssl in synchronous mode. 1927 // XMLHttpRequest over bad ssl in synchronous mode.
1888 1928
1889 // XMLHttpRequest over OK ssl in synchronous mode. 1929 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698