Index: chrome/browser/content_settings/host_content_settings_map_unittest.cc |
diff --git a/chrome/browser/content_settings/host_content_settings_map_unittest.cc b/chrome/browser/content_settings/host_content_settings_map_unittest.cc |
index 48c4e060660f49f14764086b9b65ca5817d4d179..e0e65d396dc2c5d56b97180cdeb9b79f7a8d44d4 100644 |
--- a/chrome/browser/content_settings/host_content_settings_map_unittest.cc |
+++ b/chrome/browser/content_settings/host_content_settings_map_unittest.cc |
@@ -1016,3 +1016,70 @@ TEST_F(HostContentSettingsMapTest, AddContentSettingsObserver) { |
std::string(), |
CONTENT_SETTING_DEFAULT); |
} |
+ |
+TEST_F(HostContentSettingsMapTest, OverrideAllowedWebsiteSetting) { |
+ TestingProfile profile; |
+ HostContentSettingsMap* host_content_settings_map = |
+ profile.GetHostContentSettingsMap(); |
+ GURL host("http://example.com/"); |
+ ContentSettingsPattern pattern = |
+ ContentSettingsPattern::FromString("[*.]example.com"); |
+ host_content_settings_map->SetContentSetting( |
+ pattern, |
+ ContentSettingsPattern::Wildcard(), |
+ CONTENT_SETTINGS_TYPE_GEOLOCATION, |
+ std::string(), |
+ CONTENT_SETTING_ALLOW); |
+ |
+ EXPECT_EQ(CONTENT_SETTING_ALLOW, |
+ host_content_settings_map->GetContentSetting( |
+ host, host, CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string())); |
+ |
+ // Disabling should override an allowed exception. |
+ host_content_settings_map->SetContentSettingOverride( |
+ CONTENT_SETTINGS_TYPE_GEOLOCATION, false); |
+ EXPECT_EQ(CONTENT_SETTING_BLOCK, |
+ host_content_settings_map->GetContentSetting( |
+ host, host, CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string())); |
+ |
+ host_content_settings_map->SetContentSettingOverride( |
+ CONTENT_SETTINGS_TYPE_GEOLOCATION, true); |
+ EXPECT_EQ(CONTENT_SETTING_ALLOW, |
+ host_content_settings_map->GetContentSetting( |
+ host, host, CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string())); |
+} |
+ |
+TEST_F(HostContentSettingsMapTest, OverrideAllowedDefaultSetting) { |
+ TestingProfile profile; |
+ HostContentSettingsMap* host_content_settings_map = |
+ profile.GetHostContentSettingsMap(); |
+ |
+ // Check setting defaults. |
+ EXPECT_EQ(CONTENT_SETTING_ALLOW, |
+ host_content_settings_map->GetDefaultContentSetting( |
+ CONTENT_SETTINGS_TYPE_IMAGES, NULL)); |
+ |
+ GURL host("http://example.com/"); |
+ EXPECT_EQ(CONTENT_SETTING_ALLOW, |
+ host_content_settings_map->GetContentSetting( |
+ host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
+ |
+ // Disabling should override an allowed default setting. |
+ host_content_settings_map->SetContentSettingOverride( |
+ CONTENT_SETTINGS_TYPE_IMAGES, false); |
+ EXPECT_EQ(CONTENT_SETTING_BLOCK, |
+ host_content_settings_map->GetContentSetting( |
+ host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
+ |
+ // Enabling shouldn't override positively. |
+ host_content_settings_map->SetContentSettingOverride( |
+ CONTENT_SETTINGS_TYPE_IMAGES, true); |
+ EXPECT_EQ(CONTENT_SETTING_ALLOW, |
+ host_content_settings_map->GetContentSetting( |
+ host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
+ host_content_settings_map->SetDefaultContentSetting( |
+ CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); |
+ EXPECT_EQ(CONTENT_SETTING_BLOCK, |
+ host_content_settings_map->GetContentSetting( |
+ host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
+} |