| 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 <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } | 294 } |
| 295 | 295 |
| 296 TEST_F(HostContentSettingsMapTest, Patterns) { | 296 TEST_F(HostContentSettingsMapTest, Patterns) { |
| 297 TestingProfile profile; | 297 TestingProfile profile; |
| 298 HostContentSettingsMap* host_content_settings_map = | 298 HostContentSettingsMap* host_content_settings_map = |
| 299 HostContentSettingsMapFactory::GetForProfile(&profile); | 299 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 300 | 300 |
| 301 GURL host1("http://example.com/"); | 301 GURL host1("http://example.com/"); |
| 302 GURL host2("http://www.example.com/"); | 302 GURL host2("http://www.example.com/"); |
| 303 GURL host3("http://example.org/"); | 303 GURL host3("http://example.org/"); |
| 304 ContentSettingsPattern pattern1 = |
| 305 ContentSettingsPattern::FromString("[*.]example.com"); |
| 306 ContentSettingsPattern pattern2 = |
| 307 ContentSettingsPattern::FromString("example.org"); |
| 304 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 308 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 305 host_content_settings_map->GetContentSetting( | 309 host_content_settings_map->GetContentSetting( |
| 306 host1, host1, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); | 310 host1, host1, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 307 host_content_settings_map->SetContentSettingDefaultScope( | 311 host_content_settings_map->SetContentSettingCustomScope( |
| 308 host1, GURL(), CONTENT_SETTINGS_TYPE_COOKIES, std::string(), | 312 pattern1, ContentSettingsPattern::Wildcard(), |
| 309 CONTENT_SETTING_BLOCK); | 313 CONTENT_SETTINGS_TYPE_COOKIES, std::string(), CONTENT_SETTING_BLOCK); |
| 310 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 314 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 311 host_content_settings_map->GetContentSetting( | 315 host_content_settings_map->GetContentSetting( |
| 312 host1, host1, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); | 316 host1, host1, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 313 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 317 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 314 host_content_settings_map->GetContentSetting( | 318 host_content_settings_map->GetContentSetting( |
| 315 host2, host2, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); | 319 host2, host2, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 316 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 320 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 317 host_content_settings_map->GetContentSetting( | 321 host_content_settings_map->GetContentSetting( |
| 318 host3, host3, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); | 322 host3, host3, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 319 host_content_settings_map->SetContentSettingDefaultScope( | 323 host_content_settings_map->SetContentSettingCustomScope( |
| 320 host3, GURL(), CONTENT_SETTINGS_TYPE_COOKIES, std::string(), | 324 pattern2, ContentSettingsPattern::Wildcard(), |
| 321 CONTENT_SETTING_BLOCK); | 325 CONTENT_SETTINGS_TYPE_COOKIES, std::string(), CONTENT_SETTING_BLOCK); |
| 322 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 326 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 323 host_content_settings_map->GetContentSetting( | 327 host_content_settings_map->GetContentSetting( |
| 324 host3, host3, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); | 328 host3, host3, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 325 } | 329 } |
| 326 | 330 |
| 327 TEST_F(HostContentSettingsMapTest, Observer) { | 331 TEST_F(HostContentSettingsMapTest, Observer) { |
| 328 TestingProfile profile; | 332 TestingProfile profile; |
| 329 HostContentSettingsMap* host_content_settings_map = | 333 HostContentSettingsMap* host_content_settings_map = |
| 330 HostContentSettingsMapFactory::GetForProfile(&profile); | 334 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 331 MockSettingsObserver observer(host_content_settings_map); | 335 MockSettingsObserver observer(host_content_settings_map); |
| 332 | 336 |
| 333 GURL host("http://example.com/"); | 337 GURL host("http://example.com/"); |
| 334 ContentSettingsPattern primary_pattern = | 338 ContentSettingsPattern primary_pattern = |
| 335 ContentSettingsPattern::FromString("[*.]example.com"); | 339 ContentSettingsPattern::FromString("http://example.com:80"); |
| 336 ContentSettingsPattern secondary_pattern = | 340 ContentSettingsPattern secondary_pattern = |
| 337 ContentSettingsPattern::Wildcard(); | 341 ContentSettingsPattern::Wildcard(); |
| 338 EXPECT_CALL(observer, OnContentSettingsChanged(host_content_settings_map, | 342 EXPECT_CALL(observer, OnContentSettingsChanged(host_content_settings_map, |
| 339 CONTENT_SETTINGS_TYPE_COOKIES, | 343 CONTENT_SETTINGS_TYPE_COOKIES, |
| 340 false, primary_pattern, | 344 false, primary_pattern, |
| 341 secondary_pattern, false)); | 345 secondary_pattern, false)); |
| 342 host_content_settings_map->SetContentSettingDefaultScope( | 346 host_content_settings_map->SetContentSettingDefaultScope( |
| 343 host, GURL(), CONTENT_SETTINGS_TYPE_COOKIES, std::string(), | 347 host, GURL(), CONTENT_SETTINGS_TYPE_COOKIES, std::string(), |
| 344 CONTENT_SETTING_ALLOW); | 348 CONTENT_SETTING_ALLOW); |
| 345 ::testing::Mock::VerifyAndClearExpectations(&observer); | 349 ::testing::Mock::VerifyAndClearExpectations(&observer); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 host_ending_with_dot, host_ending_with_dot, | 574 host_ending_with_dot, host_ending_with_dot, |
| 571 CONTENT_SETTINGS_TYPE_AUTOPLAY, std::string())); | 575 CONTENT_SETTINGS_TYPE_AUTOPLAY, std::string())); |
| 572 } | 576 } |
| 573 | 577 |
| 574 TEST_F(HostContentSettingsMapTest, NestedSettings) { | 578 TEST_F(HostContentSettingsMapTest, NestedSettings) { |
| 575 TestingProfile profile; | 579 TestingProfile profile; |
| 576 HostContentSettingsMap* host_content_settings_map = | 580 HostContentSettingsMap* host_content_settings_map = |
| 577 HostContentSettingsMapFactory::GetForProfile(&profile); | 581 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 578 | 582 |
| 579 GURL host("http://a.b.example.com/"); | 583 GURL host("http://a.b.example.com/"); |
| 580 GURL host1("http://example.com/"); | 584 ContentSettingsPattern pattern1 = |
| 581 GURL host2("http://b.example.com/"); | 585 ContentSettingsPattern::FromString("[*.]example.com"); |
| 586 ContentSettingsPattern pattern2 = |
| 587 ContentSettingsPattern::FromString("[*.]b.example.com"); |
| 588 ContentSettingsPattern pattern3 = |
| 589 ContentSettingsPattern::FromString("a.b.example.com"); |
| 582 | 590 |
| 583 host_content_settings_map->SetContentSettingDefaultScope( | 591 host_content_settings_map->SetContentSettingCustomScope( |
| 584 host1, GURL(), CONTENT_SETTINGS_TYPE_POPUPS, std::string(), | 592 pattern1, ContentSettingsPattern::Wildcard(), |
| 585 CONTENT_SETTING_BLOCK); | 593 CONTENT_SETTINGS_TYPE_POPUPS, std::string(), CONTENT_SETTING_BLOCK); |
| 586 | 594 |
| 587 host_content_settings_map->SetContentSettingDefaultScope( | 595 host_content_settings_map->SetContentSettingCustomScope( |
| 588 host2, GURL(), CONTENT_SETTINGS_TYPE_COOKIES, std::string(), | 596 pattern2, ContentSettingsPattern::Wildcard(), |
| 589 CONTENT_SETTING_BLOCK); | 597 CONTENT_SETTINGS_TYPE_COOKIES, std::string(), CONTENT_SETTING_BLOCK); |
| 590 | 598 |
| 591 host_content_settings_map->SetContentSettingDefaultScope( | 599 host_content_settings_map->SetContentSettingCustomScope( |
| 592 host, GURL(), CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, std::string(), | 600 pattern3, ContentSettingsPattern::Wildcard(), |
| 601 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, std::string(), |
| 593 CONTENT_SETTING_BLOCK); | 602 CONTENT_SETTING_BLOCK); |
| 594 host_content_settings_map->SetDefaultContentSetting( | 603 host_content_settings_map->SetDefaultContentSetting( |
| 595 CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK); | 604 CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK); |
| 596 | 605 |
| 597 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 606 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 598 host_content_settings_map->GetContentSetting( | 607 host_content_settings_map->GetContentSetting( |
| 599 host, host, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); | 608 host, host, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 600 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 609 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 601 host_content_settings_map->GetContentSetting( | 610 host_content_settings_map->GetContentSetting( |
| 602 host, host, CONTENT_SETTINGS_TYPE_POPUPS, std::string())); | 611 host, host, CONTENT_SETTINGS_TYPE_POPUPS, std::string())); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 | 878 |
| 870 // Set utf-8 data. | 879 // Set utf-8 data. |
| 871 { | 880 { |
| 872 DictionaryPrefUpdate update(prefs, | 881 DictionaryPrefUpdate update(prefs, |
| 873 GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES)); | 882 GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES)); |
| 874 base::DictionaryValue* all_settings_dictionary = update.Get(); | 883 base::DictionaryValue* all_settings_dictionary = update.Get(); |
| 875 ASSERT_TRUE(NULL != all_settings_dictionary); | 884 ASSERT_TRUE(NULL != all_settings_dictionary); |
| 876 | 885 |
| 877 base::DictionaryValue* dummy_payload = new base::DictionaryValue; | 886 base::DictionaryValue* dummy_payload = new base::DictionaryValue; |
| 878 dummy_payload->SetInteger("setting", CONTENT_SETTING_ALLOW); | 887 dummy_payload->SetInteger("setting", CONTENT_SETTING_ALLOW); |
| 879 all_settings_dictionary->SetWithoutPathExpansion("[*.]\xC4\x87ira.com,*", | 888 all_settings_dictionary->SetWithoutPathExpansion("www.\xC4\x87ira.com,*", |
| 880 dummy_payload); | 889 dummy_payload); |
| 881 } | 890 } |
| 882 | 891 |
| 883 HostContentSettingsMapFactory::GetForProfile(&profile); | 892 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 884 | 893 |
| 885 const base::DictionaryValue* all_settings_dictionary = | 894 const base::DictionaryValue* all_settings_dictionary = |
| 886 prefs->GetDictionary(GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES)); | 895 prefs->GetDictionary(GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES)); |
| 887 const base::DictionaryValue* result = NULL; | 896 const base::DictionaryValue* result = NULL; |
| 888 EXPECT_FALSE(all_settings_dictionary->GetDictionaryWithoutPathExpansion( | 897 EXPECT_FALSE(all_settings_dictionary->GetDictionaryWithoutPathExpansion( |
| 889 "[*.]\xC4\x87ira.com,*", &result)); | 898 "www.\xC4\x87ira.com,*", &result)); |
| 890 EXPECT_TRUE(all_settings_dictionary->GetDictionaryWithoutPathExpansion( | 899 EXPECT_TRUE(all_settings_dictionary->GetDictionaryWithoutPathExpansion( |
| 891 "[*.]xn--ira-ppa.com,*", &result)); | 900 "www.xn--ira-ppa.com,*", &result)); |
| 892 } | 901 } |
| 893 | 902 |
| 894 // If both Unicode and its punycode pattern exist, make sure we don't touch the | 903 // If both Unicode and its punycode pattern exist, make sure we don't touch the |
| 895 // settings for the punycode, and that Unicode pattern gets deleted. | 904 // settings for the punycode, and that Unicode pattern gets deleted. |
| 896 TEST_F(HostContentSettingsMapTest, CanonicalizeExceptionsUnicodeAndPunycode) { | 905 TEST_F(HostContentSettingsMapTest, CanonicalizeExceptionsUnicodeAndPunycode) { |
| 897 TestingProfile profile; | 906 TestingProfile profile; |
| 898 | 907 |
| 899 std::unique_ptr<base::Value> value = | 908 std::unique_ptr<base::Value> value = |
| 900 base::JSONReader::Read("{\"[*.]\\xC4\\x87ira.com,*\":{\"setting\":1}}"); | 909 base::JSONReader::Read("{\"[*.]\\xC4\\x87ira.com,*\":{\"setting\":1}}"); |
| 901 profile.GetPrefs()->Set(GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES), *value); | 910 profile.GetPrefs()->Set(GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES), *value); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 } | 1143 } |
| 1135 | 1144 |
| 1136 TEST_F(HostContentSettingsMapTest, AddContentSettingsObserver) { | 1145 TEST_F(HostContentSettingsMapTest, AddContentSettingsObserver) { |
| 1137 TestingProfile profile; | 1146 TestingProfile profile; |
| 1138 HostContentSettingsMap* host_content_settings_map = | 1147 HostContentSettingsMap* host_content_settings_map = |
| 1139 HostContentSettingsMapFactory::GetForProfile(&profile); | 1148 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 1140 content_settings::MockObserver mock_observer; | 1149 content_settings::MockObserver mock_observer; |
| 1141 | 1150 |
| 1142 GURL host("http://example.com/"); | 1151 GURL host("http://example.com/"); |
| 1143 ContentSettingsPattern pattern = | 1152 ContentSettingsPattern pattern = |
| 1144 ContentSettingsPattern::FromString("[*.]example.com"); | 1153 ContentSettingsPattern::FromString("http://example.com:80"); |
| 1145 EXPECT_CALL(mock_observer, OnContentSettingChanged( | 1154 EXPECT_CALL(mock_observer, OnContentSettingChanged( |
| 1146 pattern, ContentSettingsPattern::Wildcard(), | 1155 pattern, ContentSettingsPattern::Wildcard(), |
| 1147 CONTENT_SETTINGS_TYPE_COOKIES, "")); | 1156 CONTENT_SETTINGS_TYPE_COOKIES, "")); |
| 1148 | 1157 |
| 1149 host_content_settings_map->AddObserver(&mock_observer); | 1158 host_content_settings_map->AddObserver(&mock_observer); |
| 1150 | 1159 |
| 1151 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 1160 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1152 host_content_settings_map->GetContentSetting( | 1161 host_content_settings_map->GetContentSetting( |
| 1153 host, host, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); | 1162 host, host, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 1154 host_content_settings_map->SetContentSettingDefaultScope( | 1163 host_content_settings_map->SetContentSettingDefaultScope( |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1271 | 1280 |
| 1272 // After migrating old settings, changes to the setting works. | 1281 // After migrating old settings, changes to the setting works. |
| 1273 host_content_settings_map->SetContentSettingDefaultScope( | 1282 host_content_settings_map->SetContentSettingDefaultScope( |
| 1274 host, GURL(), CONTENT_SETTINGS_TYPE_KEYGEN, std::string(), | 1283 host, GURL(), CONTENT_SETTINGS_TYPE_KEYGEN, std::string(), |
| 1275 CONTENT_SETTING_BLOCK); | 1284 CONTENT_SETTING_BLOCK); |
| 1276 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 1285 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 1277 host_content_settings_map->GetContentSetting( | 1286 host_content_settings_map->GetContentSetting( |
| 1278 host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string())); | 1287 host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string())); |
| 1279 } | 1288 } |
| 1280 | 1289 |
| 1290 TEST_F(HostContentSettingsMapTest, MigrateDomainScopedSettings) { |
| 1291 TestingProfile profile; |
| 1292 HostContentSettingsMap* host_content_settings_map = |
| 1293 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 1294 |
| 1295 // Set old formatted http settings. |
| 1296 GURL http_host("http://example.com/"); |
| 1297 GURL http_host_narrower("http://a.example.com/"); |
| 1298 |
| 1299 // Change default setting to BLCOK. |
| 1300 host_content_settings_map->SetDefaultContentSetting( |
| 1301 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); |
| 1302 EXPECT_EQ( |
| 1303 CONTENT_SETTING_BLOCK, |
| 1304 host_content_settings_map->GetContentSetting( |
| 1305 http_host, http_host, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 1306 // Patterns generated for images used to be domain scoped. |
| 1307 host_content_settings_map->SetContentSettingCustomScope( |
| 1308 ContentSettingsPattern::FromURL(http_host), |
| 1309 ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_COOKIES, |
| 1310 std::string(), CONTENT_SETTING_ALLOW); |
| 1311 EXPECT_EQ( |
| 1312 CONTENT_SETTING_ALLOW, |
| 1313 host_content_settings_map->GetContentSetting( |
| 1314 http_host, http_host, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 1315 // Settings also apply to subdomains. |
| 1316 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1317 host_content_settings_map->GetContentSetting( |
| 1318 http_host_narrower, http_host_narrower, |
| 1319 CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 1320 |
| 1321 // Set old formatted https settings. |
| 1322 GURL https_host("https://example.com/"); |
| 1323 GURL https_host_narrower("https://a.example.com/"); |
| 1324 |
| 1325 // Change default setting to BLCOK. |
| 1326 host_content_settings_map->SetDefaultContentSetting( |
| 1327 CONTENT_SETTINGS_TYPE_POPUPS, CONTENT_SETTING_BLOCK); |
| 1328 EXPECT_EQ( |
| 1329 CONTENT_SETTING_BLOCK, |
| 1330 host_content_settings_map->GetContentSetting( |
| 1331 https_host, https_host, CONTENT_SETTINGS_TYPE_POPUPS, std::string())); |
| 1332 // Patterns generated for cookies used to be domain scoped. |
| 1333 host_content_settings_map->SetContentSettingCustomScope( |
| 1334 ContentSettingsPattern::FromURL(https_host), |
| 1335 ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_POPUPS, |
| 1336 std::string(), CONTENT_SETTING_ALLOW); |
| 1337 EXPECT_EQ( |
| 1338 CONTENT_SETTING_ALLOW, |
| 1339 host_content_settings_map->GetContentSetting( |
| 1340 https_host, https_host, CONTENT_SETTINGS_TYPE_POPUPS, std::string())); |
| 1341 // Settings also apply to subdomains. |
| 1342 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1343 host_content_settings_map->GetContentSetting( |
| 1344 https_host_narrower, https_host_narrower, |
| 1345 CONTENT_SETTINGS_TYPE_POPUPS, std::string())); |
| 1346 |
| 1347 host_content_settings_map->MigrateDomainScopedSettings(); |
| 1348 |
| 1349 // After migration, settings only affect origins. |
| 1350 EXPECT_EQ( |
| 1351 CONTENT_SETTING_ALLOW, |
| 1352 host_content_settings_map->GetContentSetting( |
| 1353 http_host, http_host, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 1354 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 1355 host_content_settings_map->GetContentSetting( |
| 1356 http_host_narrower, http_host_narrower, |
| 1357 CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 1358 |
| 1359 EXPECT_EQ( |
| 1360 CONTENT_SETTING_ALLOW, |
| 1361 host_content_settings_map->GetContentSetting( |
| 1362 https_host, https_host, CONTENT_SETTINGS_TYPE_POPUPS, std::string())); |
| 1363 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 1364 host_content_settings_map->GetContentSetting( |
| 1365 https_host_narrower, https_host_narrower, |
| 1366 CONTENT_SETTINGS_TYPE_POPUPS, std::string())); |
| 1367 } |
| 1368 |
| 1281 TEST_F(HostContentSettingsMapTest, InvalidPattern) { | 1369 TEST_F(HostContentSettingsMapTest, InvalidPattern) { |
| 1282 // This is a regression test for crbug.com/618529, which fixed a memory leak | 1370 // This is a regression test for crbug.com/618529, which fixed a memory leak |
| 1283 // when a website setting was set under a URL that mapped to an invalid | 1371 // when a website setting was set under a URL that mapped to an invalid |
| 1284 // pattern. | 1372 // pattern. |
| 1285 TestingProfile profile; | 1373 TestingProfile profile; |
| 1286 HostContentSettingsMap* host_content_settings_map = | 1374 HostContentSettingsMap* host_content_settings_map = |
| 1287 HostContentSettingsMapFactory::GetForProfile(&profile); | 1375 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 1288 GURL unsupported_url = GURL("view-source:http://www.google.com"); | 1376 GURL unsupported_url = GURL("view-source:http://www.google.com"); |
| 1289 base::DictionaryValue test_value; | 1377 base::DictionaryValue test_value; |
| 1290 test_value.SetString("test", "value"); | 1378 test_value.SetString("test", "value"); |
| 1291 host_content_settings_map->SetWebsiteSettingDefaultScope( | 1379 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 1292 unsupported_url, unsupported_url, CONTENT_SETTINGS_TYPE_APP_BANNER, | 1380 unsupported_url, unsupported_url, CONTENT_SETTINGS_TYPE_APP_BANNER, |
| 1293 std::string(), base::WrapUnique(test_value.DeepCopy())); | 1381 std::string(), base::WrapUnique(test_value.DeepCopy())); |
| 1294 EXPECT_EQ(nullptr, | 1382 EXPECT_EQ(nullptr, |
| 1295 host_content_settings_map->GetWebsiteSetting( | 1383 host_content_settings_map->GetWebsiteSetting( |
| 1296 unsupported_url, unsupported_url, | 1384 unsupported_url, unsupported_url, |
| 1297 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), nullptr)); | 1385 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), nullptr)); |
| 1298 } | 1386 } |
| OLD | NEW |