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

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

Issue 1754073002: Migrate old settings for ContentSettingTypes with wildcard as secondary_pattern (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scoping_set_content_setting
Patch Set: use string 'preference' 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/ssl/chrome_ssl_host_state_delegate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a530604fa391bb10f4a810f8d0d1ca8218e66834..945eabc17cfb4ef048a6050b7a16709cb3e9e8e7 100644
--- a/chrome/browser/content_settings/host_content_settings_map_unittest.cc
+++ b/chrome/browser/content_settings/host_content_settings_map_unittest.cc
@@ -1141,3 +1141,53 @@ TEST_F(HostContentSettingsMapTest, GuestProfileMigration) {
GetPrefName(CONTENT_SETTINGS_TYPE_IMAGES));
EXPECT_TRUE(all_settings_dictionary->empty());
}
+
+TEST_F(HostContentSettingsMapTest, MigrateOldSettings) {
+ TestingProfile profile;
+ HostContentSettingsMap* host_content_settings_map =
+ HostContentSettingsMapFactory::GetForProfile(&profile);
+
+ // Set old formatted settings.
+ GURL host("http://example.com/");
+ ContentSettingsPattern pattern =
+ ContentSettingsPattern::FromURLNoWildcard(host);
+
+ // Default setting is BLOCK.
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ host_content_settings_map->GetContentSetting(
+ host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string()));
+
+ host_content_settings_map->SetContentSetting(
+ pattern, pattern, CONTENT_SETTINGS_TYPE_KEYGEN, std::string(),
+ CONTENT_SETTING_ALLOW);
+ // Because of the old formatted setting entry which has two same patterns,
+ // SetContentSetting() to (host, GURL()) will be ignored.
+ host_content_settings_map->SetContentSettingDefaultScope(
+ host, GURL(), CONTENT_SETTINGS_TYPE_KEYGEN, std::string(),
+ CONTENT_SETTING_BLOCK);
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ host_content_settings_map->GetContentSetting(
+ host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string()));
+
+ host_content_settings_map->MigrateOldSettings();
+
+ ContentSettingsForOneType settings;
+ host_content_settings_map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_KEYGEN,
+ std::string(), &settings);
+ for (const ContentSettingPatternSource& setting_entry : settings) {
+ EXPECT_EQ(setting_entry.secondary_pattern,
+ ContentSettingsPattern::Wildcard());
+ }
+
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ host_content_settings_map->GetContentSetting(
+ host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string()));
+
+ // After migrating old settings, changes to the setting works.
+ host_content_settings_map->SetContentSettingDefaultScope(
+ host, GURL(), CONTENT_SETTINGS_TYPE_KEYGEN, std::string(),
+ CONTENT_SETTING_BLOCK);
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ host_content_settings_map->GetContentSetting(
+ host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string()));
+}
« no previous file with comments | « no previous file | chrome/browser/ssl/chrome_ssl_host_state_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698