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

Unified Diff: chrome/browser/permissions/permission_util_unittest.cc

Issue 2180723002: Add revocation metrics from OIB and content setting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@revocation-reporter
Patch Set: Rebase Created 4 years, 5 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/permissions/permission_util_unittest.cc
diff --git a/chrome/browser/permissions/permission_util_unittest.cc b/chrome/browser/permissions/permission_util_unittest.cc
index 17252f879295873a1ee1855ba28d83423719ce6b..b3b944c441f3237134ab1ee632c583449912aa00 100644
--- a/chrome/browser/permissions/permission_util_unittest.cc
+++ b/chrome/browser/permissions/permission_util_unittest.cc
@@ -22,6 +22,10 @@ TEST_F(PermissionUtilTest, ScopedRevocationReporter) {
HostContentSettingsMap* map =
HostContentSettingsMapFactory::GetForProfile(&profile);
GURL host("https://example.com");
+ ContentSettingsPattern host_pattern =
+ ContentSettingsPattern::FromURLNoWildcard(host);
+ ContentSettingsPattern host_containing_wildcards_pattern =
+ ContentSettingsPattern::FromString("https://[*.]example.com/");
ContentSettingsType type = CONTENT_SETTINGS_TYPE_GEOLOCATION;
PermissionSourceUI source_ui = PermissionSourceUI::SITE_SETTINGS;
@@ -68,4 +72,30 @@ TEST_F(PermissionUtilTest, ScopedRevocationReporter) {
}
histograms.ExpectBucketCount("Permissions.Action.Geolocation",
PermissionAction::REVOKED, 2);
+
+ // Allow->Block with url pattern string triggers a revocation.
+ map->SetContentSettingDefaultScope(host, host, type, std::string(),
+ CONTENT_SETTING_ALLOW);
+ {
+ PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
+ &profile, host_pattern, host_pattern, type, source_ui);
+ map->SetContentSettingCustomScope(host_pattern, host_pattern, type,
+ std::string(), CONTENT_SETTING_BLOCK);
+ }
+ histograms.ExpectBucketCount("Permissions.Action.Geolocation",
+ PermissionAction::REVOKED, 3);
+
+ // Allow->Block with non url pattern string does not trigger a revocation.
+ map->SetContentSettingDefaultScope(host, host, type, std::string(),
+ CONTENT_SETTING_ALLOW);
+ {
+ PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
+ &profile, host_containing_wildcards_pattern, host_pattern, type,
+ source_ui);
+ map->SetContentSettingCustomScope(host_containing_wildcards_pattern,
+ host_pattern, type, std::string(),
+ CONTENT_SETTING_BLOCK);
+ }
+ histograms.ExpectBucketCount("Permissions.Action.Geolocation",
+ PermissionAction::REVOKED, 3);
}
« no previous file with comments | « chrome/browser/permissions/permission_util.cc ('k') | chrome/browser/ui/website_settings/website_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698