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

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

Issue 2610183004: Wrap SSL error handler configuration with a lazy instance (Closed)
Patch Set: Add ForTesting to config setter methods Created 3 years, 11 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 <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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 207 }
208 208
209 // This observer waits for the SSLErrorHandler to start an interstitial timer 209 // This observer waits for the SSLErrorHandler to start an interstitial timer
210 // for the given web contents. 210 // for the given web contents.
211 class SSLInterstitialTimerObserver { 211 class SSLInterstitialTimerObserver {
212 public: 212 public:
213 explicit SSLInterstitialTimerObserver(content::WebContents* web_contents) 213 explicit SSLInterstitialTimerObserver(content::WebContents* web_contents)
214 : web_contents_(web_contents), message_loop_runner_(new base::RunLoop) { 214 : web_contents_(web_contents), message_loop_runner_(new base::RunLoop) {
215 callback_ = base::Bind(&SSLInterstitialTimerObserver::OnTimerStarted, 215 callback_ = base::Bind(&SSLInterstitialTimerObserver::OnTimerStarted,
216 base::Unretained(this)); 216 base::Unretained(this));
217 SSLErrorHandler::SetInterstitialTimerStartedCallbackForTest(&callback_); 217 SSLErrorHandler::SetInterstitialTimerStartedCallbackForTesting(&callback_);
218 } 218 }
219 219
220 ~SSLInterstitialTimerObserver() { 220 ~SSLInterstitialTimerObserver() {
221 SSLErrorHandler::SetInterstitialTimerStartedCallbackForTest(nullptr); 221 SSLErrorHandler::SetInterstitialTimerStartedCallbackForTesting(nullptr);
222 } 222 }
223 223
224 // Waits until the interstitial delay timer in SSLErrorHandler is started. 224 // Waits until the interstitial delay timer in SSLErrorHandler is started.
225 void WaitForTimerStarted() { message_loop_runner_->Run(); } 225 void WaitForTimerStarted() { message_loop_runner_->Run(); }
226 226
227 private: 227 private:
228 void OnTimerStarted(content::WebContents* web_contents) { 228 void OnTimerStarted(content::WebContents* web_contents) {
229 if (web_contents_ == web_contents) 229 if (web_contents_ == web_contents)
230 message_loop_runner_->Quit(); 230 message_loop_runner_->Quit();
231 } 231 }
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 } 955 }
956 956
957 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSErrorCausedByClockUsingBuildTime) { 957 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSErrorCausedByClockUsingBuildTime) {
958 ASSERT_TRUE(https_server_expired_.Start()); 958 ASSERT_TRUE(https_server_expired_.Start());
959 959
960 // Set up the build and current clock times to be more than a year apart. 960 // Set up the build and current clock times to be more than a year apart.
961 std::unique_ptr<base::SimpleTestClock> mock_clock( 961 std::unique_ptr<base::SimpleTestClock> mock_clock(
962 new base::SimpleTestClock()); 962 new base::SimpleTestClock());
963 mock_clock->SetNow(base::Time::NowFromSystemTime()); 963 mock_clock->SetNow(base::Time::NowFromSystemTime());
964 mock_clock->Advance(base::TimeDelta::FromDays(367)); 964 mock_clock->Advance(base::TimeDelta::FromDays(367));
965 SSLErrorHandler::SetClockForTest(mock_clock.get()); 965 SSLErrorHandler::SetClockForTesting(mock_clock.get());
966 ssl_errors::SetBuildTimeForTesting(base::Time::NowFromSystemTime()); 966 ssl_errors::SetBuildTimeForTesting(base::Time::NowFromSystemTime());
967 967
968 ui_test_utils::NavigateToURL(browser(), 968 ui_test_utils::NavigateToURL(browser(),
969 https_server_expired_.GetURL("/title1.html")); 969 https_server_expired_.GetURL("/title1.html"));
970 WebContents* clock_tab = browser()->tab_strip_model()->GetActiveWebContents(); 970 WebContents* clock_tab = browser()->tab_strip_model()->GetActiveWebContents();
971 content::WaitForInterstitialAttach(clock_tab); 971 content::WaitForInterstitialAttach(clock_tab);
972 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage(); 972 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage();
973 ASSERT_TRUE(clock_interstitial); 973 ASSERT_TRUE(clock_interstitial);
974 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting, 974 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting,
975 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting()); 975 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting());
(...skipping 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after
2797 IN_PROC_BROWSER_TEST_F(SSLUITest, 2797 IN_PROC_BROWSER_TEST_F(SSLUITest,
2798 SSLStatusMatchesonClockInterstitialAndAfterProceed) { 2798 SSLStatusMatchesonClockInterstitialAndAfterProceed) {
2799 ASSERT_TRUE(https_server_expired_.Start()); 2799 ASSERT_TRUE(https_server_expired_.Start());
2800 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 2800 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
2801 ASSERT_TRUE(tab); 2801 ASSERT_TRUE(tab);
2802 2802
2803 // Set up the build and current clock times to be more than a year apart. 2803 // Set up the build and current clock times to be more than a year apart.
2804 base::SimpleTestClock mock_clock; 2804 base::SimpleTestClock mock_clock;
2805 mock_clock.SetNow(base::Time::NowFromSystemTime()); 2805 mock_clock.SetNow(base::Time::NowFromSystemTime());
2806 mock_clock.Advance(base::TimeDelta::FromDays(367)); 2806 mock_clock.Advance(base::TimeDelta::FromDays(367));
2807 SSLErrorHandler::SetClockForTest(&mock_clock); 2807 SSLErrorHandler::SetClockForTesting(&mock_clock);
2808 ssl_errors::SetBuildTimeForTesting(base::Time::NowFromSystemTime()); 2808 ssl_errors::SetBuildTimeForTesting(base::Time::NowFromSystemTime());
2809 2809
2810 ui_test_utils::NavigateToURL(browser(), 2810 ui_test_utils::NavigateToURL(browser(),
2811 https_server_expired_.GetURL("/title1.html")); 2811 https_server_expired_.GetURL("/title1.html"));
2812 content::WaitForInterstitialAttach(tab); 2812 content::WaitForInterstitialAttach(tab);
2813 InterstitialPage* clock_interstitial = tab->GetInterstitialPage(); 2813 InterstitialPage* clock_interstitial = tab->GetInterstitialPage();
2814 ASSERT_TRUE(clock_interstitial); 2814 ASSERT_TRUE(clock_interstitial);
2815 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting, 2815 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting,
2816 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting()); 2816 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting());
2817 2817
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
3065 DISALLOW_COPY_AND_ASSIGN(SSLNetworkTimeBrowserTest); 3065 DISALLOW_COPY_AND_ASSIGN(SSLNetworkTimeBrowserTest);
3066 }; 3066 };
3067 3067
3068 // Tests that if an on-demand network time fetch returns that the clock 3068 // Tests that if an on-demand network time fetch returns that the clock
3069 // is okay, a normal SSL interstitial is shown. 3069 // is okay, a normal SSL interstitial is shown.
3070 IN_PROC_BROWSER_TEST_F(SSLNetworkTimeBrowserTest, OnDemandFetchClockOk) { 3070 IN_PROC_BROWSER_TEST_F(SSLNetworkTimeBrowserTest, OnDemandFetchClockOk) {
3071 ASSERT_TRUE(https_server_expired_.Start()); 3071 ASSERT_TRUE(https_server_expired_.Start());
3072 // Use a testing clock set to the time that GoodTimeResponseHandler 3072 // Use a testing clock set to the time that GoodTimeResponseHandler
3073 // returns, to simulate the system clock matching the network time. 3073 // returns, to simulate the system clock matching the network time.
3074 base::SimpleTestClock testing_clock; 3074 base::SimpleTestClock testing_clock;
3075 SSLErrorHandler::SetClockForTest(&testing_clock); 3075 SSLErrorHandler::SetClockForTesting(&testing_clock);
3076 testing_clock.SetNow( 3076 testing_clock.SetNow(
3077 base::Time::FromJsTime(network_time::kGoodTimeResponseHandlerJsTime)); 3077 base::Time::FromJsTime(network_time::kGoodTimeResponseHandlerJsTime));
3078 // Set the build time to match the testing clock, to ensure that the 3078 // Set the build time to match the testing clock, to ensure that the
3079 // build time heuristic doesn't fire. 3079 // build time heuristic doesn't fire.
3080 ssl_errors::SetBuildTimeForTesting(testing_clock.Now()); 3080 ssl_errors::SetBuildTimeForTesting(testing_clock.Now());
3081 3081
3082 // Set a long timeout to ensure that the on-demand time fetch completes. 3082 // Set a long timeout to ensure that the on-demand time fetch completes.
3083 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); 3083 SSLErrorHandler::SetInterstitialDelayForTesting(
3084 base::TimeDelta::FromHours(1));
3084 3085
3085 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 3086 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
3086 ASSERT_TRUE(contents); 3087 ASSERT_TRUE(contents);
3087 SSLInterstitialTimerObserver interstitial_timer_observer(contents); 3088 SSLInterstitialTimerObserver interstitial_timer_observer(contents);
3088 3089
3089 content::WindowedNotificationObserver observer( 3090 content::WindowedNotificationObserver observer(
3090 content::NOTIFICATION_LOAD_STOP, 3091 content::NOTIFICATION_LOAD_STOP,
3091 content::NotificationService::AllSources()); 3092 content::NotificationService::AllSources());
3092 ui_test_utils::NavigateToURLWithDisposition( 3093 ui_test_utils::NavigateToURLWithDisposition(
3093 browser(), https_server_expired_.GetURL("/"), 3094 browser(), https_server_expired_.GetURL("/"),
(...skipping 21 matching lines...) Expand all
3115 } 3116 }
3116 3117
3117 // Tests that if an on-demand network time fetch returns that the clock 3118 // Tests that if an on-demand network time fetch returns that the clock
3118 // is wrong, a bad clock interstitial is shown. 3119 // is wrong, a bad clock interstitial is shown.
3119 IN_PROC_BROWSER_TEST_F(SSLNetworkTimeBrowserTest, OnDemandFetchClockWrong) { 3120 IN_PROC_BROWSER_TEST_F(SSLNetworkTimeBrowserTest, OnDemandFetchClockWrong) {
3120 ASSERT_TRUE(https_server_expired_.Start()); 3121 ASSERT_TRUE(https_server_expired_.Start());
3121 // Use a testing clock set to a time that is different from what 3122 // Use a testing clock set to a time that is different from what
3122 // GoodTimeResponseHandler returns, simulating a system clock that is 3123 // GoodTimeResponseHandler returns, simulating a system clock that is
3123 // 30 days ahead of the network time. 3124 // 30 days ahead of the network time.
3124 base::SimpleTestClock testing_clock; 3125 base::SimpleTestClock testing_clock;
3125 SSLErrorHandler::SetClockForTest(&testing_clock); 3126 SSLErrorHandler::SetClockForTesting(&testing_clock);
3126 testing_clock.SetNow( 3127 testing_clock.SetNow(
3127 base::Time::FromJsTime(network_time::kGoodTimeResponseHandlerJsTime)); 3128 base::Time::FromJsTime(network_time::kGoodTimeResponseHandlerJsTime));
3128 testing_clock.Advance(base::TimeDelta::FromDays(30)); 3129 testing_clock.Advance(base::TimeDelta::FromDays(30));
3129 // Set the build time to match the testing clock, to ensure that the 3130 // Set the build time to match the testing clock, to ensure that the
3130 // build time heuristic doesn't fire. 3131 // build time heuristic doesn't fire.
3131 ssl_errors::SetBuildTimeForTesting(testing_clock.Now()); 3132 ssl_errors::SetBuildTimeForTesting(testing_clock.Now());
3132 3133
3133 // Set a long timeout to ensure that the on-demand time fetch completes. 3134 // Set a long timeout to ensure that the on-demand time fetch completes.
3134 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); 3135 SSLErrorHandler::SetInterstitialDelayForTesting(
3136 base::TimeDelta::FromHours(1));
3135 3137
3136 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 3138 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
3137 ASSERT_TRUE(contents); 3139 ASSERT_TRUE(contents);
3138 SSLInterstitialTimerObserver interstitial_timer_observer(contents); 3140 SSLInterstitialTimerObserver interstitial_timer_observer(contents);
3139 3141
3140 content::WindowedNotificationObserver observer( 3142 content::WindowedNotificationObserver observer(
3141 content::NOTIFICATION_LOAD_STOP, 3143 content::NOTIFICATION_LOAD_STOP,
3142 content::NotificationService::AllSources()); 3144 content::NotificationService::AllSources());
3143 3145
3144 ui_test_utils::NavigateToURLWithDisposition( 3146 ui_test_utils::NavigateToURLWithDisposition(
(...skipping 20 matching lines...) Expand all
3165 ASSERT_EQ(BadClockBlockingPage::kTypeForTesting, 3167 ASSERT_EQ(BadClockBlockingPage::kTypeForTesting,
3166 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); 3168 interstitial_page->GetDelegateForTesting()->GetTypeForTesting());
3167 } 3169 }
3168 3170
3169 // Tests that if the timeout expires before the network time fetch 3171 // Tests that if the timeout expires before the network time fetch
3170 // returns, then a normal SSL intersitial is shown. 3172 // returns, then a normal SSL intersitial is shown.
3171 IN_PROC_BROWSER_TEST_F(SSLNetworkTimeBrowserTest, 3173 IN_PROC_BROWSER_TEST_F(SSLNetworkTimeBrowserTest,
3172 TimeoutExpiresBeforeFetchCompletes) { 3174 TimeoutExpiresBeforeFetchCompletes) {
3173 ASSERT_TRUE(https_server_expired_.Start()); 3175 ASSERT_TRUE(https_server_expired_.Start());
3174 // Set the timer to fire immediately. 3176 // Set the timer to fire immediately.
3175 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta()); 3177 SSLErrorHandler::SetInterstitialDelayForTesting(base::TimeDelta());
3176 3178
3177 ui_test_utils::NavigateToURL(browser(), https_server_expired_.GetURL("/")); 3179 ui_test_utils::NavigateToURL(browser(), https_server_expired_.GetURL("/"));
3178 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 3180 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
3179 ASSERT_TRUE(contents); 3181 ASSERT_TRUE(contents);
3180 content::WaitForInterstitialAttach(contents); 3182 content::WaitForInterstitialAttach(contents);
3181 3183
3182 EXPECT_TRUE(contents->ShowingInterstitialPage()); 3184 EXPECT_TRUE(contents->ShowingInterstitialPage());
3183 InterstitialPage* interstitial_page = contents->GetInterstitialPage(); 3185 InterstitialPage* interstitial_page = contents->GetInterstitialPage();
3184 ASSERT_TRUE(interstitial_page); 3186 ASSERT_TRUE(interstitial_page);
3185 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, 3187 ASSERT_EQ(SSLBlockingPage::kTypeForTesting,
3186 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); 3188 interstitial_page->GetDelegateForTesting()->GetTypeForTesting());
3187 3189
3188 // Navigate away, and then trigger the network time response; no crash should 3190 // Navigate away, and then trigger the network time response; no crash should
3189 // occur. 3191 // occur.
3190 ASSERT_TRUE(https_server_.Start()); 3192 ASSERT_TRUE(https_server_.Start());
3191 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL("/")); 3193 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL("/"));
3192 ASSERT_NO_FATAL_FAILURE(CheckTimeQueryPending()); 3194 ASSERT_NO_FATAL_FAILURE(CheckTimeQueryPending());
3193 TriggerTimeResponse(); 3195 TriggerTimeResponse();
3194 } 3196 }
3195 3197
3196 // Tests that if the user stops the page load before either the network 3198 // Tests that if the user stops the page load before either the network
3197 // time fetch completes or the timeout expires, then there is no interstitial. 3199 // time fetch completes or the timeout expires, then there is no interstitial.
3198 IN_PROC_BROWSER_TEST_F(SSLNetworkTimeBrowserTest, StopBeforeTimeoutExpires) { 3200 IN_PROC_BROWSER_TEST_F(SSLNetworkTimeBrowserTest, StopBeforeTimeoutExpires) {
3199 ASSERT_TRUE(https_server_expired_.Start()); 3201 ASSERT_TRUE(https_server_expired_.Start());
3200 // Set the timer to a long delay. 3202 // Set the timer to a long delay.
3201 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); 3203 SSLErrorHandler::SetInterstitialDelayForTesting(
3204 base::TimeDelta::FromHours(1));
3202 3205
3203 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 3206 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
3204 ASSERT_TRUE(contents); 3207 ASSERT_TRUE(contents);
3205 SSLInterstitialTimerObserver interstitial_timer_observer(contents); 3208 SSLInterstitialTimerObserver interstitial_timer_observer(contents);
3206 3209
3207 ui_test_utils::NavigateToURLWithDisposition( 3210 ui_test_utils::NavigateToURLWithDisposition(
3208 browser(), https_server_expired_.GetURL("/"), 3211 browser(), https_server_expired_.GetURL("/"),
3209 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); 3212 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE);
3210 interstitial_timer_observer.WaitForTimerStarted(); 3213 interstitial_timer_observer.WaitForTimerStarted();
3211 3214
(...skipping 15 matching lines...) Expand all
3227 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL("/title1.html")); 3230 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL("/title1.html"));
3228 ASSERT_NO_FATAL_FAILURE(CheckTimeQueryPending()); 3231 ASSERT_NO_FATAL_FAILURE(CheckTimeQueryPending());
3229 TriggerTimeResponse(); 3232 TriggerTimeResponse();
3230 } 3233 }
3231 3234
3232 // Tests that if the user reloads the page before either the network 3235 // Tests that if the user reloads the page before either the network
3233 // time fetch completes or the timeout expires, then there is no interstitial. 3236 // time fetch completes or the timeout expires, then there is no interstitial.
3234 IN_PROC_BROWSER_TEST_F(SSLNetworkTimeBrowserTest, ReloadBeforeTimeoutExpires) { 3237 IN_PROC_BROWSER_TEST_F(SSLNetworkTimeBrowserTest, ReloadBeforeTimeoutExpires) {
3235 ASSERT_TRUE(https_server_expired_.Start()); 3238 ASSERT_TRUE(https_server_expired_.Start());
3236 // Set the timer to a long delay. 3239 // Set the timer to a long delay.
3237 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); 3240 SSLErrorHandler::SetInterstitialDelayForTesting(
3241 base::TimeDelta::FromHours(1));
3238 3242
3239 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 3243 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
3240 SSLInterstitialTimerObserver interstitial_timer_observer(contents); 3244 SSLInterstitialTimerObserver interstitial_timer_observer(contents);
3241 3245
3242 ui_test_utils::NavigateToURLWithDisposition( 3246 ui_test_utils::NavigateToURLWithDisposition(
3243 browser(), https_server_expired_.GetURL("/"), 3247 browser(), https_server_expired_.GetURL("/"),
3244 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); 3248 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE);
3245 interstitial_timer_observer.WaitForTimerStarted(); 3249 interstitial_timer_observer.WaitForTimerStarted();
3246 3250
3247 EXPECT_TRUE(contents->IsLoading()); 3251 EXPECT_TRUE(contents->IsLoading());
(...skipping 15 matching lines...) Expand all
3263 } 3267 }
3264 3268
3265 // Tests that if the user navigates away before either the network time 3269 // Tests that if the user navigates away before either the network time
3266 // fetch completes or the timeout expires, then there is no 3270 // fetch completes or the timeout expires, then there is no
3267 // interstitial. 3271 // interstitial.
3268 IN_PROC_BROWSER_TEST_F(SSLNetworkTimeBrowserTest, 3272 IN_PROC_BROWSER_TEST_F(SSLNetworkTimeBrowserTest,
3269 NavigateAwayBeforeTimeoutExpires) { 3273 NavigateAwayBeforeTimeoutExpires) {
3270 ASSERT_TRUE(https_server_expired_.Start()); 3274 ASSERT_TRUE(https_server_expired_.Start());
3271 ASSERT_TRUE(https_server_.Start()); 3275 ASSERT_TRUE(https_server_.Start());
3272 // Set the timer to a long delay. 3276 // Set the timer to a long delay.
3273 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); 3277 SSLErrorHandler::SetInterstitialDelayForTesting(
3278 base::TimeDelta::FromHours(1));
3274 3279
3275 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 3280 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
3276 SSLInterstitialTimerObserver interstitial_timer_observer(contents); 3281 SSLInterstitialTimerObserver interstitial_timer_observer(contents);
3277 3282
3278 ui_test_utils::NavigateToURLWithDisposition( 3283 ui_test_utils::NavigateToURLWithDisposition(
3279 browser(), https_server_expired_.GetURL("/"), 3284 browser(), https_server_expired_.GetURL("/"),
3280 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); 3285 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE);
3281 interstitial_timer_observer.WaitForTimerStarted(); 3286 interstitial_timer_observer.WaitForTimerStarted();
3282 3287
3283 EXPECT_TRUE(contents->IsLoading()); 3288 EXPECT_TRUE(contents->IsLoading());
(...skipping 14 matching lines...) Expand all
3298 ASSERT_NO_FATAL_FAILURE(CheckTimeQueryPending()); 3303 ASSERT_NO_FATAL_FAILURE(CheckTimeQueryPending());
3299 TriggerTimeResponse(); 3304 TriggerTimeResponse();
3300 } 3305 }
3301 3306
3302 // Tests that if the user closes the tab before the network time fetch 3307 // Tests that if the user closes the tab before the network time fetch
3303 // completes, it doesn't cause a crash. 3308 // completes, it doesn't cause a crash.
3304 IN_PROC_BROWSER_TEST_F(SSLNetworkTimeBrowserTest, 3309 IN_PROC_BROWSER_TEST_F(SSLNetworkTimeBrowserTest,
3305 CloseTabBeforeNetworkFetchCompletes) { 3310 CloseTabBeforeNetworkFetchCompletes) {
3306 ASSERT_TRUE(https_server_expired_.Start()); 3311 ASSERT_TRUE(https_server_expired_.Start());
3307 // Set the timer to fire immediately. 3312 // Set the timer to fire immediately.
3308 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta()); 3313 SSLErrorHandler::SetInterstitialDelayForTesting(base::TimeDelta());
3309 3314
3310 ui_test_utils::NavigateToURL(browser(), https_server_expired_.GetURL("/")); 3315 ui_test_utils::NavigateToURL(browser(), https_server_expired_.GetURL("/"));
3311 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 3316 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
3312 ASSERT_TRUE(contents); 3317 ASSERT_TRUE(contents);
3313 content::WaitForInterstitialAttach(contents); 3318 content::WaitForInterstitialAttach(contents);
3314 3319
3315 EXPECT_TRUE(contents->ShowingInterstitialPage()); 3320 EXPECT_TRUE(contents->ShowingInterstitialPage());
3316 InterstitialPage* interstitial_page = contents->GetInterstitialPage(); 3321 InterstitialPage* interstitial_page = contents->GetInterstitialPage();
3317 ASSERT_TRUE(interstitial_page); 3322 ASSERT_TRUE(interstitial_page);
3318 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, 3323 ASSERT_EQ(SSLBlockingPage::kTypeForTesting,
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
3503 https_server_example_domain_.GetURL("/ssl/google.html?a=b"); 3508 https_server_example_domain_.GetURL("/ssl/google.html?a=b");
3504 GURL::Replacements replacements; 3509 GURL::Replacements replacements;
3505 replacements.SetHostStr("www.mail.example.com"); 3510 replacements.SetHostStr("www.mail.example.com");
3506 GURL https_server_mismatched_url = 3511 GURL https_server_mismatched_url =
3507 https_server_url.ReplaceComponents(replacements); 3512 https_server_url.ReplaceComponents(replacements);
3508 3513
3509 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 3514 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
3510 CommonNameMismatchHandler::set_state_for_testing( 3515 CommonNameMismatchHandler::set_state_for_testing(
3511 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); 3516 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING);
3512 // Set delay long enough so that the page appears loading. 3517 // Set delay long enough so that the page appears loading.
3513 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); 3518 SSLErrorHandler::SetInterstitialDelayForTesting(
3519 base::TimeDelta::FromHours(1));
3514 SSLInterstitialTimerObserver interstitial_timer_observer(contents); 3520 SSLInterstitialTimerObserver interstitial_timer_observer(contents);
3515 3521
3516 ui_test_utils::NavigateToURLWithDisposition( 3522 ui_test_utils::NavigateToURLWithDisposition(
3517 browser(), https_server_mismatched_url, 3523 browser(), https_server_mismatched_url,
3518 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); 3524 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE);
3519 interstitial_timer_observer.WaitForTimerStarted(); 3525 interstitial_timer_observer.WaitForTimerStarted();
3520 3526
3521 EXPECT_TRUE(contents->IsLoading()); 3527 EXPECT_TRUE(contents->IsLoading());
3522 content::WindowedNotificationObserver observer( 3528 content::WindowedNotificationObserver observer(
3523 content::NOTIFICATION_LOAD_STOP, 3529 content::NOTIFICATION_LOAD_STOP,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3571 https_server_example_domain_.GetURL("/ssl/google.html?a=b"); 3577 https_server_example_domain_.GetURL("/ssl/google.html?a=b");
3572 GURL::Replacements replacements; 3578 GURL::Replacements replacements;
3573 replacements.SetHostStr("www.mail.example.com"); 3579 replacements.SetHostStr("www.mail.example.com");
3574 GURL https_server_mismatched_url = 3580 GURL https_server_mismatched_url =
3575 https_server_url.ReplaceComponents(replacements); 3581 https_server_url.ReplaceComponents(replacements);
3576 3582
3577 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 3583 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
3578 CommonNameMismatchHandler::set_state_for_testing( 3584 CommonNameMismatchHandler::set_state_for_testing(
3579 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); 3585 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING);
3580 // Set delay long enough so that the page appears loading. 3586 // Set delay long enough so that the page appears loading.
3581 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); 3587 SSLErrorHandler::SetInterstitialDelayForTesting(
3588 base::TimeDelta::FromHours(1));
3582 SSLInterstitialTimerObserver interstitial_timer_observer(contents); 3589 SSLInterstitialTimerObserver interstitial_timer_observer(contents);
3583 3590
3584 ui_test_utils::NavigateToURLWithDisposition( 3591 ui_test_utils::NavigateToURLWithDisposition(
3585 browser(), https_server_mismatched_url, 3592 browser(), https_server_mismatched_url,
3586 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); 3593 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE);
3587 interstitial_timer_observer.WaitForTimerStarted(); 3594 interstitial_timer_observer.WaitForTimerStarted();
3588 3595
3589 EXPECT_TRUE(contents->IsLoading()); 3596 EXPECT_TRUE(contents->IsLoading());
3590 content::TestNavigationObserver observer(contents, 1); 3597 content::TestNavigationObserver observer(contents, 1);
3591 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB); 3598 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3637 https_server_example_domain_.GetURL("/ssl/google.html?a=b"); 3644 https_server_example_domain_.GetURL("/ssl/google.html?a=b");
3638 GURL::Replacements replacements; 3645 GURL::Replacements replacements;
3639 replacements.SetHostStr("www.mail.example.com"); 3646 replacements.SetHostStr("www.mail.example.com");
3640 GURL https_server_mismatched_url = 3647 GURL https_server_mismatched_url =
3641 https_server_url.ReplaceComponents(replacements); 3648 https_server_url.ReplaceComponents(replacements);
3642 3649
3643 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 3650 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
3644 CommonNameMismatchHandler::set_state_for_testing( 3651 CommonNameMismatchHandler::set_state_for_testing(
3645 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); 3652 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING);
3646 // Set delay long enough so that the page appears loading. 3653 // Set delay long enough so that the page appears loading.
3647 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); 3654 SSLErrorHandler::SetInterstitialDelayForTesting(
3655 base::TimeDelta::FromHours(1));
3648 SSLInterstitialTimerObserver interstitial_timer_observer(contents); 3656 SSLInterstitialTimerObserver interstitial_timer_observer(contents);
3649 3657
3650 ui_test_utils::NavigateToURLWithDisposition( 3658 ui_test_utils::NavigateToURLWithDisposition(
3651 browser(), https_server_mismatched_url, 3659 browser(), https_server_mismatched_url,
3652 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); 3660 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE);
3653 interstitial_timer_observer.WaitForTimerStarted(); 3661 interstitial_timer_observer.WaitForTimerStarted();
3654 3662
3655 EXPECT_TRUE(contents->IsLoading()); 3663 EXPECT_TRUE(contents->IsLoading());
3656 content::TestNavigationObserver observer(contents, 1); 3664 content::TestNavigationObserver observer(contents, 1);
3657 browser()->OpenURL(content::OpenURLParams( 3665 browser()->OpenURL(content::OpenURLParams(
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
3881 3889
3882 // Visit a page over https that contains a frame with a redirect. 3890 // Visit a page over https that contains a frame with a redirect.
3883 3891
3884 // XMLHttpRequest insecure content in synchronous mode. 3892 // XMLHttpRequest insecure content in synchronous mode.
3885 3893
3886 // XMLHttpRequest insecure content in asynchronous mode. 3894 // XMLHttpRequest insecure content in asynchronous mode.
3887 3895
3888 // XMLHttpRequest over bad ssl in synchronous mode. 3896 // XMLHttpRequest over bad ssl in synchronous mode.
3889 3897
3890 // XMLHttpRequest over OK ssl in synchronous mode. 3898 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW
« no previous file with comments | « chrome/browser/captive_portal/captive_portal_browsertest.cc ('k') | chrome/browser/ssl/ssl_error_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698