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

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

Issue 2472943004: HTTP Bad: Add a switch for showing both verbose state and form warning (Closed)
Patch Set: add test 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
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | components/security_state/security_state_model.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/ssl/chrome_security_state_model_client.h" 5 #include "chrome/browser/ssl/chrome_security_state_model_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 }; 304 };
305 305
306 GURL GetURLWithNonLocalHostname(net::EmbeddedTestServer* server, 306 GURL GetURLWithNonLocalHostname(net::EmbeddedTestServer* server,
307 const std::string& path) { 307 const std::string& path) {
308 GURL::Replacements replace_host; 308 GURL::Replacements replace_host;
309 replace_host.SetHostStr("example.test"); 309 replace_host.SetHostStr("example.test");
310 return server->GetURL(path).ReplaceComponents(replace_host); 310 return server->GetURL(path).ReplaceComponents(replace_host);
311 } 311 }
312 312
313 class ChromeSecurityStateModelClientTestWithPasswordCcSwitch 313 class ChromeSecurityStateModelClientTestWithPasswordCcSwitch
314 : public ChromeSecurityStateModelClientTest { 314 : public ChromeSecurityStateModelClientTest,
315 public testing::WithParamInterface<bool> {
315 public: 316 public:
316 ChromeSecurityStateModelClientTestWithPasswordCcSwitch() 317 ChromeSecurityStateModelClientTestWithPasswordCcSwitch()
317 : ChromeSecurityStateModelClientTest() {} 318 : ChromeSecurityStateModelClientTest() {}
318 319
319 void SetUpOnMainThread() override { 320 void SetUpOnMainThread() override {
320 ASSERT_TRUE(embedded_test_server()->Start()); 321 ASSERT_TRUE(embedded_test_server()->Start());
321 ASSERT_TRUE(https_server_.Start()); 322 ASSERT_TRUE(https_server_.Start());
322 host_resolver()->AddRule("*", embedded_test_server()->GetURL("/").host()); 323 host_resolver()->AddRule("*", embedded_test_server()->GetURL("/").host());
323 SetUpMockCertVerifierForHttpsServer(0, net::OK); 324 SetUpMockCertVerifierForHttpsServer(0, net::OK);
324 } 325 }
325 326
326 void SetUpCommandLine(base::CommandLine* command_line) override { 327 void SetUpCommandLine(base::CommandLine* command_line) override {
327 ChromeSecurityStateModelClientTest::SetUpCommandLine(command_line); 328 ChromeSecurityStateModelClientTest::SetUpCommandLine(command_line);
328 command_line->AppendSwitchASCII( 329 if (GetParam()) {
329 security_state::switches::kMarkHttpAs, 330 command_line->AppendSwitchASCII(
330 security_state::switches::kMarkHttpWithPasswordsOrCcWithChip); 331 security_state::switches::kMarkHttpAs,
332 security_state::switches::
333 kMarkHttpWithPasswordsOrCcWithChipAndFormWarning);
334 } else {
335 command_line->AppendSwitchASCII(
336 security_state::switches::kMarkHttpAs,
337 security_state::switches::kMarkHttpWithPasswordsOrCcWithChip);
338 }
331 } 339 }
332 340
333 private: 341 private:
334 DISALLOW_COPY_AND_ASSIGN( 342 DISALLOW_COPY_AND_ASSIGN(
335 ChromeSecurityStateModelClientTestWithPasswordCcSwitch); 343 ChromeSecurityStateModelClientTestWithPasswordCcSwitch);
336 }; 344 };
337 345
338 class SecurityStyleChangedTest : public InProcessBrowserTest { 346 class SecurityStyleChangedTest : public InProcessBrowserTest {
339 public: 347 public:
340 SecurityStyleChangedTest() 348 SecurityStyleChangedTest()
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 &visible_security_state_sensitive_inputs); 941 &visible_security_state_sensitive_inputs);
934 EXPECT_TRUE( 942 EXPECT_TRUE(
935 visible_security_state_sensitive_inputs.displayed_password_field_on_http); 943 visible_security_state_sensitive_inputs.displayed_password_field_on_http);
936 EXPECT_TRUE(visible_security_state_sensitive_inputs 944 EXPECT_TRUE(visible_security_state_sensitive_inputs
937 .displayed_credit_card_field_on_http); 945 .displayed_credit_card_field_on_http);
938 } 946 }
939 947
940 // Tests that when a visible password field is detected on an HTTP page 948 // Tests that when a visible password field is detected on an HTTP page
941 // load, and when the command-line flag is set, the security level is 949 // load, and when the command-line flag is set, the security level is
942 // downgraded to HTTP_SHOW_WARNING. 950 // downgraded to HTTP_SHOW_WARNING.
943 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch, 951 IN_PROC_BROWSER_TEST_P(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
944 PasswordSecurityLevelDowngraded) { 952 PasswordSecurityLevelDowngraded) {
945 content::WebContents* contents = 953 content::WebContents* contents =
946 browser()->tab_strip_model()->GetActiveWebContents(); 954 browser()->tab_strip_model()->GetActiveWebContents();
947 ASSERT_TRUE(contents); 955 ASSERT_TRUE(contents);
948 956
949 ChromeSecurityStateModelClient* model_client = 957 ChromeSecurityStateModelClient* model_client =
950 ChromeSecurityStateModelClient::FromWebContents(contents); 958 ChromeSecurityStateModelClient::FromWebContents(contents);
951 ASSERT_TRUE(model_client); 959 ASSERT_TRUE(model_client);
952 960
953 ui_test_utils::NavigateToURL( 961 ui_test_utils::NavigateToURL(
954 browser(), GetURLWithNonLocalHostname(embedded_test_server(), 962 browser(), GetURLWithNonLocalHostname(embedded_test_server(),
955 "/password/simple_password.html")); 963 "/password/simple_password.html"));
956 security_state::SecurityStateModel::SecurityInfo security_info; 964 security_state::SecurityStateModel::SecurityInfo security_info;
957 model_client->GetSecurityInfo(&security_info); 965 model_client->GetSecurityInfo(&security_info);
958 EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING, 966 EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING,
959 security_info.security_level); 967 security_info.security_level);
960 968
961 content::NavigationEntry* entry = contents->GetController().GetVisibleEntry(); 969 content::NavigationEntry* entry = contents->GetController().GetVisibleEntry();
962 ASSERT_TRUE(entry); 970 ASSERT_TRUE(entry);
963 EXPECT_TRUE(entry->GetSSL().content_status & 971 EXPECT_TRUE(entry->GetSSL().content_status &
964 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); 972 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP);
965 } 973 }
966 974
967 // Tests that when an invisible password field is present on an HTTP page 975 // Tests that when an invisible password field is present on an HTTP page
968 // load, and when the command-line flag is set, the security level is 976 // load, and when the command-line flag is set, the security level is
969 // *not* downgraded to HTTP_SHOW_WARNING. 977 // *not* downgraded to HTTP_SHOW_WARNING.
970 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch, 978 IN_PROC_BROWSER_TEST_P(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
971 PasswordSecurityLevelNotDowngradedForInvisibleInput) { 979 PasswordSecurityLevelNotDowngradedForInvisibleInput) {
972 content::WebContents* contents = 980 content::WebContents* contents =
973 browser()->tab_strip_model()->GetActiveWebContents(); 981 browser()->tab_strip_model()->GetActiveWebContents();
974 ASSERT_TRUE(contents); 982 ASSERT_TRUE(contents);
975 983
976 ChromeSecurityStateModelClient* model_client = 984 ChromeSecurityStateModelClient* model_client =
977 ChromeSecurityStateModelClient::FromWebContents(contents); 985 ChromeSecurityStateModelClient::FromWebContents(contents);
978 ASSERT_TRUE(model_client); 986 ASSERT_TRUE(model_client);
979 987
980 ui_test_utils::NavigateToURL( 988 ui_test_utils::NavigateToURL(
981 browser(), 989 browser(),
982 GetURLWithNonLocalHostname(embedded_test_server(), 990 GetURLWithNonLocalHostname(embedded_test_server(),
983 "/password/invisible_password.html")); 991 "/password/invisible_password.html"));
984 security_state::SecurityStateModel::SecurityInfo security_info; 992 security_state::SecurityStateModel::SecurityInfo security_info;
985 model_client->GetSecurityInfo(&security_info); 993 model_client->GetSecurityInfo(&security_info);
986 EXPECT_EQ(security_state::SecurityStateModel::NONE, 994 EXPECT_EQ(security_state::SecurityStateModel::NONE,
987 security_info.security_level); 995 security_info.security_level);
988 996
989 content::NavigationEntry* entry = contents->GetController().GetVisibleEntry(); 997 content::NavigationEntry* entry = contents->GetController().GetVisibleEntry();
990 ASSERT_TRUE(entry); 998 ASSERT_TRUE(entry);
991 EXPECT_FALSE(entry->GetSSL().content_status & 999 EXPECT_FALSE(entry->GetSSL().content_status &
992 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); 1000 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP);
993 } 1001 }
994 1002
995 // Tests that when a visible password field is detected inside an iframe 1003 // Tests that when a visible password field is detected inside an iframe
996 // on an HTTP page load, and when the command-line flag is set, the 1004 // on an HTTP page load, and when the command-line flag is set, the
997 // security level is downgraded to HTTP_SHOW_WARNING. 1005 // security level is downgraded to HTTP_SHOW_WARNING.
998 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch, 1006 IN_PROC_BROWSER_TEST_P(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
999 PasswordSecurityLevelDowngradedFromIframe) { 1007 PasswordSecurityLevelDowngradedFromIframe) {
1000 content::WebContents* contents = 1008 content::WebContents* contents =
1001 browser()->tab_strip_model()->GetActiveWebContents(); 1009 browser()->tab_strip_model()->GetActiveWebContents();
1002 ASSERT_TRUE(contents); 1010 ASSERT_TRUE(contents);
1003 1011
1004 ChromeSecurityStateModelClient* model_client = 1012 ChromeSecurityStateModelClient* model_client =
1005 ChromeSecurityStateModelClient::FromWebContents(contents); 1013 ChromeSecurityStateModelClient::FromWebContents(contents);
1006 ASSERT_TRUE(model_client); 1014 ASSERT_TRUE(model_client);
1007 1015
1008 ui_test_utils::NavigateToURL( 1016 ui_test_utils::NavigateToURL(
1009 browser(), 1017 browser(),
1010 GetURLWithNonLocalHostname(embedded_test_server(), 1018 GetURLWithNonLocalHostname(embedded_test_server(),
1011 "/password/simple_password_in_iframe.html")); 1019 "/password/simple_password_in_iframe.html"));
1012 security_state::SecurityStateModel::SecurityInfo security_info; 1020 security_state::SecurityStateModel::SecurityInfo security_info;
1013 model_client->GetSecurityInfo(&security_info); 1021 model_client->GetSecurityInfo(&security_info);
1014 EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING, 1022 EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING,
1015 security_info.security_level); 1023 security_info.security_level);
1016 1024
1017 content::NavigationEntry* entry = contents->GetController().GetVisibleEntry(); 1025 content::NavigationEntry* entry = contents->GetController().GetVisibleEntry();
1018 ASSERT_TRUE(entry); 1026 ASSERT_TRUE(entry);
1019 EXPECT_TRUE(entry->GetSSL().content_status & 1027 EXPECT_TRUE(entry->GetSSL().content_status &
1020 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); 1028 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP);
1021 } 1029 }
1022 1030
1023 // Tests that when a visible password field is detected inside an iframe 1031 // Tests that when a visible password field is detected inside an iframe
1024 // on an HTTP page load, and when the command-line flag is set, the 1032 // on an HTTP page load, and when the command-line flag is set, the
1025 // security level is downgraded to HTTP_SHOW_WARNING, even if the iframe 1033 // security level is downgraded to HTTP_SHOW_WARNING, even if the iframe
1026 // itself was loaded over HTTPS. 1034 // itself was loaded over HTTPS.
1027 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch, 1035 IN_PROC_BROWSER_TEST_P(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
1028 PasswordSecurityLevelDowngradedFromHttpsIframe) { 1036 PasswordSecurityLevelDowngradedFromHttpsIframe) {
1029 content::WebContents* contents = 1037 content::WebContents* contents =
1030 browser()->tab_strip_model()->GetActiveWebContents(); 1038 browser()->tab_strip_model()->GetActiveWebContents();
1031 ASSERT_TRUE(contents); 1039 ASSERT_TRUE(contents);
1032 1040
1033 ChromeSecurityStateModelClient* model_client = 1041 ChromeSecurityStateModelClient* model_client =
1034 ChromeSecurityStateModelClient::FromWebContents(contents); 1042 ChromeSecurityStateModelClient::FromWebContents(contents);
1035 ASSERT_TRUE(model_client); 1043 ASSERT_TRUE(model_client);
1036 1044
1037 // Navigate to an HTTP URL, which loads an iframe using the host and port of 1045 // Navigate to an HTTP URL, which loads an iframe using the host and port of
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 // The appropriate SSLStatus flags should be set, however. 1091 // The appropriate SSLStatus flags should be set, however.
1084 content::NavigationEntry* entry = contents->GetController().GetVisibleEntry(); 1092 content::NavigationEntry* entry = contents->GetController().GetVisibleEntry();
1085 ASSERT_TRUE(entry); 1093 ASSERT_TRUE(entry);
1086 EXPECT_TRUE(entry->GetSSL().content_status & 1094 EXPECT_TRUE(entry->GetSSL().content_status &
1087 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); 1095 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP);
1088 } 1096 }
1089 1097
1090 // Tests that when a visible password field is detected on an HTTPS page 1098 // Tests that when a visible password field is detected on an HTTPS page
1091 // load, and when the command-line flag is set, the security level is 1099 // load, and when the command-line flag is set, the security level is
1092 // *not* downgraded to HTTP_SHOW_WARNING. 1100 // *not* downgraded to HTTP_SHOW_WARNING.
1093 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch, 1101 IN_PROC_BROWSER_TEST_P(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
1094 PasswordSecurityLevelNotDowngradedOnHttps) { 1102 PasswordSecurityLevelNotDowngradedOnHttps) {
1095 content::WebContents* contents = 1103 content::WebContents* contents =
1096 browser()->tab_strip_model()->GetActiveWebContents(); 1104 browser()->tab_strip_model()->GetActiveWebContents();
1097 ASSERT_TRUE(contents); 1105 ASSERT_TRUE(contents);
1098 1106
1099 ChromeSecurityStateModelClient* model_client = 1107 ChromeSecurityStateModelClient* model_client =
1100 ChromeSecurityStateModelClient::FromWebContents(contents); 1108 ChromeSecurityStateModelClient::FromWebContents(contents);
1101 ASSERT_TRUE(model_client); 1109 ASSERT_TRUE(model_client);
1102 1110
1103 GURL url = GetURLWithNonLocalHostname(&https_server_, 1111 GURL url = GetURLWithNonLocalHostname(&https_server_,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 ConsoleWebContentsDelegate* delegate) { 1187 ConsoleWebContentsDelegate* delegate) {
1180 const std::vector<base::string16>& messages = delegate->console_messages(); 1188 const std::vector<base::string16>& messages = delegate->console_messages();
1181 ASSERT_EQ(1u, messages.size()); 1189 ASSERT_EQ(1u, messages.size());
1182 EXPECT_NE(base::string16::npos, 1190 EXPECT_NE(base::string16::npos,
1183 messages[0].find(base::ASCIIToUTF16("warning will be added"))); 1191 messages[0].find(base::ASCIIToUTF16("warning will be added")));
1184 } 1192 }
1185 1193
1186 // Tests that console messages are printed upon a call to 1194 // Tests that console messages are printed upon a call to
1187 // GetSecurityInfo() on an HTTP_SHOW_WARNING page, exactly once per 1195 // GetSecurityInfo() on an HTTP_SHOW_WARNING page, exactly once per
1188 // main-frame navigation. 1196 // main-frame navigation.
1189 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch, 1197 IN_PROC_BROWSER_TEST_P(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
1190 ConsoleMessage) { 1198 ConsoleMessage) {
1191 ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate( 1199 ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate(
1192 Browser::CreateParams(browser()->profile())); 1200 Browser::CreateParams(browser()->profile()));
1193 content::WebContents* original_contents = 1201 content::WebContents* original_contents =
1194 browser()->tab_strip_model()->GetActiveWebContents(); 1202 browser()->tab_strip_model()->GetActiveWebContents();
1195 content::WebContents* contents = 1203 content::WebContents* contents =
1196 content::WebContents::Create(content::WebContents::CreateParams( 1204 content::WebContents::Create(content::WebContents::CreateParams(
1197 original_contents->GetBrowserContext())); 1205 original_contents->GetBrowserContext()));
1198 ASSERT_TRUE(contents); 1206 ASSERT_TRUE(contents);
1199 contents->SetDelegate(delegate); 1207 contents->SetDelegate(delegate);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 client->GetSecurityInfo(&security_info); 1331 client->GetSecurityInfo(&security_info);
1324 EXPECT_EQ(security_state::SecurityStateModel::NONE, 1332 EXPECT_EQ(security_state::SecurityStateModel::NONE,
1325 security_info.security_level); 1333 security_info.security_level);
1326 EXPECT_TRUE(security_info.displayed_private_user_data_input_on_http); 1334 EXPECT_TRUE(security_info.displayed_private_user_data_input_on_http);
1327 1335
1328 ASSERT_NO_FATAL_FAILURE(CheckForOneFutureHttpWarningConsoleMessage(delegate)); 1336 ASSERT_NO_FATAL_FAILURE(CheckForOneFutureHttpWarningConsoleMessage(delegate));
1329 } 1337 }
1330 1338
1331 // Tests that additional HTTP_SHOW_WARNING console messages are not 1339 // Tests that additional HTTP_SHOW_WARNING console messages are not
1332 // printed after subframe navigations. 1340 // printed after subframe navigations.
1333 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch, 1341 IN_PROC_BROWSER_TEST_P(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
1334 ConsoleMessageNotPrintedForFrameNavigation) { 1342 ConsoleMessageNotPrintedForFrameNavigation) {
1335 ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate( 1343 ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate(
1336 Browser::CreateParams(browser()->profile())); 1344 Browser::CreateParams(browser()->profile()));
1337 content::WebContents* original_contents = 1345 content::WebContents* original_contents =
1338 browser()->tab_strip_model()->GetActiveWebContents(); 1346 browser()->tab_strip_model()->GetActiveWebContents();
1339 content::WebContents* contents = 1347 content::WebContents* contents =
1340 content::WebContents::Create(content::WebContents::CreateParams( 1348 content::WebContents::Create(content::WebContents::CreateParams(
1341 original_contents->GetBrowserContext())); 1349 original_contents->GetBrowserContext()));
1342 ASSERT_TRUE(contents); 1350 ASSERT_TRUE(contents);
1343 contents->SetDelegate(delegate); 1351 contents->SetDelegate(delegate);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 second_message.Run(); 1415 second_message.Run();
1408 1416
1409 client->GetSecurityInfo(&security_info); 1417 client->GetSecurityInfo(&security_info);
1410 EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING, 1418 EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING,
1411 security_info.security_level); 1419 security_info.security_level);
1412 ASSERT_NO_FATAL_FAILURE(CheckForOneHttpWarningConsoleMessage(delegate)); 1420 ASSERT_NO_FATAL_FAILURE(CheckForOneHttpWarningConsoleMessage(delegate));
1413 } 1421 }
1414 1422
1415 // Tests that additional HTTP_SHOW_WARNING console messages are not 1423 // Tests that additional HTTP_SHOW_WARNING console messages are not
1416 // printed after pushState navigations. 1424 // printed after pushState navigations.
1417 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch, 1425 IN_PROC_BROWSER_TEST_P(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
1418 ConsoleMessageNotPrintedForPushStateNavigation) { 1426 ConsoleMessageNotPrintedForPushStateNavigation) {
1419 ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate( 1427 ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate(
1420 Browser::CreateParams(browser()->profile())); 1428 Browser::CreateParams(browser()->profile()));
1421 content::WebContents* original_contents = 1429 content::WebContents* original_contents =
1422 browser()->tab_strip_model()->GetActiveWebContents(); 1430 browser()->tab_strip_model()->GetActiveWebContents();
1423 content::WebContents* contents = 1431 content::WebContents* contents =
1424 content::WebContents::Create(content::WebContents::CreateParams( 1432 content::WebContents::Create(content::WebContents::CreateParams(
1425 original_contents->GetBrowserContext())); 1433 original_contents->GetBrowserContext()));
1426 ASSERT_TRUE(contents); 1434 ASSERT_TRUE(contents);
1427 contents->SetDelegate(delegate); 1435 contents->SetDelegate(delegate);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 delegate->set_console_message_callback(second_message.QuitClosure()); 1492 delegate->set_console_message_callback(second_message.QuitClosure());
1485 contents->OnPasswordInputShownOnHttp(); 1493 contents->OnPasswordInputShownOnHttp();
1486 second_message.Run(); 1494 second_message.Run();
1487 1495
1488 client->GetSecurityInfo(&security_info); 1496 client->GetSecurityInfo(&security_info);
1489 EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING, 1497 EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING,
1490 security_info.security_level); 1498 security_info.security_level);
1491 ASSERT_NO_FATAL_FAILURE(CheckForOneHttpWarningConsoleMessage(delegate)); 1499 ASSERT_NO_FATAL_FAILURE(CheckForOneHttpWarningConsoleMessage(delegate));
1492 } 1500 }
1493 1501
1502 INSTANTIATE_TEST_CASE_P(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
1503 ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
1504 testing::Bool());
estark 2016/11/05 03:44:22 nit: maybe you could add a comment here that 'true
lshang 2016/11/05 03:56:53 Done.
1505
1494 // Tests that the SecurityStateModel for a WebContents is up to date 1506 // Tests that the SecurityStateModel for a WebContents is up to date
1495 // when the WebContents is inserted into a Browser's TabStripModel. 1507 // when the WebContents is inserted into a Browser's TabStripModel.
1496 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, AddedTab) { 1508 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, AddedTab) {
1497 ASSERT_TRUE(https_server_.Start()); 1509 ASSERT_TRUE(https_server_.Start());
1498 SetUpMockCertVerifierForHttpsServer(0, net::OK); 1510 SetUpMockCertVerifierForHttpsServer(0, net::OK);
1499 1511
1500 content::WebContents* tab = 1512 content::WebContents* tab =
1501 browser()->tab_strip_model()->GetActiveWebContents(); 1513 browser()->tab_strip_model()->GetActiveWebContents();
1502 ASSERT_TRUE(tab); 1514 ASSERT_TRUE(tab);
1503 1515
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 ChromeSecurityStateModelClient* model_client = 2053 ChromeSecurityStateModelClient* model_client =
2042 ChromeSecurityStateModelClient::FromWebContents(web_contents); 2054 ChromeSecurityStateModelClient::FromWebContents(web_contents);
2043 ASSERT_TRUE(model_client); 2055 ASSERT_TRUE(model_client);
2044 SecurityStateModel::SecurityInfo security_info; 2056 SecurityStateModel::SecurityInfo security_info;
2045 model_client->GetSecurityInfo(&security_info); 2057 model_client->GetSecurityInfo(&security_info);
2046 EXPECT_EQ(SecurityStateModel::SECURE, security_info.security_level); 2058 EXPECT_EQ(SecurityStateModel::SECURE, security_info.security_level);
2047 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses); 2059 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses);
2048 } 2060 }
2049 2061
2050 } // namespace 2062 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | components/security_state/security_state_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698