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

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

Issue 7537025: Add new Content settings type AUTO-SUBMIT-CERTIFICATE (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 4 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) 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 std::string(), 143 std::string(),
144 CONTENT_SETTING_ALLOW); 144 CONTENT_SETTING_ALLOW);
145 desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] = 145 desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] =
146 CONTENT_SETTING_ALLOW; 146 CONTENT_SETTING_ALLOW;
147 desired_settings.settings[CONTENT_SETTINGS_TYPE_POPUPS] = 147 desired_settings.settings[CONTENT_SETTINGS_TYPE_POPUPS] =
148 CONTENT_SETTING_BLOCK; 148 CONTENT_SETTING_BLOCK;
149 desired_settings.settings[CONTENT_SETTINGS_TYPE_GEOLOCATION] = 149 desired_settings.settings[CONTENT_SETTINGS_TYPE_GEOLOCATION] =
150 CONTENT_SETTING_ASK; 150 CONTENT_SETTING_ASK;
151 desired_settings.settings[CONTENT_SETTINGS_TYPE_NOTIFICATIONS] = 151 desired_settings.settings[CONTENT_SETTINGS_TYPE_NOTIFICATIONS] =
152 CONTENT_SETTING_ASK; 152 CONTENT_SETTING_ASK;
153 desired_settings.settings[CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE] =
154 CONTENT_SETTING_BLOCK;
153 ContentSettings settings = 155 ContentSettings settings =
154 host_content_settings_map->GetContentSettings(host, host); 156 host_content_settings_map->GetContentSettings(host, host);
155 EXPECT_TRUE(SettingsEqual(desired_settings, settings)); 157 EXPECT_TRUE(SettingsEqual(desired_settings, settings));
156 158
157 // Check returning all hosts for a setting. 159 // Check returning all hosts for a setting.
158 ContentSettingsPattern pattern2 = 160 ContentSettingsPattern pattern2 =
159 ContentSettingsPattern::FromString("[*.]example.org"); 161 ContentSettingsPattern::FromString("[*.]example.org");
160 host_content_settings_map->SetContentSetting( 162 host_content_settings_map->SetContentSetting(
161 pattern2, 163 pattern2,
162 ContentSettingsPattern::Wildcard(), 164 ContentSettingsPattern::Wildcard(),
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 desired_settings.settings[CONTENT_SETTINGS_TYPE_JAVASCRIPT] = 591 desired_settings.settings[CONTENT_SETTINGS_TYPE_JAVASCRIPT] =
590 CONTENT_SETTING_BLOCK; 592 CONTENT_SETTING_BLOCK;
591 desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] = 593 desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] =
592 CONTENT_SETTING_BLOCK; 594 CONTENT_SETTING_BLOCK;
593 desired_settings.settings[CONTENT_SETTINGS_TYPE_POPUPS] = 595 desired_settings.settings[CONTENT_SETTINGS_TYPE_POPUPS] =
594 CONTENT_SETTING_BLOCK; 596 CONTENT_SETTING_BLOCK;
595 desired_settings.settings[CONTENT_SETTINGS_TYPE_GEOLOCATION] = 597 desired_settings.settings[CONTENT_SETTINGS_TYPE_GEOLOCATION] =
596 CONTENT_SETTING_ASK; 598 CONTENT_SETTING_ASK;
597 desired_settings.settings[CONTENT_SETTINGS_TYPE_NOTIFICATIONS] = 599 desired_settings.settings[CONTENT_SETTINGS_TYPE_NOTIFICATIONS] =
598 CONTENT_SETTING_ASK; 600 CONTENT_SETTING_ASK;
601 desired_settings.settings[CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE] =
602 CONTENT_SETTING_BLOCK;
599 ContentSettings settings = 603 ContentSettings settings =
600 host_content_settings_map->GetContentSettings(host, host); 604 host_content_settings_map->GetContentSettings(host, host);
601 EXPECT_TRUE(SettingsEqual(desired_settings, settings)); 605 EXPECT_TRUE(SettingsEqual(desired_settings, settings));
602 EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_COOKIES], 606 EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_COOKIES],
603 settings.settings[CONTENT_SETTINGS_TYPE_COOKIES]); 607 settings.settings[CONTENT_SETTINGS_TYPE_COOKIES]);
604 EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_IMAGES], 608 EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_IMAGES],
605 settings.settings[CONTENT_SETTINGS_TYPE_IMAGES]); 609 settings.settings[CONTENT_SETTINGS_TYPE_IMAGES]);
606 EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS], 610 EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS],
607 settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS]); 611 settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS]);
608 EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_POPUPS], 612 EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_POPUPS],
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 TEST_F(HostContentSettingsMapTest, NonDefaultSettings) { 783 TEST_F(HostContentSettingsMapTest, NonDefaultSettings) {
780 TestingProfile profile; 784 TestingProfile profile;
781 HostContentSettingsMap* host_content_settings_map = 785 HostContentSettingsMap* host_content_settings_map =
782 profile.GetHostContentSettingsMap(); 786 profile.GetHostContentSettingsMap();
783 787
784 GURL host("http://example.com/"); 788 GURL host("http://example.com/");
785 ContentSettingsPattern pattern = 789 ContentSettingsPattern pattern =
786 ContentSettingsPattern::FromString("[*.]example.com"); 790 ContentSettingsPattern::FromString("[*.]example.com");
787 791
788 ContentSettings desired_settings(CONTENT_SETTING_DEFAULT); 792 ContentSettings desired_settings(CONTENT_SETTING_DEFAULT);
793 desired_settings.settings[CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE] =
794 CONTENT_SETTING_BLOCK;
789 ContentSettings settings = 795 ContentSettings settings =
790 host_content_settings_map->GetNonDefaultContentSettings(host, host); 796 host_content_settings_map->GetNonDefaultContentSettings(host, host);
791 EXPECT_TRUE(SettingsEqual(desired_settings, settings)); 797 EXPECT_TRUE(SettingsEqual(desired_settings, settings));
792 798
793 host_content_settings_map->SetContentSetting( 799 host_content_settings_map->SetContentSetting(
794 pattern, 800 pattern,
795 ContentSettingsPattern::Wildcard(), 801 ContentSettingsPattern::Wildcard(),
796 CONTENT_SETTINGS_TYPE_IMAGES, 802 CONTENT_SETTINGS_TYPE_IMAGES,
797 "", 803 "",
798 CONTENT_SETTING_BLOCK); 804 CONTENT_SETTING_BLOCK);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 host_content_settings_map->GetCookieContentSetting( 1257 host_content_settings_map->GetCookieContentSetting(
1252 kAllowedSite, kFirstPartySite, true)); 1258 kAllowedSite, kFirstPartySite, true));
1253 EXPECT_EQ(CONTENT_SETTING_ALLOW, 1259 EXPECT_EQ(CONTENT_SETTING_ALLOW,
1254 host_content_settings_map->GetCookieContentSetting( 1260 host_content_settings_map->GetCookieContentSetting(
1255 kAllowedSite, kAllowedSite, false)); 1261 kAllowedSite, kAllowedSite, false));
1256 EXPECT_EQ(CONTENT_SETTING_ALLOW, 1262 EXPECT_EQ(CONTENT_SETTING_ALLOW,
1257 host_content_settings_map->GetCookieContentSetting( 1263 host_content_settings_map->GetCookieContentSetting(
1258 kAllowedSite, kAllowedSite, true)); 1264 kAllowedSite, kAllowedSite, true));
1259 } 1265 }
1260 1266
1267 TEST_F(HostContentSettingsMapTest, AutoSubmitCertificate) {
Mattias Nissler (ping if slow) 2011/08/09 15:37:25 Isn't this exactly the same test you had before, b
markusheintz_ 2011/08/15 19:09:04 You are right. I removed the duplicated test.
1268 TestingProfile profile;
1269 HostContentSettingsMap* host_content_settings_map =
1270 profile.GetHostContentSettingsMap();
1271
1272 EXPECT_EQ(CONTENT_SETTING_BLOCK,
1273 host_content_settings_map->GetDefaultContentSetting(
1274 CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE));
1275
1276 GURL example_url("http://www.example.com/");
1277 EXPECT_EQ(CONTENT_SETTING_BLOCK,
1278 host_content_settings_map->GetContentSetting(
1279 example_url,
1280 example_url,
1281 CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE,
1282 ""));
1283
1284 // Set the content settings pattern list for origins to auto submit
1285 // certificates.
1286 TestingPrefService* prefs = profile.GetTestingPrefService();
1287 ListValue* value = new ListValue();
1288 value->Append(Value::CreateStringValue("[*.]example.com"));
1289 prefs->SetManagedPref(prefs::kManagedAutoSubmitCertificateForUrls,
1290 value);
1291
1292 EXPECT_EQ(CONTENT_SETTING_ALLOW,
1293 host_content_settings_map->GetContentSetting(
1294 example_url,
1295 example_url,
1296 CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE,
1297 ""));
1298 EXPECT_EQ(CONTENT_SETTING_BLOCK,
1299 host_content_settings_map->GetContentSetting(
1300 GURL("http://www.bar.com/"),
1301 GURL("http://www.bar.com/"),
1302 CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE,
1303 ""));
1304 }
1261 } // namespace 1305 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698