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

Unified Diff: chrome/browser/push_messaging/push_messaging_permission_context_unittest.cc

Issue 1816123002: Add testing for subscription from service workers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix asan errors Created 4 years, 9 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/push_messaging/push_messaging_permission_context_unittest.cc
diff --git a/chrome/browser/push_messaging/push_messaging_permission_context_unittest.cc b/chrome/browser/push_messaging/push_messaging_permission_context_unittest.cc
index 14acbfa02455e4b96620e60e8e14a87ebfb2d0a6..7cda2a7a47ca41f469e02140a33f4558f180aa68 100644
--- a/chrome/browser/push_messaging/push_messaging_permission_context_unittest.cc
+++ b/chrome/browser/push_messaging/push_messaging_permission_context_unittest.cc
@@ -85,14 +85,14 @@ TEST_F(PushMessagingPermissionContextTest, HasPermissionPrompt) {
EXPECT_EQ(CONTENT_SETTING_ASK,
context.GetPermissionStatus(GURL(kOriginA), GURL(kOriginA)));
- // Just granting notifications should still prompt
- SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
+ // Just granting push messaging permission should still prompt.
+ SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
CONTENT_SETTING_ALLOW);
EXPECT_EQ(CONTENT_SETTING_ASK,
context.GetPermissionStatus(GURL(kOriginA), GURL(kOriginA)));
- // Just granting push should still prompt
+ // Just granting notifications should allow if push messaging is not blocked.
SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
CONTENT_SETTING_ASK);
SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
@@ -100,6 +100,16 @@ TEST_F(PushMessagingPermissionContextTest, HasPermissionPrompt) {
EXPECT_EQ(CONTENT_SETTING_ASK,
context.GetPermissionStatus(GURL(kOriginA), GURL(kOriginA)));
+
+ // Granting allow notifications but explicitly denying push messaging should
+ // block.
+ SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
+ CONTENT_SETTING_ALLOW);
+ SetContentSetting(&profile, CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
+ CONTENT_SETTING_BLOCK);
+
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ context.GetPermissionStatus(GURL(kOriginA), GURL(kOriginA)));
}
TEST_F(PushMessagingPermissionContextTest, HasPermissionDenySettingsMismatch) {
@@ -214,19 +224,20 @@ TEST_F(PushMessagingPermissionContextTest, RequestPermission) {
HostContentSettingsMapFactory::GetForProfile(&profile)->GetContentSetting(
GURL(kOriginA), GURL(kOriginA), CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
std::string()));
- EXPECT_EQ(CONTENT_SETTING_ASK,
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
context.GetPermissionStatus(GURL(kOriginA), GURL(kOriginA)));
// If a website already has notifications permission, push permission is
- // silently granted once the website requests it.
+ // silently assumed to be granted.
NavigateAndCommit(GURL(kOriginA));
context.RequestPermission(web_contents(), request_id, GURL(kOriginA),
callback);
- EXPECT_TRUE(context.was_persisted());
+ // Although the permission check goes through, the push message permission
+ // isn't actually updated.
EXPECT_TRUE(context.was_granted());
EXPECT_EQ(
- CONTENT_SETTING_ALLOW,
+ CONTENT_SETTING_ASK,
HostContentSettingsMapFactory::GetForProfile(&profile)->GetContentSetting(
GURL(kOriginA), GURL(kOriginA), CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
std::string()));
@@ -246,7 +257,6 @@ TEST_F(PushMessagingPermissionContextTest, RequestAfterRevokingNotifications) {
NavigateAndCommit(GURL(kOriginA));
context.RequestPermission(web_contents(), request_id, GURL(kOriginA),
callback);
- EXPECT_TRUE(context.was_persisted());
EXPECT_TRUE(context.was_granted());
EXPECT_EQ(CONTENT_SETTING_ALLOW,
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_permission_context.cc ('k') | chrome/test/data/push_messaging/push_constants.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698