зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
ab51b2424c
Коммит
415b58b0a0
|
@ -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
|
||||
);
|
||||
|
|
|
@ -21,6 +21,8 @@ class OpenWindowTest : BaseSessionTest() {
|
|||
|
||||
@Before
|
||||
fun setup() {
|
||||
sessionRule.setPrefsUntilTestEnd(mapOf("dom.webnotifications.requireuserinteraction" to false))
|
||||
|
||||
// Grant "desktop notification" permission
|
||||
mainSession.delegateUntilTestEnd(object : Callbacks.PermissionDelegate {
|
||||
override fun onContentPermissionRequest(session: GeckoSession, uri: String?, type: Int, callback: GeckoSession.PermissionDelegate.Callback) {
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ class WebNotificationTest : BaseSessionTest() {
|
|||
mainSession.loadTestPath(HELLO_HTML_PATH)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
sessionRule.setPrefsUntilTestEnd(mapOf("dom.webnotifications.requireuserinteraction" to false))
|
||||
|
||||
// Grant "desktop notification" permission
|
||||
mainSession.delegateUntilTestEnd(object : Callbacks.PermissionDelegate {
|
||||
override fun onContentPermissionRequest(session: GeckoSession, uri: String?, type: Int, callback: GeckoSession.PermissionDelegate.Callback) {
|
||||
|
|
|
@ -57,6 +57,7 @@ class WebPushTest : BaseSessionTest() {
|
|||
|
||||
@Before
|
||||
fun setup() {
|
||||
sessionRule.setPrefsUntilTestEnd(mapOf("dom.webnotifications.requireuserinteraction" to false))
|
||||
// Grant "desktop notification" permission
|
||||
mainSession.delegateUntilTestEnd(object : Callbacks.PermissionDelegate {
|
||||
override fun onContentPermissionRequest(session: GeckoSession, uri: String?, type: Int, callback: GeckoSession.PermissionDelegate.Callback) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче