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

Side by Side Diff: chrome/browser/content_settings/cookie_settings_unittest.cc

Issue 535773002: Android: Remove more browser extensions code, including some that snuck back in. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/content_settings/host_content_settings_map.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/auto_reset.h" 5 #include "base/auto_reset.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/content_settings/cookie_settings.h" 8 #include "chrome/browser/content_settings/cookie_settings.h"
9 #include "chrome/common/pref_names.h" 9 #include "chrome/common/pref_names.h"
10 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 kAllowedSite, kFirstPartySite)); 115 kAllowedSite, kFirstPartySite));
116 EXPECT_TRUE(cookie_settings_->IsSettingCookieAllowed( 116 EXPECT_TRUE(cookie_settings_->IsSettingCookieAllowed(
117 kAllowedSite, kFirstPartySite)); 117 kAllowedSite, kFirstPartySite));
118 EXPECT_FALSE(cookie_settings_->IsCookieSessionOnly(kAllowedSite)); 118 EXPECT_FALSE(cookie_settings_->IsCookieSessionOnly(kAllowedSite));
119 119
120 // Extensions should always be allowed to use cookies. 120 // Extensions should always be allowed to use cookies.
121 EXPECT_TRUE(cookie_settings_->IsReadingCookieAllowed( 121 EXPECT_TRUE(cookie_settings_->IsReadingCookieAllowed(
122 kAllowedSite, kExtensionURL)); 122 kAllowedSite, kExtensionURL));
123 EXPECT_TRUE(cookie_settings_->IsSettingCookieAllowed( 123 EXPECT_TRUE(cookie_settings_->IsSettingCookieAllowed(
124 kAllowedSite, kExtensionURL)); 124 kAllowedSite, kExtensionURL));
125
126 // Extensions should always be allowed to use cookies.
127 EXPECT_TRUE(cookie_settings_->IsReadingCookieAllowed(
128 kAllowedSite, kExtensionURL));
129 EXPECT_TRUE(cookie_settings_->IsSettingCookieAllowed(
130 kAllowedSite, kExtensionURL));
131 } 125 }
132 126
133 TEST_F(CookieSettingsTest, CookiesThirdPartyBlockedAllSitesAllowed) { 127 TEST_F(CookieSettingsTest, CookiesThirdPartyBlockedAllSitesAllowed) {
134 cookie_settings_->SetCookieSetting( 128 cookie_settings_->SetCookieSetting(
135 ContentSettingsPattern::FromURL(kAllowedSite), 129 ContentSettingsPattern::FromURL(kAllowedSite),
136 ContentSettingsPattern::Wildcard(), 130 ContentSettingsPattern::Wildcard(),
137 CONTENT_SETTING_ALLOW); 131 CONTENT_SETTING_ALLOW);
138 profile_.GetPrefs()->SetBoolean(prefs::kBlockThirdPartyCookies, true); 132 profile_.GetPrefs()->SetBoolean(prefs::kBlockThirdPartyCookies, true);
139 // As an example for a pattern that matches all hosts but not all origins, 133 // As an example for a pattern that matches all hosts but not all origins,
140 // match all HTTPS sites. 134 // match all HTTPS sites.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 CONTENT_SETTING_BLOCK); 253 CONTENT_SETTING_BLOCK);
260 254
261 // Regular cookie settings also apply to extensions. 255 // Regular cookie settings also apply to extensions.
262 EXPECT_FALSE(cookie_settings_->IsReadingCookieAllowed( 256 EXPECT_FALSE(cookie_settings_->IsReadingCookieAllowed(
263 kBlockedSite, kExtensionURL)); 257 kBlockedSite, kExtensionURL));
264 } 258 }
265 259
266 TEST_F(CookieSettingsTest, ExtensionsOwnCookies) { 260 TEST_F(CookieSettingsTest, ExtensionsOwnCookies) {
267 cookie_settings_->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK); 261 cookie_settings_->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
268 262
263 #if defined(ENABLE_EXTENSIONS)
269 // Extensions can always use cookies (and site data) in their own origin. 264 // Extensions can always use cookies (and site data) in their own origin.
270 EXPECT_TRUE(cookie_settings_->IsReadingCookieAllowed( 265 EXPECT_TRUE(cookie_settings_->IsReadingCookieAllowed(
271 kExtensionURL, kExtensionURL)); 266 kExtensionURL, kExtensionURL));
267 #else
268 // Except if extensions are disabled. Then the extension-specific checks do
269 // not exist and the default setting is to block.
270 EXPECT_FALSE(cookie_settings_->IsReadingCookieAllowed(
271 kExtensionURL, kExtensionURL));
272 #endif
272 } 273 }
273 274
274 TEST_F(CookieSettingsTest, ExtensionsThirdParty) { 275 TEST_F(CookieSettingsTest, ExtensionsThirdParty) {
275 profile_.GetPrefs()->SetBoolean(prefs::kBlockThirdPartyCookies, true); 276 profile_.GetPrefs()->SetBoolean(prefs::kBlockThirdPartyCookies, true);
276 277
277 // XHRs stemming from extensions are exempt from third-party cookie blocking 278 // XHRs stemming from extensions are exempt from third-party cookie blocking
278 // rules (as the first party is always the extension's security origin). 279 // rules (as the first party is always the extension's security origin).
279 EXPECT_TRUE(cookie_settings_->IsSettingCookieAllowed( 280 EXPECT_TRUE(cookie_settings_->IsSettingCookieAllowed(
280 kBlockedSite, kExtensionURL)); 281 kBlockedSite, kExtensionURL));
281 } 282 }
282 283
283 } // namespace 284 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/content_settings/host_content_settings_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698