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

Unified Diff: chrome/browser/content_settings/content_settings_policy_provider_unittest.cc

Issue 1865803002: [Policy Experimental] Add policies to allow Cookies and Pop-ups exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync; compile fix in PolicyProvider::GetUserExceptionsUsageSettingForType(). Created 4 years, 8 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 | chrome/browser/content_settings/host_content_settings_map_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/content_settings/content_settings_policy_provider_unittest.cc
diff --git a/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc b/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc
index 5ed0ab45775a952f54b2299dba18aba5a7e9795b..62356bcc971175b8619a4b76b6e83652668a036b 100644
--- a/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc
+++ b/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc
@@ -254,4 +254,55 @@ TEST_F(PolicyProviderTest, AutoSelectCertificateList) {
provider.ShutdownOnUIThread();
}
+TEST_F(PolicyProviderTest, GetUserExceptionsUsageSettingForType) {
+ struct {
+ ContentSettingsType content_type;
+ const char* pref_exception_setting;
+ } kTypeInfos[] = {
+ {CONTENT_SETTINGS_TYPE_COOKIES, prefs::kUserCookiesExceptionsUsage},
+ {CONTENT_SETTINGS_TYPE_POPUPS, prefs::kUserPopupsExceptionsUsage},
+ };
+
+ TestingProfile profile;
+ syncable_prefs::TestingPrefServiceSyncable* prefs =
+ profile.GetTestingPrefService();
+ PolicyProvider provider(prefs);
+
+ for (const auto& type_info : kTypeInfos) {
+ // Initially not set.
+ EXPECT_EQ(USER_EXCEPTIONS_DEFAULT,
+ provider.GetUserExceptionsUsageSettingForType(
+ type_info.content_type));
+
+ // Set value.
+ prefs->SetManagedPref(type_info.pref_exception_setting,
+ new base::FundamentalValue(CONTENT_SETTING_ALLOW));
+ EXPECT_EQ(USER_EXCEPTIONS_ALLOW,
+ provider.GetUserExceptionsUsageSettingForType(
+ type_info.content_type));
+
+ // Clear value.
+ prefs->RemoveManagedPref(type_info.pref_exception_setting);
+ EXPECT_EQ(USER_EXCEPTIONS_DEFAULT,
+ provider.GetUserExceptionsUsageSettingForType(
+ type_info.content_type));
+
+ // Try to set as user pref: Should have no effect.
+ prefs->SetUserPref(type_info.pref_exception_setting,
+ new base::FundamentalValue(CONTENT_SETTING_ALLOW));
+ EXPECT_EQ(USER_EXCEPTIONS_DEFAULT,
+ provider.GetUserExceptionsUsageSettingForType(
+ type_info.content_type));
+
+ // Set value again and leave it lingering around.
+ prefs->SetManagedPref(type_info.pref_exception_setting,
+ new base::FundamentalValue(CONTENT_SETTING_ALLOW));
+ EXPECT_EQ(USER_EXCEPTIONS_ALLOW,
+ provider.GetUserExceptionsUsageSettingForType(
+ type_info.content_type));
+ }
+
+ provider.ShutdownOnUIThread();
+}
+
} // namespace content_settings
« no previous file with comments | « no previous file | chrome/browser/content_settings/host_content_settings_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698