| OLD | NEW |
| 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 "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, AllowCookiesUsingExceptions) { | 159 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, AllowCookiesUsingExceptions) { |
| 160 ASSERT_TRUE(embedded_test_server()->Start()); | 160 ASSERT_TRUE(embedded_test_server()->Start()); |
| 161 GURL url = embedded_test_server()->GetURL("/setcookie.html"); | 161 GURL url = embedded_test_server()->GetURL("/setcookie.html"); |
| 162 content_settings::CookieSettings* settings = | 162 content_settings::CookieSettings* settings = |
| 163 CookieSettingsFactory::GetForProfile(browser()->profile()).get(); | 163 CookieSettingsFactory::GetForProfile(browser()->profile()).get(); |
| 164 settings->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK); | 164 settings->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK); |
| 165 | 165 |
| 166 ui_test_utils::NavigateToURL(browser(), url); | 166 ui_test_utils::NavigateToURL(browser(), url); |
| 167 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty()); | 167 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty()); |
| 168 | 168 |
| 169 settings->SetCookieSetting( | 169 settings->SetCookieSetting(url, CONTENT_SETTING_ALLOW); |
| 170 ContentSettingsPattern::FromURL(url), | |
| 171 ContentSettingsPattern::Wildcard(), CONTENT_SETTING_ALLOW); | |
| 172 | 170 |
| 173 ui_test_utils::NavigateToURL(browser(), url); | 171 ui_test_utils::NavigateToURL(browser(), url); |
| 174 ASSERT_FALSE(GetCookies(browser()->profile(), url).empty()); | 172 ASSERT_FALSE(GetCookies(browser()->profile(), url).empty()); |
| 175 } | 173 } |
| 176 | 174 |
| 177 // Verify that cookies can be blocked for a specific website using exceptions. | 175 // Verify that cookies can be blocked for a specific website using exceptions. |
| 178 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, BlockCookiesUsingExceptions) { | 176 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, BlockCookiesUsingExceptions) { |
| 179 ASSERT_TRUE(embedded_test_server()->Start()); | 177 ASSERT_TRUE(embedded_test_server()->Start()); |
| 180 GURL url = embedded_test_server()->GetURL("/setcookie.html"); | 178 GURL url = embedded_test_server()->GetURL("/setcookie.html"); |
| 181 content_settings::CookieSettings* settings = | 179 content_settings::CookieSettings* settings = |
| 182 CookieSettingsFactory::GetForProfile(browser()->profile()).get(); | 180 CookieSettingsFactory::GetForProfile(browser()->profile()).get(); |
| 183 settings->SetCookieSetting(ContentSettingsPattern::FromURL(url), | 181 settings->SetCookieSetting(url, CONTENT_SETTING_BLOCK); |
| 184 ContentSettingsPattern::Wildcard(), | |
| 185 CONTENT_SETTING_BLOCK); | |
| 186 | 182 |
| 187 ui_test_utils::NavigateToURL(browser(), url); | 183 ui_test_utils::NavigateToURL(browser(), url); |
| 188 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty()); | 184 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty()); |
| 189 | 185 |
| 190 ASSERT_TRUE(https_server_.Start()); | 186 ASSERT_TRUE(https_server_.Start()); |
| 191 GURL unblocked_url = https_server_.GetURL("/cookie1.html"); | 187 GURL unblocked_url = https_server_.GetURL("/cookie1.html"); |
| 192 | 188 |
| 193 ui_test_utils::NavigateToURL(browser(), unblocked_url); | 189 ui_test_utils::NavigateToURL(browser(), unblocked_url); |
| 194 ASSERT_FALSE(GetCookies(browser()->profile(), unblocked_url).empty()); | 190 ASSERT_FALSE(GetCookies(browser()->profile(), unblocked_url).empty()); |
| 195 } | 191 } |
| 196 | 192 |
| 197 // This fails on ChromeOS because kRestoreOnStartup is ignored and the startup | 193 // This fails on ChromeOS because kRestoreOnStartup is ignored and the startup |
| 198 // preference is always "continue where I left off. | 194 // preference is always "continue where I left off. |
| 199 #if !defined(OS_CHROMEOS) | 195 #if !defined(OS_CHROMEOS) |
| 200 | 196 |
| 201 // Verify that cookies can be allowed and set using exceptions for particular | 197 // Verify that cookies can be allowed and set using exceptions for particular |
| 202 // website(s) only for a session when all others are blocked. | 198 // website(s) only for a session when all others are blocked. |
| 203 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, | 199 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, |
| 204 PRE_AllowCookiesForASessionUsingExceptions) { | 200 PRE_AllowCookiesForASessionUsingExceptions) { |
| 205 // NOTE: don't use test_server here, since we need the port to be the same | 201 // NOTE: don't use test_server here, since we need the port to be the same |
| 206 // across the restart. | 202 // across the restart. |
| 207 GURL url = URLRequestMockHTTPJob::GetMockUrl("setcookie.html"); | 203 GURL url = URLRequestMockHTTPJob::GetMockUrl("setcookie.html"); |
| 208 content_settings::CookieSettings* settings = | 204 content_settings::CookieSettings* settings = |
| 209 CookieSettingsFactory::GetForProfile(browser()->profile()).get(); | 205 CookieSettingsFactory::GetForProfile(browser()->profile()).get(); |
| 210 settings->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK); | 206 settings->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK); |
| 211 | 207 |
| 212 ui_test_utils::NavigateToURL(browser(), url); | 208 ui_test_utils::NavigateToURL(browser(), url); |
| 213 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty()); | 209 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty()); |
| 214 | 210 |
| 215 settings->SetCookieSetting( | 211 settings->SetCookieSetting(url, CONTENT_SETTING_SESSION_ONLY); |
| 216 ContentSettingsPattern::FromURL(url), | |
| 217 ContentSettingsPattern::Wildcard(), CONTENT_SETTING_SESSION_ONLY); | |
| 218 ui_test_utils::NavigateToURL(browser(), url); | 212 ui_test_utils::NavigateToURL(browser(), url); |
| 219 ASSERT_FALSE(GetCookies(browser()->profile(), url).empty()); | 213 ASSERT_FALSE(GetCookies(browser()->profile(), url).empty()); |
| 220 } | 214 } |
| 221 | 215 |
| 222 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, | 216 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, |
| 223 AllowCookiesForASessionUsingExceptions) { | 217 AllowCookiesForASessionUsingExceptions) { |
| 224 GURL url = URLRequestMockHTTPJob::GetMockUrl("setcookie.html"); | 218 GURL url = URLRequestMockHTTPJob::GetMockUrl("setcookie.html"); |
| 225 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty()); | 219 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty()); |
| 226 } | 220 } |
| 227 | 221 |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 587 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 594 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 588 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 595 switches::kAshBrowserTests)) | 589 switches::kAshBrowserTests)) |
| 596 return; | 590 return; |
| 597 #endif | 591 #endif |
| 598 RunJavaScriptBlockedTest("load_nacl_no_js.html", true); | 592 RunJavaScriptBlockedTest("load_nacl_no_js.html", true); |
| 599 } | 593 } |
| 600 #endif // !defined(DISABLE_NACL) | 594 #endif // !defined(DISABLE_NACL) |
| 601 | 595 |
| 602 #endif // defined(ENABLE_PLUGINS) | 596 #endif // defined(ENABLE_PLUGINS) |
| OLD | NEW |