| 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 2fee449e3612cdf2de23f9a73225f8f6bf56ef21..9823dfe5a34976759f533704d9f5450fa0e2aff4 100644
|
| --- a/chrome/browser/content_settings/host_content_settings_map_unittest.cc
|
| +++ b/chrome/browser/content_settings/host_content_settings_map_unittest.cc
|
| @@ -368,7 +368,7 @@ TEST_F(HostContentSettingsMapTest, Observer) {
|
|
|
| GURL host("http://example.com/");
|
| ContentSettingsPattern primary_pattern =
|
| - ContentSettingsPattern::FromString("[*.]example.com");
|
| + ContentSettingsPattern::FromString("http://example.com:80");
|
| ContentSettingsPattern secondary_pattern =
|
| ContentSettingsPattern::Wildcard();
|
| EXPECT_CALL(observer, OnContentSettingsChanged(host_content_settings_map,
|
| @@ -949,7 +949,7 @@ TEST_F(HostContentSettingsMapTest, CanonicalizeExceptionsUnicodeOnly) {
|
|
|
| base::DictionaryValue* dummy_payload = new base::DictionaryValue;
|
| dummy_payload->SetInteger("setting", CONTENT_SETTING_ALLOW);
|
| - all_settings_dictionary->SetWithoutPathExpansion("[*.]\xC4\x87ira.com,*",
|
| + all_settings_dictionary->SetWithoutPathExpansion("www.\xC4\x87ira.com,*",
|
| dummy_payload);
|
| }
|
|
|
| @@ -959,9 +959,9 @@ TEST_F(HostContentSettingsMapTest, CanonicalizeExceptionsUnicodeOnly) {
|
| prefs->GetDictionary(GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES));
|
| const base::DictionaryValue* result = NULL;
|
| EXPECT_FALSE(all_settings_dictionary->GetDictionaryWithoutPathExpansion(
|
| - "[*.]\xC4\x87ira.com,*", &result));
|
| + "www.\xC4\x87ira.com,*", &result));
|
| EXPECT_TRUE(all_settings_dictionary->GetDictionaryWithoutPathExpansion(
|
| - "[*.]xn--ira-ppa.com,*", &result));
|
| + "www.xn--ira-ppa.com,*", &result));
|
| }
|
|
|
| // If both Unicode and its punycode pattern exist, make sure we don't touch the
|
| @@ -1214,7 +1214,7 @@ TEST_F(HostContentSettingsMapTest, AddContentSettingsObserver) {
|
|
|
| GURL host("http://example.com/");
|
| ContentSettingsPattern pattern =
|
| - ContentSettingsPattern::FromString("[*.]example.com");
|
| + ContentSettingsPattern::FromString("http://example.com:80");
|
| EXPECT_CALL(mock_observer, OnContentSettingChanged(
|
| pattern, ContentSettingsPattern::Wildcard(),
|
| CONTENT_SETTINGS_TYPE_COOKIES, ""));
|
| @@ -1355,6 +1355,13 @@ TEST_F(HostContentSettingsMapTest, MigrateDomainScopedSettings) {
|
| TestingProfile profile;
|
| HostContentSettingsMap* host_content_settings_map =
|
| HostContentSettingsMapFactory::GetForProfile(&profile);
|
| + PrefService* prefs = profile.GetPrefs();
|
| + // Set the pref to its initial state so that migration can be done later in
|
| + // the test (normally it is done on construction of HostContentSettingsMap).
|
| + int default_value;
|
| + prefs->GetDefaultPrefValue(prefs::kDomainToOriginMigrationStatus)
|
| + ->GetAsInteger(&default_value);
|
| + prefs->SetInteger(prefs::kDomainToOriginMigrationStatus, default_value);
|
|
|
| // Set old formatted http settings.
|
| GURL http_host("http://example.com/");
|
| @@ -1468,34 +1475,42 @@ TEST_F(HostContentSettingsMapTest, MigrateDomainScopedSettings) {
|
| // once after syncing (even when these events occur multiple times).
|
| TEST_F(HostContentSettingsMapTest, DomainToOriginMigrationStatus) {
|
| TestingProfile profile;
|
| -
|
| - HostContentSettingsMap* host_content_settings_map =
|
| - HostContentSettingsMapFactory::GetForProfile(&profile);
|
| + PrefService* prefs = profile.GetPrefs();
|
|
|
| GURL http_host("http://example.com/");
|
| GURL http_host_narrower("http://a.example.com/");
|
| + std::string host_pattern_string =
|
| + ContentSettingsPattern::FromURL(http_host).ToString();
|
| +
|
| + {
|
| + DictionaryPrefUpdate update(prefs,
|
| + GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES));
|
| + base::DictionaryValue* all_settings_dictionary = update.Get();
|
| + ASSERT_TRUE(NULL != all_settings_dictionary);
|
| +
|
| + base::DictionaryValue* domain_setting = new base::DictionaryValue;
|
| + domain_setting->SetInteger("setting", CONTENT_SETTING_ALLOW);
|
| + all_settings_dictionary->SetWithoutPathExpansion(host_pattern_string + ",*",
|
| + domain_setting);
|
| + }
|
| +
|
| + const base::DictionaryValue* all_settings_dictionary =
|
| + prefs->GetDictionary(GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES));
|
| + const base::DictionaryValue* result = NULL;
|
| + EXPECT_TRUE(all_settings_dictionary->GetDictionaryWithoutPathExpansion(
|
| + "[*.]example.com,*", &result));
|
| +
|
| + // Migration is done on construction of HostContentSettingsMap.
|
| + HostContentSettingsMap* host_content_settings_map =
|
| + HostContentSettingsMapFactory::GetForProfile(&profile);
|
|
|
| // Change default setting to BLOCK.
|
| host_content_settings_map->SetDefaultContentSetting(
|
| CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK);
|
| - // Set domain scoped settings.
|
| - host_content_settings_map->SetContentSettingCustomScope(
|
| - ContentSettingsPattern::FromURL(http_host),
|
| - ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_COOKIES,
|
| - std::string(), CONTENT_SETTING_ALLOW);
|
| EXPECT_EQ(
|
| CONTENT_SETTING_ALLOW,
|
| host_content_settings_map->GetContentSetting(
|
| http_host, http_host, CONTENT_SETTINGS_TYPE_COOKIES, std::string()));
|
| - // Settings apply to subdomains.
|
| - EXPECT_EQ(CONTENT_SETTING_ALLOW,
|
| - host_content_settings_map->GetContentSetting(
|
| - http_host_narrower, http_host_narrower,
|
| - CONTENT_SETTINGS_TYPE_COOKIES, std::string()));
|
| -
|
| - // Do migration before sync.
|
| - host_content_settings_map->MigrateDomainScopedSettings(false);
|
| -
|
| // Settings only apply to origins. Migration got executed.
|
| EXPECT_EQ(CONTENT_SETTING_BLOCK,
|
| host_content_settings_map->GetContentSetting(
|
|
|