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

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

Issue 15984016: Call scoped_refptr<T>::get() rather than relying on implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/content_settings/cookie_settings.h" 9 #include "chrome/browser/content_settings/cookie_settings.h"
10 #include "chrome/browser/content_settings/host_content_settings_map.h" 10 #include "chrome/browser/content_settings/host_content_settings_map.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 CookieSettings::Factory::GetForProfile(browser()->profile())-> 150 CookieSettings::Factory::GetForProfile(browser()->profile())->
151 GetDefaultCookieSetting(NULL)); 151 GetDefaultCookieSetting(NULL));
152 } 152 }
153 153
154 // Verify that cookies can be allowed and set using exceptions for particular 154 // Verify that cookies can be allowed and set using exceptions for particular
155 // website(s) when all others are blocked. 155 // website(s) when all others are blocked.
156 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, AllowCookiesUsingExceptions) { 156 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, AllowCookiesUsingExceptions) {
157 ASSERT_TRUE(test_server()->Start()); 157 ASSERT_TRUE(test_server()->Start());
158 GURL url = test_server()->GetURL("files/setcookie.html"); 158 GURL url = test_server()->GetURL("files/setcookie.html");
159 CookieSettings* settings = 159 CookieSettings* settings =
160 CookieSettings::Factory::GetForProfile(browser()->profile()); 160 CookieSettings::Factory::GetForProfile(browser()->profile()).get();
161 settings->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK); 161 settings->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
162 162
163 ui_test_utils::NavigateToURL(browser(), url); 163 ui_test_utils::NavigateToURL(browser(), url);
164 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty()); 164 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty());
165 165
166 settings->SetCookieSetting( 166 settings->SetCookieSetting(
167 ContentSettingsPattern::FromURL(url), 167 ContentSettingsPattern::FromURL(url),
168 ContentSettingsPattern::Wildcard(), CONTENT_SETTING_ALLOW); 168 ContentSettingsPattern::Wildcard(), CONTENT_SETTING_ALLOW);
169 169
170 ui_test_utils::NavigateToURL(browser(), url); 170 ui_test_utils::NavigateToURL(browser(), url);
171 ASSERT_FALSE(GetCookies(browser()->profile(), url).empty()); 171 ASSERT_FALSE(GetCookies(browser()->profile(), url).empty());
172 } 172 }
173 173
174 // Verify that cookies can be blocked for a specific website using exceptions. 174 // Verify that cookies can be blocked for a specific website using exceptions.
175 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, BlockCookiesUsingExceptions) { 175 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, BlockCookiesUsingExceptions) {
176 ASSERT_TRUE(test_server()->Start()); 176 ASSERT_TRUE(test_server()->Start());
177 GURL url = test_server()->GetURL("files/setcookie.html"); 177 GURL url = test_server()->GetURL("files/setcookie.html");
178 CookieSettings* settings = 178 CookieSettings* settings =
179 CookieSettings::Factory::GetForProfile(browser()->profile()); 179 CookieSettings::Factory::GetForProfile(browser()->profile()).get();
180 settings->SetCookieSetting( 180 settings->SetCookieSetting(ContentSettingsPattern::FromURL(url),
181 ContentSettingsPattern::FromURL(url), 181 ContentSettingsPattern::Wildcard(),
182 ContentSettingsPattern::Wildcard(), CONTENT_SETTING_BLOCK); 182 CONTENT_SETTING_BLOCK);
183 183
184 ui_test_utils::NavigateToURL(browser(), url); 184 ui_test_utils::NavigateToURL(browser(), url);
185 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty()); 185 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty());
186 186
187 ASSERT_TRUE(https_server_.Start()); 187 ASSERT_TRUE(https_server_.Start());
188 GURL unblocked_url = https_server_.GetURL("files/cookie1.html"); 188 GURL unblocked_url = https_server_.GetURL("files/cookie1.html");
189 189
190 ui_test_utils::NavigateToURL(browser(), unblocked_url); 190 ui_test_utils::NavigateToURL(browser(), unblocked_url);
191 ASSERT_FALSE(GetCookies(browser()->profile(), unblocked_url).empty()); 191 ASSERT_FALSE(GetCookies(browser()->profile(), unblocked_url).empty());
192 } 192 }
193 193
194 // This fails on ChromeOS because kRestoreOnStartup is ignored and the startup 194 // This fails on ChromeOS because kRestoreOnStartup is ignored and the startup
195 // preference is always "continue where I left off. 195 // preference is always "continue where I left off.
196 #if !defined(OS_CHROMEOS) 196 #if !defined(OS_CHROMEOS)
197 197
198 // Verify that cookies can be allowed and set using exceptions for particular 198 // Verify that cookies can be allowed and set using exceptions for particular
199 // website(s) only for a session when all others are blocked. 199 // website(s) only for a session when all others are blocked.
200 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, 200 IN_PROC_BROWSER_TEST_F(ContentSettingsTest,
201 PRE_AllowCookiesForASessionUsingExceptions) { 201 PRE_AllowCookiesForASessionUsingExceptions) {
202 // NOTE: don't use test_server here, since we need the port to be the same 202 // NOTE: don't use test_server here, since we need the port to be the same
203 // across the restart. 203 // across the restart.
204 GURL url = URLRequestMockHTTPJob::GetMockUrl( 204 GURL url = URLRequestMockHTTPJob::GetMockUrl(
205 base::FilePath(FILE_PATH_LITERAL("setcookie.html"))); 205 base::FilePath(FILE_PATH_LITERAL("setcookie.html")));
206 CookieSettings* settings = 206 CookieSettings* settings =
207 CookieSettings::Factory::GetForProfile(browser()->profile()); 207 CookieSettings::Factory::GetForProfile(browser()->profile()).get();
208 settings->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK); 208 settings->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
209 209
210 ui_test_utils::NavigateToURL(browser(), url); 210 ui_test_utils::NavigateToURL(browser(), url);
211 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty()); 211 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty());
212 212
213 settings->SetCookieSetting( 213 settings->SetCookieSetting(
214 ContentSettingsPattern::FromURL(url), 214 ContentSettingsPattern::FromURL(url),
215 ContentSettingsPattern::Wildcard(), CONTENT_SETTING_SESSION_ONLY); 215 ContentSettingsPattern::Wildcard(), CONTENT_SETTING_SESSION_ONLY);
216 ui_test_utils::NavigateToURL(browser(), url); 216 ui_test_utils::NavigateToURL(browser(), url);
217 ASSERT_FALSE(GetCookies(browser()->profile(), url).empty()); 217 ASSERT_FALSE(GetCookies(browser()->profile(), url).empty());
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 RunJavaScriptBlockedTest("load_widevine_no_js.html", true); 604 RunJavaScriptBlockedTest("load_widevine_no_js.html", true);
605 #endif 605 #endif
606 #endif // defined(ENABLE_PEPPER_CDMS) 606 #endif // defined(ENABLE_PEPPER_CDMS)
607 607
608 #if !defined(DISABLE_NACL) 608 #if !defined(DISABLE_NACL)
609 RunJavaScriptBlockedTest("load_nacl_no_js.html", true); 609 RunJavaScriptBlockedTest("load_nacl_no_js.html", true);
610 #endif 610 #endif
611 } 611 }
612 612
613 #endif // defined(ENABLE_PLUGINS) 613 #endif // defined(ENABLE_PLUGINS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698