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

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

Issue 2928453002: Add MarkHttpAsDangerous test and correct other MarkNonSecureAs tests (Closed)
Patch Set: Address review feedback Created 3 years, 6 months 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 | « no previous file | testing/variations/fieldtrial_testing_config.json » ('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 (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
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 {
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);
Ilya Sherman 2017/06/05 23:21:12 Is this still needed given that you are removing t
elawrence 2017/06/06 01:05:17 An important caveat for this CL is that we will ve
Ilya Sherman 2017/06/06 05:51:13 I see. I'm not very thrilled about this choice, a
elawrence 2017/06/06 19:50:02 Yeah, that's not great.
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
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 =
1314 base::FieldTrialList::CreateFieldTrial( 1325 base::FieldTrialList::CreateFieldTrial(
1315 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous); 1326 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous);
Ilya Sherman 2017/06/05 23:21:12 If the code is launched to stable, then why do you
elawrence 2017/06/06 01:05:17 Marking of HTTP is controlled by chrome://flags#ma
1327 ASSERT_TRUE(trial != nullptr);
1316 1328
1317 content::WebContents* contents = 1329 content::WebContents* contents =
1318 browser()->tab_strip_model()->GetActiveWebContents(); 1330 browser()->tab_strip_model()->GetActiveWebContents();
1319 ASSERT_TRUE(contents); 1331 ASSERT_TRUE(contents);
1320 1332
1321 SecurityStateTabHelper* helper = 1333 SecurityStateTabHelper* helper =
1322 SecurityStateTabHelper::FromWebContents(contents); 1334 SecurityStateTabHelper::FromWebContents(contents);
1323 ASSERT_TRUE(helper); 1335 ASSERT_TRUE(helper);
1324 1336
1325 ui_test_utils::NavigateToURL(browser(), GURL("file:///")); 1337 ui_test_utils::NavigateToURL(browser(), GURL("file:///"));
1326 security_state::SecurityInfo security_info; 1338 security_state::SecurityInfo security_info;
1327 helper->GetSecurityInfo(&security_info); 1339 helper->GetSecurityInfo(&security_info);
1328 EXPECT_EQ(security_state::NONE, security_info.security_level); 1340 EXPECT_EQ(security_state::NONE, security_info.security_level);
1329 } 1341 }
1330 1342
1331 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkAboutAsNonSecure) { 1343 IN_PROC_BROWSER_TEST_F(SSLUITestIgnoringFieldTrialConfig,
1344 MarkAboutAsNonSecure) {
1332 scoped_refptr<base::FieldTrial> trial = 1345 scoped_refptr<base::FieldTrial> trial =
1333 base::FieldTrialList::CreateFieldTrial( 1346 base::FieldTrialList::CreateFieldTrial(
1334 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous); 1347 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous);
1348 ASSERT_TRUE(trial != nullptr);
1335 1349
1336 content::WebContents* contents = 1350 content::WebContents* contents =
1337 browser()->tab_strip_model()->GetActiveWebContents(); 1351 browser()->tab_strip_model()->GetActiveWebContents();
1338 ASSERT_TRUE(contents); 1352 ASSERT_TRUE(contents);
1339 1353
1340 SecurityStateTabHelper* helper = 1354 SecurityStateTabHelper* helper =
1341 SecurityStateTabHelper::FromWebContents(contents); 1355 SecurityStateTabHelper::FromWebContents(contents);
1342 ASSERT_TRUE(helper); 1356 ASSERT_TRUE(helper);
1343 1357
1344 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); 1358 ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
(...skipping 11 matching lines...) Expand all
1356 SecurityStateTabHelper* helper = 1370 SecurityStateTabHelper* helper =
1357 SecurityStateTabHelper::FromWebContents(contents); 1371 SecurityStateTabHelper::FromWebContents(contents);
1358 ASSERT_TRUE(helper); 1372 ASSERT_TRUE(helper);
1359 1373
1360 ui_test_utils::NavigateToURL(browser(), GURL("data:text/plain,hello")); 1374 ui_test_utils::NavigateToURL(browser(), GURL("data:text/plain,hello"));
1361 security_state::SecurityInfo security_info; 1375 security_state::SecurityInfo security_info;
1362 helper->GetSecurityInfo(&security_info); 1376 helper->GetSecurityInfo(&security_info);
1363 EXPECT_EQ(security_state::HTTP_SHOW_WARNING, security_info.security_level); 1377 EXPECT_EQ(security_state::HTTP_SHOW_WARNING, security_info.security_level);
1364 } 1378 }
1365 1379
1366 IN_PROC_BROWSER_TEST_F(SSLUITest, MarkBlobAsNonSecure) { 1380 // Ensure that HTTP origins are marked correctly when the MarkNonSecureAs field
1381 // trial is set to MarkHttpAsDangerous.
1382 IN_PROC_BROWSER_TEST_F(SSLUITestIgnoringFieldTrialConfig, MarkHTTPAsDangerous) {
1367 scoped_refptr<base::FieldTrial> trial = 1383 scoped_refptr<base::FieldTrial> trial =
1368 base::FieldTrialList::CreateFieldTrial( 1384 base::FieldTrialList::CreateFieldTrial(
1369 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous); 1385 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous);
1386 ASSERT_TRUE(trial != nullptr);
1387
1388 ASSERT_TRUE(embedded_test_server()->Start());
1389
1390 // Navigate to a non-local HTTP page.
1391 ui_test_utils::NavigateToURL(browser(), GURL("http://example.com/"));
1392 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
1393 SecurityStateTabHelper* helper = SecurityStateTabHelper::FromWebContents(tab);
1394 ASSERT_TRUE(helper);
1395
1396 security_state::SecurityInfo security_info;
1397 helper->GetSecurityInfo(&security_info);
1398 EXPECT_EQ(security_state::DANGEROUS, security_info.security_level);
1399 }
1400
1401 IN_PROC_BROWSER_TEST_F(SSLUITestIgnoringFieldTrialConfig, MarkBlobAsNonSecure) {
1402 scoped_refptr<base::FieldTrial> trial =
1403 base::FieldTrialList::CreateFieldTrial(
1404 "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous);
1405 ASSERT_TRUE(trial != nullptr);
1370 1406
1371 content::WebContents* contents = 1407 content::WebContents* contents =
1372 browser()->tab_strip_model()->GetActiveWebContents(); 1408 browser()->tab_strip_model()->GetActiveWebContents();
1373 ASSERT_TRUE(contents); 1409 ASSERT_TRUE(contents);
1374 1410
1375 SecurityStateTabHelper* helper = 1411 SecurityStateTabHelper* helper =
1376 SecurityStateTabHelper::FromWebContents(contents); 1412 SecurityStateTabHelper::FromWebContents(contents);
1377 ASSERT_TRUE(helper); 1413 ASSERT_TRUE(helper);
1378 1414
1379 ui_test_utils::NavigateToURL( 1415 ui_test_utils::NavigateToURL(
(...skipping 3346 matching lines...) Expand 10 before | Expand all | Expand 10 after
4726 4762
4727 // Visit a page over https that contains a frame with a redirect. 4763 // Visit a page over https that contains a frame with a redirect.
4728 4764
4729 // XMLHttpRequest insecure content in synchronous mode. 4765 // XMLHttpRequest insecure content in synchronous mode.
4730 4766
4731 // XMLHttpRequest insecure content in asynchronous mode. 4767 // XMLHttpRequest insecure content in asynchronous mode.
4732 4768
4733 // XMLHttpRequest over bad ssl in synchronous mode. 4769 // XMLHttpRequest over bad ssl in synchronous mode.
4734 4770
4735 // XMLHttpRequest over OK ssl in synchronous mode. 4771 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW
« no previous file with comments | « no previous file | testing/variations/fieldtrial_testing_config.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698