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

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

Issue 2448943002: Refactor SecurityStateModel/Clients for simplicity and reusability. (Closed)
Patch Set: fix DEPS. Created 4 years, 1 month 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 14 matching lines...) Expand all
25 #include "chrome/app/chrome_command_ids.h" 25 #include "chrome/app/chrome_command_ids.h"
26 #include "chrome/browser/browser_process.h" 26 #include "chrome/browser/browser_process.h"
27 #include "chrome/browser/chrome_notification_types.h" 27 #include "chrome/browser/chrome_notification_types.h"
28 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 28 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
29 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h" 29 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h"
30 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/browser/ssl/bad_clock_blocking_page.h" 31 #include "chrome/browser/ssl/bad_clock_blocking_page.h"
32 #include "chrome/browser/ssl/cert_report_helper.h" 32 #include "chrome/browser/ssl/cert_report_helper.h"
33 #include "chrome/browser/ssl/cert_verifier_browser_test.h" 33 #include "chrome/browser/ssl/cert_verifier_browser_test.h"
34 #include "chrome/browser/ssl/certificate_reporting_test_utils.h" 34 #include "chrome/browser/ssl/certificate_reporting_test_utils.h"
35 #include "chrome/browser/ssl/chrome_security_state_model_client.h"
36 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" 35 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
37 #include "chrome/browser/ssl/common_name_mismatch_handler.h" 36 #include "chrome/browser/ssl/common_name_mismatch_handler.h"
37 #include "chrome/browser/ssl/security_state_tab_helper.h"
38 #include "chrome/browser/ssl/ssl_blocking_page.h" 38 #include "chrome/browser/ssl/ssl_blocking_page.h"
39 #include "chrome/browser/ssl/ssl_error_handler.h" 39 #include "chrome/browser/ssl/ssl_error_handler.h"
40 #include "chrome/browser/ui/browser.h" 40 #include "chrome/browser/ui/browser.h"
41 #include "chrome/browser/ui/browser_commands.h" 41 #include "chrome/browser/ui/browser_commands.h"
42 #include "chrome/browser/ui/browser_finder.h" 42 #include "chrome/browser/ui/browser_finder.h"
43 #include "chrome/browser/ui/browser_navigator.h" 43 #include "chrome/browser/ui/browser_navigator.h"
44 #include "chrome/browser/ui/browser_navigator_params.h" 44 #include "chrome/browser/ui/browser_navigator_params.h"
45 #include "chrome/browser/ui/browser_tabstrip.h" 45 #include "chrome/browser/ui/browser_tabstrip.h"
46 #include "chrome/browser/ui/tabs/tab_strip_model.h" 46 #include "chrome/browser/ui/tabs/tab_strip_model.h"
47 #include "chrome/common/chrome_paths.h" 47 #include "chrome/common/chrome_paths.h"
48 #include "chrome/common/chrome_switches.h" 48 #include "chrome/common/chrome_switches.h"
49 #include "chrome/common/pref_names.h" 49 #include "chrome/common/pref_names.h"
50 #include "chrome/test/base/in_process_browser_test.h" 50 #include "chrome/test/base/in_process_browser_test.h"
51 #include "chrome/test/base/ui_test_utils.h" 51 #include "chrome/test/base/ui_test_utils.h"
52 #include "components/content_settings/core/browser/host_content_settings_map.h" 52 #include "components/content_settings/core/browser/host_content_settings_map.h"
53 #include "components/network_time/network_time_tracker.h" 53 #include "components/network_time/network_time_tracker.h"
54 #include "components/prefs/pref_service.h" 54 #include "components/prefs/pref_service.h"
55 #include "components/security_interstitials/core/controller_client.h" 55 #include "components/security_interstitials/core/controller_client.h"
56 #include "components/security_interstitials/core/metrics_helper.h" 56 #include "components/security_interstitials/core/metrics_helper.h"
57 #include "components/security_state/security_state_model.h" 57 #include "components/security_state/core/security_state.h"
58 #include "components/security_state/switches.h" 58 #include "components/security_state/core/switches.h"
59 #include "components/ssl_errors/error_classification.h" 59 #include "components/ssl_errors/error_classification.h"
60 #include "components/variations/variations_associated_data.h" 60 #include "components/variations/variations_associated_data.h"
61 #include "components/web_modal/web_contents_modal_dialog_manager.h" 61 #include "components/web_modal/web_contents_modal_dialog_manager.h"
62 #include "content/public/browser/browser_context.h" 62 #include "content/public/browser/browser_context.h"
63 #include "content/public/browser/interstitial_page.h" 63 #include "content/public/browser/interstitial_page.h"
64 #include "content/public/browser/navigation_controller.h" 64 #include "content/public/browser/navigation_controller.h"
65 #include "content/public/browser/navigation_entry.h" 65 #include "content/public/browser/navigation_entry.h"
66 #include "content/public/browser/notification_details.h" 66 #include "content/public/browser/notification_details.h"
67 #include "content/public/browser/notification_service.h" 67 #include "content/public/browser/notification_service.h"
68 #include "content/public/browser/render_frame_host.h" 68 #include "content/public/browser/render_frame_host.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 bool ran_insecure_content = 152 bool ran_insecure_content =
153 !!(entry.GetSSL().content_status & SSLStatus::RAN_INSECURE_CONTENT); 153 !!(entry.GetSSL().content_status & SSLStatus::RAN_INSECURE_CONTENT);
154 EXPECT_EQ(!!(expected_authentication_state & AuthState::RAN_INSECURE_CONTENT), 154 EXPECT_EQ(!!(expected_authentication_state & AuthState::RAN_INSECURE_CONTENT),
155 ran_insecure_content); 155 ran_insecure_content);
156 } 156 }
157 157
158 } // namespace AuthState 158 } // namespace AuthState
159 159
160 namespace SecurityStyle { 160 namespace SecurityStyle {
161 161
162 void Check( 162 void Check(WebContents* tab,
163 WebContents* tab, 163 security_state::SecurityLevel expected_security_level) {
164 security_state::SecurityStateModel::SecurityLevel expected_security_level) { 164 SecurityStateTabHelper* helper = SecurityStateTabHelper::FromWebContents(tab);
165 ChromeSecurityStateModelClient* model_client = 165 security_state::SecurityInfo security_info;
166 ChromeSecurityStateModelClient::FromWebContents(tab); 166 helper->GetSecurityInfo(&security_info);
167 security_state::SecurityStateModel::SecurityInfo security_info;
168 model_client->GetSecurityInfo(&security_info);
169 EXPECT_EQ(expected_security_level, security_info.security_level); 167 EXPECT_EQ(expected_security_level, security_info.security_level);
170 } 168 }
171 169
172 } // namespace SecurityStyle 170 } // namespace SecurityStyle
173 171
174 namespace CertError { 172 namespace CertError {
175 173
176 enum CertErrorFlags { 174 enum CertErrorFlags {
177 NONE = 0 175 NONE = 0
178 }; 176 };
179 177
180 void Check(const NavigationEntry& entry, net::CertStatus error) { 178 void Check(const NavigationEntry& entry, net::CertStatus error) {
181 if (error) { 179 if (error) {
182 EXPECT_EQ(error, entry.GetSSL().cert_status & error); 180 EXPECT_EQ(error, entry.GetSSL().cert_status & error);
183 net::CertStatus extra_cert_errors = 181 net::CertStatus extra_cert_errors =
184 error ^ (entry.GetSSL().cert_status & net::CERT_STATUS_ALL_ERRORS); 182 error ^ (entry.GetSSL().cert_status & net::CERT_STATUS_ALL_ERRORS);
185 EXPECT_FALSE(extra_cert_errors) << "Got unexpected cert error: " 183 EXPECT_FALSE(extra_cert_errors) << "Got unexpected cert error: "
186 << extra_cert_errors; 184 << extra_cert_errors;
187 } else { 185 } else {
188 EXPECT_EQ(0U, entry.GetSSL().cert_status & net::CERT_STATUS_ALL_ERRORS); 186 EXPECT_EQ(0U, entry.GetSSL().cert_status & net::CERT_STATUS_ALL_ERRORS);
189 } 187 }
190 } 188 }
191 189
192 } // namespace CertError 190 } // namespace CertError
193 191
194 void CheckSecurityState( 192 void CheckSecurityState(WebContents* tab,
195 WebContents* tab, 193 net::CertStatus expected_error,
196 net::CertStatus expected_error, 194 security_state::SecurityLevel expected_security_level,
197 security_state::SecurityStateModel::SecurityLevel expected_security_level, 195 int expected_authentication_state) {
198 int expected_authentication_state) {
199 ASSERT_FALSE(tab->IsCrashed()); 196 ASSERT_FALSE(tab->IsCrashed());
200 NavigationEntry* entry = tab->GetController().GetActiveEntry(); 197 NavigationEntry* entry = tab->GetController().GetActiveEntry();
201 ASSERT_TRUE(entry); 198 ASSERT_TRUE(entry);
202 CertError::Check(*entry, expected_error); 199 CertError::Check(*entry, expected_error);
203 SecurityStyle::Check(tab, expected_security_level); 200 SecurityStyle::Check(tab, expected_security_level);
204 AuthState::Check(*entry, expected_authentication_state); 201 AuthState::Check(*entry, expected_authentication_state);
205 } 202 }
206 203
207 // This observer waits for the SSLErrorHandler to start an interstitial timer 204 // This observer waits for the SSLErrorHandler to start an interstitial timer
208 // for the given web contents. 205 // for the given web contents.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 void SetUpCommandLine(base::CommandLine* command_line) override { 306 void SetUpCommandLine(base::CommandLine* command_line) override {
310 // Browser will both run and display insecure content. 307 // Browser will both run and display insecure content.
311 command_line->AppendSwitch(switches::kAllowRunningInsecureContent); 308 command_line->AppendSwitch(switches::kAllowRunningInsecureContent);
312 // Use process-per-site so that navigating to a same-site page in a 309 // Use process-per-site so that navigating to a same-site page in a
313 // new tab will use the same process. 310 // new tab will use the same process.
314 command_line->AppendSwitch(switches::kProcessPerSite); 311 command_line->AppendSwitch(switches::kProcessPerSite);
315 } 312 }
316 313
317 void CheckAuthenticatedState(WebContents* tab, 314 void CheckAuthenticatedState(WebContents* tab,
318 int expected_authentication_state) { 315 int expected_authentication_state) {
319 CheckSecurityState(tab, CertError::NONE, 316 CheckSecurityState(tab, CertError::NONE, security_state::SECURE,
320 security_state::SecurityStateModel::SECURE,
321 expected_authentication_state); 317 expected_authentication_state);
322 } 318 }
323 319
324 void CheckUnauthenticatedState(WebContents* tab, 320 void CheckUnauthenticatedState(WebContents* tab,
325 int expected_authentication_state) { 321 int expected_authentication_state) {
326 CheckSecurityState(tab, CertError::NONE, 322 CheckSecurityState(tab, CertError::NONE, security_state::NONE,
327 security_state::SecurityStateModel::NONE,
328 expected_authentication_state); 323 expected_authentication_state);
329 } 324 }
330 325
331 void CheckAuthenticationBrokenState(WebContents* tab, 326 void CheckAuthenticationBrokenState(WebContents* tab,
332 net::CertStatus error, 327 net::CertStatus error,
333 int expected_authentication_state) { 328 int expected_authentication_state) {
334 CheckSecurityState(tab, error, 329 CheckSecurityState(tab, error, security_state::DANGEROUS,
335 security_state::SecurityStateModel::DANGEROUS,
336 expected_authentication_state); 330 expected_authentication_state);
337 // CERT_STATUS_UNABLE_TO_CHECK_REVOCATION doesn't lower the security level 331 // CERT_STATUS_UNABLE_TO_CHECK_REVOCATION doesn't lower the security level
338 // to DANGEROUS. 332 // to DANGEROUS.
339 ASSERT_NE(net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION, error); 333 ASSERT_NE(net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION, error);
340 } 334 }
341 335
342 void CheckWorkerLoadResult(WebContents* tab, bool expected_load) { 336 void CheckWorkerLoadResult(WebContents* tab, bool expected_load) {
343 // Workers are async and we don't have notifications for them passing 337 // Workers are async and we don't have notifications for them passing
344 // messages since they do it between renderer and worker processes. 338 // messages since they do it between renderer and worker processes.
345 // So have a polling loop, check every 200ms, timeout at 30s. 339 // So have a polling loop, check every 200ms, timeout at 30s.
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 958
965 ui_test_utils::NavigateToURL(browser(), 959 ui_test_utils::NavigateToURL(browser(),
966 https_server_expired_.GetURL("/title1.html")); 960 https_server_expired_.GetURL("/title1.html"));
967 WebContents* clock_tab = browser()->tab_strip_model()->GetActiveWebContents(); 961 WebContents* clock_tab = browser()->tab_strip_model()->GetActiveWebContents();
968 content::WaitForInterstitialAttach(clock_tab); 962 content::WaitForInterstitialAttach(clock_tab);
969 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage(); 963 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage();
970 ASSERT_TRUE(clock_interstitial); 964 ASSERT_TRUE(clock_interstitial);
971 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting, 965 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting,
972 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting()); 966 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting());
973 CheckSecurityState(clock_tab, net::CERT_STATUS_DATE_INVALID, 967 CheckSecurityState(clock_tab, net::CERT_STATUS_DATE_INVALID,
974 security_state::SecurityStateModel::DANGEROUS, 968 security_state::DANGEROUS,
975 AuthState::SHOWING_INTERSTITIAL); 969 AuthState::SHOWING_INTERSTITIAL);
976 } 970 }
977 971
978 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSErrorCausedByClockUsingNetwork) { 972 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSErrorCausedByClockUsingNetwork) {
979 ASSERT_TRUE(https_server_expired_.Start()); 973 ASSERT_TRUE(https_server_expired_.Start());
980 974
981 // Set network forward ten minutes, which is sufficient to trigger 975 // Set network forward ten minutes, which is sufficient to trigger
982 // the interstitial. 976 // the interstitial.
983 g_browser_process->network_time_tracker()->UpdateNetworkTime( 977 g_browser_process->network_time_tracker()->UpdateNetworkTime(
984 base::Time::Now() + base::TimeDelta::FromMinutes(10), 978 base::Time::Now() + base::TimeDelta::FromMinutes(10),
985 base::TimeDelta::FromMilliseconds(1), /* resolution */ 979 base::TimeDelta::FromMilliseconds(1), /* resolution */
986 base::TimeDelta::FromMilliseconds(500), /* latency */ 980 base::TimeDelta::FromMilliseconds(500), /* latency */
987 base::TimeTicks::Now() /* posting time of this update */); 981 base::TimeTicks::Now() /* posting time of this update */);
988 982
989 ui_test_utils::NavigateToURL(browser(), 983 ui_test_utils::NavigateToURL(browser(),
990 https_server_expired_.GetURL("/title1.html")); 984 https_server_expired_.GetURL("/title1.html"));
991 WebContents* clock_tab = browser()->tab_strip_model()->GetActiveWebContents(); 985 WebContents* clock_tab = browser()->tab_strip_model()->GetActiveWebContents();
992 content::WaitForInterstitialAttach(clock_tab); 986 content::WaitForInterstitialAttach(clock_tab);
993 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage(); 987 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage();
994 ASSERT_TRUE(clock_interstitial); 988 ASSERT_TRUE(clock_interstitial);
995 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting, 989 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting,
996 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting()); 990 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting());
997 CheckSecurityState(clock_tab, net::CERT_STATUS_DATE_INVALID, 991 CheckSecurityState(clock_tab, net::CERT_STATUS_DATE_INVALID,
998 security_state::SecurityStateModel::DANGEROUS, 992 security_state::DANGEROUS,
999 AuthState::SHOWING_INTERSTITIAL); 993 AuthState::SHOWING_INTERSTITIAL);
1000 } 994 }
1001 995
1002 // Visits a page with https error and then goes back using Browser::GoBack. 996 // Visits a page with https error and then goes back using Browser::GoBack.
1003 IN_PROC_BROWSER_TEST_F(SSLUITest, 997 IN_PROC_BROWSER_TEST_F(SSLUITest,
1004 TestHTTPSExpiredCertAndGoBackViaButton) { 998 TestHTTPSExpiredCertAndGoBackViaButton) {
1005 ASSERT_TRUE(embedded_test_server()->Start()); 999 ASSERT_TRUE(embedded_test_server()->Start());
1006 ASSERT_TRUE(https_server_expired_.Start()); 1000 ASSERT_TRUE(https_server_expired_.Start());
1007 1001
1008 // First navigate to an HTTP page. 1002 // First navigate to an HTTP page.
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 // MarkNonSecureAs field trial is enabled. 1188 // MarkNonSecureAs field trial is enabled.
1195 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkFileAsNonSecure) { 1189 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkFileAsNonSecure) {
1196 scoped_refptr<base::FieldTrial> trial = 1190 scoped_refptr<base::FieldTrial> trial =
1197 base::FieldTrialList::CreateFieldTrial( 1191 base::FieldTrialList::CreateFieldTrial(
1198 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous); 1192 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous);
1199 1193
1200 content::WebContents* contents = 1194 content::WebContents* contents =
1201 browser()->tab_strip_model()->GetActiveWebContents(); 1195 browser()->tab_strip_model()->GetActiveWebContents();
1202 ASSERT_TRUE(contents); 1196 ASSERT_TRUE(contents);
1203 1197
1204 ChromeSecurityStateModelClient* model_client = 1198 SecurityStateTabHelper* helper =
1205 ChromeSecurityStateModelClient::FromWebContents(contents); 1199 SecurityStateTabHelper::FromWebContents(contents);
1206 ASSERT_TRUE(model_client); 1200 ASSERT_TRUE(helper);
1207 1201
1208 ui_test_utils::NavigateToURL(browser(), GURL("file:///")); 1202 ui_test_utils::NavigateToURL(browser(), GURL("file:///"));
1209 security_state::SecurityStateModel::SecurityInfo security_info; 1203 security_state::SecurityInfo security_info;
1210 model_client->GetSecurityInfo(&security_info); 1204 helper->GetSecurityInfo(&security_info);
1211 EXPECT_EQ(security_state::SecurityStateModel::NONE, 1205 EXPECT_EQ(security_state::NONE, security_info.security_level);
1212 security_info.security_level);
1213 } 1206 }
1214 1207
1215 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkAboutAsNonSecure) { 1208 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkAboutAsNonSecure) {
1216 scoped_refptr<base::FieldTrial> trial = 1209 scoped_refptr<base::FieldTrial> trial =
1217 base::FieldTrialList::CreateFieldTrial( 1210 base::FieldTrialList::CreateFieldTrial(
1218 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous); 1211 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous);
1219 1212
1220 content::WebContents* contents = 1213 content::WebContents* contents =
1221 browser()->tab_strip_model()->GetActiveWebContents(); 1214 browser()->tab_strip_model()->GetActiveWebContents();
1222 ASSERT_TRUE(contents); 1215 ASSERT_TRUE(contents);
1223 1216
1224 ChromeSecurityStateModelClient* model_client = 1217 SecurityStateTabHelper* helper =
1225 ChromeSecurityStateModelClient::FromWebContents(contents); 1218 SecurityStateTabHelper::FromWebContents(contents);
1226 ASSERT_TRUE(model_client); 1219 ASSERT_TRUE(helper);
1227 1220
1228 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); 1221 ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
1229 security_state::SecurityStateModel::SecurityInfo security_info; 1222 security_state::SecurityInfo security_info;
1230 model_client->GetSecurityInfo(&security_info); 1223 helper->GetSecurityInfo(&security_info);
1231 EXPECT_EQ(security_state::SecurityStateModel::NONE, 1224 EXPECT_EQ(security_state::NONE, security_info.security_level);
1232 security_info.security_level);
1233 } 1225 }
1234 1226
1235 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkDataAsNonSecure) { 1227 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkDataAsNonSecure) {
1236 scoped_refptr<base::FieldTrial> trial = 1228 scoped_refptr<base::FieldTrial> trial =
1237 base::FieldTrialList::CreateFieldTrial( 1229 base::FieldTrialList::CreateFieldTrial(
1238 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous); 1230 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous);
1239 1231
1240 content::WebContents* contents = 1232 content::WebContents* contents =
1241 browser()->tab_strip_model()->GetActiveWebContents(); 1233 browser()->tab_strip_model()->GetActiveWebContents();
1242 ASSERT_TRUE(contents); 1234 ASSERT_TRUE(contents);
1243 1235
1244 ChromeSecurityStateModelClient* model_client = 1236 SecurityStateTabHelper* helper =
1245 ChromeSecurityStateModelClient::FromWebContents(contents); 1237 SecurityStateTabHelper::FromWebContents(contents);
1246 ASSERT_TRUE(model_client); 1238 ASSERT_TRUE(helper);
1247 1239
1248 ui_test_utils::NavigateToURL(browser(), GURL("data:text/plain,hello")); 1240 ui_test_utils::NavigateToURL(browser(), GURL("data:text/plain,hello"));
1249 security_state::SecurityStateModel::SecurityInfo security_info; 1241 security_state::SecurityInfo security_info;
1250 model_client->GetSecurityInfo(&security_info); 1242 helper->GetSecurityInfo(&security_info);
1251 EXPECT_EQ(security_state::SecurityStateModel::NONE, 1243 EXPECT_EQ(security_state::NONE, security_info.security_level);
1252 security_info.security_level);
1253 } 1244 }
1254 1245
1255 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkBlobAsNonSecure) { 1246 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkBlobAsNonSecure) {
1256 scoped_refptr<base::FieldTrial> trial = 1247 scoped_refptr<base::FieldTrial> trial =
1257 base::FieldTrialList::CreateFieldTrial( 1248 base::FieldTrialList::CreateFieldTrial(
1258 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous); 1249 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous);
1259 1250
1260 content::WebContents* contents = 1251 content::WebContents* contents =
1261 browser()->tab_strip_model()->GetActiveWebContents(); 1252 browser()->tab_strip_model()->GetActiveWebContents();
1262 ASSERT_TRUE(contents); 1253 ASSERT_TRUE(contents);
1263 1254
1264 ChromeSecurityStateModelClient* model_client = 1255 SecurityStateTabHelper* helper =
1265 ChromeSecurityStateModelClient::FromWebContents(contents); 1256 SecurityStateTabHelper::FromWebContents(contents);
1266 ASSERT_TRUE(model_client); 1257 ASSERT_TRUE(helper);
1267 1258
1268 ui_test_utils::NavigateToURL( 1259 ui_test_utils::NavigateToURL(
1269 browser(), 1260 browser(),
1270 GURL("blob:chrome://newtab/49a463bb-fac8-476c-97bf-5d7076c3ea1a")); 1261 GURL("blob:chrome://newtab/49a463bb-fac8-476c-97bf-5d7076c3ea1a"));
1271 security_state::SecurityStateModel::SecurityInfo security_info; 1262 security_state::SecurityInfo security_info;
1272 model_client->GetSecurityInfo(&security_info); 1263 helper->GetSecurityInfo(&security_info);
1273 EXPECT_EQ(security_state::SecurityStateModel::NONE, 1264 EXPECT_EQ(security_state::NONE, security_info.security_level);
1274 security_info.security_level);
1275 } 1265 }
1276 1266
1277 #if defined(USE_NSS_CERTS) 1267 #if defined(USE_NSS_CERTS)
1278 class SSLUITestWithClientCert : public SSLUITest { 1268 class SSLUITestWithClientCert : public SSLUITest {
1279 public: 1269 public:
1280 SSLUITestWithClientCert() : cert_db_(NULL) {} 1270 SSLUITestWithClientCert() : cert_db_(NULL) {}
1281 1271
1282 void SetUpOnMainThread() override { 1272 void SetUpOnMainThread() override {
1283 SSLUITest::SetUpOnMainThread(); 1273 SSLUITest::SetUpOnMainThread();
1284 1274
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 std::string replacement_path; 1465 std::string replacement_path;
1476 GetFilePathWithHostAndPortReplacement( 1466 GetFilePathWithHostAndPortReplacement(
1477 "/ssl/page_displays_insecure_content.html", 1467 "/ssl/page_displays_insecure_content.html",
1478 embedded_test_server()->host_port_pair(), &replacement_path); 1468 embedded_test_server()->host_port_pair(), &replacement_path);
1479 1469
1480 // Load a page that displays insecure content. 1470 // Load a page that displays insecure content.
1481 ui_test_utils::NavigateToURL(browser(), 1471 ui_test_utils::NavigateToURL(browser(),
1482 https_server_.GetURL(replacement_path)); 1472 https_server_.GetURL(replacement_path));
1483 1473
1484 CheckSecurityState(browser()->tab_strip_model()->GetActiveWebContents(), 1474 CheckSecurityState(browser()->tab_strip_model()->GetActiveWebContents(),
1485 CertError::NONE, security_state::SecurityStateModel::NONE, 1475 CertError::NONE, security_state::NONE,
1486 AuthState::DISPLAYED_INSECURE_CONTENT); 1476 AuthState::DISPLAYED_INSECURE_CONTENT);
1487 } 1477 }
1488 1478
1489 // Test that if the user proceeds and the checkbox is checked, a report 1479 // Test that if the user proceeds and the checkbox is checked, a report
1490 // is sent or not sent depending on the Finch config. 1480 // is sent or not sent depending on the Finch config.
1491 IN_PROC_BROWSER_TEST_F(SSLUITestWithExtendedReporting, 1481 IN_PROC_BROWSER_TEST_F(SSLUITestWithExtendedReporting,
1492 TestBrokenHTTPSProceedReporting) { 1482 TestBrokenHTTPSProceedReporting) {
1493 certificate_reporting_test_utils::ExpectReport expect_report = 1483 certificate_reporting_test_utils::ExpectReport expect_report =
1494 certificate_reporting_test_utils::GetReportExpectedFromFinch(); 1484 certificate_reporting_test_utils::GetReportExpectedFromFinch();
1495 TestBrokenHTTPSReporting( 1485 TestBrokenHTTPSReporting(
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 1695
1706 // Load the insecure image. 1696 // Load the insecure image.
1707 bool js_result = false; 1697 bool js_result = false;
1708 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 1698 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1709 tab, 1699 tab,
1710 "loadBadImage();", 1700 "loadBadImage();",
1711 &js_result)); 1701 &js_result));
1712 EXPECT_TRUE(js_result); 1702 EXPECT_TRUE(js_result);
1713 1703
1714 // We should now have insecure content. 1704 // We should now have insecure content.
1715 CheckSecurityState(tab, CertError::NONE, 1705 CheckSecurityState(tab, CertError::NONE, security_state::NONE,
1716 security_state::SecurityStateModel::NONE,
1717 AuthState::DISPLAYED_INSECURE_CONTENT); 1706 AuthState::DISPLAYED_INSECURE_CONTENT);
1718 } 1707 }
1719 1708
1720 // Visits two pages from the same origin: one that displays insecure content and 1709 // Visits two pages from the same origin: one that displays insecure content and
1721 // one that doesn't. The test checks that we do not propagate the insecure 1710 // one that doesn't. The test checks that we do not propagate the insecure
1722 // content state from one to the other. 1711 // content state from one to the other.
1723 IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysInsecureContentTwoTabs) { 1712 IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysInsecureContentTwoTabs) {
1724 ASSERT_TRUE(embedded_test_server()->Start()); 1713 ASSERT_TRUE(embedded_test_server()->Start());
1725 ASSERT_TRUE(https_server_.Start()); 1714 ASSERT_TRUE(https_server_.Start());
1726 1715
(...skipping 17 matching lines...) Expand all
1744 params.tabstrip_index = 0; 1733 params.tabstrip_index = 0;
1745 params.source_contents = tab1; 1734 params.source_contents = tab1;
1746 content::WindowedNotificationObserver observer( 1735 content::WindowedNotificationObserver observer(
1747 content::NOTIFICATION_LOAD_STOP, 1736 content::NOTIFICATION_LOAD_STOP,
1748 content::NotificationService::AllSources()); 1737 content::NotificationService::AllSources());
1749 chrome::Navigate(&params); 1738 chrome::Navigate(&params);
1750 WebContents* tab2 = params.target_contents; 1739 WebContents* tab2 = params.target_contents;
1751 observer.Wait(); 1740 observer.Wait();
1752 1741
1753 // The new tab has insecure content. 1742 // The new tab has insecure content.
1754 CheckSecurityState(tab2, CertError::NONE, 1743 CheckSecurityState(tab2, CertError::NONE, security_state::NONE,
1755 security_state::SecurityStateModel::NONE,
1756 AuthState::DISPLAYED_INSECURE_CONTENT); 1744 AuthState::DISPLAYED_INSECURE_CONTENT);
1757 1745
1758 // The original tab should not be contaminated. 1746 // The original tab should not be contaminated.
1759 CheckAuthenticatedState(tab1, AuthState::NONE); 1747 CheckAuthenticatedState(tab1, AuthState::NONE);
1760 } 1748 }
1761 1749
1762 // Visits two pages from the same origin: one that runs insecure content and one 1750 // Visits two pages from the same origin: one that runs insecure content and one
1763 // that doesn't. The test checks that we propagate the insecure content state 1751 // that doesn't. The test checks that we propagate the insecure content state
1764 // from one to the other. 1752 // from one to the other.
1765 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRunsInsecureContentTwoTabs) { 1753 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRunsInsecureContentTwoTabs) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1821 // Load original page over HTTP. 1809 // Load original page over HTTP.
1822 const GURL url_http = embedded_test_server()->GetURL(replacement_path); 1810 const GURL url_http = embedded_test_server()->GetURL(replacement_path);
1823 ui_test_utils::NavigateToURL(browser(), url_http); 1811 ui_test_utils::NavigateToURL(browser(), url_http);
1824 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 1812 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
1825 CheckUnauthenticatedState(tab, AuthState::NONE); 1813 CheckUnauthenticatedState(tab, AuthState::NONE);
1826 1814
1827 // Load again but over SSL. It should be marked as displaying insecure 1815 // Load again but over SSL. It should be marked as displaying insecure
1828 // content (even though the image comes from the WebCore memory cache). 1816 // content (even though the image comes from the WebCore memory cache).
1829 const GURL url_https = https_server_.GetURL(replacement_path); 1817 const GURL url_https = https_server_.GetURL(replacement_path);
1830 ui_test_utils::NavigateToURL(browser(), url_https); 1818 ui_test_utils::NavigateToURL(browser(), url_https);
1831 CheckSecurityState(tab, CertError::NONE, 1819 CheckSecurityState(tab, CertError::NONE, security_state::NONE,
1832 security_state::SecurityStateModel::NONE,
1833 AuthState::DISPLAYED_INSECURE_CONTENT); 1820 AuthState::DISPLAYED_INSECURE_CONTENT);
1834 } 1821 }
1835 1822
1836 // http://crbug.com/84729 1823 // http://crbug.com/84729
1837 #if defined(OS_CHROMEOS) 1824 #if defined(OS_CHROMEOS)
1838 #define MAYBE_TestRunsCachedInsecureContent \ 1825 #define MAYBE_TestRunsCachedInsecureContent \
1839 DISABLED_TestRunsCachedInsecureContent 1826 DISABLED_TestRunsCachedInsecureContent
1840 #else 1827 #else
1841 #define MAYBE_TestRunsCachedInsecureContent TestRunsCachedInsecureContent 1828 #define MAYBE_TestRunsCachedInsecureContent TestRunsCachedInsecureContent
1842 #endif // defined(OS_CHROMEOS) 1829 #endif // defined(OS_CHROMEOS)
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
2171 " window.domAutomationController.setAutomationId(0);" 2158 " window.domAutomationController.setAutomationId(0);"
2172 " window.domAutomationController.send('mixed-image-loaded');" 2159 " window.domAutomationController.send('mixed-image-loaded');"
2173 "};" 2160 "};"
2174 "var img = document.createElement('img');" 2161 "var img = document.createElement('img');"
2175 "img.onload = loaded;" 2162 "img.onload = loaded;"
2176 "img.src = '" + 2163 "img.src = '" +
2177 https_url.spec() + "';" 2164 https_url.spec() + "';"
2178 "document.body.appendChild(img);")); 2165 "document.body.appendChild(img);"));
2179 2166
2180 run_loop.Run(); 2167 run_loop.Run();
2181 CheckSecurityState(tab, CertError::NONE, 2168 CheckSecurityState(tab, CertError::NONE, security_state::NONE,
2182 security_state::SecurityStateModel::NONE,
2183 AuthState::DISPLAYED_INSECURE_CONTENT); 2169 AuthState::DISPLAYED_INSECURE_CONTENT);
2184 } 2170 }
2185 2171
2186 // Visits a page to which we could not connect (bad port) over http and https 2172 // Visits a page to which we could not connect (bad port) over http and https
2187 // and make sure the security style is correct. 2173 // and make sure the security style is correct.
2188 IN_PROC_BROWSER_TEST_F(SSLUITest, TestConnectToBadPort) { 2174 IN_PROC_BROWSER_TEST_F(SSLUITest, TestConnectToBadPort) {
2189 ui_test_utils::NavigateToURL(browser(), GURL("http://localhost:17")); 2175 ui_test_utils::NavigateToURL(browser(), GURL("http://localhost:17"));
2190 CheckUnauthenticatedState( 2176 CheckUnauthenticatedState(
2191 browser()->tab_strip_model()->GetActiveWebContents(), 2177 browser()->tab_strip_model()->GetActiveWebContents(),
2192 AuthState::SHOWING_ERROR); 2178 AuthState::SHOWING_ERROR);
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
2452 // the user approves the bad certificate. 2438 // the user approves the bad certificate.
2453 ui_test_utils::NavigateToURL( 2439 ui_test_utils::NavigateToURL(
2454 browser(), https_server_mismatched_.GetURL("/ssl/blank_page.html")); 2440 browser(), https_server_mismatched_.GetURL("/ssl/blank_page.html"));
2455 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 2441 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
2456 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, 2442 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
2457 AuthState::SHOWING_INTERSTITIAL); 2443 AuthState::SHOWING_INTERSTITIAL);
2458 ProceedThroughInterstitial(tab); 2444 ProceedThroughInterstitial(tab);
2459 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, 2445 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
2460 AuthState::NONE); 2446 AuthState::NONE);
2461 2447
2462 ChromeSecurityStateModelClient* client = 2448 SecurityStateTabHelper* helper = SecurityStateTabHelper::FromWebContents(tab);
2463 ChromeSecurityStateModelClient::FromWebContents(tab); 2449 ASSERT_TRUE(helper);
2464 ASSERT_TRUE(client); 2450 security_state::SecurityInfo security_info;
2465 security_state::SecurityStateModel::SecurityInfo security_info; 2451 helper->GetSecurityInfo(&security_info);
2466 client->GetSecurityInfo(&security_info); 2452 EXPECT_EQ(security_state::CONTENT_STATUS_NONE,
2467 EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_NONE,
2468 security_info.mixed_content_status); 2453 security_info.mixed_content_status);
2469 EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_NONE, 2454 EXPECT_EQ(security_state::CONTENT_STATUS_NONE,
2470 security_info.content_with_cert_errors_status); 2455 security_info.content_with_cert_errors_status);
2471 2456
2472 // Navigate to safe page that has Worker loading unsafe content. 2457 // Navigate to safe page that has Worker loading unsafe content.
2473 // Expect content to load but be marked as auth broken due to running insecure 2458 // Expect content to load but be marked as auth broken due to running insecure
2474 // content. 2459 // content.
2475 std::string page_with_unsafe_worker_path; 2460 std::string page_with_unsafe_worker_path;
2476 GetPageWithUnsafeWorkerPath(https_server_mismatched_, 2461 GetPageWithUnsafeWorkerPath(https_server_mismatched_,
2477 &page_with_unsafe_worker_path); 2462 &page_with_unsafe_worker_path);
2478 ui_test_utils::NavigateToURL( 2463 ui_test_utils::NavigateToURL(
2479 browser(), https_server_.GetURL(page_with_unsafe_worker_path)); 2464 browser(), https_server_.GetURL(page_with_unsafe_worker_path));
2480 CheckWorkerLoadResult(tab, true); // Worker loads insecure content 2465 CheckWorkerLoadResult(tab, true); // Worker loads insecure content
2481 CheckAuthenticationBrokenState(tab, CertError::NONE, AuthState::NONE); 2466 CheckAuthenticationBrokenState(tab, CertError::NONE, AuthState::NONE);
2482 2467
2483 client->GetSecurityInfo(&security_info); 2468 helper->GetSecurityInfo(&security_info);
2484 EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_NONE, 2469 EXPECT_EQ(security_state::CONTENT_STATUS_NONE,
2485 security_info.mixed_content_status); 2470 security_info.mixed_content_status);
2486 EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_RAN, 2471 EXPECT_EQ(security_state::CONTENT_STATUS_RAN,
2487 security_info.content_with_cert_errors_status); 2472 security_info.content_with_cert_errors_status);
2488 } 2473 }
2489 2474
2490 // Visits a page with unsafe content and makes sure that if a user exception to 2475 // Visits a page with unsafe content and makes sure that if a user exception to
2491 // the certificate error is present, the image is loaded and script executes. 2476 // the certificate error is present, the image is loaded and script executes.
2492 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsWithUserException) { 2477 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsWithUserException) {
2493 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 2478 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
2494 ASSERT_NO_FATAL_FAILURE(SetUpUnsafeContentsWithUserException( 2479 ASSERT_NO_FATAL_FAILURE(SetUpUnsafeContentsWithUserException(
2495 "/ssl/page_with_unsafe_contents.html")); 2480 "/ssl/page_with_unsafe_contents.html"));
2496 CheckAuthenticationBrokenState(tab, CertError::NONE, AuthState::NONE); 2481 CheckAuthenticationBrokenState(tab, CertError::NONE, AuthState::NONE);
2497 2482
2498 ChromeSecurityStateModelClient* client = 2483 SecurityStateTabHelper* helper = SecurityStateTabHelper::FromWebContents(tab);
2499 ChromeSecurityStateModelClient::FromWebContents(tab); 2484 ASSERT_TRUE(helper);
2500 ASSERT_TRUE(client); 2485 security_state::SecurityInfo security_info;
2501 security_state::SecurityStateModel::SecurityInfo security_info; 2486 helper->GetSecurityInfo(&security_info);
2502 client->GetSecurityInfo(&security_info); 2487 EXPECT_EQ(security_state::CONTENT_STATUS_NONE,
2503 EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_NONE,
2504 security_info.mixed_content_status); 2488 security_info.mixed_content_status);
2505 EXPECT_EQ( 2489 EXPECT_EQ(security_state::CONTENT_STATUS_DISPLAYED_AND_RAN,
2506 security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN, 2490 security_info.content_with_cert_errors_status);
2507 security_info.content_with_cert_errors_status);
2508 2491
2509 int img_width; 2492 int img_width;
2510 EXPECT_TRUE(content::ExecuteScriptAndExtractInt( 2493 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(
2511 tab, "window.domAutomationController.send(ImageWidth());", &img_width)); 2494 tab, "window.domAutomationController.send(ImageWidth());", &img_width));
2512 // In order to check that the image was loaded, we check its width. 2495 // In order to check that the image was loaded, we check its width.
2513 // The actual image (Google logo) is 114 pixels wide, so we assume a good 2496 // The actual image (Google logo) is 114 pixels wide, so we assume a good
2514 // image is greater than 100. 2497 // image is greater than 100.
2515 EXPECT_GT(img_width, 100); 2498 EXPECT_GT(img_width, 100);
2516 2499
2517 bool js_result = false; 2500 bool js_result = false;
2518 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 2501 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
2519 tab, "window.domAutomationController.send(IsFooSet());", &js_result)); 2502 tab, "window.domAutomationController.send(IsFooSet());", &js_result));
2520 EXPECT_TRUE(js_result); 2503 EXPECT_TRUE(js_result);
2521 2504
2522 // Test that active subresources with the same certificate errors as 2505 // Test that active subresources with the same certificate errors as
2523 // the main resources also get noted in |content_with_cert_errors_status|. 2506 // the main resources also get noted in |content_with_cert_errors_status|.
2524 std::string replacement_path; 2507 std::string replacement_path;
2525 GetFilePathWithHostAndPortReplacement( 2508 GetFilePathWithHostAndPortReplacement(
2526 "/ssl/page_with_unsafe_contents.html", 2509 "/ssl/page_with_unsafe_contents.html",
2527 https_server_mismatched_.host_port_pair(), &replacement_path); 2510 https_server_mismatched_.host_port_pair(), &replacement_path);
2528 ui_test_utils::NavigateToURL( 2511 ui_test_utils::NavigateToURL(
2529 browser(), https_server_mismatched_.GetURL(replacement_path)); 2512 browser(), https_server_mismatched_.GetURL(replacement_path));
2530 js_result = false; 2513 js_result = false;
2531 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 2514 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
2532 tab, "window.domAutomationController.send(IsFooSet());", &js_result)); 2515 tab, "window.domAutomationController.send(IsFooSet());", &js_result));
2533 EXPECT_TRUE(js_result); 2516 EXPECT_TRUE(js_result);
2534 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, 2517 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
2535 AuthState::NONE); 2518 AuthState::NONE);
2536 2519
2537 client->GetSecurityInfo(&security_info); 2520 helper->GetSecurityInfo(&security_info);
2538 EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_NONE, 2521 EXPECT_EQ(security_state::CONTENT_STATUS_NONE,
2539 security_info.mixed_content_status); 2522 security_info.mixed_content_status);
2540 EXPECT_EQ( 2523 EXPECT_EQ(security_state::CONTENT_STATUS_DISPLAYED_AND_RAN,
2541 security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN, 2524 security_info.content_with_cert_errors_status);
2542 security_info.content_with_cert_errors_status);
2543 } 2525 }
2544 2526
2545 // Like the test above, but only displaying inactive content (an image). 2527 // Like the test above, but only displaying inactive content (an image).
2546 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeImageWithUserException) { 2528 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeImageWithUserException) {
2547 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 2529 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
2548 ASSERT_NO_FATAL_FAILURE( 2530 ASSERT_NO_FATAL_FAILURE(
2549 SetUpUnsafeContentsWithUserException("/ssl/page_with_unsafe_image.html")); 2531 SetUpUnsafeContentsWithUserException("/ssl/page_with_unsafe_image.html"));
2550 2532
2551 ChromeSecurityStateModelClient* client = 2533 SecurityStateTabHelper* helper = SecurityStateTabHelper::FromWebContents(tab);
2552 ChromeSecurityStateModelClient::FromWebContents(tab); 2534 ASSERT_TRUE(helper);
2553 ASSERT_TRUE(client); 2535 security_state::SecurityInfo security_info;
2554 security_state::SecurityStateModel::SecurityInfo security_info; 2536 helper->GetSecurityInfo(&security_info);
2555 client->GetSecurityInfo(&security_info); 2537 EXPECT_EQ(security_state::CONTENT_STATUS_NONE,
2556 EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_NONE,
2557 security_info.mixed_content_status); 2538 security_info.mixed_content_status);
2558 EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED, 2539 EXPECT_EQ(security_state::CONTENT_STATUS_DISPLAYED,
2559 security_info.content_with_cert_errors_status); 2540 security_info.content_with_cert_errors_status);
2560 EXPECT_EQ(security_state::SecurityStateModel::NONE, 2541 EXPECT_EQ(security_state::NONE, security_info.security_level);
2561 security_info.security_level);
2562 EXPECT_EQ(0u, security_info.cert_status); 2542 EXPECT_EQ(0u, security_info.cert_status);
2563 2543
2564 int img_width; 2544 int img_width;
2565 EXPECT_TRUE(content::ExecuteScriptAndExtractInt( 2545 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(
2566 tab, "window.domAutomationController.send(ImageWidth());", &img_width)); 2546 tab, "window.domAutomationController.send(ImageWidth());", &img_width));
2567 // In order to check that the image was loaded, we check its width. 2547 // In order to check that the image was loaded, we check its width.
2568 // The actual image (Google logo) is 114 pixels wide, so we assume a good 2548 // The actual image (Google logo) is 114 pixels wide, so we assume a good
2569 // image is greater than 100. 2549 // image is greater than 100.
2570 EXPECT_GT(img_width, 100); 2550 EXPECT_GT(img_width, 100);
2571 } 2551 }
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2916 2896
2917 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 2897 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
2918 content::TestNavigationObserver observer( 2898 content::TestNavigationObserver observer(
2919 contents, 2899 contents,
2920 // With PlzNavigate, the renderer only sees one navigation (i.e. not the 2900 // With PlzNavigate, the renderer only sees one navigation (i.e. not the
2921 // redirect, since that happens in the browser). 2901 // redirect, since that happens in the browser).
2922 content::IsBrowserSideNavigationEnabled() ? 1 : 2); 2902 content::IsBrowserSideNavigationEnabled() ? 1 : 2);
2923 ui_test_utils::NavigateToURL(browser(), https_server_mismatched_url); 2903 ui_test_utils::NavigateToURL(browser(), https_server_mismatched_url);
2924 observer.Wait(); 2904 observer.Wait();
2925 2905
2926 CheckSecurityState(contents, CertError::NONE, 2906 CheckSecurityState(contents, CertError::NONE, security_state::SECURE,
2927 security_state::SecurityStateModel::SECURE,
2928 AuthState::NONE); 2907 AuthState::NONE);
2929 replacements.SetHostStr("mail.example.com"); 2908 replacements.SetHostStr("mail.example.com");
2930 GURL https_server_new_url = https_server_url.ReplaceComponents(replacements); 2909 GURL https_server_new_url = https_server_url.ReplaceComponents(replacements);
2931 // Verify that the current URL is the suggested URL. 2910 // Verify that the current URL is the suggested URL.
2932 EXPECT_EQ(https_server_new_url.spec(), 2911 EXPECT_EQ(https_server_new_url.spec(),
2933 contents->GetLastCommittedURL().spec()); 2912 contents->GetLastCommittedURL().spec());
2934 } 2913 }
2935 2914
2936 // Visit the URL example.org on a server that presents a valid certificate 2915 // Visit the URL example.org on a server that presents a valid certificate
2937 // for www.example.org. Verify that the page redirects to www.example.org. 2916 // for www.example.org. Verify that the page redirects to www.example.org.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2975 2954
2976 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 2955 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
2977 content::TestNavigationObserver observer( 2956 content::TestNavigationObserver observer(
2978 contents, 2957 contents,
2979 // With PlzNavigate, the renderer only sees one navigation (i.e. not the 2958 // With PlzNavigate, the renderer only sees one navigation (i.e. not the
2980 // redirect, since that happens in the browser). 2959 // redirect, since that happens in the browser).
2981 content::IsBrowserSideNavigationEnabled() ? 1 : 2); 2960 content::IsBrowserSideNavigationEnabled() ? 1 : 2);
2982 ui_test_utils::NavigateToURL(browser(), https_server_mismatched_url); 2961 ui_test_utils::NavigateToURL(browser(), https_server_mismatched_url);
2983 observer.Wait(); 2962 observer.Wait();
2984 2963
2985 CheckSecurityState(contents, CertError::NONE, 2964 CheckSecurityState(contents, CertError::NONE, security_state::SECURE,
2986 security_state::SecurityStateModel::SECURE,
2987 AuthState::NONE); 2965 AuthState::NONE);
2988 } 2966 }
2989 2967
2990 // Tests this scenario: 2968 // Tests this scenario:
2991 // - |CommonNameMismatchHandler| does not give a callback as it's set into the 2969 // - |CommonNameMismatchHandler| does not give a callback as it's set into the
2992 // state |IGNORE_REQUESTS_FOR_TESTING|. So no suggested URL check result can 2970 // state |IGNORE_REQUESTS_FOR_TESTING|. So no suggested URL check result can
2993 // arrive. 2971 // arrive.
2994 // - A cert error triggers an interstitial timer with a very long timeout. 2972 // - A cert error triggers an interstitial timer with a very long timeout.
2995 // - No suggested URL check results arrive, causing the tab to appear as loading 2973 // - No suggested URL check results arrive, causing the tab to appear as loading
2996 // indefinitely (also because the timer has a long timeout). 2974 // indefinitely (also because the timer has a long timeout).
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
3221 ASSERT_TRUE(https_server.Start()); 3199 ASSERT_TRUE(https_server.Start());
3222 3200
3223 mock_cert_verifier()->set_default_result( 3201 mock_cert_verifier()->set_default_result(
3224 net::ERR_CERT_NAME_CONSTRAINT_VIOLATION); 3202 net::ERR_CERT_NAME_CONSTRAINT_VIOLATION);
3225 3203
3226 ui_test_utils::NavigateToURL(browser(), 3204 ui_test_utils::NavigateToURL(browser(),
3227 https_server.GetURL("/ssl/google.html")); 3205 https_server.GetURL("/ssl/google.html"));
3228 3206
3229 CheckSecurityState(browser()->tab_strip_model()->GetActiveWebContents(), 3207 CheckSecurityState(browser()->tab_strip_model()->GetActiveWebContents(),
3230 net::CERT_STATUS_NAME_CONSTRAINT_VIOLATION, 3208 net::CERT_STATUS_NAME_CONSTRAINT_VIOLATION,
3231 security_state::SecurityStateModel::DANGEROUS, 3209 security_state::DANGEROUS,
3232 AuthState::SHOWING_INTERSTITIAL); 3210 AuthState::SHOWING_INTERSTITIAL);
3233 } 3211 }
3234 3212
3235 IN_PROC_BROWSER_TEST_F(SSLUITest, RestoreHasSSLState) { 3213 IN_PROC_BROWSER_TEST_F(SSLUITest, RestoreHasSSLState) {
3236 ASSERT_TRUE(https_server_.Start()); 3214 ASSERT_TRUE(https_server_.Start());
3237 GURL url(https_server_.GetURL("/ssl/google.html")); 3215 GURL url(https_server_.GetURL("/ssl/google.html"));
3238 ui_test_utils::NavigateToURL(browser(), url); 3216 ui_test_utils::NavigateToURL(browser(), url);
3239 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 3217 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
3240 CheckAuthenticatedState(tab, AuthState::NONE); 3218 CheckAuthenticatedState(tab, AuthState::NONE);
3241 3219
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
3340 ASSERT_TRUE(embedded_test_server()->Start()); 3318 ASSERT_TRUE(embedded_test_server()->Start());
3341 ASSERT_TRUE(https_server_.Start()); 3319 ASSERT_TRUE(https_server_.Start());
3342 3320
3343 GURL url = 3321 GURL url =
3344 GURL(https_server_.GetURL("/ssl/redirect.html").spec() 3322 GURL(https_server_.GetURL("/ssl/redirect.html").spec()
3345 + "?" + 3323 + "?" +
3346 https_server_.GetURL("/ssl/page_displays_insecure_content.html").spec()); 3324 https_server_.GetURL("/ssl/page_displays_insecure_content.html").spec());
3347 3325
3348 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), url, 2); 3326 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), url, 2);
3349 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 3327 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
3350 CheckSecurityState(tab, CertError::NONE, 3328 CheckSecurityState(tab, CertError::NONE, security_state::NONE,
3351 security_state::SecurityStateModel::NONE,
3352 AuthState::DISPLAYED_INSECURE_CONTENT); 3329 AuthState::DISPLAYED_INSECURE_CONTENT);
3353 } 3330 }
3354 3331
3355 // Checks that in-page navigations during page load preserves SSL state. 3332 // Checks that in-page navigations during page load preserves SSL state.
3356 IN_PROC_BROWSER_TEST_F(SSLUITest, InPageNavigationDuringLoadSSLState) { 3333 IN_PROC_BROWSER_TEST_F(SSLUITest, InPageNavigationDuringLoadSSLState) {
3357 ASSERT_TRUE(https_server_.Start()); 3334 ASSERT_TRUE(https_server_.Start());
3358 3335
3359 ui_test_utils::NavigateToURL( 3336 ui_test_utils::NavigateToURL(
3360 browser(), 3337 browser(),
3361 https_server_.GetURL("/ssl/in_page_navigation_during_load.html")); 3338 https_server_.GetURL("/ssl/in_page_navigation_during_load.html"));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3410 3387
3411 // Visit a page over https that contains a frame with a redirect. 3388 // Visit a page over https that contains a frame with a redirect.
3412 3389
3413 // XMLHttpRequest insecure content in synchronous mode. 3390 // XMLHttpRequest insecure content in synchronous mode.
3414 3391
3415 // XMLHttpRequest insecure content in asynchronous mode. 3392 // XMLHttpRequest insecure content in asynchronous mode.
3416 3393
3417 // XMLHttpRequest over bad ssl in synchronous mode. 3394 // XMLHttpRequest over bad ssl in synchronous mode.
3418 3395
3419 // XMLHttpRequest over OK ssl in synchronous mode. 3396 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698