Chromium Code Reviews| 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" |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 692 ui_test_utils::NavigateToURL(browser(), | 692 ui_test_utils::NavigateToURL(browser(), |
| 693 https_server_.GetURL(replacement_path)); | 693 https_server_.GetURL(replacement_path)); |
| 694 } | 694 } |
| 695 | 695 |
| 696 private: | 696 private: |
| 697 typedef net::SpawnedTestServer::SSLOptions SSLOptions; | 697 typedef net::SpawnedTestServer::SSLOptions SSLOptions; |
| 698 | 698 |
| 699 DISALLOW_COPY_AND_ASSIGN(SSLUITest); | 699 DISALLOW_COPY_AND_ASSIGN(SSLUITest); |
| 700 }; | 700 }; |
| 701 | 701 |
| 702 class SSLUITestIgnoringFieldTrialConfig : public SSLUITest { | |
|
estark
2017/06/05 21:07:33
I think we should do what you've done here, but al
elawrence
2017/06/05 21:42:44
Done.
| |
| 703 public: | |
| 704 SSLUITestIgnoringFieldTrialConfig() : SSLUITest() {} | |
| 705 | |
| 706 void SetUpCommandLine(base::CommandLine* command_line) override { | |
| 707 // Ensure that fieldtrial_testing_config.json does not interfere. | |
| 708 command_line->AppendSwitch( | |
| 709 variations::switches::kDisableFieldTrialTestingConfig); | |
| 710 } | |
| 711 }; | |
| 712 | |
| 702 class SSLUITestBlock : public SSLUITest { | 713 class SSLUITestBlock : public SSLUITest { |
| 703 public: | 714 public: |
| 704 SSLUITestBlock() : SSLUITest() {} | 715 SSLUITestBlock() : SSLUITest() {} |
| 705 | 716 |
| 706 // Browser will not run insecure content. | 717 // Browser will not run insecure content. |
| 707 void SetUpCommandLine(base::CommandLine* command_line) override { | 718 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 708 // By overriding SSLUITest, we won't apply the flag that allows running | 719 // By overriding SSLUITest, we won't apply the flag that allows running |
| 709 // insecure content. | 720 // insecure content. |
| 710 } | 721 } |
| 711 }; | 722 }; |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1302 ProceedThroughInterstitial(tab); | 1313 ProceedThroughInterstitial(tab); |
| 1303 | 1314 |
| 1304 // Test page run a WebSocket wss connection test. The result will be shown | 1315 // Test page run a WebSocket wss connection test. The result will be shown |
| 1305 // as page title. | 1316 // as page title. |
| 1306 const base::string16 result = watcher.WaitAndGetTitle(); | 1317 const base::string16 result = watcher.WaitAndGetTitle(); |
| 1307 EXPECT_TRUE(base::LowerCaseEqualsASCII(result, "pass")); | 1318 EXPECT_TRUE(base::LowerCaseEqualsASCII(result, "pass")); |
| 1308 } | 1319 } |
| 1309 | 1320 |
| 1310 // Ensure that non-standard origins are marked correctly when the | 1321 // Ensure that non-standard origins are marked correctly when the |
| 1311 // MarkNonSecureAs field trial is enabled. | 1322 // MarkNonSecureAs field trial is enabled. |
| 1312 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkFileAsNonSecure) { | 1323 IN_PROC_BROWSER_TEST_F(SSLUITestIgnoringFieldTrialConfig, MarkFileAsNonSecure) { |
| 1313 scoped_refptr<base::FieldTrial> trial = | 1324 scoped_refptr<base::FieldTrial> trial = |
|
estark
2017/06/05 21:07:33
nit: maybe ASSERT_TRUE(trial) after each of these?
elawrence
2017/06/05 21:44:51
Done; though using the more explicit (x!=nullptr)
| |
| 1314 base::FieldTrialList::CreateFieldTrial( | 1325 base::FieldTrialList::CreateFieldTrial( |
| 1315 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous); | 1326 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous); |
| 1316 | 1327 |
| 1317 content::WebContents* contents = | 1328 content::WebContents* contents = |
| 1318 browser()->tab_strip_model()->GetActiveWebContents(); | 1329 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1319 ASSERT_TRUE(contents); | 1330 ASSERT_TRUE(contents); |
| 1320 | 1331 |
| 1321 SecurityStateTabHelper* helper = | 1332 SecurityStateTabHelper* helper = |
| 1322 SecurityStateTabHelper::FromWebContents(contents); | 1333 SecurityStateTabHelper::FromWebContents(contents); |
| 1323 ASSERT_TRUE(helper); | 1334 ASSERT_TRUE(helper); |
| 1324 | 1335 |
| 1325 ui_test_utils::NavigateToURL(browser(), GURL("file:///")); | 1336 ui_test_utils::NavigateToURL(browser(), GURL("file:///")); |
| 1326 security_state::SecurityInfo security_info; | 1337 security_state::SecurityInfo security_info; |
| 1327 helper->GetSecurityInfo(&security_info); | 1338 helper->GetSecurityInfo(&security_info); |
| 1328 EXPECT_EQ(security_state::NONE, security_info.security_level); | 1339 EXPECT_EQ(security_state::NONE, security_info.security_level); |
| 1329 } | 1340 } |
| 1330 | 1341 |
| 1331 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkAboutAsNonSecure) { | 1342 IN_PROC_BROWSER_TEST_F(SSLUITestIgnoringFieldTrialConfig, |
| 1343 MarkAboutAsNonSecure) { | |
| 1332 scoped_refptr<base::FieldTrial> trial = | 1344 scoped_refptr<base::FieldTrial> trial = |
| 1333 base::FieldTrialList::CreateFieldTrial( | 1345 base::FieldTrialList::CreateFieldTrial( |
| 1334 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous); | 1346 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous); |
| 1335 | 1347 |
| 1336 content::WebContents* contents = | 1348 content::WebContents* contents = |
| 1337 browser()->tab_strip_model()->GetActiveWebContents(); | 1349 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1338 ASSERT_TRUE(contents); | 1350 ASSERT_TRUE(contents); |
| 1339 | 1351 |
| 1340 SecurityStateTabHelper* helper = | 1352 SecurityStateTabHelper* helper = |
| 1341 SecurityStateTabHelper::FromWebContents(contents); | 1353 SecurityStateTabHelper::FromWebContents(contents); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1356 SecurityStateTabHelper* helper = | 1368 SecurityStateTabHelper* helper = |
| 1357 SecurityStateTabHelper::FromWebContents(contents); | 1369 SecurityStateTabHelper::FromWebContents(contents); |
| 1358 ASSERT_TRUE(helper); | 1370 ASSERT_TRUE(helper); |
| 1359 | 1371 |
| 1360 ui_test_utils::NavigateToURL(browser(), GURL("data:text/plain,hello")); | 1372 ui_test_utils::NavigateToURL(browser(), GURL("data:text/plain,hello")); |
| 1361 security_state::SecurityInfo security_info; | 1373 security_state::SecurityInfo security_info; |
| 1362 helper->GetSecurityInfo(&security_info); | 1374 helper->GetSecurityInfo(&security_info); |
| 1363 EXPECT_EQ(security_state::HTTP_SHOW_WARNING, security_info.security_level); | 1375 EXPECT_EQ(security_state::HTTP_SHOW_WARNING, security_info.security_level); |
| 1364 } | 1376 } |
| 1365 | 1377 |
| 1366 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkBlobAsNonSecure) { | 1378 // Ensure that HTTP origins are marked correctly when the MarkNonSecureAs field |
| 1379 // trial is set to MarkHttpAsDangerous. | |
| 1380 IN_PROC_BROWSER_TEST_F(SSLUITestIgnoringFieldTrialConfig, MarkHTTPAsDangerous) { | |
| 1367 scoped_refptr<base::FieldTrial> trial = | 1381 scoped_refptr<base::FieldTrial> trial = |
| 1368 base::FieldTrialList::CreateFieldTrial( | 1382 base::FieldTrialList::CreateFieldTrial( |
| 1369 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous); | 1383 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous); |
| 1384 | |
| 1385 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1386 | |
| 1387 // Navigate to a non-local HTTP page. | |
| 1388 ui_test_utils::NavigateToURL(browser(), GURL("http://example.com/")); | |
| 1389 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | |
| 1390 SecurityStateTabHelper* helper = SecurityStateTabHelper::FromWebContents(tab); | |
| 1391 ASSERT_TRUE(helper); | |
| 1392 | |
| 1393 security_state::SecurityInfo security_info; | |
| 1394 helper->GetSecurityInfo(&security_info); | |
| 1395 EXPECT_EQ(security_state::DANGEROUS, security_info.security_level); | |
| 1396 } | |
| 1397 | |
| 1398 IN_PROC_BROWSER_TEST_F(SSLUITestIgnoringFieldTrialConfig, MarkBlobAsNonSecure) { | |
| 1399 scoped_refptr<base::FieldTrial> trial = | |
| 1400 base::FieldTrialList::CreateFieldTrial( | |
| 1401 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous); | |
| 1370 | 1402 |
| 1371 content::WebContents* contents = | 1403 content::WebContents* contents = |
| 1372 browser()->tab_strip_model()->GetActiveWebContents(); | 1404 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1373 ASSERT_TRUE(contents); | 1405 ASSERT_TRUE(contents); |
| 1374 | 1406 |
| 1375 SecurityStateTabHelper* helper = | 1407 SecurityStateTabHelper* helper = |
| 1376 SecurityStateTabHelper::FromWebContents(contents); | 1408 SecurityStateTabHelper::FromWebContents(contents); |
| 1377 ASSERT_TRUE(helper); | 1409 ASSERT_TRUE(helper); |
| 1378 | 1410 |
| 1379 ui_test_utils::NavigateToURL( | 1411 ui_test_utils::NavigateToURL( |
| (...skipping 3346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4726 | 4758 |
| 4727 // Visit a page over https that contains a frame with a redirect. | 4759 // Visit a page over https that contains a frame with a redirect. |
| 4728 | 4760 |
| 4729 // XMLHttpRequest insecure content in synchronous mode. | 4761 // XMLHttpRequest insecure content in synchronous mode. |
| 4730 | 4762 |
| 4731 // XMLHttpRequest insecure content in asynchronous mode. | 4763 // XMLHttpRequest insecure content in asynchronous mode. |
| 4732 | 4764 |
| 4733 // XMLHttpRequest over bad ssl in synchronous mode. | 4765 // XMLHttpRequest over bad ssl in synchronous mode. |
| 4734 | 4766 |
| 4735 // XMLHttpRequest over OK ssl in synchronous mode. | 4767 // XMLHttpRequest over OK ssl in synchronous mode. |
| OLD | NEW |