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

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

Issue 8383004: Adding CookieSettings for storing cookie content settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing the rebase. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/stringprintf.h" 5 #include "base/stringprintf.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/content_settings/cookie_settings.h"
7 #include "chrome/browser/content_settings/host_content_settings_map.h" 8 #include "chrome/browser/content_settings/host_content_settings_map.h"
8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
9 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
12 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
13 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
14 #include "net/test/test_server.h" 15 #include "net/test/test_server.h"
15 16
16 // Regression test for http://crbug.com/63649. 17 // Regression test for http://crbug.com/63649.
17 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, RedirectLoopCookies) { 18 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, RedirectLoopCookies) {
18 ASSERT_TRUE(test_server()->Start()); 19 ASSERT_TRUE(test_server()->Start());
19 20
20 GURL test_url = test_server()->GetURL("files/redirect-loop.html"); 21 GURL test_url = test_server()->GetURL("files/redirect-loop.html");
21 22
22 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( 23 CookieSettings::GetForProfile(browser()->profile())->
23 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); 24 SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
24 25
25 ui_test_utils::NavigateToURL(browser(), test_url); 26 ui_test_utils::NavigateToURL(browser(), test_url);
26 27
27 TabContentsWrapper* tab_contents = browser()->GetSelectedTabContentsWrapper(); 28 TabContentsWrapper* tab_contents = browser()->GetSelectedTabContentsWrapper();
28 ASSERT_EQ(UTF8ToUTF16(test_url.spec() + " failed to load"), 29 ASSERT_EQ(UTF8ToUTF16(test_url.spec() + " failed to load"),
29 tab_contents->tab_contents()->GetTitle()); 30 tab_contents->tab_contents()->GetTitle());
30 31
31 EXPECT_TRUE(tab_contents->content_settings()->IsContentBlocked( 32 EXPECT_TRUE(tab_contents->content_settings()->IsContentBlocked(
32 CONTENT_SETTINGS_TYPE_COOKIES)); 33 CONTENT_SETTINGS_TYPE_COOKIES));
33 } 34 }
(...skipping 19 matching lines...) Expand all
53 ASSERT_TRUE(test_server()->Start()); 54 ASSERT_TRUE(test_server()->Start());
54 55
55 net::HostPortPair host_port = test_server()->host_port_pair(); 56 net::HostPortPair host_port = test_server()->host_port_pair();
56 DCHECK_EQ(host_port.host(), std::string("127.0.0.1")); 57 DCHECK_EQ(host_port.host(), std::string("127.0.0.1"));
57 58
58 std::string redirect(base::StringPrintf( 59 std::string redirect(base::StringPrintf(
59 "http://localhost:%d/files/redirect-cross-origin.html", 60 "http://localhost:%d/files/redirect-cross-origin.html",
60 host_port.port())); 61 host_port.port()));
61 GURL test_url = test_server()->GetURL("server-redirect?" + redirect); 62 GURL test_url = test_server()->GetURL("server-redirect?" + redirect);
62 63
63 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( 64 CookieSettings::GetForProfile(browser()->profile())->
64 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); 65 SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
65 66
66 ui_test_utils::NavigateToURL(browser(), test_url); 67 ui_test_utils::NavigateToURL(browser(), test_url);
67 68
68 TabContentsWrapper* tab_contents = browser()->GetSelectedTabContentsWrapper(); 69 TabContentsWrapper* tab_contents = browser()->GetSelectedTabContentsWrapper();
69 70
70 EXPECT_TRUE(tab_contents->content_settings()->IsContentBlocked( 71 EXPECT_TRUE(tab_contents->content_settings()->IsContentBlocked(
71 CONTENT_SETTINGS_TYPE_COOKIES)); 72 CONTENT_SETTINGS_TYPE_COOKIES));
72 } 73 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_worker_message_filter.cc ('k') | chrome/browser/content_settings/cookie_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698