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