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

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

Issue 8462003: Exempt chrome-extension:// from third-party cookie rules, but not from regular content settings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 9 years, 1 month 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/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 8fc783b8d513bfde58d620a646088717c7d98a38..af8421992d74212154ff460e15acaa44e9a1f1e5 100644
--- a/chrome/browser/content_settings/cookie_settings_unittest.cc
+++ b/chrome/browser/content_settings/cookie_settings_unittest.cc
@@ -233,4 +233,38 @@ TEST_F(CookieSettingsTest, CookiesBlockSingleFirstParty) {
kAllowedSite, kFirstPartySite));
}
+TEST_F(CookieSettingsTest, ExtensionsRegularSettings) {
+ TestingProfile profile;
+ CookieSettings* cookie_settings = CookieSettings::GetForProfile(&profile);
+ cookie_settings->SetCookieSetting(
+ ContentSettingsPattern::FromURL(kBlockedSite),
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTING_BLOCK);
+
+ // Regular cookie settings also apply to extensions.
+ EXPECT_FALSE(cookie_settings->IsReadingCookieAllowed(
+ kBlockedSite, kExtensionURL));
+}
+
+TEST_F(CookieSettingsTest, ExtensionsOwnCookies) {
+ TestingProfile profile;
+ CookieSettings* cookie_settings = CookieSettings::GetForProfile(&profile);
+ cookie_settings->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
+
+ // Extensions can always use cookies (and site data) in their own origin.
+ EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed(
+ kExtensionURL, kExtensionURL));
+}
+
+TEST_F(CookieSettingsTest, ExtensionsThirdParty) {
+ TestingProfile profile;
+ CookieSettings* cookie_settings = CookieSettings::GetForProfile(&profile);
+ profile.GetPrefs()->SetBoolean(prefs::kBlockThirdPartyCookies, true);
+
+ // XHRs stemming from extensions are exempt from third-party cookie blocking
+ // rules (as the first party is always the extension's security origin).
+ EXPECT_TRUE(cookie_settings->IsSettingCookieAllowed(
+ kBlockedSite, kExtensionURL));
+}
+
} // namespace

Powered by Google App Engine
This is Rietveld 408576698