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

Unified Diff: chrome/browser/extensions/api/content_settings/content_settings_apitest.cc

Issue 23694020: Don't clear existing extension-defined preferences and content settings when reloading or updating… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/content_settings/content_settings_apitest.cc
diff --git a/chrome/browser/extensions/api/content_settings/content_settings_apitest.cc b/chrome/browser/extensions/api/content_settings/content_settings_apitest.cc
index 10fb4127985c68c0e1648dc54df9fea158246e01..045ef18c9f59a444eeaa628cad0938bd329f62cb 100644
--- a/chrome/browser/extensions/api/content_settings/content_settings_apitest.cc
+++ b/chrome/browser/extensions/api/content_settings/content_settings_apitest.cc
@@ -17,92 +17,102 @@
namespace extensions {
-IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentSettings) {
- EXPECT_TRUE(RunExtensionTest("content_settings/standard")) << message_;
+class ExtensionContentSettingsApiTest : public ExtensionApiTest {
+ public:
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ ExtensionApiTest::SetUpCommandLine(command_line);
+ command_line->AppendSwitch(switches::kDisablePluginsDiscovery);
+ }
- HostContentSettingsMap* map =
- browser()->profile()->GetHostContentSettingsMap();
- CookieSettings* cookie_settings =
- CookieSettings::Factory::GetForProfile(browser()->profile()).get();
+ protected:
+ void CheckContentSettings() {
+ HostContentSettingsMap* map =
+ browser()->profile()->GetHostContentSettingsMap();
+ CookieSettings* cookie_settings =
+ CookieSettings::Factory::GetForProfile(browser()->profile()).get();
- // Check default content settings by using an unknown URL.
- GURL example_url("http://www.example.com");
- EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed(
- example_url, example_url));
- EXPECT_TRUE(cookie_settings->IsSettingCookieAllowed(
- example_url, example_url));
- EXPECT_TRUE(cookie_settings->IsCookieSessionOnly(example_url));
- EXPECT_EQ(CONTENT_SETTING_ALLOW,
- map->GetContentSetting(example_url,
- example_url,
- CONTENT_SETTINGS_TYPE_IMAGES,
- std::string()));
- EXPECT_EQ(CONTENT_SETTING_BLOCK,
- map->GetContentSetting(example_url,
- example_url,
- CONTENT_SETTINGS_TYPE_JAVASCRIPT,
- std::string()));
- EXPECT_EQ(CONTENT_SETTING_ALLOW,
- map->GetContentSetting(example_url,
- example_url,
- CONTENT_SETTINGS_TYPE_PLUGINS,
- std::string()));
- EXPECT_EQ(CONTENT_SETTING_BLOCK,
- map->GetContentSetting(example_url,
- example_url,
- CONTENT_SETTINGS_TYPE_POPUPS,
- std::string()));
-#if 0
- // TODO(bauerb): Enable once geolocation settings are integrated into the
- // HostContentSettingsMap.
- EXPECT_EQ(CONTENT_SETTING_ALLOW,
- map->GetContentSetting(example_url,
- example_url,
- CONTENT_SETTINGS_TYPE_GEOLOCATION,
- std::string()));
-#endif
- EXPECT_EQ(CONTENT_SETTING_ASK,
- map->GetContentSetting(example_url,
- example_url,
- CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
- std::string()));
+ // Check default content settings by using an unknown URL.
+ GURL example_url("http://www.example.com");
+ EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed(
+ example_url, example_url));
+ EXPECT_TRUE(cookie_settings->IsSettingCookieAllowed(
+ example_url, example_url));
+ EXPECT_TRUE(cookie_settings->IsCookieSessionOnly(example_url));
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ map->GetContentSetting(example_url,
+ example_url,
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ std::string()));
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ map->GetContentSetting(example_url,
+ example_url,
+ CONTENT_SETTINGS_TYPE_JAVASCRIPT,
+ std::string()));
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ map->GetContentSetting(example_url,
+ example_url,
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ std::string()));
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ map->GetContentSetting(example_url,
+ example_url,
+ CONTENT_SETTINGS_TYPE_POPUPS,
+ std::string()));
+ #if 0
+ // TODO(bauerb): Enable once geolocation settings are integrated into the
+ // HostContentSettingsMap.
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ map->GetContentSetting(example_url,
+ example_url,
+ CONTENT_SETTINGS_TYPE_GEOLOCATION,
+ std::string()));
+ #endif
+ EXPECT_EQ(CONTENT_SETTING_ASK,
+ map->GetContentSetting(example_url,
+ example_url,
+ CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
+ std::string()));
- // Check content settings for www.google.com
- GURL url("http://www.google.com");
- EXPECT_FALSE(cookie_settings->IsReadingCookieAllowed(url, url));
- EXPECT_EQ(CONTENT_SETTING_ALLOW,
- map->GetContentSetting(
- url, url, CONTENT_SETTINGS_TYPE_IMAGES, std::string()));
- EXPECT_EQ(CONTENT_SETTING_BLOCK,
- map->GetContentSetting(
- url, url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string()));
- EXPECT_EQ(CONTENT_SETTING_BLOCK,
- map->GetContentSetting(
- url, url, CONTENT_SETTINGS_TYPE_PLUGINS, std::string()));
- EXPECT_EQ(CONTENT_SETTING_ALLOW,
- map->GetContentSetting(
- url, url, CONTENT_SETTINGS_TYPE_POPUPS, std::string()));
+ // Check content settings for www.google.com
+ GURL url("http://www.google.com");
+ EXPECT_FALSE(cookie_settings->IsReadingCookieAllowed(url, url));
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ map->GetContentSetting(
+ url, url, CONTENT_SETTINGS_TYPE_IMAGES, std::string()));
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ map->GetContentSetting(
+ url, url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string()));
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ map->GetContentSetting(
+ url, url, CONTENT_SETTINGS_TYPE_PLUGINS, std::string()));
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ map->GetContentSetting(
+ url, url, CONTENT_SETTINGS_TYPE_POPUPS, std::string()));
#if 0
EXPECT_EQ(CONTENT_SETTING_BLOCK,
map->GetContentSetting(
url, url, CONTENT_SETTINGS_TYPE_GEOLOCATION, ""));
#endif
- EXPECT_EQ(CONTENT_SETTING_BLOCK,
- map->GetContentSetting(
- url, url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string()));
-}
-
-class ContentSettingsGetResourceIdentifiersTest : public ExtensionApiTest {
- public:
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
- ExtensionApiTest::SetUpCommandLine(command_line);
- command_line->AppendSwitch(switches::kDisablePluginsDiscovery);
+ EXPECT_EQ(
+ CONTENT_SETTING_BLOCK,
+ map->GetContentSetting(
+ url, url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string()));
}
};
+IN_PROC_BROWSER_TEST_F(ExtensionContentSettingsApiTest, Standard) {
+ EXPECT_TRUE(RunExtensionTest("content_settings/standard")) << message_;
+
+ CheckContentSettings();
+
+ // The settings should not be reset when the extension is reloaded.
Jeffrey Yasskin 2013/09/06 21:31:56 Could you also check that an uninstall+reinstall d
+ ReloadExtension(last_loaded_extension_id_);
+ CheckContentSettings();
+}
+
// Flaky on the trybots. See http://crbug.com/96725.
-IN_PROC_BROWSER_TEST_F(ContentSettingsGetResourceIdentifiersTest,
- DISABLED_Test) {
+IN_PROC_BROWSER_TEST_F(ExtensionContentSettingsApiTest,
+ DISABLED_GetResourceIdentifiers) {
base::FilePath::CharType kFooPath[] =
FILE_PATH_LITERAL("/plugins/foo.plugin");
base::FilePath::CharType kBarPath[] =

Powered by Google App Engine
This is Rietveld 408576698