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

Unified Diff: chrome/browser/ssl/ssl_browser_tests.cc

Issue 2928453002: Add MarkHttpAsDangerous test and correct other MarkNonSecureAs tests (Closed)
Patch Set: Change tests to use command line flag 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | testing/variations/fieldtrial_testing_config.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ssl/ssl_browser_tests.cc
diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc
index fe83aa907a7652395726717625abc553a385ffba..c8705556df213813a396dc1d649f861bd34307b2 100644
--- a/chrome/browser/ssl/ssl_browser_tests.cc
+++ b/chrome/browser/ssl/ssl_browser_tests.cc
@@ -20,6 +20,7 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/histogram_tester.h"
+#include "base/test/scoped_command_line.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_clock.h"
#include "base/threading/thread_restrictions.h"
@@ -1307,12 +1308,13 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestWSSInvalidCertAndGoForward) {
EXPECT_TRUE(base::LowerCaseEqualsASCII(result, "pass"));
}
-// Ensure that non-standard origins are marked correctly when the
-// MarkNonSecureAs field trial is enabled.
+// Ensure that non-standard origins are marked as neutral when the
+// MarkNonSecureAs Dangerous flag is enabled.
IN_PROC_BROWSER_TEST_F(SSLUITest, MarkFileAsNonSecure) {
- scoped_refptr<base::FieldTrial> trial =
- base::FieldTrialList::CreateFieldTrial(
- "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous);
+ base::test::ScopedCommandLine scoped_command_line;
+ scoped_command_line.GetProcessCommandLine()->AppendSwitchASCII(
+ security_state::switches::kMarkHttpAs,
+ security_state::switches::kMarkHttpAsDangerous);
content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents();
@@ -1328,10 +1330,13 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, MarkFileAsNonSecure) {
EXPECT_EQ(security_state::NONE, security_info.security_level);
}
+// Ensure that about-protocol origins are marked as neutral when the
+// MarkNonSecureAs Dangerous flag is enabled.
IN_PROC_BROWSER_TEST_F(SSLUITest, MarkAboutAsNonSecure) {
- scoped_refptr<base::FieldTrial> trial =
- base::FieldTrialList::CreateFieldTrial(
- "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous);
+ base::test::ScopedCommandLine scoped_command_line;
+ scoped_command_line.GetProcessCommandLine()->AppendSwitchASCII(
+ security_state::switches::kMarkHttpAs,
+ security_state::switches::kMarkHttpAsDangerous);
content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents();
@@ -1363,10 +1368,34 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, MarkDataAsNonSecure) {
EXPECT_EQ(security_state::HTTP_SHOW_WARNING, security_info.security_level);
}
+// Ensure that HTTP-protocol origins are marked as Dangerous when the
+// MarkNonSecureAs Dangerous flag is enabled.
+IN_PROC_BROWSER_TEST_F(SSLUITest, MarkHTTPAsDangerous) {
+ base::test::ScopedCommandLine scoped_command_line;
+ scoped_command_line.GetProcessCommandLine()->AppendSwitchASCII(
+ security_state::switches::kMarkHttpAs,
+ security_state::switches::kMarkHttpAsDangerous);
+
+ ASSERT_TRUE(embedded_test_server()->Start());
+
+ // Navigate to a non-local HTTP page.
+ ui_test_utils::NavigateToURL(browser(), GURL("http://example.com/"));
+ WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
+ SecurityStateTabHelper* helper = SecurityStateTabHelper::FromWebContents(tab);
+ ASSERT_TRUE(helper);
+
+ security_state::SecurityInfo security_info;
+ helper->GetSecurityInfo(&security_info);
+ EXPECT_EQ(security_state::DANGEROUS, security_info.security_level);
+}
+
+// Ensure that blob-protocol origins are marked as neutral when the
+// MarkNonSecureAs Dangerous flag is enabled.
IN_PROC_BROWSER_TEST_F(SSLUITest, MarkBlobAsNonSecure) {
- scoped_refptr<base::FieldTrial> trial =
- base::FieldTrialList::CreateFieldTrial(
- "MarkNonSecureAs", security_state::switches::kMarkHttpAsDangerous);
+ base::test::ScopedCommandLine scoped_command_line;
+ scoped_command_line.GetProcessCommandLine()->AppendSwitchASCII(
+ security_state::switches::kMarkHttpAs,
+ security_state::switches::kMarkHttpAsDangerous);
content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents();
« 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