summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2022-05-12 10:09:09 +0200
committerFlorian Bruhin <me@the-compiler.org>2022-05-12 10:11:09 +0200
commit484dbbf0a3a4dac2c5011bc93ee832facb0a9ff8 (patch)
treebc80bebe98bb6b710bd170c3009e3b8d43539331
parentd4b72850f66392999cfd55ae679bc79e823fbb0e (diff)
downloadqutebrowser-484dbbf0a3a4dac2c5011bc93ee832facb0a9ff8.tar.gz
qutebrowser-484dbbf0a3a4dac2c5011bc93ee832facb0a9ff8.zip
Apply MathML darkmode workaround for display math
See e.g. https://en.wikipedia.org/wiki/Gradient#General_coordinates (cherry picked from commit 5e2fe7924e7de7fce6421b5399a3b633cff8b5a0)
-rw-r--r--qutebrowser/browser/shared.py3
-rw-r--r--tests/end2end/data/darkmode/mathml-display.html23
-rw-r--r--tests/end2end/data/darkmode/mathml-inline.html (renamed from tests/end2end/data/darkmode/mathml.html)0
-rw-r--r--tests/end2end/test_invocations.py5
4 files changed, 28 insertions, 3 deletions
diff --git a/qutebrowser/browser/shared.py b/qutebrowser/browser/shared.py
index f195bbf28..3ea323d96 100644
--- a/qutebrowser/browser/shared.py
+++ b/qutebrowser/browser/shared.py
@@ -341,7 +341,8 @@ def get_user_stylesheet(searching=False):
'misc-mathml-darkmode' not in config.val.content.site_specific_quirks.skip):
# WORKAROUND for MathML-output on Wikipedia being black on black.
# See https://bugs.chromium.org/p/chromium/issues/detail?id=1126606
- css += '\nimg.mwe-math-fallback-image-inline { filter: invert(100%); }'
+ css += ('\nimg.mwe-math-fallback-image-inline, '
+ 'img.mwe-math-fallback-image-display { filter: invert(100%); }')
return css
diff --git a/tests/end2end/data/darkmode/mathml-display.html b/tests/end2end/data/darkmode/mathml-display.html
new file mode 100644
index 000000000..f0c280cca
--- /dev/null
+++ b/tests/end2end/data/darkmode/mathml-display.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>MathML-like SVG</title>
+ </head>
+ <body style="margin: 0; background-color: #ffff99">
+ <!--
+ Image based on: https://en.wikipedia.org/wiki/Pythagorean_theorem
+ with a black square added for testing.
+
+ onload based on:
+ https://stackoverflow.com/questions/53423742/waiting-for-an-image-to-finish-rendering
+ -->
+ <img
+ class="mwe-math-fallback-image-display"
+ src="mathml.svg"
+ alt="Pythagorean theorem"
+ onload="requestAnimationFrame(() => requestAnimationFrame(() => console.log('Image loaded')));"
+ >
+ <!-- -->
+ </body>
+</html>
diff --git a/tests/end2end/data/darkmode/mathml.html b/tests/end2end/data/darkmode/mathml-inline.html
index fa2371638..fa2371638 100644
--- a/tests/end2end/data/darkmode/mathml.html
+++ b/tests/end2end/data/darkmode/mathml-inline.html
diff --git a/tests/end2end/test_invocations.py b/tests/end2end/test_invocations.py
index 43809cfd4..667a4ee72 100644
--- a/tests/end2end/test_invocations.py
+++ b/tests/end2end/test_invocations.py
@@ -723,7 +723,8 @@ def test_dark_mode(webengine_versions, quteproc_new, request,
)
-def test_dark_mode_mathml(quteproc_new, request, qtbot):
+@pytest.mark.parametrize("suffix", ["inline", "display"])
+def test_dark_mode_mathml(quteproc_new, request, qtbot, suffix):
if not request.config.webengine:
pytest.skip("Skipped with QtWebKit")
@@ -734,7 +735,7 @@ def test_dark_mode_mathml(quteproc_new, request, qtbot):
]
quteproc_new.start(args)
- quteproc_new.open_path('data/darkmode/mathml.html')
+ quteproc_new.open_path(f'data/darkmode/mathml-{suffix}.html')
quteproc_new.wait_for_js('Image loaded')
# First make sure loading finished by looking outside of the image