notifications: Rename/consolidate settings

This commit is contained in:
Florian Bruhin 2021-03-25 16:11:05 +01:00
parent b63185f18d
commit d2e69454ce
8 changed files with 45 additions and 42 deletions

View File

@ -181,8 +181,8 @@
|<<content.mouse_lock,content.mouse_lock>>|Allow websites to lock your mouse pointer.
|<<content.mute,content.mute>>|Automatically mute tabs.
|<<content.netrc_file,content.netrc_file>>|Netrc-file for HTTP authentication.
|<<content.notification_presenter,content.notification_presenter>>|What notification presenter to use for web notifications.
|<<content.notifications,content.notifications>>|Allow websites to show notifications.
|<<content.notifications.enabled,content.notifications.enabled>>|Allow websites to show notifications.
|<<content.notifications.presenter,content.notifications.presenter>>|What notification presenter to use for web notifications.
|<<content.pdfjs,content.pdfjs>>|Allow pdf.js to view PDF files in the browser.
|<<content.persistent_storage,content.persistent_storage>>|Allow websites to request persistent storage quota via `navigator.webkitPersistentStorage.requestQuota`.
|<<content.plugins,content.plugins>>|Enable plugins in Web pages.
@ -2501,8 +2501,26 @@ Type: <<types,File>>
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: <<types,BoolAsk>>
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: <<types,BoolAsk>>
Valid values:
* +true+
* +false+
* +ask+
Default: +pass:[ask]+
[[content.pdfjs]]
=== content.pdfjs
Allow pdf.js to view PDF files in the browser.

View File

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

View File

@ -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',

View File

@ -357,7 +357,7 @@ class BrowserPage(QWebPage):
return
options = {
QWebPage.Notifications: 'content.notifications',
QWebPage.Notifications: 'content.notifications.enabled',
QWebPage.Geolocation: 'content.geolocation',
}
messages = {

View File

@ -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:

View File

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

View File

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

View File

@ -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'