Bug 1608588 - Auto-deny desktop-notification permission appropriately r=geckoview-reviewers,esawin

This causes us to automatically deny the `desktop-notification`
permission if there is no user interaction, like desktop Firefox. This is
not enforced if the `dom.webnotifications.requireuserinteraction`
preference is set to `false`

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
James Willcox 2020-01-23 16:28:42 +00:00
parent dd6f2af24c
commit e2ee347144
2 changed files with 14 additions and 0 deletions

View File

@ -236,6 +236,19 @@ GeckoViewPermission.prototype = {
}
let perm = types.queryElementAt(0, Ci.nsIContentPermissionType);
if (
perm.type === "desktop-notification" &&
!aRequest.isHandlingUserInput &&
Services.prefs.getBoolPref(
"dom.webnotifications.requireuserinteraction",
true
)
) {
// We need user interaction and don't have it.
aRequest.cancel();
return;
}
let dispatcher = GeckoViewUtils.getDispatcherForWindow(
aRequest.window ? aRequest.window : aRequest.element.ownerGlobal
);

View File

@ -219,6 +219,7 @@ class PermissionDelegateTest : BaseSessionTest() {
}
@Test fun notification() {
sessionRule.setPrefsUntilTestEnd(mapOf("dom.webnotifications.requireuserinteraction" to false))
mainSession.loadTestPath(HELLO_HTML_PATH)
mainSession.waitForPageStop()