summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-06-09 10:22:17 +0200
committerFlorian Bruhin <me@the-compiler.org>2021-06-09 10:22:17 +0200
commit96149c7e28e41a2d65464fee81b364b3f2474e64 (patch)
treee905a26064aa0cd7c633b4709cd116bb8d92da88
parente6261ad92ef138b7eac1266a7f20133ff6bc0ece (diff)
downloadqutebrowser-96149c7e28e41a2d65464fee81b364b3f2474e64.tar.gz
qutebrowser-96149c7e28e41a2d65464fee81b364b3f2474e64.zip
Add content.prefers_reduced_motion
Closes #6530
-rw-r--r--doc/changelog.asciidoc6
-rw-r--r--doc/help/settings.asciidoc16
-rw-r--r--qutebrowser/config/configdata.yml13
-rw-r--r--qutebrowser/config/qtargs.py6
-rw-r--r--tests/end2end/data/prefers_reduced_motion.html38
-rw-r--r--tests/end2end/test_invocations.py20
6 files changed, 98 insertions, 1 deletions
diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc
index 83d8a9601..02d388517 100644
--- a/doc/changelog.asciidoc
+++ b/doc/changelog.asciidoc
@@ -19,6 +19,12 @@ breaking changes (such as renamed commands) can happen in minor releases.
v2.3.0 (unreleased)
-------------------
+Added
+~~~~~
+
+- New `content.prefers_reduced_motion` setting to request websites to reduce
+ non-essential motion/animations.
+
Changed
~~~~~~~
diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc
index fb208e48c..2fc4440a6 100644
--- a/doc/help/settings.asciidoc
+++ b/doc/help/settings.asciidoc
@@ -187,6 +187,7 @@
|<<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.
+|<<content.prefers_reduced_motion,content.prefers_reduced_motion>>|Request websites to minimize non-essentials animations and motion.
|<<content.print_element_backgrounds,content.print_element_backgrounds>>|Draw the background color and images also when the page is printed.
|<<content.private_browsing,content.private_browsing>>|Open new windows in private browsing mode which does not record visited pages.
|<<content.proxy,content.proxy>>|Proxy to use.
@@ -2607,6 +2608,21 @@ Type: <<types,Bool>>
Default: +pass:[false]+
+[[content.prefers_reduced_motion]]
+=== content.prefers_reduced_motion
+Request websites to minimize non-essentials animations and motion.
+This results in the `prefers-reduced-motion` CSS media query to evaluate to `reduce` (rather than `no-preference`).
+
+This setting requires a restart.
+
+On QtWebEngine, this setting requires Qt 5.14 or newer.
+
+On QtWebKit, this setting is unavailable.
+
+Type: <<types,Bool>>
+
+Default: +pass:[false]+
+
[[content.print_element_backgrounds]]
=== content.print_element_backgrounds
Draw the background color and images also when the page is printed.
diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml
index b85e84be2..78d9c9bf7 100644
--- a/qutebrowser/config/configdata.yml
+++ b/qutebrowser/config/configdata.yml
@@ -528,6 +528,19 @@ content.frame_flattening:
This will flatten all the frames to become one scrollable page.
+content.prefers_reduced_motion:
+ default: false
+ type: Bool
+ backend:
+ QtWebEngine: Qt 5.14
+ QtWebKit: false
+ restart: true
+ desc: >-
+ Request websites to minimize non-essentials animations and motion.
+
+ This results in the `prefers-reduced-motion` CSS media query to evaluate to
+ `reduce` (rather than `no-preference`).
+
content.site_specific_quirks:
renamed: content.site_specific_quirks.enabled
diff --git a/qutebrowser/config/qtargs.py b/qutebrowser/config/qtargs.py
index cb17a0ced..c38ef5b01 100644
--- a/qutebrowser/config/qtargs.py
+++ b/qutebrowser/config/qtargs.py
@@ -334,7 +334,11 @@ def _qtwebengine_settings_args(versions: version.WebEngineVersions) -> Iterator[
},
'content.headers.referer': {
'always': None,
- }
+ },
+ 'content.prefers_reduced_motion': {
+ True: '--force-prefers-reduced-motion',
+ False: None,
+ },
}
qt_514_ver = utils.VersionNumber(5, 14)
diff --git a/tests/end2end/data/prefers_reduced_motion.html b/tests/end2end/data/prefers_reduced_motion.html
new file mode 100644
index 000000000..a37d43864
--- /dev/null
+++ b/tests/end2end/data/prefers_reduced_motion.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Prefers reduced motion test</title>
+ <style>
+#reduce-text {
+ display: none;
+}
+#no-preference-text {
+ display: none;
+}
+
+@media (prefers-reduced-motion: no-preference) {
+ #no-preference-text {
+ display: inline;
+ }
+ #missing-support-text {
+ display: none;
+ }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ #reduce-text {
+ display: inline;
+ }
+ #missing-support-text {
+ display: none;
+ }
+}
+ </style>
+ </head>
+ <body>
+ <p id="reduce-text">Reduced motion preference detected.</p>
+ <p id="no-preference-text">No preference detected.</p>
+ <p id="missing-support-text">Preference support missing.</p>
+ </body>
+</html>
diff --git a/tests/end2end/test_invocations.py b/tests/end2end/test_invocations.py
index 71cbfcb90..971be903c 100644
--- a/tests/end2end/test_invocations.py
+++ b/tests/end2end/test_invocations.py
@@ -752,6 +752,26 @@ def test_dark_mode_mathml(quteproc_new, request, qtbot):
)
+@testutils.qt514
+@pytest.mark.parametrize('value, preference', [
+ ('true', 'Reduced motion'),
+ ('false', 'No'),
+])
+def test_prefers_reduced_motion(quteproc_new, request, qtbot, value, preference):
+ if not request.config.webengine:
+ pytest.skip("Skipped with QtWebKit")
+
+ args = _base_args(request.config) + [
+ '--temp-basedir',
+ '-s', 'content.prefers_reduced_motion', value,
+ ]
+ quteproc_new.start(args)
+
+ quteproc_new.open_path('data/prefers_reduced_motion.html')
+ content = quteproc_new.get_content()
+ assert content == f"{preference} preference detected."
+
+
def test_unavailable_backend(request, quteproc_new):
"""Test starting with a backend which isn't available.