summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_content_settings_apitest.cc
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-09 14:17:38 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-09 14:17:38 +0000
commitfa062426cde3d551d07a82a9e6a9ee2dfc15e6a4 (patch)
tree4baf4ceac1ddfffa7234c86e20776173c43fc6a7 /chrome/browser/extensions/extension_content_settings_apitest.cc
parent9f39293c0507c538c944de86ca6ce002c6feb2b2 (diff)
downloadchromium_src-fa062426cde3d551d07a82a9e6a9ee2dfc15e6a4.zip
chromium_src-fa062426cde3d551d07a82a9e6a9ee2dfc15e6a4.tar.gz
chromium_src-fa062426cde3d551d07a82a9e6a9ee2dfc15e6a4.tar.bz2
Content settings extension API
BUG=71067 TEST= Review URL: http://codereview.chromium.org/7029031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88526 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_content_settings_apitest.cc')
-rw-r--r--chrome/browser/extensions/extension_content_settings_apitest.cc54
1 files changed, 54 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_content_settings_apitest.cc b/chrome/browser/extensions/extension_content_settings_apitest.cc
index 1ec6923..0d8a704 100644
--- a/chrome/browser/extensions/extension_content_settings_apitest.cc
+++ b/chrome/browser/extensions/extension_content_settings_apitest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
@@ -25,6 +26,59 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentSettings) {
EXPECT_TRUE(pref->IsExtensionControlled());
EXPECT_FALSE(pref_service->GetBoolean(prefs::kBlockThirdPartyCookies));
EXPECT_TRUE(pref_service->GetBoolean(prefs::kEnableReferrers));
+ HostContentSettingsMap* map =
+ browser()->profile()->GetHostContentSettingsMap();
+
+ // Check default content settings by using an unknown URL.
+ GURL example_url("http://www.example.com");
+ EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY,
+ map->GetCookieContentSetting(example_url, example_url,
+ false));
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ map->GetContentSetting(example_url, CONTENT_SETTINGS_TYPE_IMAGES,
+ std::string()));
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ map->GetContentSetting(example_url,
+ CONTENT_SETTINGS_TYPE_JAVASCRIPT,
+ std::string()));
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ map->GetContentSetting(example_url, CONTENT_SETTINGS_TYPE_PLUGINS,
+ std::string()));
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ map->GetContentSetting(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,
+ CONTENT_SETTINGS_TYPE_GEOLOCATION,
+ std::string()));
+#endif
+ EXPECT_EQ(CONTENT_SETTING_ASK,
+ map->GetContentSetting(example_url,
+ CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
+ std::string()));
+
+ // Check content settings for www.google.com
+ GURL url("http://www.google.com");
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ map->GetCookieContentSetting(url, url, false));
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ map->GetContentSetting(url, CONTENT_SETTINGS_TYPE_IMAGES, ""));
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ map->GetContentSetting(url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ map->GetContentSetting(url, CONTENT_SETTINGS_TYPE_PLUGINS, ""));
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ map->GetContentSetting(url, CONTENT_SETTINGS_TYPE_POPUPS, ""));
+#if 0
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ map->GetContentSetting(url, CONTENT_SETTINGS_TYPE_GEOLOCATION, ""));
+#endif
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ map->GetContentSetting(url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
+ ""));
}
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PersistentIncognitoContentSettings) {