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

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

Issue 2075103002: Change ContentSettingsType's scoping type and hookup migration code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@do_migration_after_sync
Patch Set: revise test Created 4 years, 5 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
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 3f64748e1111ec5572bbfe9640bd23a018f396c8..a09e3e4dd58e1981a3610f17c45b1958067ea2bc 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,9 @@ 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.
+ prefs->SetInteger(prefs::kDomainToOriginMigrationStatus, 0);
raymes 2016/07/21 01:13:57 Maybe we can set it to the default value: prefs->S
lshang 2016/07/22 02:58:38 Done.
// Set old formatted http settings.
GURL http_host("http://example.com/");
@@ -1462,21 +1465,20 @@ TEST_F(HostContentSettingsMapTest, MigrateDomainScopedSettings) {
EXPECT_TRUE(settings[0].primary_pattern.ToString() ==
"https://example.com:443");
EXPECT_TRUE(settings[1].primary_pattern.ToString() == "*");
+
+ prefs->SetInteger(prefs::kDomainToOriginMigrationStatus, 0);
raymes 2016/07/21 01:13:57 nit: this isn't needed. The test state should get
lshang 2016/07/22 02:58:38 Done.
}
TEST_F(HostContentSettingsMapTest, DomainToOriginMigrationStatus) {
TestingProfile profile;
PrefService* prefs = profile.GetPrefs();
-
- HostContentSettingsMap* host_content_settings_map =
- HostContentSettingsMapFactory::GetForProfile(&profile);
-
// Initial state is NOT_MIGRATED.
EXPECT_EQ(0, prefs->GetInteger(prefs::kDomainToOriginMigrationStatus));
// Do migration on HostContentSettingsMap construction will change the state
// to MIGRATED_BEFORE_SYNC.
- host_content_settings_map->MigrateDomainScopedSettings(false);
+ HostContentSettingsMap* host_content_settings_map =
+ HostContentSettingsMapFactory::GetForProfile(&profile);
EXPECT_EQ(1, prefs->GetInteger(prefs::kDomainToOriginMigrationStatus));
// Another call on HostContentSettingsMap construction to do migration will
@@ -1492,6 +1494,8 @@ TEST_F(HostContentSettingsMapTest, DomainToOriginMigrationStatus) {
// (i.e. migration has finished, won't get executed anymore).
host_content_settings_map->MigrateDomainScopedSettings(true);
EXPECT_EQ(2, prefs->GetInteger(prefs::kDomainToOriginMigrationStatus));
+
+ prefs->SetInteger(prefs::kDomainToOriginMigrationStatus, 0);
raymes 2016/07/21 01:13:57 nit: this isn't needed
lshang 2016/07/22 02:58:38 Done.
}
TEST_F(HostContentSettingsMapTest, InvalidPattern) {

Powered by Google App Engine
This is Rietveld 408576698