Commit 143ecbc0 authored by David Van Cleve's avatar David Van Cleve Committed by Commit Bot

Adds NoReferrers feature bugfix and test coverage

crrev.com/c/1808144 replaced the ancient --no-referrers
command-line switch with a base::Feature. The change
contained a bug and didn't add sufficient test coverage beyond
what was already present---and there was no test coverage already
present!

This patch remedies both the bug and the lack of coverage:
1. The bug was a failure to sync the base::Feature to a profile-scoped
pref; the previous patch only propagated the base::Feature to a
system-scoped (local state) pref. This is fixed by having the pref's
default value, set in prefs_tab_helper.cc, depend on the value of the
Feature.
2. This patch adds additional referrer policy browsertest coverage
to make sure that, when the NoReferrers feature is on, the browser
sends no referrers.

R=jochen

Bug: 1004486
Change-Id: Idc98b6d912dd59b23eab6eeef128e7a6992758ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1842040
Commit-Queue: David Van Cleve <davidvc@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703492}
parent bf1b96ef
......@@ -671,7 +671,24 @@ struct ReferrerOverrideParams {
cross_origin_to_same_origin_redirect, same_origin_subresource,
same_origin_to_cross_origin_subresource_redirect;
} kReferrerOverrideParams[] = {
// TODO(davidvc, subsequent CL): Add a block of parameters for kNoReferrers.
{.feature_to_enable = features::kNoReferrers,
.baseline_policy = network::mojom::ReferrerPolicy::kAlways,
// The renderer's "have we completely disabled referrers?"
// implementation resets requests' referrer policies to the default when
// it excises their referrers.
.expected_policy =
content::Referrer::NetReferrerPolicyToBlinkReferrerPolicy(
content::Referrer::GetDefaultReferrerPolicy()),
.same_origin_nav = ReferrerPolicyTest::EXPECT_EMPTY_REFERRER,
.cross_origin_nav = ReferrerPolicyTest::EXPECT_EMPTY_REFERRER,
.cross_origin_downgrade_nav = ReferrerPolicyTest::EXPECT_EMPTY_REFERRER,
.same_origin_to_cross_origin_redirect =
ReferrerPolicyTest::EXPECT_EMPTY_REFERRER,
.cross_origin_to_same_origin_redirect =
ReferrerPolicyTest::EXPECT_EMPTY_REFERRER,
.same_origin_subresource = ReferrerPolicyTest::EXPECT_EMPTY_REFERRER,
.same_origin_to_cross_origin_subresource_redirect =
ReferrerPolicyTest::EXPECT_EMPTY_REFERRER},
{
.feature_to_enable =
network::features::kCapReferrerToOriginOnCrossOrigin,
......
......@@ -25,6 +25,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_preferences_util.h"
#include "chrome/browser/ui/prefs/pref_watcher.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_font_webkit_names.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_names_util.h"
......@@ -352,7 +353,9 @@ void PrefsTabHelper::RegisterProfilePrefs(
pref_defaults.tabs_to_links);
registry->RegisterBooleanPref(prefs::kWebKitAllowRunningInsecureContent,
false);
registry->RegisterBooleanPref(prefs::kEnableReferrers, true);
registry->RegisterBooleanPref(
prefs::kEnableReferrers,
!base::FeatureList::IsEnabled(features::kNoReferrers));
registry->RegisterBooleanPref(prefs::kEnableEncryptedMedia, true);
#if defined(OS_ANDROID)
registry->RegisterDoublePref(prefs::kWebKitFontScaleFactor, 1.0);
......
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