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

Unified Diff: chrome/browser/ssl/ssl_browser_tests.cc

Issue 1772143002: Use network time for bad clock interstitial. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: estark review 1 Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ssl/ssl_browser_tests.cc
diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc
index 0f0c4656d414f90b1d0ac19b2d451207fa3b39ee..21409240f7b2b7cfeb31cce1bb19ab592015d79b 100644
--- a/chrome/browser/ssl/ssl_browser_tests.cc
+++ b/chrome/browser/ssl/ssl_browser_tests.cc
@@ -49,6 +49,7 @@
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
+#include "components/network_time/network_time_tracker.h"
#include "components/prefs/pref_service.h"
#include "components/security_interstitials/core/controller_client.h"
#include "components/security_interstitials/core/metrics_helper.h"
@@ -523,12 +524,13 @@ class SSLUITest
ASSERT_TRUE(https_server_expired_.Start());
ASSERT_NO_FATAL_FAILURE(SetUpMockReporter());
- // Set up the build and current clock times to be more than a year apart.
- scoped_ptr<base::SimpleTestClock> mock_clock(new base::SimpleTestClock());
- mock_clock->SetNow(base::Time::NowFromSystemTime());
- mock_clock->Advance(base::TimeDelta::FromDays(367));
- SSLErrorHandler::SetClockForTest(mock_clock.get());
- ssl_errors::SetBuildTimeForTesting(base::Time::NowFromSystemTime());
+ // Set network time back ten minutes, which is sufficient to
+ // trigger the reporting.
+ g_browser_process->network_time_tracker()->UpdateNetworkTime(
+ base::Time::Now() - base::TimeDelta::FromMinutes(10),
+ base::TimeDelta::FromMilliseconds(1), /* resolution */
+ base::TimeDelta::FromMilliseconds(500), /* latency */
+ base::TimeTicks::Now() /* posting time of this update */);
// Opt in to sending reports for invalid certificate chains.
certificate_reporting_test_utils::SetCertReportingOptIn(browser, opt_in);
@@ -898,7 +900,7 @@ IN_PROC_BROWSER_TEST_F(SSLUITestIgnoreLocalhostCertErrors,
EXPECT_EQ(title, expected_title);
}
-IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSErrorCausedByClock) {
+IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSErrorCausedByClockUsingBuildTime) {
ASSERT_TRUE(https_server_expired_.Start());
// Set up the build and current clock times to be more than a year apart.
@@ -917,6 +919,26 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSErrorCausedByClock) {
clock_interstitial->GetDelegateForTesting()->GetTypeForTesting());
}
+IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSErrorCausedByClockUsingNetwork) {
+ ASSERT_TRUE(https_server_expired_.Start());
+
+ // Set network forward ten minutes, which is sufficient to trigger
+ // the interstitial.
+ g_browser_process->network_time_tracker()->UpdateNetworkTime(
+ base::Time::Now() + base::TimeDelta::FromMinutes(10),
+ base::TimeDelta::FromMilliseconds(1), /* resolution */
+ base::TimeDelta::FromMilliseconds(500), /* latency */
+ base::TimeTicks::Now() /* posting time of this update */);
+
+ ui_test_utils::NavigateToURL(browser(), https_server_expired_.GetURL("/"));
+ WebContents* clock_tab = browser()->tab_strip_model()->GetActiveWebContents();
+ content::WaitForInterstitialAttach(clock_tab);
+ InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage();
+ ASSERT_TRUE(clock_interstitial);
+ EXPECT_EQ(BadClockBlockingPage::kTypeForTesting,
+ clock_interstitial->GetDelegateForTesting()->GetTypeForTesting());
+}
+
// Visits a page with https error and then goes back using Browser::GoBack.
IN_PROC_BROWSER_TEST_F(SSLUITest,
TestHTTPSExpiredCertAndGoBackViaButton) {

Powered by Google App Engine
This is Rietveld 408576698