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

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: rebase again 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 536
527 // We should be back to the original good page. 537 // We should be back to the original good page.
528 CheckAuthenticatedState(tab, AuthState::NONE); 538 CheckAuthenticatedState(tab, AuthState::NONE);
529 539
530 // Try to navigate to a new page. (to make sure bug 5800 is fixed). 540 // Try to navigate to a new page. (to make sure bug 5800 is fixed).
531 ui_test_utils::NavigateToURL(browser(), 541 ui_test_utils::NavigateToURL(browser(),
532 test_server()->GetURL("files/ssl/google.html")); 542 test_server()->GetURL("files/ssl/google.html"));
533 CheckUnauthenticatedState(tab, AuthState::NONE); 543 CheckUnauthenticatedState(tab, AuthState::NONE);
534 } 544 }
535 545
546 // Test that localhost pages don't show an interstitial.
547 IN_PROC_BROWSER_TEST_F(SSLUITestIgnoreLocalhostCertErrors,
548 TestNoInterstitialOnLocalhost) {
549 ASSERT_TRUE(https_server_.Start());
550
551 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
552
553 // Navigate to a localhost page.
554 GURL url = https_server_.GetURL("files/ssl/page_with_subresource.html");
555 GURL::Replacements replacements;
556 std::string new_host("localhost");
557 replacements.SetHostStr(new_host);
558 url = url.ReplaceComponents(replacements);
559
560 ui_test_utils::NavigateToURL(browser(), url);
561
562 // We should see no interstitial, but we should have an error
563 // (red-crossed-out-https) in the URL bar.
564 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
565 AuthState::NONE);
566
567 // We should see that the script tag in the page loaded and ran (and
568 // wasn't blocked by the certificate error).
569 base::string16 title;
570 base::string16 expected_title = base::ASCIIToUTF16("This script has loaded");
571 ui_test_utils::GetCurrentTabTitle(browser(), &title);
572 EXPECT_EQ(title, expected_title);
573 }
574
536 // Visits a page with https error and then goes back using Browser::GoBack. 575 // Visits a page with https error and then goes back using Browser::GoBack.
537 IN_PROC_BROWSER_TEST_F(SSLUITest, 576 IN_PROC_BROWSER_TEST_F(SSLUITest,
538 TestHTTPSExpiredCertAndGoBackViaButton) { 577 TestHTTPSExpiredCertAndGoBackViaButton) {
539 ASSERT_TRUE(test_server()->Start()); 578 ASSERT_TRUE(test_server()->Start());
540 ASSERT_TRUE(https_server_expired_.Start()); 579 ASSERT_TRUE(https_server_expired_.Start());
541 580
542 // First navigate to an HTTP page. 581 // First navigate to an HTTP page.
543 ui_test_utils::NavigateToURL(browser(), 582 ui_test_utils::NavigateToURL(browser(),
544 test_server()->GetURL("files/ssl/google.html")); 583 test_server()->GetURL("files/ssl/google.html"));
545 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 584 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 1915
1877 // Visit a page over https that contains a frame with a redirect. 1916 // Visit a page over https that contains a frame with a redirect.
1878 1917
1879 // XMLHttpRequest insecure content in synchronous mode. 1918 // XMLHttpRequest insecure content in synchronous mode.
1880 1919
1881 // XMLHttpRequest insecure content in asynchronous mode. 1920 // XMLHttpRequest insecure content in asynchronous mode.
1882 1921
1883 // XMLHttpRequest over bad ssl in synchronous mode. 1922 // XMLHttpRequest over bad ssl in synchronous mode.
1884 1923
1885 // XMLHttpRequest over OK ssl in synchronous mode. 1924 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW
« no previous file with comments | « chrome/browser/ssl/chrome_ssl_host_state_delegate_test.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698