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

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

Issue 2456383003: Reland of Trigger Dangerous indicator for unsafe subresources (Closed)
Patch Set: initialize is_subframe 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/ssl/chrome_security_state_model_client.cc ('k') | chrome/browser/ui/browser.h » ('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 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 ASSERT_TRUE(client); 1224 ASSERT_TRUE(client);
1225 security_state::SecurityStateModel::SecurityInfo security_info; 1225 security_state::SecurityStateModel::SecurityInfo security_info;
1226 client->GetSecurityInfo(&security_info); 1226 client->GetSecurityInfo(&security_info);
1227 EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING, 1227 EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING,
1228 security_info.security_level); 1228 security_info.security_level);
1229 1229
1230 // Check that the expected console message is present. 1230 // Check that the expected console message is present.
1231 ASSERT_NO_FATAL_FAILURE(CheckForOneHttpWarningConsoleMessage(delegate)); 1231 ASSERT_NO_FATAL_FAILURE(CheckForOneHttpWarningConsoleMessage(delegate));
1232 delegate->ClearConsoleMessages(); 1232 delegate->ClearConsoleMessages();
1233 1233
1234 // Two subsequent triggers of VisibleSSLStateChanged -- one on the 1234 // Two subsequent triggers of VisibleSecurityStateChanged -- one on the
1235 // same navigation and one on another navigation -- should only result 1235 // same navigation and one on another navigation -- should only result
1236 // in one additional console message. 1236 // in one additional console message.
1237 contents->OnCreditCardInputShownOnHttp(); 1237 contents->OnCreditCardInputShownOnHttp();
1238 GURL second_http_url = 1238 GURL second_http_url =
1239 GetURLWithNonLocalHostname(embedded_test_server(), "/title2.html"); 1239 GetURLWithNonLocalHostname(embedded_test_server(), "/title2.html");
1240 ui_test_utils::NavigateToURL(delegate, second_http_url); 1240 ui_test_utils::NavigateToURL(delegate, second_http_url);
1241 entry = contents->GetController().GetVisibleEntry(); 1241 entry = contents->GetController().GetVisibleEntry();
1242 ASSERT_TRUE(entry); 1242 ASSERT_TRUE(entry);
1243 EXPECT_EQ(second_http_url, entry->GetURL()); 1243 EXPECT_EQ(second_http_url, entry->GetURL());
1244 1244
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 security_state::SecurityStateModel::SecurityInfo security_info; 1297 security_state::SecurityStateModel::SecurityInfo security_info;
1298 client->GetSecurityInfo(&security_info); 1298 client->GetSecurityInfo(&security_info);
1299 EXPECT_EQ(security_state::SecurityStateModel::NONE, 1299 EXPECT_EQ(security_state::SecurityStateModel::NONE,
1300 security_info.security_level); 1300 security_info.security_level);
1301 EXPECT_TRUE(security_info.displayed_private_user_data_input_on_http); 1301 EXPECT_TRUE(security_info.displayed_private_user_data_input_on_http);
1302 1302
1303 // Check that the expected console message is present. 1303 // Check that the expected console message is present.
1304 ASSERT_NO_FATAL_FAILURE(CheckForOneFutureHttpWarningConsoleMessage(delegate)); 1304 ASSERT_NO_FATAL_FAILURE(CheckForOneFutureHttpWarningConsoleMessage(delegate));
1305 delegate->ClearConsoleMessages(); 1305 delegate->ClearConsoleMessages();
1306 1306
1307 // Two subsequent triggers of VisibleSSLStateChanged -- one on the 1307 // Two subsequent triggers of VisibleSecurityStateChanged -- one on the
1308 // same navigation and one on another navigation -- should only result 1308 // same navigation and one on another navigation -- should only result
1309 // in one additional console message. 1309 // in one additional console message.
1310 contents->OnCreditCardInputShownOnHttp(); 1310 contents->OnCreditCardInputShownOnHttp();
1311 GURL second_http_url = 1311 GURL second_http_url =
1312 GetURLWithNonLocalHostname(embedded_test_server(), "/title2.html"); 1312 GetURLWithNonLocalHostname(embedded_test_server(), "/title2.html");
1313 ui_test_utils::NavigateToURL(delegate, second_http_url); 1313 ui_test_utils::NavigateToURL(delegate, second_http_url);
1314 entry = contents->GetController().GetVisibleEntry(); 1314 entry = contents->GetController().GetVisibleEntry();
1315 ASSERT_TRUE(entry); 1315 ASSERT_TRUE(entry);
1316 EXPECT_EQ(second_http_url, entry->GetURL()); 1316 EXPECT_EQ(second_http_url, entry->GetURL());
1317 1317
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 ASSERT_TRUE(client); 1368 ASSERT_TRUE(client);
1369 security_state::SecurityStateModel::SecurityInfo security_info; 1369 security_state::SecurityStateModel::SecurityInfo security_info;
1370 client->GetSecurityInfo(&security_info); 1370 client->GetSecurityInfo(&security_info);
1371 EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING, 1371 EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING,
1372 security_info.security_level); 1372 security_info.security_level);
1373 1373
1374 // Check that the expected console message is present. 1374 // Check that the expected console message is present.
1375 ASSERT_NO_FATAL_FAILURE(CheckForOneHttpWarningConsoleMessage(delegate)); 1375 ASSERT_NO_FATAL_FAILURE(CheckForOneHttpWarningConsoleMessage(delegate));
1376 delegate->ClearConsoleMessages(); 1376 delegate->ClearConsoleMessages();
1377 1377
1378 // Navigate the subframe and trigger VisibleSSLStateChanged 1378 // Navigate the subframe and trigger VisibleSecurityStateChanged
1379 // again. While the security level is still HTTP_SHOW_WARNING, an 1379 // again. While the security level is still HTTP_SHOW_WARNING, an
1380 // additional console message should not be logged because there was 1380 // additional console message should not be logged because there was
1381 // already a console message logged for the current main-frame 1381 // already a console message logged for the current main-frame
1382 // navigation. 1382 // navigation.
1383 content::WindowedNotificationObserver subframe_observer( 1383 content::WindowedNotificationObserver subframe_observer(
1384 content::NOTIFICATION_LOAD_STOP, 1384 content::NOTIFICATION_LOAD_STOP,
1385 content::Source<content::NavigationController>( 1385 content::Source<content::NavigationController>(
1386 &contents->GetController())); 1386 &contents->GetController()));
1387 EXPECT_TRUE(content::ExecuteScript( 1387 EXPECT_TRUE(content::ExecuteScript(
1388 contents, "document.getElementById('navFrame').src = '/title2.html';")); 1388 contents, "document.getElementById('navFrame').src = '/title2.html';"));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 ASSERT_TRUE(client); 1452 ASSERT_TRUE(client);
1453 security_state::SecurityStateModel::SecurityInfo security_info; 1453 security_state::SecurityStateModel::SecurityInfo security_info;
1454 client->GetSecurityInfo(&security_info); 1454 client->GetSecurityInfo(&security_info);
1455 EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING, 1455 EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING,
1456 security_info.security_level); 1456 security_info.security_level);
1457 1457
1458 // Check that the expected console message is present. 1458 // Check that the expected console message is present.
1459 ASSERT_NO_FATAL_FAILURE(CheckForOneHttpWarningConsoleMessage(delegate)); 1459 ASSERT_NO_FATAL_FAILURE(CheckForOneHttpWarningConsoleMessage(delegate));
1460 delegate->ClearConsoleMessages(); 1460 delegate->ClearConsoleMessages();
1461 1461
1462 // Navigate with pushState and trigger VisibleSSLStateChanged 1462 // Navigate with pushState and trigger VisibleSecurityStateChanged
1463 // again. While the security level is still HTTP_SHOW_WARNING, an 1463 // again. While the security level is still HTTP_SHOW_WARNING, an
1464 // additional console message should not be logged because there was 1464 // additional console message should not be logged because there was
1465 // already a console message logged for the current main-frame 1465 // already a console message logged for the current main-frame
1466 // navigation. 1466 // navigation.
1467 EXPECT_TRUE(content::ExecuteScript( 1467 EXPECT_TRUE(content::ExecuteScript(
1468 contents, "history.pushState({ foo: 'bar' }, 'foo', 'bar');")); 1468 contents, "history.pushState({ foo: 'bar' }, 'foo', 'bar');"));
1469 contents->OnCreditCardInputShownOnHttp(); 1469 contents->OnCreditCardInputShownOnHttp();
1470 EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING, 1470 EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING,
1471 security_info.security_level); 1471 security_info.security_level);
1472 1472
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 ChromeSecurityStateModelClient* model_client = 2041 ChromeSecurityStateModelClient* model_client =
2042 ChromeSecurityStateModelClient::FromWebContents(web_contents); 2042 ChromeSecurityStateModelClient::FromWebContents(web_contents);
2043 ASSERT_TRUE(model_client); 2043 ASSERT_TRUE(model_client);
2044 SecurityStateModel::SecurityInfo security_info; 2044 SecurityStateModel::SecurityInfo security_info;
2045 model_client->GetSecurityInfo(&security_info); 2045 model_client->GetSecurityInfo(&security_info);
2046 EXPECT_EQ(SecurityStateModel::SECURE, security_info.security_level); 2046 EXPECT_EQ(SecurityStateModel::SECURE, security_info.security_level);
2047 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses); 2047 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses);
2048 } 2048 }
2049 2049
2050 } // namespace 2050 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ssl/chrome_security_state_model_client.cc ('k') | chrome/browser/ui/browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698