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
Родитель dd6f2af24c
Коммит e2ee347144
2 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -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
);

Просмотреть файл

@ -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()