| 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/test/histogram_tester.h" | 16 #include "base/test/histogram_tester.h" |
| 17 #include "base/test/simple_test_clock.h" |
| 17 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
| 18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 19 #include "chrome/app/chrome_command_ids.h" | 20 #include "chrome/app/chrome_command_ids.h" |
| 20 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
| 22 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h" | 23 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h" |
| 23 #include "chrome/browser/net/certificate_error_reporter.h" | 24 #include "chrome/browser/net/certificate_error_reporter.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/ssl/bad_clock_blocking_page.h" |
| 25 #include "chrome/browser/ssl/cert_logger.pb.h" | 27 #include "chrome/browser/ssl/cert_logger.pb.h" |
| 26 #include "chrome/browser/ssl/cert_report_helper.h" | 28 #include "chrome/browser/ssl/cert_report_helper.h" |
| 27 #include "chrome/browser/ssl/cert_verifier_browser_test.h" | 29 #include "chrome/browser/ssl/cert_verifier_browser_test.h" |
| 28 #include "chrome/browser/ssl/certificate_error_report.h" | 30 #include "chrome/browser/ssl/certificate_error_report.h" |
| 29 #include "chrome/browser/ssl/certificate_reporting_test_utils.h" | 31 #include "chrome/browser/ssl/certificate_reporting_test_utils.h" |
| 30 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" | 32 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" |
| 31 #include "chrome/browser/ssl/common_name_mismatch_handler.h" | 33 #include "chrome/browser/ssl/common_name_mismatch_handler.h" |
| 32 #include "chrome/browser/ssl/connection_security.h" | 34 #include "chrome/browser/ssl/connection_security.h" |
| 33 #include "chrome/browser/ssl/ssl_blocking_page.h" | 35 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 36 #include "chrome/browser/ssl/ssl_error_classification.h" |
| 34 #include "chrome/browser/ssl/ssl_error_handler.h" | 37 #include "chrome/browser/ssl/ssl_error_handler.h" |
| 35 #include "chrome/browser/ui/browser.h" | 38 #include "chrome/browser/ui/browser.h" |
| 36 #include "chrome/browser/ui/browser_commands.h" | 39 #include "chrome/browser/ui/browser_commands.h" |
| 37 #include "chrome/browser/ui/browser_navigator.h" | 40 #include "chrome/browser/ui/browser_navigator.h" |
| 38 #include "chrome/browser/ui/browser_tabstrip.h" | 41 #include "chrome/browser/ui/browser_tabstrip.h" |
| 39 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 42 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 40 #include "chrome/common/chrome_paths.h" | 43 #include "chrome/common/chrome_paths.h" |
| 41 #include "chrome/common/chrome_switches.h" | 44 #include "chrome/common/chrome_switches.h" |
| 42 #include "chrome/common/pref_names.h" | 45 #include "chrome/common/pref_names.h" |
| 43 #include "chrome/test/base/in_process_browser_test.h" | 46 #include "chrome/test/base/in_process_browser_test.h" |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 AuthState::NONE); | 775 AuthState::NONE); |
| 773 | 776 |
| 774 // We should see that the script tag in the page loaded and ran (and | 777 // We should see that the script tag in the page loaded and ran (and |
| 775 // wasn't blocked by the certificate error). | 778 // wasn't blocked by the certificate error). |
| 776 base::string16 title; | 779 base::string16 title; |
| 777 base::string16 expected_title = base::ASCIIToUTF16("This script has loaded"); | 780 base::string16 expected_title = base::ASCIIToUTF16("This script has loaded"); |
| 778 ui_test_utils::GetCurrentTabTitle(browser(), &title); | 781 ui_test_utils::GetCurrentTabTitle(browser(), &title); |
| 779 EXPECT_EQ(title, expected_title); | 782 EXPECT_EQ(title, expected_title); |
| 780 } | 783 } |
| 781 | 784 |
| 785 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSErrorCausedByClock) { |
| 786 ASSERT_TRUE(https_server_expired_.Start()); |
| 787 |
| 788 // Set up the build and current clock times to be more than a year apart. |
| 789 scoped_ptr<base::SimpleTestClock> mock_clock(new base::SimpleTestClock()); |
| 790 mock_clock->SetNow(base::Time::NowFromSystemTime()); |
| 791 mock_clock->Advance(base::TimeDelta::FromDays(367)); |
| 792 SSLErrorHandler::SetClockForTest(mock_clock.get()); |
| 793 SSLErrorClassification::SetBuildTimeForTesting( |
| 794 base::Time::NowFromSystemTime()); |
| 795 |
| 796 ui_test_utils::NavigateToURL(browser(), https_server_expired_.GetURL("/")); |
| 797 WebContents* clock_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 798 content::WaitForInterstitialAttach(clock_tab); |
| 799 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage(); |
| 800 ASSERT_TRUE(clock_interstitial); |
| 801 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting, |
| 802 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting()); |
| 803 } |
| 804 |
| 782 // Visits a page with https error and then goes back using Browser::GoBack. | 805 // Visits a page with https error and then goes back using Browser::GoBack. |
| 783 IN_PROC_BROWSER_TEST_F(SSLUITest, | 806 IN_PROC_BROWSER_TEST_F(SSLUITest, |
| 784 TestHTTPSExpiredCertAndGoBackViaButton) { | 807 TestHTTPSExpiredCertAndGoBackViaButton) { |
| 785 ASSERT_TRUE(test_server()->Start()); | 808 ASSERT_TRUE(test_server()->Start()); |
| 786 ASSERT_TRUE(https_server_expired_.Start()); | 809 ASSERT_TRUE(https_server_expired_.Start()); |
| 787 | 810 |
| 788 // First navigate to an HTTP page. | 811 // First navigate to an HTTP page. |
| 789 ui_test_utils::NavigateToURL(browser(), | 812 ui_test_utils::NavigateToURL(browser(), |
| 790 test_server()->GetURL("files/ssl/google.html")); | 813 test_server()->GetURL("files/ssl/google.html")); |
| 791 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 814 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| (...skipping 1924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2716 | 2739 |
| 2717 // Visit a page over https that contains a frame with a redirect. | 2740 // Visit a page over https that contains a frame with a redirect. |
| 2718 | 2741 |
| 2719 // XMLHttpRequest insecure content in synchronous mode. | 2742 // XMLHttpRequest insecure content in synchronous mode. |
| 2720 | 2743 |
| 2721 // XMLHttpRequest insecure content in asynchronous mode. | 2744 // XMLHttpRequest insecure content in asynchronous mode. |
| 2722 | 2745 |
| 2723 // XMLHttpRequest over bad ssl in synchronous mode. | 2746 // XMLHttpRequest over bad ssl in synchronous mode. |
| 2724 | 2747 |
| 2725 // XMLHttpRequest over OK ssl in synchronous mode. | 2748 // XMLHttpRequest over OK ssl in synchronous mode. |
| OLD | NEW |