Bug 1570674 - Default to "Never Allow" for notification permission prompt denials. r=Ehsan

Differential Revision: https://phabricator.services.mozilla.com/D43081

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Johann Hofmann 2019-08-22 16:24:56 +00:00
parent c7d4860e5d
commit e91d880e08
5 changed files with 41 additions and 11 deletions

View File

@ -400,6 +400,8 @@ pref("permissions.default.shortcuts", 0);
pref("permissions.desktop-notification.postPrompt.enabled", false);
#endif
pref("permissions.desktop-notification.notNow.enabled", false);
pref("permissions.fullscreen.allowed", false);
pref("permissions.postPrompt.animate", true);

View File

@ -100,6 +100,10 @@ add_task(async function setup() {
Services.telemetry.canRecordExtended = true;
Services.prefs.setBoolPref("permissions.eventTelemetry.enabled", true);
Services.prefs.setBoolPref(
"permissions.desktop-notification.notNow.enabled",
true
);
// Add some example permissions.
let uri = Services.io.newURI(PERMISSIONS_PAGE);
@ -118,6 +122,9 @@ add_task(async function setup() {
registerCleanupFunction(() => {
Services.perms.removeAll();
Services.prefs.clearUserPref("permissions.eventTelemetry.enabled");
Services.prefs.clearUserPref(
"permissions.desktop-notification.notNow.enabled"
);
Services.telemetry.canRecordExtended = oldCanRecord;
});

View File

@ -872,6 +872,11 @@ function DesktopNotificationPermissionPrompt(request) {
"postPromptEnabled",
"permissions.desktop-notification.postPrompt.enabled"
);
XPCOMUtils.defineLazyPreferenceGetter(
this,
"notNowEnabled",
"permissions.desktop-notification.notNow.enabled"
);
}
DesktopNotificationPermissionPrompt.prototype = {
@ -921,24 +926,26 @@ DesktopNotificationPermissionPrompt.prototype = {
action: SitePermissions.ALLOW,
scope: SitePermissions.SCOPE_PERSISTENT,
},
{
];
if (this.notNowEnabled) {
actions.push({
label: gBrowserBundle.GetStringFromName("webNotifications.notNow"),
accessKey: gBrowserBundle.GetStringFromName(
"webNotifications.notNow.accesskey"
),
action: SitePermissions.BLOCK,
},
];
if (!PrivateBrowsingUtils.isBrowserPrivate(this.browser)) {
actions.push({
label: gBrowserBundle.GetStringFromName("webNotifications.never"),
accessKey: gBrowserBundle.GetStringFromName(
"webNotifications.never.accesskey"
),
action: SitePermissions.BLOCK,
scope: SitePermissions.SCOPE_PERSISTENT,
});
}
actions.push({
label: gBrowserBundle.GetStringFromName("webNotifications.never"),
accessKey: gBrowserBundle.GetStringFromName(
"webNotifications.never.accesskey"
),
action: SitePermissions.BLOCK,
scope: PrivateBrowsingUtils.isBrowserPrivate(this.browser)
? SitePermissions.SCOPE_SESSION
: SitePermissions.SCOPE_PERSISTENT,
});
return actions;
},

View File

@ -24,8 +24,15 @@ add_task(async function test_desktop_notification_permission_prompt() {
"dom.webnotifications.requireuserinteraction",
false
);
Services.prefs.setBoolPref(
"permissions.desktop-notification.notNow.enabled",
true
);
await testPrompt(PermissionUI.DesktopNotificationPermissionPrompt);
Services.prefs.clearUserPref("dom.webnotifications.requireuserinteraction");
Services.prefs.clearUserPref(
"permissions.desktop-notification.notNow.enabled"
);
});
// Tests that PersistentStoragePermissionPrompt works as expected

View File

@ -96,8 +96,15 @@ add_task(async function setup() {
"dom.webnotifications.requireuserinteraction",
false
);
Services.prefs.setBoolPref(
"permissions.desktop-notification.notNow.enabled",
true
);
SimpleTest.registerCleanupFunction(() => {
Services.prefs.clearUserPref("dom.webnotifications.requireuserinteraction");
Services.prefs.clearUserPref(
"permissions.desktop-notification.notNow.enabled"
);
PermissionTestUtils.remove(ORIGIN_URI, PERMISSION_NAME);
});
});