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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "chrome/browser/ui/browser_navigator.h" | 42 #include "chrome/browser/ui/browser_navigator.h" |
43 #include "chrome/browser/ui/browser_navigator_params.h" | 43 #include "chrome/browser/ui/browser_navigator_params.h" |
44 #include "chrome/browser/ui/browser_tabstrip.h" | 44 #include "chrome/browser/ui/browser_tabstrip.h" |
45 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 45 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
46 #include "chrome/common/chrome_paths.h" | 46 #include "chrome/common/chrome_paths.h" |
47 #include "chrome/common/chrome_switches.h" | 47 #include "chrome/common/chrome_switches.h" |
48 #include "chrome/common/pref_names.h" | 48 #include "chrome/common/pref_names.h" |
49 #include "chrome/test/base/in_process_browser_test.h" | 49 #include "chrome/test/base/in_process_browser_test.h" |
50 #include "chrome/test/base/ui_test_utils.h" | 50 #include "chrome/test/base/ui_test_utils.h" |
51 #include "components/content_settings/core/browser/host_content_settings_map.h" | 51 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 52 #include "components/network_time/network_time_tracker.h" |
52 #include "components/prefs/pref_service.h" | 53 #include "components/prefs/pref_service.h" |
53 #include "components/security_interstitials/core/controller_client.h" | 54 #include "components/security_interstitials/core/controller_client.h" |
54 #include "components/security_interstitials/core/metrics_helper.h" | 55 #include "components/security_interstitials/core/metrics_helper.h" |
55 #include "components/security_state/security_state_model.h" | 56 #include "components/security_state/security_state_model.h" |
56 #include "components/security_state/switches.h" | 57 #include "components/security_state/switches.h" |
57 #include "components/ssl_errors/error_classification.h" | 58 #include "components/ssl_errors/error_classification.h" |
58 #include "components/variations/variations_associated_data.h" | 59 #include "components/variations/variations_associated_data.h" |
59 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 60 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
60 #include "content/public/browser/browser_context.h" | 61 #include "content/public/browser/browser_context.h" |
61 #include "content/public/browser/cert_store.h" | 62 #include "content/public/browser/cert_store.h" |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 // Helper function for testing invalid certificate chain reporting with the | 517 // Helper function for testing invalid certificate chain reporting with the |
517 // bad clock interstitial. | 518 // bad clock interstitial. |
518 void TestBadClockReporting( | 519 void TestBadClockReporting( |
519 certificate_reporting_test_utils::OptIn opt_in, | 520 certificate_reporting_test_utils::OptIn opt_in, |
520 certificate_reporting_test_utils::ExpectReport expect_report, | 521 certificate_reporting_test_utils::ExpectReport expect_report, |
521 Browser* browser) { | 522 Browser* browser) { |
522 base::RunLoop run_loop; | 523 base::RunLoop run_loop; |
523 ASSERT_TRUE(https_server_expired_.Start()); | 524 ASSERT_TRUE(https_server_expired_.Start()); |
524 ASSERT_NO_FATAL_FAILURE(SetUpMockReporter()); | 525 ASSERT_NO_FATAL_FAILURE(SetUpMockReporter()); |
525 | 526 |
526 // Set up the build and current clock times to be more than a year apart. | 527 // Set network time back ten minutes, which is sufficient to |
527 scoped_ptr<base::SimpleTestClock> mock_clock(new base::SimpleTestClock()); | 528 // trigger the reporting. |
528 mock_clock->SetNow(base::Time::NowFromSystemTime()); | 529 g_browser_process->network_time_tracker()->UpdateNetworkTime( |
529 mock_clock->Advance(base::TimeDelta::FromDays(367)); | 530 base::Time::Now() - base::TimeDelta::FromMinutes(10), |
530 SSLErrorHandler::SetClockForTest(mock_clock.get()); | 531 base::TimeDelta::FromMilliseconds(1), /* resolution */ |
531 ssl_errors::SetBuildTimeForTesting(base::Time::NowFromSystemTime()); | 532 base::TimeDelta::FromMilliseconds(500), /* latency */ |
| 533 base::TimeTicks::Now() /* posting time of this update */); |
532 | 534 |
533 // Opt in to sending reports for invalid certificate chains. | 535 // Opt in to sending reports for invalid certificate chains. |
534 certificate_reporting_test_utils::SetCertReportingOptIn(browser, opt_in); | 536 certificate_reporting_test_utils::SetCertReportingOptIn(browser, opt_in); |
535 | 537 |
536 ui_test_utils::NavigateToURL(browser, https_server_expired_.GetURL("/")); | 538 ui_test_utils::NavigateToURL(browser, https_server_expired_.GetURL("/")); |
537 | 539 |
538 WebContents* tab = browser->tab_strip_model()->GetActiveWebContents(); | 540 WebContents* tab = browser->tab_strip_model()->GetActiveWebContents(); |
539 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 541 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, |
540 AuthState::SHOWING_INTERSTITIAL); | 542 AuthState::SHOWING_INTERSTITIAL); |
541 | 543 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 AuthState::NONE); | 893 AuthState::NONE); |
892 | 894 |
893 // We should see that the script tag in the page loaded and ran (and | 895 // We should see that the script tag in the page loaded and ran (and |
894 // wasn't blocked by the certificate error). | 896 // wasn't blocked by the certificate error). |
895 base::string16 title; | 897 base::string16 title; |
896 base::string16 expected_title = base::ASCIIToUTF16("This script has loaded"); | 898 base::string16 expected_title = base::ASCIIToUTF16("This script has loaded"); |
897 ui_test_utils::GetCurrentTabTitle(browser(), &title); | 899 ui_test_utils::GetCurrentTabTitle(browser(), &title); |
898 EXPECT_EQ(title, expected_title); | 900 EXPECT_EQ(title, expected_title); |
899 } | 901 } |
900 | 902 |
901 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSErrorCausedByClock) { | 903 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSErrorCausedByClockUsingBuildTime) { |
902 ASSERT_TRUE(https_server_expired_.Start()); | 904 ASSERT_TRUE(https_server_expired_.Start()); |
903 | 905 |
904 // Set up the build and current clock times to be more than a year apart. | 906 // Set up the build and current clock times to be more than a year apart. |
905 scoped_ptr<base::SimpleTestClock> mock_clock(new base::SimpleTestClock()); | 907 scoped_ptr<base::SimpleTestClock> mock_clock(new base::SimpleTestClock()); |
906 mock_clock->SetNow(base::Time::NowFromSystemTime()); | 908 mock_clock->SetNow(base::Time::NowFromSystemTime()); |
907 mock_clock->Advance(base::TimeDelta::FromDays(367)); | 909 mock_clock->Advance(base::TimeDelta::FromDays(367)); |
908 SSLErrorHandler::SetClockForTest(mock_clock.get()); | 910 SSLErrorHandler::SetClockForTest(mock_clock.get()); |
909 ssl_errors::SetBuildTimeForTesting(base::Time::NowFromSystemTime()); | 911 ssl_errors::SetBuildTimeForTesting(base::Time::NowFromSystemTime()); |
910 | 912 |
911 ui_test_utils::NavigateToURL(browser(), https_server_expired_.GetURL("/")); | 913 ui_test_utils::NavigateToURL(browser(), https_server_expired_.GetURL("/")); |
912 WebContents* clock_tab = browser()->tab_strip_model()->GetActiveWebContents(); | 914 WebContents* clock_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
913 content::WaitForInterstitialAttach(clock_tab); | 915 content::WaitForInterstitialAttach(clock_tab); |
914 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage(); | 916 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage(); |
915 ASSERT_TRUE(clock_interstitial); | 917 ASSERT_TRUE(clock_interstitial); |
916 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting, | 918 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting, |
917 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting()); | 919 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting()); |
918 } | 920 } |
919 | 921 |
| 922 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSErrorCausedByClockUsingNetwork) { |
| 923 ASSERT_TRUE(https_server_expired_.Start()); |
| 924 |
| 925 // Set network forward ten minutes, which is sufficient to trigger |
| 926 // the interstitial. |
| 927 g_browser_process->network_time_tracker()->UpdateNetworkTime( |
| 928 base::Time::Now() + base::TimeDelta::FromMinutes(10), |
| 929 base::TimeDelta::FromMilliseconds(1), /* resolution */ |
| 930 base::TimeDelta::FromMilliseconds(500), /* latency */ |
| 931 base::TimeTicks::Now() /* posting time of this update */); |
| 932 |
| 933 ui_test_utils::NavigateToURL(browser(), https_server_expired_.GetURL("/")); |
| 934 WebContents* clock_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 935 content::WaitForInterstitialAttach(clock_tab); |
| 936 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage(); |
| 937 ASSERT_TRUE(clock_interstitial); |
| 938 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting, |
| 939 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting()); |
| 940 } |
| 941 |
920 // Visits a page with https error and then goes back using Browser::GoBack. | 942 // Visits a page with https error and then goes back using Browser::GoBack. |
921 IN_PROC_BROWSER_TEST_F(SSLUITest, | 943 IN_PROC_BROWSER_TEST_F(SSLUITest, |
922 TestHTTPSExpiredCertAndGoBackViaButton) { | 944 TestHTTPSExpiredCertAndGoBackViaButton) { |
923 ASSERT_TRUE(embedded_test_server()->Start()); | 945 ASSERT_TRUE(embedded_test_server()->Start()); |
924 ASSERT_TRUE(https_server_expired_.Start()); | 946 ASSERT_TRUE(https_server_expired_.Start()); |
925 | 947 |
926 // First navigate to an HTTP page. | 948 // First navigate to an HTTP page. |
927 ui_test_utils::NavigateToURL( | 949 ui_test_utils::NavigateToURL( |
928 browser(), embedded_test_server()->GetURL("/ssl/google.html")); | 950 browser(), embedded_test_server()->GetURL("/ssl/google.html")); |
929 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 951 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2976 | 2998 |
2977 // Visit a page over https that contains a frame with a redirect. | 2999 // Visit a page over https that contains a frame with a redirect. |
2978 | 3000 |
2979 // XMLHttpRequest insecure content in synchronous mode. | 3001 // XMLHttpRequest insecure content in synchronous mode. |
2980 | 3002 |
2981 // XMLHttpRequest insecure content in asynchronous mode. | 3003 // XMLHttpRequest insecure content in asynchronous mode. |
2982 | 3004 |
2983 // XMLHttpRequest over bad ssl in synchronous mode. | 3005 // XMLHttpRequest over bad ssl in synchronous mode. |
2984 | 3006 |
2985 // XMLHttpRequest over OK ssl in synchronous mode. | 3007 // XMLHttpRequest over OK ssl in synchronous mode. |
OLD | NEW |