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 interstitial. |
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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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, TestHTTPSErrorCausedByClock) { |
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()); |
estark
2016/03/08 23:17:36
Can you please add a test like this one, except us
mab
2016/03/09 23:35:27
Makes sense, done.
| |
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, |
(...skipping 2059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2976 | 2978 |
2977 // Visit a page over https that contains a frame with a redirect. | 2979 // Visit a page over https that contains a frame with a redirect. |
2978 | 2980 |
2979 // XMLHttpRequest insecure content in synchronous mode. | 2981 // XMLHttpRequest insecure content in synchronous mode. |
2980 | 2982 |
2981 // XMLHttpRequest insecure content in asynchronous mode. | 2983 // XMLHttpRequest insecure content in asynchronous mode. |
2982 | 2984 |
2983 // XMLHttpRequest over bad ssl in synchronous mode. | 2985 // XMLHttpRequest over bad ssl in synchronous mode. |
2984 | 2986 |
2985 // XMLHttpRequest over OK ssl in synchronous mode. | 2987 // XMLHttpRequest over OK ssl in synchronous mode. |
OLD | NEW |