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

Side by Side Diff: chrome/browser/ssl/ssl_browser_tests.cc

Issue 1317593002: Have SSLErrorHandler decide which type of interstitial to display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix browser tests Created 5 years, 3 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/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"
34 #include "chrome/browser/ssl/ssl_error_handler.h" 36 #include "chrome/browser/ssl/ssl_error_handler.h"
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 AuthState::NONE); 774 AuthState::NONE);
773 775
774 // We should see that the script tag in the page loaded and ran (and 776 // We should see that the script tag in the page loaded and ran (and
775 // wasn't blocked by the certificate error). 777 // wasn't blocked by the certificate error).
776 base::string16 title; 778 base::string16 title;
777 base::string16 expected_title = base::ASCIIToUTF16("This script has loaded"); 779 base::string16 expected_title = base::ASCIIToUTF16("This script has loaded");
778 ui_test_utils::GetCurrentTabTitle(browser(), &title); 780 ui_test_utils::GetCurrentTabTitle(browser(), &title);
779 EXPECT_EQ(title, expected_title); 781 EXPECT_EQ(title, expected_title);
780 } 782 }
781 783
784 // The build time is only available reliably on official builds.
estark 2015/09/01 13:28:28 Can you explain this comment more? It seems like a
felt 2015/09/01 15:49:41 Ah this was an oversight, I used to have the test
785 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSErrorCausedByClock) {
786 ASSERT_TRUE(https_server_expired_.Start());
787 scoped_ptr<base::SimpleTestClock> mock_clock(new base::SimpleTestClock());
788 mock_clock->SetNow(base::Time::NowFromSystemTime());
789 mock_clock->Advance(base::TimeDelta::FromDays(367));
790 SSLErrorHandler::SetClockForTest(mock_clock.get());
791 ui_test_utils::NavigateToURL(browser(), https_server_expired_.GetURL("/"));
792 WebContents* clock_tab = browser()->tab_strip_model()->GetActiveWebContents();
793 content::WaitForInterstitialAttach(clock_tab);
794 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage();
795 ASSERT_TRUE(clock_interstitial);
796 ASSERT_EQ(BadClockBlockingPage::kTypeForTesting,
estark 2015/09/01 13:28:28 nit: This should probably be EXPECT_EQ.
felt 2015/09/01 15:49:41 Done.
797 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting());
798 }
799
782 // Visits a page with https error and then goes back using Browser::GoBack. 800 // Visits a page with https error and then goes back using Browser::GoBack.
783 IN_PROC_BROWSER_TEST_F(SSLUITest, 801 IN_PROC_BROWSER_TEST_F(SSLUITest,
784 TestHTTPSExpiredCertAndGoBackViaButton) { 802 TestHTTPSExpiredCertAndGoBackViaButton) {
785 ASSERT_TRUE(test_server()->Start()); 803 ASSERT_TRUE(test_server()->Start());
786 ASSERT_TRUE(https_server_expired_.Start()); 804 ASSERT_TRUE(https_server_expired_.Start());
787 805
788 // First navigate to an HTTP page. 806 // First navigate to an HTTP page.
789 ui_test_utils::NavigateToURL(browser(), 807 ui_test_utils::NavigateToURL(browser(),
790 test_server()->GetURL("files/ssl/google.html")); 808 test_server()->GetURL("files/ssl/google.html"));
791 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 809 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
(...skipping 1924 matching lines...) Expand 10 before | Expand all | Expand 10 after
2716 2734
2717 // Visit a page over https that contains a frame with a redirect. 2735 // Visit a page over https that contains a frame with a redirect.
2718 2736
2719 // XMLHttpRequest insecure content in synchronous mode. 2737 // XMLHttpRequest insecure content in synchronous mode.
2720 2738
2721 // XMLHttpRequest insecure content in asynchronous mode. 2739 // XMLHttpRequest insecure content in asynchronous mode.
2722 2740
2723 // XMLHttpRequest over bad ssl in synchronous mode. 2741 // XMLHttpRequest over bad ssl in synchronous mode.
2724 2742
2725 // XMLHttpRequest over OK ssl in synchronous mode. 2743 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698