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/security_state_tab_helper.h" | 5 #include "chrome/browser/ssl/security_state_tab_helper.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 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 EXPECT_NE(base::string16::npos, | 1282 EXPECT_NE(base::string16::npos, |
1283 messages[0].find(base::ASCIIToUTF16("warning will be added"))); | 1283 messages[0].find(base::ASCIIToUTF16("warning will be added"))); |
1284 } | 1284 } |
1285 | 1285 |
1286 // Tests that console messages are printed upon a call to | 1286 // Tests that console messages are printed upon a call to |
1287 // GetSecurityInfo() on an HTTP_SHOW_WARNING page, exactly once per | 1287 // GetSecurityInfo() on an HTTP_SHOW_WARNING page, exactly once per |
1288 // main-frame navigation. | 1288 // main-frame navigation. |
1289 IN_PROC_BROWSER_TEST_F(SecurityStateTabHelperTestWithPasswordCcSwitch, | 1289 IN_PROC_BROWSER_TEST_F(SecurityStateTabHelperTestWithPasswordCcSwitch, |
1290 ConsoleMessage) { | 1290 ConsoleMessage) { |
1291 ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate( | 1291 ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate( |
1292 Browser::CreateParams(browser()->profile())); | 1292 Browser::CreateParams(browser()->profile(), true)); |
1293 content::WebContents* original_contents = | 1293 content::WebContents* original_contents = |
1294 browser()->tab_strip_model()->GetActiveWebContents(); | 1294 browser()->tab_strip_model()->GetActiveWebContents(); |
1295 content::WebContents* contents = | 1295 content::WebContents* contents = |
1296 content::WebContents::Create(content::WebContents::CreateParams( | 1296 content::WebContents::Create(content::WebContents::CreateParams( |
1297 original_contents->GetBrowserContext())); | 1297 original_contents->GetBrowserContext())); |
1298 ASSERT_TRUE(contents); | 1298 ASSERT_TRUE(contents); |
1299 contents->SetDelegate(delegate); | 1299 contents->SetDelegate(delegate); |
1300 delegate->tab_strip_model()->AppendWebContents(contents, true); | 1300 delegate->tab_strip_model()->AppendWebContents(contents, true); |
1301 int index = delegate->tab_strip_model()->GetIndexOfWebContents(contents); | 1301 int index = delegate->tab_strip_model()->GetIndexOfWebContents(contents); |
1302 delegate->tab_strip_model()->ActivateTabAt(index, true); | 1302 delegate->tab_strip_model()->ActivateTabAt(index, true); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 ASSERT_NO_FATAL_FAILURE(CheckForOneHttpWarningConsoleMessage(delegate)); | 1352 ASSERT_NO_FATAL_FAILURE(CheckForOneHttpWarningConsoleMessage(delegate)); |
1353 } | 1353 } |
1354 | 1354 |
1355 // Tests that console messages are printed upon a call to | 1355 // Tests that console messages are printed upon a call to |
1356 // GetSecurityInfo() on a NONE page that will be marked | 1356 // GetSecurityInfo() on a NONE page that will be marked |
1357 // HTTP_SHOW_WARNING in future, exactly once per main-frame navigation. | 1357 // HTTP_SHOW_WARNING in future, exactly once per main-frame navigation. |
1358 IN_PROC_BROWSER_TEST_F(SecurityStateTabHelperTest, ConsoleMessage) { | 1358 IN_PROC_BROWSER_TEST_F(SecurityStateTabHelperTest, ConsoleMessage) { |
1359 ASSERT_TRUE(embedded_test_server()->Start()); | 1359 ASSERT_TRUE(embedded_test_server()->Start()); |
1360 host_resolver()->AddRule("*", embedded_test_server()->GetURL("/").host()); | 1360 host_resolver()->AddRule("*", embedded_test_server()->GetURL("/").host()); |
1361 ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate( | 1361 ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate( |
1362 Browser::CreateParams(browser()->profile())); | 1362 Browser::CreateParams(browser()->profile(), true)); |
1363 content::WebContents* original_contents = | 1363 content::WebContents* original_contents = |
1364 browser()->tab_strip_model()->GetActiveWebContents(); | 1364 browser()->tab_strip_model()->GetActiveWebContents(); |
1365 content::WebContents* contents = | 1365 content::WebContents* contents = |
1366 content::WebContents::Create(content::WebContents::CreateParams( | 1366 content::WebContents::Create(content::WebContents::CreateParams( |
1367 original_contents->GetBrowserContext())); | 1367 original_contents->GetBrowserContext())); |
1368 ASSERT_TRUE(contents); | 1368 ASSERT_TRUE(contents); |
1369 contents->SetDelegate(delegate); | 1369 contents->SetDelegate(delegate); |
1370 delegate->tab_strip_model()->AppendWebContents(contents, true); | 1370 delegate->tab_strip_model()->AppendWebContents(contents, true); |
1371 int index = delegate->tab_strip_model()->GetIndexOfWebContents(contents); | 1371 int index = delegate->tab_strip_model()->GetIndexOfWebContents(contents); |
1372 delegate->tab_strip_model()->ActivateTabAt(index, true); | 1372 delegate->tab_strip_model()->ActivateTabAt(index, true); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1441 EXPECT_TRUE(security_info.displayed_credit_card_field_on_http); | 1441 EXPECT_TRUE(security_info.displayed_credit_card_field_on_http); |
1442 | 1442 |
1443 ASSERT_NO_FATAL_FAILURE(CheckForOneFutureHttpWarningConsoleMessage(delegate)); | 1443 ASSERT_NO_FATAL_FAILURE(CheckForOneFutureHttpWarningConsoleMessage(delegate)); |
1444 } | 1444 } |
1445 | 1445 |
1446 // Tests that additional HTTP_SHOW_WARNING console messages are not | 1446 // Tests that additional HTTP_SHOW_WARNING console messages are not |
1447 // printed after subframe navigations. | 1447 // printed after subframe navigations. |
1448 IN_PROC_BROWSER_TEST_F(SecurityStateTabHelperTestWithPasswordCcSwitch, | 1448 IN_PROC_BROWSER_TEST_F(SecurityStateTabHelperTestWithPasswordCcSwitch, |
1449 ConsoleMessageNotPrintedForFrameNavigation) { | 1449 ConsoleMessageNotPrintedForFrameNavigation) { |
1450 ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate( | 1450 ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate( |
1451 Browser::CreateParams(browser()->profile())); | 1451 Browser::CreateParams(browser()->profile(), true)); |
1452 content::WebContents* original_contents = | 1452 content::WebContents* original_contents = |
1453 browser()->tab_strip_model()->GetActiveWebContents(); | 1453 browser()->tab_strip_model()->GetActiveWebContents(); |
1454 content::WebContents* contents = | 1454 content::WebContents* contents = |
1455 content::WebContents::Create(content::WebContents::CreateParams( | 1455 content::WebContents::Create(content::WebContents::CreateParams( |
1456 original_contents->GetBrowserContext())); | 1456 original_contents->GetBrowserContext())); |
1457 ASSERT_TRUE(contents); | 1457 ASSERT_TRUE(contents); |
1458 contents->SetDelegate(delegate); | 1458 contents->SetDelegate(delegate); |
1459 delegate->tab_strip_model()->AppendWebContents(contents, true); | 1459 delegate->tab_strip_model()->AppendWebContents(contents, true); |
1460 int index = delegate->tab_strip_model()->GetIndexOfWebContents(contents); | 1460 int index = delegate->tab_strip_model()->GetIndexOfWebContents(contents); |
1461 delegate->tab_strip_model()->ActivateTabAt(index, true); | 1461 delegate->tab_strip_model()->ActivateTabAt(index, true); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1522 helper->GetSecurityInfo(&security_info); | 1522 helper->GetSecurityInfo(&security_info); |
1523 EXPECT_EQ(security_state::HTTP_SHOW_WARNING, security_info.security_level); | 1523 EXPECT_EQ(security_state::HTTP_SHOW_WARNING, security_info.security_level); |
1524 ASSERT_NO_FATAL_FAILURE(CheckForOneHttpWarningConsoleMessage(delegate)); | 1524 ASSERT_NO_FATAL_FAILURE(CheckForOneHttpWarningConsoleMessage(delegate)); |
1525 } | 1525 } |
1526 | 1526 |
1527 // Tests that additional HTTP_SHOW_WARNING console messages are not | 1527 // Tests that additional HTTP_SHOW_WARNING console messages are not |
1528 // printed after pushState navigations. | 1528 // printed after pushState navigations. |
1529 IN_PROC_BROWSER_TEST_F(SecurityStateTabHelperTestWithPasswordCcSwitch, | 1529 IN_PROC_BROWSER_TEST_F(SecurityStateTabHelperTestWithPasswordCcSwitch, |
1530 ConsoleMessageNotPrintedForPushStateNavigation) { | 1530 ConsoleMessageNotPrintedForPushStateNavigation) { |
1531 ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate( | 1531 ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate( |
1532 Browser::CreateParams(browser()->profile())); | 1532 Browser::CreateParams(browser()->profile(), true)); |
1533 content::WebContents* original_contents = | 1533 content::WebContents* original_contents = |
1534 browser()->tab_strip_model()->GetActiveWebContents(); | 1534 browser()->tab_strip_model()->GetActiveWebContents(); |
1535 content::WebContents* contents = | 1535 content::WebContents* contents = |
1536 content::WebContents::Create(content::WebContents::CreateParams( | 1536 content::WebContents::Create(content::WebContents::CreateParams( |
1537 original_contents->GetBrowserContext())); | 1537 original_contents->GetBrowserContext())); |
1538 ASSERT_TRUE(contents); | 1538 ASSERT_TRUE(contents); |
1539 contents->SetDelegate(delegate); | 1539 contents->SetDelegate(delegate); |
1540 delegate->tab_strip_model()->AppendWebContents(contents, true); | 1540 delegate->tab_strip_model()->AppendWebContents(contents, true); |
1541 int index = delegate->tab_strip_model()->GetIndexOfWebContents(contents); | 1541 int index = delegate->tab_strip_model()->GetIndexOfWebContents(contents); |
1542 delegate->tab_strip_model()->ActivateTabAt(index, true); | 1542 delegate->tab_strip_model()->ActivateTabAt(index, true); |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2155 SecurityStateTabHelper* helper = | 2155 SecurityStateTabHelper* helper = |
2156 SecurityStateTabHelper::FromWebContents(web_contents); | 2156 SecurityStateTabHelper::FromWebContents(web_contents); |
2157 ASSERT_TRUE(helper); | 2157 ASSERT_TRUE(helper); |
2158 security_state::SecurityInfo security_info; | 2158 security_state::SecurityInfo security_info; |
2159 helper->GetSecurityInfo(&security_info); | 2159 helper->GetSecurityInfo(&security_info); |
2160 EXPECT_EQ(security_state::SECURE, security_info.security_level); | 2160 EXPECT_EQ(security_state::SECURE, security_info.security_level); |
2161 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses); | 2161 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses); |
2162 } | 2162 } |
2163 | 2163 |
2164 } // namespace | 2164 } // namespace |
OLD | NEW |