| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/browser.h" | 5 #include "chrome/browser/browser.h" |
| 6 #include "chrome/browser/net/url_request_context_getter.h" | 6 #include "chrome/browser/net/url_request_context_getter.h" |
| 7 #include "chrome/browser/profile.h" | 7 #include "chrome/browser/profile.h" |
| 8 #include "chrome/common/pref_names.h" | 8 #include "chrome/common/pref_names.h" |
| 9 #include "chrome/common/pref_service.h" | 9 #include "chrome/common/pref_service.h" |
| 10 #include "chrome/test/in_process_browser_test.h" | 10 #include "chrome/test/in_process_browser_test.h" |
| 11 #include "chrome/test/ui_test_utils.h" | 11 #include "chrome/test/ui_test_utils.h" |
| 12 #include "net/base/mock_host_resolver.h" | 12 #include "net/base/mock_host_resolver.h" |
| 13 | 13 |
| 14 class CookiePolicyBrowserTest : public InProcessBrowserTest { | 14 class CookiePolicyBrowserTest : public InProcessBrowserTest { |
| 15 public: | 15 public: |
| 16 CookiePolicyBrowserTest() {} | 16 CookiePolicyBrowserTest() {} |
| 17 | 17 |
| 18 private: | 18 private: |
| 19 DISALLOW_COPY_AND_ASSIGN(CookiePolicyBrowserTest); | 19 DISALLOW_COPY_AND_ASSIGN(CookiePolicyBrowserTest); |
| 20 }; | 20 }; |
| 21 | 21 |
| 22 // TODO(darin): Re-enable these tests once the new third-party cookie blocking |
| 23 // preference is hooked up. |
| 24 #if 0 |
| 22 // Visits a page that sets a first-party cookie. | 25 // Visits a page that sets a first-party cookie. |
| 23 IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, AllowFirstPartyCookies) { | 26 IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, AllowFirstPartyCookies) { |
| 24 HTTPTestServer* server = StartHTTPServer(); | 27 HTTPTestServer* server = StartHTTPServer(); |
| 25 ASSERT_TRUE(server != NULL); | 28 ASSERT_TRUE(server != NULL); |
| 26 | 29 |
| 27 PrefService* prefs = browser()->profile()->GetPrefs(); | 30 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 28 prefs->SetInteger(prefs::kCookieBehavior, | 31 prefs->SetInteger(prefs::kCookieBehavior, |
| 29 net::CookiePolicy::BLOCK_THIRD_PARTY_COOKIES); | 32 net::CookiePolicy::BLOCK_THIRD_PARTY_COOKIES); |
| 30 net::CookiePolicy::Type policy_type = net::CookiePolicy::FromInt( | 33 net::CookiePolicy::Type policy_type = net::CookiePolicy::FromInt( |
| 31 prefs->GetInteger(prefs::kCookieBehavior)); | 34 prefs->GetInteger(prefs::kCookieBehavior)); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 ASSERT_EQ("", cookie); | 82 ASSERT_EQ("", cookie); |
| 80 | 83 |
| 81 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 84 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 82 | 85 |
| 83 ui_test_utils::NavigateToURL(browser(), | 86 ui_test_utils::NavigateToURL(browser(), |
| 84 GURL(url.spec() + redirected_url.spec())); | 87 GURL(url.spec() + redirected_url.spec())); |
| 85 | 88 |
| 86 cookie = cookie_store->GetCookies(redirected_url); | 89 cookie = cookie_store->GetCookies(redirected_url); |
| 87 EXPECT_EQ("cookie2", cookie); | 90 EXPECT_EQ("cookie2", cookie); |
| 88 } | 91 } |
| 92 #endif |
| OLD | NEW |