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

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

Issue 900803002: Introduce a CookieSettings for incognito mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 | « chrome/browser/content_settings/cookie_settings.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/content_settings/cookie_settings_unittest.cc
diff --git a/chrome/browser/content_settings/cookie_settings_unittest.cc b/chrome/browser/content_settings/cookie_settings_unittest.cc
index 30b547f7e00d28c04e3add8ccbf9f10dcae3b8fa..60e5a94fb091bba656d64c5b2c0eabec04189f93 100644
--- a/chrome/browser/content_settings/cookie_settings_unittest.cc
+++ b/chrome/browser/content_settings/cookie_settings_unittest.cc
@@ -281,4 +281,69 @@ TEST_F(CookieSettingsTest, ExtensionsThirdParty) {
kBlockedSite, kExtensionURL));
}
+TEST_F(CookieSettingsTest, IncognitoBehaviorOfBlockingRules) {
+ scoped_refptr<CookieSettings> incognito_settings =
+ CookieSettings::Factory::GetForProfile(profile_.GetOffTheRecordProfile());
+
+ // Modify the regular cookie settings after the incognito cookie settings have
+ // been instantiated.
+ cookie_settings_->SetCookieSetting(
+ ContentSettingsPattern::FromURL(kBlockedSite),
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTING_BLOCK);
+
+ // The modification should apply to the regular profile and incognito profile.
+ EXPECT_FALSE(cookie_settings_->IsReadingCookieAllowed(
+ kBlockedSite, kBlockedSite));
+ EXPECT_FALSE(incognito_settings->IsReadingCookieAllowed(
+ kBlockedSite, kBlockedSite));
+
+ // Modify an incognito cookie setting and check that this does not propagate
+ // into regular mode.
+ incognito_settings->SetCookieSetting(
+ ContentSettingsPattern::FromURL(kHttpsSite),
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTING_BLOCK);
+ EXPECT_TRUE(cookie_settings_->IsReadingCookieAllowed(
+ kHttpsSite, kHttpsSite));
+ EXPECT_FALSE(incognito_settings->IsReadingCookieAllowed(
+ kHttpsSite, kHttpsSite));
+}
+
+TEST_F(CookieSettingsTest, IncognitoBehaviorOfBlockingEverything) {
+ scoped_refptr<CookieSettings> incognito_settings =
+ CookieSettings::Factory::GetForProfile(profile_.GetOffTheRecordProfile());
+
+ // Apply the general blocking to the regular profile.
+ cookie_settings_->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
+
+ // It should be effective for regular and incognito session.
+ EXPECT_FALSE(cookie_settings_->IsReadingCookieAllowed(
+ kFirstPartySite, kFirstPartySite));
+ EXPECT_FALSE(incognito_settings->IsReadingCookieAllowed(
+ kFirstPartySite, kFirstPartySite));
+
+ // A whitelisted item set in incognito mode should only apply to incognito
+ // mode.
+ incognito_settings->SetCookieSetting(
+ ContentSettingsPattern::FromURL(kAllowedSite),
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTING_ALLOW);
+ EXPECT_TRUE(incognito_settings->IsReadingCookieAllowed(
+ kAllowedSite, kAllowedSite));
+ EXPECT_FALSE(cookie_settings_->IsReadingCookieAllowed(
+ kAllowedSite, kAllowedSite));
+
+ // A whitelisted item set in regular mode should apply to regular and
+ // incognito mode.
+ cookie_settings_->SetCookieSetting(
+ ContentSettingsPattern::FromURL(kHttpsSite),
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTING_ALLOW);
+ EXPECT_TRUE(incognito_settings->IsReadingCookieAllowed(
+ kHttpsSite, kHttpsSite));
+ EXPECT_TRUE(cookie_settings_->IsReadingCookieAllowed(
+ kHttpsSite, kHttpsSite));
+}
+
} // namespace
« no previous file with comments | « chrome/browser/content_settings/cookie_settings.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698