diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index c997d05fb..1b5aa6205 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -181,8 +181,8 @@ |<>|Allow websites to lock your mouse pointer. |<>|Automatically mute tabs. |<>|Netrc-file for HTTP authentication. -|<>|What notification presenter to use for web notifications. -|<>|Allow websites to show notifications. +|<>|Allow websites to show notifications. +|<>|What notification presenter to use for web notifications. |<>|Allow pdf.js to view PDF files in the browser. |<>|Allow websites to request persistent storage quota via `navigator.webkitPersistentStorage.requestQuota`. |<>|Enable plugins in Web pages. @@ -2501,8 +2501,26 @@ Type: <> Default: empty -[[content.notification_presenter]] -=== content.notification_presenter +[[content.notifications.enabled]] +=== content.notifications.enabled +Allow websites to show notifications. + +This setting supports URL patterns. + +On QtWebEngine, this setting requires Qt 5.13 or newer. + +Type: <> + +Valid values: + + * +true+ + * +false+ + * +ask+ + +Default: +pass:[ask]+ + +[[content.notifications.presenter]] +=== content.notifications.presenter What notification presenter to use for web notifications. Note that with Qt 5.14, certain JavaScript features for notifications will not work with the libnotify notification presenter (the `click` and `close` events, as well as the `tag` option to replace existing notifications). @@ -2522,24 +2540,6 @@ Valid values: Default: +pass:[auto]+ -[[content.notifications]] -=== content.notifications -Allow websites to show notifications. - -This setting supports URL patterns. - -On QtWebEngine, this setting requires Qt 5.13 or newer. - -Type: <> - -Valid values: - - * +true+ - * +false+ - * +ask+ - -Default: +pass:[ask]+ - [[content.pdfjs]] === content.pdfjs Allow pdf.js to view PDF files in the browser. diff --git a/qutebrowser/browser/webengine/notification.py b/qutebrowser/browser/webengine/notification.py index 238b2ee5a..21037abe1 100644 --- a/qutebrowser/browser/webengine/notification.py +++ b/qutebrowser/browser/webengine/notification.py @@ -55,7 +55,7 @@ def init() -> None: Always succeeds, but might log an error. """ - setting = config.val.content.notification_presenter + setting = config.val.content.notifications.presenter if setting not in ["auto", "libnotify"]: return diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index 5fda708bd..754b764cb 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -833,7 +833,7 @@ class _WebEnginePermissions(QObject): # https://www.riverbankcomputing.com/pipermail/pyqt/2019-July/041903.html _options = { - 0: 'content.notifications', + 0: 'content.notifications.enabled', QWebEnginePage.Geolocation: 'content.geolocation', QWebEnginePage.MediaAudioCapture: 'content.media.audio_capture', QWebEnginePage.MediaVideoCapture: 'content.media.video_capture', diff --git a/qutebrowser/browser/webkit/webpage.py b/qutebrowser/browser/webkit/webpage.py index 6c92042b1..6fd11b7c8 100644 --- a/qutebrowser/browser/webkit/webpage.py +++ b/qutebrowser/browser/webkit/webpage.py @@ -357,7 +357,7 @@ class BrowserPage(QWebPage): return options = { - QWebPage.Notifications: 'content.notifications', + QWebPage.Notifications: 'content.notifications.enabled', QWebPage.Geolocation: 'content.geolocation', } messages = { diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index fd488f2b1..e561d38b8 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -901,6 +901,9 @@ content.netrc_file: If unset, `~/.netrc` is used. content.notifications: + renamed: content.notifications.enabled + +content.notifications.enabled: default: ask type: BoolAsk supports_pattern: true @@ -909,7 +912,7 @@ content.notifications: QtWebKit: true desc: Allow websites to show notifications. -content.notification_presenter: +content.notifications.presenter: default: auto restart: true # no way to clear the presenter libnotify installs type: diff --git a/tests/end2end/features/notifications.feature b/tests/end2end/features/notifications.feature index 829bd9464..480bab4ad 100644 --- a/tests/end2end/features/notifications.feature +++ b/tests/end2end/features/notifications.feature @@ -5,7 +5,7 @@ Feature: Notifications Background: When I open data/javascript/notifications.html - And I set content.notifications to true + And I set content.notifications.enabled to true And I run :click-element id button Scenario: Notification is shown diff --git a/tests/end2end/features/prompts.feature b/tests/end2end/features/prompts.feature index 2bbef829b..028f1a7b9 100644 --- a/tests/end2end/features/prompts.feature +++ b/tests/end2end/features/prompts.feature @@ -84,7 +84,7 @@ Feature: Prompts Scenario: Blocking question interrupted by async one Given I have a fresh instance When I set content.javascript.alert to true - And I set content.notifications to ask + And I set content.notifications.enabled to ask And I open data/prompt/jsalert.html And I run :click-element id button And I wait for a prompt @@ -101,7 +101,7 @@ Feature: Prompts @qtwebengine_notifications Scenario: Async question interrupted by async one Given I have a fresh instance - When I set content.notifications to ask + When I set content.notifications.enabled to ask And I open data/prompt/notifications.html in a new tab And I run :click-element id button And I wait for a prompt @@ -117,7 +117,7 @@ Feature: Prompts @qtwebengine_notifications Scenario: Async question interrupted by blocking one Given I have a fresh instance - When I set content.notifications to ask + When I set content.notifications.enabled to ask And I set content.javascript.alert to true And I open data/prompt/notifications.html in a new tab And I run :click-element id button @@ -278,7 +278,7 @@ Feature: Prompts @qtwebengine_notifications Scenario: Always rejecting notifications Given I have a fresh instance - When I set content.notifications to false + When I set content.notifications.enabled to false And I open data/prompt/notifications.html in a new tab And I run :click-element id button Then the javascript message "notification permission denied" should be logged @@ -286,7 +286,7 @@ Feature: Prompts @qtwebengine_notifications Scenario: Always accepting notifications Given I have a fresh instance - When I set content.notifications to true + When I set content.notifications.enabled to true And I open data/prompt/notifications.html in a new tab And I run :click-element id button Then the javascript message "notification permission granted" should be logged @@ -294,7 +294,7 @@ Feature: Prompts @qtwebengine_notifications Scenario: notifications with ask -> false Given I have a fresh instance - When I set content.notifications to ask + When I set content.notifications.enabled to ask And I open data/prompt/notifications.html in a new tab And I run :click-element id button And I wait for a prompt @@ -304,18 +304,18 @@ Feature: Prompts @qtwebengine_notifications Scenario: notifications with ask -> false and save Given I have a fresh instance - When I set content.notifications to ask + When I set content.notifications.enabled to ask And I open data/prompt/notifications.html in a new tab And I run :click-element id button And I wait for a prompt And I run :prompt-accept --save no Then the javascript message "notification permission denied" should be logged - And the per-domain option content.notifications should be set to false for http://localhost:(port) + And the per-domain option content.notifications.enabled should be set to false for http://localhost:(port) @qtwebengine_notifications Scenario: notifications with ask -> true Given I have a fresh instance - When I set content.notifications to ask + When I set content.notifications.enabled to ask And I open data/prompt/notifications.html in a new tab And I run :click-element id button And I wait for a prompt @@ -325,19 +325,19 @@ Feature: Prompts @qtwebengine_notifications Scenario: notifications with ask -> true and save Given I have a fresh instance - When I set content.notifications to ask + When I set content.notifications.enabled to ask And I open data/prompt/notifications.html in a new tab And I run :click-element id button And I wait for a prompt And I run :prompt-accept --save yes Then the javascript message "notification permission granted" should be logged - And the per-domain option content.notifications should be set to true for http://localhost:(port) + And the per-domain option content.notifications.enabled should be set to true for http://localhost:(port) # This actually gives us a denied rather than an aborted @xfail_norun Scenario: notifications with ask -> abort Given I have a fresh instance - When I set content.notifications to ask + When I set content.notifications.enabled to ask And I open data/prompt/notifications.html in a new tab And I run :click-element id button And I wait for a prompt @@ -347,7 +347,7 @@ Feature: Prompts @qtwebengine_notifications Scenario: answering notification after closing tab Given I have a fresh instance - When I set content.notifications to ask + When I set content.notifications.enabled to ask And I open data/prompt/notifications.html in a new tab And I run :click-element id button And I wait for a prompt @@ -521,7 +521,7 @@ Feature: Prompts @qtwebengine_notifications Scenario: Interrupting SSL prompt during a notification prompt Given I have a fresh instance - When I set content.notifications to ask + When I set content.notifications.enabled to ask And I set content.tls.certificate_errors to ask And I open data/prompt/notifications.html in a new tab And I run :click-element id button diff --git a/tests/unit/browser/webengine/test_webenginetab.py b/tests/unit/browser/webengine/test_webenginetab.py index 156f7d26f..274e216ba 100644 --- a/tests/unit/browser/webengine/test_webenginetab.py +++ b/tests/unit/browser/webengine/test_webenginetab.py @@ -173,5 +173,5 @@ def test_notification_permission_workaround(): pytest.skip("No Notifications member") permissions = webenginetab._WebEnginePermissions - assert permissions._options[notifications] == 'content.notifications' + assert permissions._options[notifications] == 'content.notifications.enabled' assert permissions._messages[notifications] == 'show notifications'