diff --git a/mobile/android/components/geckoview/GeckoViewPermission.js b/mobile/android/components/geckoview/GeckoViewPermission.js index d9f580e6454f..e79be9eae2cf 100644 --- a/mobile/android/components/geckoview/GeckoViewPermission.js +++ b/mobile/android/components/geckoview/GeckoViewPermission.js @@ -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 ); diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/OpenWindowTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/OpenWindowTest.kt index f52f594d39f5..0736b6a52d06 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/OpenWindowTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/OpenWindowTest.kt @@ -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) { diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PermissionDelegateTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PermissionDelegateTest.kt index 2cd5695a814c..6fe081c85ba5 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PermissionDelegateTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PermissionDelegateTest.kt @@ -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() diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/WebNotificationTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/WebNotificationTest.kt index bf10211c41b3..c1a101ae9dcd 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/WebNotificationTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/WebNotificationTest.kt @@ -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) { diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/WebPushTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/WebPushTest.kt index 6da7ca8b1566..dccc7298176b 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/WebPushTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/WebPushTest.kt @@ -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) {