Commit 1f3ba552 authored by Livvie Lin's avatar Livvie Lin Committed by Commit Bot

Reland "Add HTTPDangerWarning experiment to field trial testing config"

This is a reland of 702cbe72

The original change was reverted due to failures of the changed tests on trunk
(see crbug.com/1029292), so this updated CL uses conditional expectations based
on whether the feature is enabled.

Original change's description:
> Add HTTPDangerWarning experiment to field trial testing config
>
> Bug: 1027626
> Change-Id: I70ddfb8cb18b7e045e8c6f30ce7d398d0c2f1c1b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1929862
> Reviewed-by: Brian White <bcwhite@chromium.org>
> Reviewed-by: Carlos IL <carlosil@chromium.org>
> Reviewed-by: Steven Holte <holte@chromium.org>
> Commit-Queue: Livvie Lin <livvielin@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#719730}

Bug: 1027626
Change-Id: I16415497b537b1350af79c88f76a03ef48ae488c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1946671Reviewed-by: default avatarCarlos IL <carlosil@chromium.org>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Commit-Queue: Livvie Lin <livvielin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721006}
parent d47cd17a
......@@ -180,6 +180,22 @@ security_state::SecurityLevel GetLevelForPassiveMixedContent() {
: security_state::NONE;
}
blink::SecurityStyle GetSecurityStyleForHttp() {
bool http_danger_warning_enabled = false;
if (base::FeatureList::IsEnabled(
security_state::features::kMarkHttpAsFeature)) {
std::string parameter = base::GetFieldTrialParamValueByFeature(
security_state::features::kMarkHttpAsFeature,
security_state::features::kMarkHttpAsFeatureParameterName);
if (parameter ==
security_state::features::kMarkHttpAsParameterDangerWarning) {
http_danger_warning_enabled = true;
}
}
return http_danger_warning_enabled ? blink::SecurityStyle::kInsecure
: blink::SecurityStyle::kNeutral;
}
// A delegate class that allows emulating selection of a file for an
// INPUT TYPE=FILE form field.
class FileChooserDelegate : public content::WebContentsDelegate {
......@@ -1108,7 +1124,9 @@ IN_PROC_BROWSER_TEST_F(SecurityStateTabHelperTest,
// Ensure that WebContentsObservers don't show an incorrect Form Not Secure
// explanation. Regression test for https://crbug.com/691412.
EXPECT_EQ(0u, observer.latest_explanations().neutral_explanations.size());
EXPECT_EQ(blink::SecurityStyle::kNeutral, observer.latest_security_style());
// The below expectation is based on the feature flag set in the field trial
// testing config.
EXPECT_EQ(GetSecurityStyleForHttp(), observer.latest_security_style());
content::NavigationEntry* entry = contents->GetController().GetVisibleEntry();
ASSERT_TRUE(entry);
......@@ -1230,7 +1248,9 @@ IN_PROC_BROWSER_TEST_F(SecurityStateTabHelperTest,
// Ensure that WebContentsObservers don't show an incorrect Form Not Secure
// explanation. Regression test for https://crbug.com/691412.
EXPECT_EQ(0u, observer.latest_explanations().neutral_explanations.size());
EXPECT_EQ(blink::SecurityStyle::kNeutral, observer.latest_security_style());
// The below expectation is based on the feature flag set in the field trial
// testing config.
EXPECT_EQ(GetSecurityStyleForHttp(), observer.latest_security_style());
content::NavigationEntry* entry = contents->GetController().GetVisibleEntry();
ASSERT_TRUE(entry);
......@@ -1640,7 +1660,9 @@ IN_PROC_BROWSER_TEST_F(
GURL mixed_content_url(https_server_.GetURL(replacement_path));
ui_test_utils::NavigateToURL(browser(), mixed_content_url);
EXPECT_EQ(blink::SecurityStyle::kNeutral, observer.latest_security_style());
// The below expectation is based on the feature flag set in the field trial
// testing config.
EXPECT_EQ(GetSecurityStyleForHttp(), observer.latest_security_style());
const content::SecurityStyleExplanations& mixed_content_explanation =
observer.latest_explanations();
......
......@@ -2900,7 +2900,7 @@
]
}
],
"HTTPReallyBadFinal": [
"HTTPDangerWarning": [
{
"platforms": [
"android",
......@@ -2914,7 +2914,7 @@
{
"name": "enabled",
"params": {
"treatment": "dangerous"
"treatment": "danger-warning"
},
"enable_features": [
"MarkHttpAs"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment