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

Side by Side Diff: chrome/browser/captive_portal/captive_portal_browsertest.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
« no previous file with comments | « no previous file | chrome/browser/ssl/ssl_browser_tests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <map> 5 #include <map>
6 #include <memory> 6 #include <memory>
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 864
865 DISALLOW_COPY_AND_ASSIGN(SSLInterstitialTimerObserver); 865 DISALLOW_COPY_AND_ASSIGN(SSLInterstitialTimerObserver);
866 }; 866 };
867 867
868 SSLInterstitialTimerObserver::SSLInterstitialTimerObserver( 868 SSLInterstitialTimerObserver::SSLInterstitialTimerObserver(
869 content::WebContents* web_contents) 869 content::WebContents* web_contents)
870 : web_contents_(web_contents), 870 : web_contents_(web_contents),
871 message_loop_runner_(new content::MessageLoopRunner) { 871 message_loop_runner_(new content::MessageLoopRunner) {
872 callback_ = base::Bind(&SSLInterstitialTimerObserver::OnTimerStarted, 872 callback_ = base::Bind(&SSLInterstitialTimerObserver::OnTimerStarted,
873 base::Unretained(this)); 873 base::Unretained(this));
874 SSLErrorHandler::SetInterstitialTimerStartedCallbackForTest(&callback_); 874 SSLErrorHandler::SetInterstitialTimerStartedCallbackForTesting(&callback_);
875 } 875 }
876 876
877 SSLInterstitialTimerObserver::~SSLInterstitialTimerObserver() { 877 SSLInterstitialTimerObserver::~SSLInterstitialTimerObserver() {
878 SSLErrorHandler::SetInterstitialTimerStartedCallbackForTest(nullptr); 878 SSLErrorHandler::SetInterstitialTimerStartedCallbackForTesting(nullptr);
879 } 879 }
880 880
881 void SSLInterstitialTimerObserver::WaitForTimerStarted() { 881 void SSLInterstitialTimerObserver::WaitForTimerStarted() {
882 message_loop_runner_->Run(); 882 message_loop_runner_->Run();
883 } 883 }
884 884
885 void SSLInterstitialTimerObserver::OnTimerStarted( 885 void SSLInterstitialTimerObserver::OnTimerStarted(
886 content::WebContents* web_contents) { 886 content::WebContents* web_contents) {
887 if (web_contents_ == web_contents && message_loop_runner_.get()) 887 if (web_contents_ == web_contents && message_loop_runner_.get())
888 message_loop_runner_->Quit(); 888 message_loop_runner_->Quit();
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 EnableCaptivePortalDetection(browser()->profile(), true); 1118 EnableCaptivePortalDetection(browser()->profile(), true);
1119 1119
1120 // Set the captive portal service to use URLRequestMockCaptivePortalJob's 1120 // Set the captive portal service to use URLRequestMockCaptivePortalJob's
1121 // mock URL, by default. 1121 // mock URL, by default.
1122 SetUpCaptivePortalService(browser()->profile(), 1122 SetUpCaptivePortalService(browser()->profile(),
1123 GURL(kMockCaptivePortalTestUrl)); 1123 GURL(kMockCaptivePortalTestUrl));
1124 1124
1125 // Set SSL interstitial delay long enough so that a captive portal result 1125 // Set SSL interstitial delay long enough so that a captive portal result
1126 // is guaranteed to arrive during this window, and a captive portal 1126 // is guaranteed to arrive during this window, and a captive portal
1127 // error page is displayed instead of an SSL interstitial. 1127 // error page is displayed instead of an SSL interstitial.
1128 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); 1128 SSLErrorHandler::SetInterstitialDelayForTesting(
1129 base::TimeDelta::FromHours(1));
1129 } 1130 }
1130 1131
1131 void CaptivePortalBrowserTest::TearDownOnMainThread() { 1132 void CaptivePortalBrowserTest::TearDownOnMainThread() {
1132 // No test should have a captive portal check pending on quit. 1133 // No test should have a captive portal check pending on quit.
1133 EXPECT_FALSE(CheckPending(browser())); 1134 EXPECT_FALSE(CheckPending(browser()));
1134 } 1135 }
1135 1136
1136 void CaptivePortalBrowserTest::SetUpCommandLine( 1137 void CaptivePortalBrowserTest::SetUpCommandLine(
1137 base::CommandLine* command_line) { 1138 base::CommandLine* command_line) {
1138 // Enable finch experiment for captive portal interstitials. 1139 // Enable finch experiment for captive portal interstitials.
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 ASSERT_TRUE(embedded_test_server()->Start()); 2333 ASSERT_TRUE(embedded_test_server()->Start());
2333 2334
2334 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); 2335 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
2335 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_MISMATCHED_NAME); 2336 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_MISMATCHED_NAME);
2336 https_server.ServeFilesFromSourceDirectory("chrome/test/data"); 2337 https_server.ServeFilesFromSourceDirectory("chrome/test/data");
2337 ASSERT_TRUE(https_server.Start()); 2338 ASSERT_TRUE(https_server.Start());
2338 2339
2339 // Set SSL interstitial delay to zero so that a captive portal result can not 2340 // Set SSL interstitial delay to zero so that a captive portal result can not
2340 // arrive during this window, so an SSL interstitial is displayed instead 2341 // arrive during this window, so an SSL interstitial is displayed instead
2341 // of a captive portal error page. 2342 // of a captive portal error page.
2342 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta()); 2343 SSLErrorHandler::SetInterstitialDelayForTesting(base::TimeDelta());
2343 TabStripModel* tab_strip_model = browser()->tab_strip_model(); 2344 TabStripModel* tab_strip_model = browser()->tab_strip_model();
2344 WebContents* broken_tab_contents = tab_strip_model->GetActiveWebContents(); 2345 WebContents* broken_tab_contents = tab_strip_model->GetActiveWebContents();
2345 2346
2346 // Setting the delay to zero above has a race condition: A captive portal 2347 // Setting the delay to zero above has a race condition: A captive portal
2347 // result triggered by a cert error can arrive before the SSL interstitial 2348 // result triggered by a cert error can arrive before the SSL interstitial
2348 // display timer is fired, even though it's set to zero. 2349 // display timer is fired, even though it's set to zero.
2349 // To avoid this, disable captive portal checks until the SSL interstitial is 2350 // To avoid this, disable captive portal checks until the SSL interstitial is
2350 // displayed. Once it's displayed, enable portal checks and fire one. 2351 // displayed. Once it's displayed, enable portal checks and fire one.
2351 // NOTE: this doesn't occur with PlzNavigate, since the SSL interstitial timer 2352 // NOTE: this doesn't occur with PlzNavigate, since the SSL interstitial timer
2352 // is fired synchronously due to different timings when 2353 // is fired synchronously due to different timings when
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
2839 2840
2840 EXPECT_EQ(CaptivePortalTabReloader::STATE_NEEDS_RELOAD, 2841 EXPECT_EQ(CaptivePortalTabReloader::STATE_NEEDS_RELOAD,
2841 GetStateOfTabReloaderAt(browser(), broken_tab_index)); 2842 GetStateOfTabReloaderAt(browser(), broken_tab_index));
2842 2843
2843 WaitForInterstitialAttach(broken_tab_contents); 2844 WaitForInterstitialAttach(broken_tab_contents);
2844 portal_observer.WaitForResults(1); 2845 portal_observer.WaitForResults(1);
2845 2846
2846 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, 2847 EXPECT_EQ(SSLBlockingPage::kTypeForTesting,
2847 GetInterstitialType(broken_tab_contents)); 2848 GetInterstitialType(broken_tab_contents));
2848 } 2849 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ssl/ssl_browser_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698