| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/metrics/field_trial.h" | 16 #include "base/metrics/field_trial.h" |
| 17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 18 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/test/histogram_tester.h" | 22 #include "base/test/histogram_tester.h" |
| 23 #include "base/test/scoped_command_line.h" |
| 23 #include "base/test/scoped_feature_list.h" | 24 #include "base/test/scoped_feature_list.h" |
| 24 #include "base/test/simple_test_clock.h" | 25 #include "base/test/simple_test_clock.h" |
| 25 #include "base/threading/thread_restrictions.h" | 26 #include "base/threading/thread_restrictions.h" |
| 26 #include "base/threading/thread_task_runner_handle.h" | 27 #include "base/threading/thread_task_runner_handle.h" |
| 27 #include "base/time/default_clock.h" | 28 #include "base/time/default_clock.h" |
| 28 #include "base/time/default_tick_clock.h" | 29 #include "base/time/default_tick_clock.h" |
| 29 #include "base/time/time.h" | 30 #include "base/time/time.h" |
| 30 #include "build/build_config.h" | 31 #include "build/build_config.h" |
| 31 #include "chrome/app/chrome_command_ids.h" | 32 #include "chrome/app/chrome_command_ids.h" |
| 32 #include "chrome/browser/browser_process.h" | 33 #include "chrome/browser/browser_process.h" |
| (...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1300 | 1301 |
| 1301 // Proceed anyway. | 1302 // Proceed anyway. |
| 1302 ProceedThroughInterstitial(tab); | 1303 ProceedThroughInterstitial(tab); |
| 1303 | 1304 |
| 1304 // Test page run a WebSocket wss connection test. The result will be shown | 1305 // Test page run a WebSocket wss connection test. The result will be shown |
| 1305 // as page title. | 1306 // as page title. |
| 1306 const base::string16 result = watcher.WaitAndGetTitle(); | 1307 const base::string16 result = watcher.WaitAndGetTitle(); |
| 1307 EXPECT_TRUE(base::LowerCaseEqualsASCII(result, "pass")); | 1308 EXPECT_TRUE(base::LowerCaseEqualsASCII(result, "pass")); |
| 1308 } | 1309 } |
| 1309 | 1310 |
| 1310 // Ensure that non-standard origins are marked correctly when the | 1311 // Ensure that non-standard origins are marked as neutral when the |
| 1311 // MarkNonSecureAs field trial is enabled. | 1312 // MarkNonSecureAs Dangerous flag is enabled. |
| 1312 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkFileAsNonSecure) { | 1313 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkFileAsNonSecure) { |
| 1313 scoped_refptr<base::FieldTrial> trial = | 1314 base::test::ScopedCommandLine scoped_command_line; |
| 1314 base::FieldTrialList::CreateFieldTrial( | 1315 scoped_command_line.GetProcessCommandLine()->AppendSwitchASCII( |
| 1315 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous); | 1316 security_state::switches::kMarkHttpAs, |
| 1317 security_state::switches::kMarkHttpAsDangerous); |
| 1316 | 1318 |
| 1317 content::WebContents* contents = | 1319 content::WebContents* contents = |
| 1318 browser()->tab_strip_model()->GetActiveWebContents(); | 1320 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1319 ASSERT_TRUE(contents); | 1321 ASSERT_TRUE(contents); |
| 1320 | 1322 |
| 1321 SecurityStateTabHelper* helper = | 1323 SecurityStateTabHelper* helper = |
| 1322 SecurityStateTabHelper::FromWebContents(contents); | 1324 SecurityStateTabHelper::FromWebContents(contents); |
| 1323 ASSERT_TRUE(helper); | 1325 ASSERT_TRUE(helper); |
| 1324 | 1326 |
| 1325 ui_test_utils::NavigateToURL(browser(), GURL("file:///")); | 1327 ui_test_utils::NavigateToURL(browser(), GURL("file:///")); |
| 1326 security_state::SecurityInfo security_info; | 1328 security_state::SecurityInfo security_info; |
| 1327 helper->GetSecurityInfo(&security_info); | 1329 helper->GetSecurityInfo(&security_info); |
| 1328 EXPECT_EQ(security_state::NONE, security_info.security_level); | 1330 EXPECT_EQ(security_state::NONE, security_info.security_level); |
| 1329 } | 1331 } |
| 1330 | 1332 |
| 1333 // Ensure that about-protocol origins are marked as neutral when the |
| 1334 // MarkNonSecureAs Dangerous flag is enabled. |
| 1331 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkAboutAsNonSecure) { | 1335 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkAboutAsNonSecure) { |
| 1332 scoped_refptr<base::FieldTrial> trial = | 1336 base::test::ScopedCommandLine scoped_command_line; |
| 1333 base::FieldTrialList::CreateFieldTrial( | 1337 scoped_command_line.GetProcessCommandLine()->AppendSwitchASCII( |
| 1334 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous); | 1338 security_state::switches::kMarkHttpAs, |
| 1339 security_state::switches::kMarkHttpAsDangerous); |
| 1335 | 1340 |
| 1336 content::WebContents* contents = | 1341 content::WebContents* contents = |
| 1337 browser()->tab_strip_model()->GetActiveWebContents(); | 1342 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1338 ASSERT_TRUE(contents); | 1343 ASSERT_TRUE(contents); |
| 1339 | 1344 |
| 1340 SecurityStateTabHelper* helper = | 1345 SecurityStateTabHelper* helper = |
| 1341 SecurityStateTabHelper::FromWebContents(contents); | 1346 SecurityStateTabHelper::FromWebContents(contents); |
| 1342 ASSERT_TRUE(helper); | 1347 ASSERT_TRUE(helper); |
| 1343 | 1348 |
| 1344 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); | 1349 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1356 SecurityStateTabHelper* helper = | 1361 SecurityStateTabHelper* helper = |
| 1357 SecurityStateTabHelper::FromWebContents(contents); | 1362 SecurityStateTabHelper::FromWebContents(contents); |
| 1358 ASSERT_TRUE(helper); | 1363 ASSERT_TRUE(helper); |
| 1359 | 1364 |
| 1360 ui_test_utils::NavigateToURL(browser(), GURL("data:text/plain,hello")); | 1365 ui_test_utils::NavigateToURL(browser(), GURL("data:text/plain,hello")); |
| 1361 security_state::SecurityInfo security_info; | 1366 security_state::SecurityInfo security_info; |
| 1362 helper->GetSecurityInfo(&security_info); | 1367 helper->GetSecurityInfo(&security_info); |
| 1363 EXPECT_EQ(security_state::HTTP_SHOW_WARNING, security_info.security_level); | 1368 EXPECT_EQ(security_state::HTTP_SHOW_WARNING, security_info.security_level); |
| 1364 } | 1369 } |
| 1365 | 1370 |
| 1371 // Ensure that HTTP-protocol origins are marked as Dangerous when the |
| 1372 // MarkNonSecureAs Dangerous flag is enabled. |
| 1373 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkHTTPAsDangerous) { |
| 1374 base::test::ScopedCommandLine scoped_command_line; |
| 1375 scoped_command_line.GetProcessCommandLine()->AppendSwitchASCII( |
| 1376 security_state::switches::kMarkHttpAs, |
| 1377 security_state::switches::kMarkHttpAsDangerous); |
| 1378 |
| 1379 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1380 |
| 1381 // Navigate to a non-local HTTP page. |
| 1382 ui_test_utils::NavigateToURL(browser(), GURL("http://example.com/")); |
| 1383 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 1384 SecurityStateTabHelper* helper = SecurityStateTabHelper::FromWebContents(tab); |
| 1385 ASSERT_TRUE(helper); |
| 1386 |
| 1387 security_state::SecurityInfo security_info; |
| 1388 helper->GetSecurityInfo(&security_info); |
| 1389 EXPECT_EQ(security_state::DANGEROUS, security_info.security_level); |
| 1390 } |
| 1391 |
| 1392 // Ensure that blob-protocol origins are marked as neutral when the |
| 1393 // MarkNonSecureAs Dangerous flag is enabled. |
| 1366 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkBlobAsNonSecure) { | 1394 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkBlobAsNonSecure) { |
| 1367 scoped_refptr<base::FieldTrial> trial = | 1395 base::test::ScopedCommandLine scoped_command_line; |
| 1368 base::FieldTrialList::CreateFieldTrial( | 1396 scoped_command_line.GetProcessCommandLine()->AppendSwitchASCII( |
| 1369 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous); | 1397 security_state::switches::kMarkHttpAs, |
| 1398 security_state::switches::kMarkHttpAsDangerous); |
| 1370 | 1399 |
| 1371 content::WebContents* contents = | 1400 content::WebContents* contents = |
| 1372 browser()->tab_strip_model()->GetActiveWebContents(); | 1401 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1373 ASSERT_TRUE(contents); | 1402 ASSERT_TRUE(contents); |
| 1374 | 1403 |
| 1375 SecurityStateTabHelper* helper = | 1404 SecurityStateTabHelper* helper = |
| 1376 SecurityStateTabHelper::FromWebContents(contents); | 1405 SecurityStateTabHelper::FromWebContents(contents); |
| 1377 ASSERT_TRUE(helper); | 1406 ASSERT_TRUE(helper); |
| 1378 | 1407 |
| 1379 ui_test_utils::NavigateToURL( | 1408 ui_test_utils::NavigateToURL( |
| (...skipping 3346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4726 | 4755 |
| 4727 // Visit a page over https that contains a frame with a redirect. | 4756 // Visit a page over https that contains a frame with a redirect. |
| 4728 | 4757 |
| 4729 // XMLHttpRequest insecure content in synchronous mode. | 4758 // XMLHttpRequest insecure content in synchronous mode. |
| 4730 | 4759 |
| 4731 // XMLHttpRequest insecure content in asynchronous mode. | 4760 // XMLHttpRequest insecure content in asynchronous mode. |
| 4732 | 4761 |
| 4733 // XMLHttpRequest over bad ssl in synchronous mode. | 4762 // XMLHttpRequest over bad ssl in synchronous mode. |
| 4734 | 4763 |
| 4735 // XMLHttpRequest over OK ssl in synchronous mode. | 4764 // XMLHttpRequest over OK ssl in synchronous mode. |
| OLD | NEW |