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

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

Issue 2494033002: Revert "HTTP Bad: Split out UMA metrics for password vs credit card "Not secure" warnings" (Closed)
Patch Set: 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 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 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 first_message.Run(); 1307 first_message.Run();
1308 1308
1309 // Check that the correct state was actually triggered. 1309 // Check that the correct state was actually triggered.
1310 ChromeSecurityStateModelClient* client = 1310 ChromeSecurityStateModelClient* client =
1311 ChromeSecurityStateModelClient::FromWebContents(contents); 1311 ChromeSecurityStateModelClient::FromWebContents(contents);
1312 ASSERT_TRUE(client); 1312 ASSERT_TRUE(client);
1313 security_state::SecurityStateModel::SecurityInfo security_info; 1313 security_state::SecurityStateModel::SecurityInfo security_info;
1314 client->GetSecurityInfo(&security_info); 1314 client->GetSecurityInfo(&security_info);
1315 EXPECT_EQ(security_state::SecurityStateModel::NONE, 1315 EXPECT_EQ(security_state::SecurityStateModel::NONE,
1316 security_info.security_level); 1316 security_info.security_level);
1317 EXPECT_TRUE(security_info.displayed_password_field_on_http); 1317 EXPECT_TRUE(security_info.displayed_private_user_data_input_on_http);
1318 1318
1319 // Check that the expected console message is present. 1319 // Check that the expected console message is present.
1320 ASSERT_NO_FATAL_FAILURE(CheckForOneFutureHttpWarningConsoleMessage(delegate)); 1320 ASSERT_NO_FATAL_FAILURE(CheckForOneFutureHttpWarningConsoleMessage(delegate));
1321 delegate->ClearConsoleMessages(); 1321 delegate->ClearConsoleMessages();
1322 1322
1323 // Two subsequent triggers of VisibleSecurityStateChanged -- one on the 1323 // Two subsequent triggers of VisibleSecurityStateChanged -- one on the
1324 // same navigation and one on another navigation -- should only result 1324 // same navigation and one on another navigation -- should only result
1325 // in one additional console message. 1325 // in one additional console message.
1326 contents->OnCreditCardInputShownOnHttp(); 1326 contents->OnCreditCardInputShownOnHttp();
1327 GURL second_http_url = 1327 GURL second_http_url =
1328 GetURLWithNonLocalHostname(embedded_test_server(), "/title2.html"); 1328 GetURLWithNonLocalHostname(embedded_test_server(), "/title2.html");
1329 ui_test_utils::NavigateToURL(delegate, second_http_url); 1329 ui_test_utils::NavigateToURL(delegate, second_http_url);
1330 entry = contents->GetController().GetVisibleEntry(); 1330 entry = contents->GetController().GetVisibleEntry();
1331 ASSERT_TRUE(entry); 1331 ASSERT_TRUE(entry);
1332 EXPECT_EQ(second_http_url, entry->GetURL()); 1332 EXPECT_EQ(second_http_url, entry->GetURL());
1333 1333
1334 base::RunLoop second_message; 1334 base::RunLoop second_message;
1335 delegate->set_console_message_callback(second_message.QuitClosure()); 1335 delegate->set_console_message_callback(second_message.QuitClosure());
1336 contents->OnPasswordInputShownOnHttp(); 1336 contents->OnPasswordInputShownOnHttp();
1337 second_message.Run(); 1337 second_message.Run();
1338 1338
1339 client->GetSecurityInfo(&security_info); 1339 client->GetSecurityInfo(&security_info);
1340 EXPECT_EQ(security_state::SecurityStateModel::NONE, 1340 EXPECT_EQ(security_state::SecurityStateModel::NONE,
1341 security_info.security_level); 1341 security_info.security_level);
1342 EXPECT_TRUE(security_info.displayed_password_field_on_http); 1342 EXPECT_TRUE(security_info.displayed_private_user_data_input_on_http);
1343 EXPECT_FALSE(security_info.displayed_credit_card_field_on_http);
1344
1345 ASSERT_NO_FATAL_FAILURE(CheckForOneFutureHttpWarningConsoleMessage(delegate));
1346 delegate->ClearConsoleMessages();
1347
1348 // Check that a console message is printed for credit card field shown.
1349 ui_test_utils::NavigateToURL(delegate, http_url);
1350 entry = contents->GetController().GetVisibleEntry();
1351 ASSERT_TRUE(entry);
1352 EXPECT_EQ(http_url, entry->GetURL());
1353
1354 base::RunLoop third_message;
1355 delegate->set_console_message_callback(third_message.QuitClosure());
1356 contents->OnCreditCardInputShownOnHttp();
1357 third_message.Run();
1358
1359 client->GetSecurityInfo(&security_info);
1360 EXPECT_EQ(security_state::SecurityStateModel::NONE,
1361 security_info.security_level);
1362 EXPECT_TRUE(security_info.displayed_credit_card_field_on_http);
1363 1343
1364 ASSERT_NO_FATAL_FAILURE(CheckForOneFutureHttpWarningConsoleMessage(delegate)); 1344 ASSERT_NO_FATAL_FAILURE(CheckForOneFutureHttpWarningConsoleMessage(delegate));
1365 } 1345 }
1366 1346
1367 // Tests that additional HTTP_SHOW_WARNING console messages are not 1347 // Tests that additional HTTP_SHOW_WARNING console messages are not
1368 // printed after subframe navigations. 1348 // printed after subframe navigations.
1369 IN_PROC_BROWSER_TEST_P(ChromeSecurityStateModelClientTestWithPasswordCcSwitch, 1349 IN_PROC_BROWSER_TEST_P(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
1370 ConsoleMessageNotPrintedForFrameNavigation) { 1350 ConsoleMessageNotPrintedForFrameNavigation) {
1371 ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate( 1351 ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate(
1372 Browser::CreateParams(browser()->profile())); 1352 Browser::CreateParams(browser()->profile()));
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 ChromeSecurityStateModelClient* model_client = 2064 ChromeSecurityStateModelClient* model_client =
2085 ChromeSecurityStateModelClient::FromWebContents(web_contents); 2065 ChromeSecurityStateModelClient::FromWebContents(web_contents);
2086 ASSERT_TRUE(model_client); 2066 ASSERT_TRUE(model_client);
2087 SecurityStateModel::SecurityInfo security_info; 2067 SecurityStateModel::SecurityInfo security_info;
2088 model_client->GetSecurityInfo(&security_info); 2068 model_client->GetSecurityInfo(&security_info);
2089 EXPECT_EQ(SecurityStateModel::SECURE, security_info.security_level); 2069 EXPECT_EQ(SecurityStateModel::SECURE, security_info.security_level);
2090 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses); 2070 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses);
2091 } 2071 }
2092 2072
2093 } // namespace 2073 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698