| OLD | NEW |
| 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/auto_reset.h" | 5 #include "base/auto_reset.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "chrome/browser/content_settings/content_settings_details.h" | 9 #include "chrome/browser/content_settings/content_settings_details.h" |
| 10 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 249 |
| 250 // Make a copy of the default pref value so we can reset it later. | 250 // Make a copy of the default pref value so we can reset it later. |
| 251 scoped_ptr<Value> default_value(prefs->FindPreference( | 251 scoped_ptr<Value> default_value(prefs->FindPreference( |
| 252 prefs::kDefaultContentSettings)->GetValue()->DeepCopy()); | 252 prefs::kDefaultContentSettings)->GetValue()->DeepCopy()); |
| 253 | 253 |
| 254 GURL host("http://example.com"); | 254 GURL host("http://example.com"); |
| 255 | 255 |
| 256 host_content_settings_map->SetDefaultContentSetting( | 256 host_content_settings_map->SetDefaultContentSetting( |
| 257 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); | 257 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); |
| 258 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 258 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 259 host_content_settings_map->GetContentSetting( | 259 host_content_settings_map->GetCookieContentSetting( |
| 260 host, CONTENT_SETTINGS_TYPE_COOKIES, "")); | 260 host, host, true)); |
| 261 | 261 |
| 262 // Make a copy of the pref's new value so we can reset it later. | 262 // Make a copy of the pref's new value so we can reset it later. |
| 263 scoped_ptr<Value> new_value(prefs->FindPreference( | 263 scoped_ptr<Value> new_value(prefs->FindPreference( |
| 264 prefs::kDefaultContentSettings)->GetValue()->DeepCopy()); | 264 prefs::kDefaultContentSettings)->GetValue()->DeepCopy()); |
| 265 | 265 |
| 266 // Clearing the backing pref should also clear the internal cache. | 266 // Clearing the backing pref should also clear the internal cache. |
| 267 prefs->Set(prefs::kDefaultContentSettings, *default_value); | 267 prefs->Set(prefs::kDefaultContentSettings, *default_value); |
| 268 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 268 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 269 host_content_settings_map->GetContentSetting( | 269 host_content_settings_map->GetCookieContentSetting( |
| 270 host, CONTENT_SETTINGS_TYPE_COOKIES, "")); | 270 host, host, true)); |
| 271 | 271 |
| 272 // Reseting the pref to its previous value should update the cache. | 272 // Reseting the pref to its previous value should update the cache. |
| 273 prefs->Set(prefs::kDefaultContentSettings, *new_value); | 273 prefs->Set(prefs::kDefaultContentSettings, *new_value); |
| 274 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 274 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 275 host_content_settings_map->GetContentSetting( | 275 host_content_settings_map->GetCookieContentSetting( |
| 276 host, CONTENT_SETTINGS_TYPE_COOKIES, "")); | 276 host, host, true)); |
| 277 } | 277 } |
| 278 | 278 |
| 279 TEST_F(HostContentSettingsMapTest, ObserveExceptionPref) { | 279 TEST_F(HostContentSettingsMapTest, ObserveExceptionPref) { |
| 280 TestingProfile profile; | 280 TestingProfile profile; |
| 281 HostContentSettingsMap* host_content_settings_map = | 281 HostContentSettingsMap* host_content_settings_map = |
| 282 profile.GetHostContentSettingsMap(); | 282 profile.GetHostContentSettingsMap(); |
| 283 | 283 |
| 284 PrefService* prefs = profile.GetPrefs(); | 284 PrefService* prefs = profile.GetPrefs(); |
| 285 | 285 |
| 286 // Make a copy of the default pref value so we can reset it later. | 286 // Make a copy of the default pref value so we can reset it later. |
| 287 scoped_ptr<Value> default_value(prefs->FindPreference( | 287 scoped_ptr<Value> default_value(prefs->FindPreference( |
| 288 prefs::kContentSettingsPatterns)->GetValue()->DeepCopy()); | 288 prefs::kContentSettingsPatterns)->GetValue()->DeepCopy()); |
| 289 | 289 |
| 290 ContentSettingsPattern pattern = | 290 ContentSettingsPattern pattern = |
| 291 ContentSettingsPattern::FromString("[*.]example.com"); | 291 ContentSettingsPattern::FromString("[*.]example.com"); |
| 292 GURL host("http://example.com"); | 292 GURL host("http://example.com"); |
| 293 | 293 |
| 294 host_content_settings_map->SetContentSetting(pattern, | 294 host_content_settings_map->SetContentSetting(pattern, |
| 295 CONTENT_SETTINGS_TYPE_COOKIES, "", CONTENT_SETTING_BLOCK); | 295 CONTENT_SETTINGS_TYPE_COOKIES, "", CONTENT_SETTING_BLOCK); |
| 296 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 296 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 297 host_content_settings_map->GetContentSetting( | 297 host_content_settings_map->GetCookieContentSetting( |
| 298 host, CONTENT_SETTINGS_TYPE_COOKIES, "")); | 298 host, host, true)); |
| 299 | 299 |
| 300 // Make a copy of the pref's new value so we can reset it later. | 300 // Make a copy of the pref's new value so we can reset it later. |
| 301 scoped_ptr<Value> new_value(prefs->FindPreference( | 301 scoped_ptr<Value> new_value(prefs->FindPreference( |
| 302 prefs::kContentSettingsPatterns)->GetValue()->DeepCopy()); | 302 prefs::kContentSettingsPatterns)->GetValue()->DeepCopy()); |
| 303 | 303 |
| 304 // Clearing the backing pref should also clear the internal cache. | 304 // Clearing the backing pref should also clear the internal cache. |
| 305 prefs->Set(prefs::kContentSettingsPatterns, *default_value); | 305 prefs->Set(prefs::kContentSettingsPatterns, *default_value); |
| 306 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 306 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 307 host_content_settings_map->GetContentSetting( | 307 host_content_settings_map->GetCookieContentSetting( |
| 308 host, CONTENT_SETTINGS_TYPE_COOKIES, "")); | 308 host, host, true)); |
| 309 | 309 |
| 310 // Reseting the pref to its previous value should update the cache. | 310 // Reseting the pref to its previous value should update the cache. |
| 311 prefs->Set(prefs::kContentSettingsPatterns, *new_value); | 311 prefs->Set(prefs::kContentSettingsPatterns, *new_value); |
| 312 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 312 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 313 host_content_settings_map->GetContentSetting( | 313 host_content_settings_map->GetCookieContentSetting( |
| 314 host, CONTENT_SETTINGS_TYPE_COOKIES, "")); | 314 host, host, true)); |
| 315 } | 315 } |
| 316 | 316 |
| 317 TEST_F(HostContentSettingsMapTest, HostTrimEndingDotCheck) { | 317 TEST_F(HostContentSettingsMapTest, HostTrimEndingDotCheck) { |
| 318 TestingProfile profile; | 318 TestingProfile profile; |
| 319 HostContentSettingsMap* host_content_settings_map = | 319 HostContentSettingsMap* host_content_settings_map = |
| 320 profile.GetHostContentSettingsMap(); | 320 profile.GetHostContentSettingsMap(); |
| 321 | 321 |
| 322 ContentSettingsPattern pattern = | 322 ContentSettingsPattern pattern = |
| 323 ContentSettingsPattern::FromString("[*.]example.com"); | 323 ContentSettingsPattern::FromString("[*.]example.com"); |
| 324 GURL host_ending_with_dot("http://example.com./"); | 324 GURL host_ending_with_dot("http://example.com./"); |
| 325 | 325 |
| 326 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 326 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 327 host_content_settings_map->GetContentSetting( | 327 host_content_settings_map->GetContentSetting( |
| 328 host_ending_with_dot, CONTENT_SETTINGS_TYPE_IMAGES, "")); | 328 host_ending_with_dot, CONTENT_SETTINGS_TYPE_IMAGES, "")); |
| 329 host_content_settings_map->SetContentSetting(pattern, | 329 host_content_settings_map->SetContentSetting(pattern, |
| 330 CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_DEFAULT); | 330 CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_DEFAULT); |
| 331 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 331 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 332 host_content_settings_map->GetContentSetting( | 332 host_content_settings_map->GetContentSetting( |
| 333 host_ending_with_dot, CONTENT_SETTINGS_TYPE_IMAGES, "")); | 333 host_ending_with_dot, CONTENT_SETTINGS_TYPE_IMAGES, "")); |
| 334 host_content_settings_map->SetContentSetting(pattern, | 334 host_content_settings_map->SetContentSetting(pattern, |
| 335 CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_BLOCK); | 335 CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_BLOCK); |
| 336 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 336 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 337 host_content_settings_map->GetContentSetting( | 337 host_content_settings_map->GetContentSetting( |
| 338 host_ending_with_dot, CONTENT_SETTINGS_TYPE_IMAGES, "")); | 338 host_ending_with_dot, CONTENT_SETTINGS_TYPE_IMAGES, "")); |
| 339 | 339 |
| 340 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 340 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 341 host_content_settings_map->GetContentSetting( | 341 host_content_settings_map->GetCookieContentSetting( |
| 342 host_ending_with_dot, CONTENT_SETTINGS_TYPE_COOKIES, "")); | 342 host_ending_with_dot, host_ending_with_dot, true)); |
| 343 host_content_settings_map->SetContentSetting(pattern, | 343 host_content_settings_map->SetContentSetting(pattern, |
| 344 CONTENT_SETTINGS_TYPE_COOKIES, "", CONTENT_SETTING_DEFAULT); | 344 CONTENT_SETTINGS_TYPE_COOKIES, "", CONTENT_SETTING_DEFAULT); |
| 345 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 345 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 346 host_content_settings_map->GetContentSetting( | 346 host_content_settings_map->GetCookieContentSetting( |
| 347 host_ending_with_dot, CONTENT_SETTINGS_TYPE_COOKIES, "")); | 347 host_ending_with_dot, host_ending_with_dot, true)); |
| 348 host_content_settings_map->SetContentSetting(pattern, | 348 host_content_settings_map->SetContentSetting(pattern, |
| 349 CONTENT_SETTINGS_TYPE_COOKIES, "", CONTENT_SETTING_BLOCK); | 349 CONTENT_SETTINGS_TYPE_COOKIES, "", CONTENT_SETTING_BLOCK); |
| 350 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 350 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 351 host_content_settings_map->GetContentSetting( | 351 host_content_settings_map->GetCookieContentSetting( |
| 352 host_ending_with_dot, CONTENT_SETTINGS_TYPE_COOKIES, "")); | 352 host_ending_with_dot, host_ending_with_dot, true)); |
| 353 | 353 |
| 354 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 354 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 355 host_content_settings_map->GetContentSetting( | 355 host_content_settings_map->GetContentSetting( |
| 356 host_ending_with_dot, CONTENT_SETTINGS_TYPE_JAVASCRIPT, "")); | 356 host_ending_with_dot, CONTENT_SETTINGS_TYPE_JAVASCRIPT, "")); |
| 357 host_content_settings_map->SetContentSetting(pattern, | 357 host_content_settings_map->SetContentSetting(pattern, |
| 358 CONTENT_SETTINGS_TYPE_JAVASCRIPT, "", CONTENT_SETTING_DEFAULT); | 358 CONTENT_SETTINGS_TYPE_JAVASCRIPT, "", CONTENT_SETTING_DEFAULT); |
| 359 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 359 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 360 host_content_settings_map->GetContentSetting( | 360 host_content_settings_map->GetContentSetting( |
| 361 host_ending_with_dot, CONTENT_SETTINGS_TYPE_JAVASCRIPT, "")); | 361 host_ending_with_dot, CONTENT_SETTINGS_TYPE_JAVASCRIPT, "")); |
| 362 host_content_settings_map->SetContentSetting(pattern, | 362 host_content_settings_map->SetContentSetting(pattern, |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 EXPECT_TRUE(host_content_settings_map->IsBlockThirdPartyCookiesManaged()); | 894 EXPECT_TRUE(host_content_settings_map->IsBlockThirdPartyCookiesManaged()); |
| 895 EXPECT_TRUE(host_content_settings_map->BlockThirdPartyCookies()); | 895 EXPECT_TRUE(host_content_settings_map->BlockThirdPartyCookies()); |
| 896 | 896 |
| 897 // After unsetting the managed value for the preference BlockThirdPartyCookies | 897 // After unsetting the managed value for the preference BlockThirdPartyCookies |
| 898 // the default value should be returned now. | 898 // the default value should be returned now. |
| 899 prefs->RemoveManagedPref(prefs::kBlockThirdPartyCookies); | 899 prefs->RemoveManagedPref(prefs::kBlockThirdPartyCookies); |
| 900 EXPECT_FALSE(host_content_settings_map->IsBlockThirdPartyCookiesManaged()); | 900 EXPECT_FALSE(host_content_settings_map->IsBlockThirdPartyCookiesManaged()); |
| 901 EXPECT_FALSE(host_content_settings_map->BlockThirdPartyCookies()); | 901 EXPECT_FALSE(host_content_settings_map->BlockThirdPartyCookies()); |
| 902 } | 902 } |
| 903 | 903 |
| 904 // Tests for cookie content settings. |
| 905 const GURL kBlockedSite = GURL("http://ads.thirdparty.com"); |
| 906 const GURL kAllowedSite = GURL("http://good.allays.com"); |
| 907 const GURL kFirstPartySite = GURL("http://cool.things.com"); |
| 908 |
| 909 TEST_F(HostContentSettingsMapTest, CookiesBlockSingle) { |
| 910 TestingProfile profile; |
| 911 HostContentSettingsMap* host_content_settings_map = |
| 912 profile.GetHostContentSettingsMap(); |
| 913 host_content_settings_map->AddExceptionForURL( |
| 914 kBlockedSite, CONTENT_SETTINGS_TYPE_COOKIES, "", |
| 915 CONTENT_SETTING_BLOCK); |
| 916 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 917 host_content_settings_map->GetCookieContentSetting( |
| 918 kBlockedSite, kBlockedSite, false)); |
| 919 } |
| 920 |
| 921 TEST_F(HostContentSettingsMapTest, CookiesBlockThirdParty) { |
| 922 TestingProfile profile; |
| 923 HostContentSettingsMap* host_content_settings_map = |
| 924 profile.GetHostContentSettingsMap(); |
| 925 host_content_settings_map->SetBlockThirdPartyCookies(true); |
| 926 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 927 host_content_settings_map->GetCookieContentSetting( |
| 928 kBlockedSite, kFirstPartySite, false)); |
| 929 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 930 host_content_settings_map->GetCookieContentSetting( |
| 931 kBlockedSite, kFirstPartySite, true)); |
| 932 |
| 933 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
| 934 AutoReset<CommandLine> auto_reset(cmd, *cmd); |
| 935 cmd->AppendSwitch(switches::kBlockReadingThirdPartyCookies); |
| 936 |
| 937 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 938 host_content_settings_map->GetCookieContentSetting( |
| 939 kBlockedSite, kFirstPartySite, false)); |
| 940 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 941 host_content_settings_map->GetCookieContentSetting( |
| 942 kBlockedSite, kFirstPartySite, true)); |
| 943 } |
| 944 |
| 945 TEST_F(HostContentSettingsMapTest, CookiesAllowThirdParty) { |
| 946 TestingProfile profile; |
| 947 HostContentSettingsMap* host_content_settings_map = |
| 948 profile.GetHostContentSettingsMap(); |
| 949 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 950 host_content_settings_map->GetCookieContentSetting( |
| 951 kBlockedSite, kFirstPartySite, false)); |
| 952 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 953 host_content_settings_map->GetCookieContentSetting( |
| 954 kBlockedSite, kFirstPartySite, true)); |
| 955 } |
| 956 |
| 957 TEST_F(HostContentSettingsMapTest, CookiesExplicitBlockSingleThirdParty) { |
| 958 TestingProfile profile; |
| 959 HostContentSettingsMap* host_content_settings_map = |
| 960 profile.GetHostContentSettingsMap(); |
| 961 host_content_settings_map->AddExceptionForURL( |
| 962 kBlockedSite, CONTENT_SETTINGS_TYPE_COOKIES, "", |
| 963 CONTENT_SETTING_BLOCK); |
| 964 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 965 host_content_settings_map->GetCookieContentSetting( |
| 966 kBlockedSite, kFirstPartySite, false)); |
| 967 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 968 host_content_settings_map->GetCookieContentSetting( |
| 969 kBlockedSite, kFirstPartySite, true)); |
| 970 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 971 host_content_settings_map->GetCookieContentSetting( |
| 972 kAllowedSite, kFirstPartySite, true)); |
| 973 } |
| 974 |
| 975 TEST_F(HostContentSettingsMapTest, CookiesExplicitSessionOnly) { |
| 976 TestingProfile profile; |
| 977 HostContentSettingsMap* host_content_settings_map = |
| 978 profile.GetHostContentSettingsMap(); |
| 979 host_content_settings_map->AddExceptionForURL( |
| 980 kBlockedSite, CONTENT_SETTINGS_TYPE_COOKIES, "", |
| 981 CONTENT_SETTING_SESSION_ONLY); |
| 982 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, |
| 983 host_content_settings_map->GetCookieContentSetting( |
| 984 kBlockedSite, kFirstPartySite, false)); |
| 985 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, |
| 986 host_content_settings_map->GetCookieContentSetting( |
| 987 kBlockedSite, kFirstPartySite, true)); |
| 988 |
| 989 host_content_settings_map->SetBlockThirdPartyCookies(true); |
| 990 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, |
| 991 host_content_settings_map->GetCookieContentSetting( |
| 992 kBlockedSite, kFirstPartySite, false)); |
| 993 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 994 host_content_settings_map->GetCookieContentSetting( |
| 995 kBlockedSite, kFirstPartySite, true)); |
| 996 } |
| 997 |
| 998 TEST_F(HostContentSettingsMapTest, CookiesThirdPartyAlwaysBlocked) { |
| 999 TestingProfile profile; |
| 1000 HostContentSettingsMap* host_content_settings_map = |
| 1001 profile.GetHostContentSettingsMap(); |
| 1002 host_content_settings_map->AddExceptionForURL( |
| 1003 kAllowedSite, CONTENT_SETTINGS_TYPE_COOKIES, "", |
| 1004 CONTENT_SETTING_ALLOW); |
| 1005 host_content_settings_map->SetBlockThirdPartyCookies(true); |
| 1006 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1007 host_content_settings_map->GetCookieContentSetting( |
| 1008 kAllowedSite, kFirstPartySite, false)); |
| 1009 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 1010 host_content_settings_map->GetCookieContentSetting( |
| 1011 kAllowedSite, kFirstPartySite, true)); |
| 1012 |
| 1013 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
| 1014 AutoReset<CommandLine> auto_reset(cmd, *cmd); |
| 1015 cmd->AppendSwitch(switches::kBlockReadingThirdPartyCookies); |
| 1016 |
| 1017 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 1018 host_content_settings_map->GetCookieContentSetting( |
| 1019 kAllowedSite, kFirstPartySite, false)); |
| 1020 } |
| 1021 |
| 1022 TEST_F(HostContentSettingsMapTest, CookiesBlockEverything) { |
| 1023 TestingProfile profile; |
| 1024 HostContentSettingsMap* host_content_settings_map = |
| 1025 profile.GetHostContentSettingsMap(); |
| 1026 host_content_settings_map->SetDefaultContentSetting( |
| 1027 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); |
| 1028 |
| 1029 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 1030 host_content_settings_map->GetCookieContentSetting( |
| 1031 kFirstPartySite, kFirstPartySite, false)); |
| 1032 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 1033 host_content_settings_map->GetCookieContentSetting( |
| 1034 kFirstPartySite, kFirstPartySite, true)); |
| 1035 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 1036 host_content_settings_map->GetCookieContentSetting( |
| 1037 kAllowedSite, kFirstPartySite, true)); |
| 1038 } |
| 1039 |
| 1040 TEST_F(HostContentSettingsMapTest, CookiesBlockEverythingExceptAllowed) { |
| 1041 TestingProfile profile; |
| 1042 HostContentSettingsMap* host_content_settings_map = |
| 1043 profile.GetHostContentSettingsMap(); |
| 1044 host_content_settings_map->SetDefaultContentSetting( |
| 1045 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); |
| 1046 host_content_settings_map->AddExceptionForURL( |
| 1047 kAllowedSite, CONTENT_SETTINGS_TYPE_COOKIES, "", |
| 1048 CONTENT_SETTING_ALLOW); |
| 1049 |
| 1050 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 1051 host_content_settings_map->GetCookieContentSetting( |
| 1052 kFirstPartySite, kFirstPartySite, false)); |
| 1053 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 1054 host_content_settings_map->GetCookieContentSetting( |
| 1055 kFirstPartySite, kFirstPartySite, true)); |
| 1056 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1057 host_content_settings_map->GetCookieContentSetting( |
| 1058 kAllowedSite, kFirstPartySite, false)); |
| 1059 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1060 host_content_settings_map->GetCookieContentSetting( |
| 1061 kAllowedSite, kFirstPartySite, true)); |
| 1062 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1063 host_content_settings_map->GetCookieContentSetting( |
| 1064 kAllowedSite, kAllowedSite, false)); |
| 1065 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1066 host_content_settings_map->GetCookieContentSetting( |
| 1067 kAllowedSite, kAllowedSite, true)); |
| 1068 } |
| 1069 |
| 904 } // namespace | 1070 } // namespace |
| OLD | NEW |