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

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

Issue 440423003: Clean content_settings_pattern_parser.* from unnecessary dependencies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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/chrome_content_settings_client.h"
9 #include "chrome/common/content_settings_pattern.h" 10 #include "chrome/common/content_settings_pattern.h"
10 #include "chrome/common/pref_names.h" 11 #include "chrome/common/pref_names.h"
11 #include "chrome/test/base/testing_profile.h" 12 #include "chrome/test/base/testing_profile.h"
12 #include "content/public/test/test_browser_thread.h" 13 #include "content/public/test/test_browser_thread.h"
13 #include "net/base/static_cookie_policy.h" 14 #include "net/base/static_cookie_policy.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "url/gurl.h" 16 #include "url/gurl.h"
16 17
17 using content::BrowserThread; 18 using content::BrowserThread;
18 19
19 namespace { 20 namespace {
20 21
22 ContentSettingsPattern CreatePattern(const std::string& pattern) {
23 content_settings::ChromeContentSettingsClient client;
24 return ContentSettingsPattern::FromString(&client, pattern);
25 }
26
21 class CookieSettingsTest : public testing::Test { 27 class CookieSettingsTest : public testing::Test {
22 public: 28 public:
23 CookieSettingsTest() 29 CookieSettingsTest()
24 : ui_thread_(BrowserThread::UI, &message_loop_), 30 : ui_thread_(BrowserThread::UI, &message_loop_),
25 cookie_settings_(CookieSettings::Factory::GetForProfile(&profile_) 31 cookie_settings_(CookieSettings::Factory::GetForProfile(&profile_)
26 .get()), 32 .get()),
27 kBlockedSite("http://ads.thirdparty.com"), 33 kBlockedSite("http://ads.thirdparty.com"),
28 kAllowedSite("http://good.allays.com"), 34 kAllowedSite("http://good.allays.com"),
29 kFirstPartySite("http://cool.things.com"), 35 kFirstPartySite("http://cool.things.com"),
30 kBlockedFirstPartySite("http://no.thirdparties.com"), 36 kBlockedFirstPartySite("http://no.thirdparties.com"),
31 kExtensionURL("chrome-extension://deadbeef"), 37 kExtensionURL("chrome-extension://deadbeef"),
32 kHttpsSite("https://example.com"), 38 kHttpsSite("https://example.com"),
33 kAllHttpsSitesPattern(ContentSettingsPattern::FromString("https://*")) { 39 kAllHttpsSitesPattern(CreatePattern("https://*")) {
34 } 40 }
35 41
36 protected: 42 protected:
37 base::MessageLoop message_loop_; 43 base::MessageLoop message_loop_;
38 content::TestBrowserThread ui_thread_; 44 content::TestBrowserThread ui_thread_;
39 TestingProfile profile_; 45 TestingProfile profile_;
40 CookieSettings* cookie_settings_; 46 CookieSettings* cookie_settings_;
41 const GURL kBlockedSite; 47 const GURL kBlockedSite;
42 const GURL kAllowedSite; 48 const GURL kAllowedSite;
43 const GURL kFirstPartySite; 49 const GURL kFirstPartySite;
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 TEST_F(CookieSettingsTest, ExtensionsThirdParty) { 280 TEST_F(CookieSettingsTest, ExtensionsThirdParty) {
275 profile_.GetPrefs()->SetBoolean(prefs::kBlockThirdPartyCookies, true); 281 profile_.GetPrefs()->SetBoolean(prefs::kBlockThirdPartyCookies, true);
276 282
277 // XHRs stemming from extensions are exempt from third-party cookie blocking 283 // XHRs stemming from extensions are exempt from third-party cookie blocking
278 // rules (as the first party is always the extension's security origin). 284 // rules (as the first party is always the extension's security origin).
279 EXPECT_TRUE(cookie_settings_->IsSettingCookieAllowed( 285 EXPECT_TRUE(cookie_settings_->IsSettingCookieAllowed(
280 kBlockedSite, kExtensionURL)); 286 kBlockedSite, kExtensionURL));
281 } 287 }
282 288
283 } // namespace 289 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698