Chromium Code Reviews| 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 0be5dea1bd5f01290ac2e59a7471b4e3a8f0dea5..364eceb393c03eb7d01a9d83049993d22238cb4c 100644 |
| --- a/chrome/browser/content_settings/host_content_settings_map_unittest.cc |
| +++ b/chrome/browser/content_settings/host_content_settings_map_unittest.cc |
| @@ -1162,3 +1162,52 @@ TEST_F(HostContentSettingsMapTest, AddContentSettingsObserver) { |
| std::string(), |
| CONTENT_SETTING_DEFAULT); |
| } |
| + |
|
msramek
2016/01/19 13:35:07
Following the comment in host_content_settings_map
raymes
2016/01/19 23:31:39
Agreed. This seems like a reasonable solution for
|
| +TEST_F(HostContentSettingsMapTest, GuestProfile) { |
| + TestingProfile profile; |
| + profile.SetGuestSession(true); |
| + HostContentSettingsMap* host_content_settings_map = |
| + HostContentSettingsMapFactory::GetForProfile(&profile); |
| + |
| + GURL host("http://example.com/"); |
| + ContentSettingsPattern pattern = |
| + ContentSettingsPattern::FromString("[*.]example.com"); |
| + |
| + EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| + host_content_settings_map->GetContentSetting( |
| + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
| + |
| + // Changing content settings should not result in any prefs being stored |
| + // however the value should be set in memory. |
| + host_content_settings_map->SetContentSetting( |
| + pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_IMAGES, |
| + std::string(), CONTENT_SETTING_BLOCK); |
| + EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| + host_content_settings_map->GetContentSetting( |
| + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
| + |
| + const base::DictionaryValue* all_settings_dictionary = |
| + profile.GetPrefs()->GetDictionary( |
| + GetPrefName(CONTENT_SETTINGS_TYPE_IMAGES)); |
| + EXPECT_TRUE(all_settings_dictionary->empty()); |
| +} |
| + |
| +// We used to incorrectly store content settings in prefs for the guest profile. |
| +// We need to ensure these get deleted appropriately. |
| +TEST_F(HostContentSettingsMapTest, GuestProfileMigration) { |
| + TestingProfile profile; |
| + profile.SetGuestSession(true); |
| + |
| + // Set a pref manually in the guest profile. |
| + scoped_ptr<base::Value> value = |
| + base::JSONReader::Read("{\"[*.]\\xC4\\x87ira.com,*\":{\"setting\":1}}"); |
| + profile.GetPrefs()->Set(GetPrefName(CONTENT_SETTINGS_TYPE_IMAGES), *value); |
| + |
| + // Test that during construction all the prefs get cleared. |
| + HostContentSettingsMapFactory::GetForProfile(&profile); |
| + |
| + const base::DictionaryValue* all_settings_dictionary = |
| + profile.GetPrefs()->GetDictionary( |
| + GetPrefName(CONTENT_SETTINGS_TYPE_IMAGES)); |
| + EXPECT_TRUE(all_settings_dictionary->empty()); |
| +} |