diff options
author | Florian Bruhin <me@the-compiler.org> | 2022-05-12 10:09:09 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2022-05-12 10:10:49 +0200 |
commit | 5e2fe7924e7de7fce6421b5399a3b633cff8b5a0 (patch) | |
tree | 8584898569b3aae1336e5d5dd4927a7a9e6663cc | |
parent | 047a44c4c154125d248464813bb8fff5fd3ea9b5 (diff) | |
download | qutebrowser-5e2fe7924e7de7fce6421b5399a3b633cff8b5a0.tar.gz qutebrowser-5e2fe7924e7de7fce6421b5399a3b633cff8b5a0.zip |
Apply MathML darkmode workaround for display math
See e.g. https://en.wikipedia.org/wiki/Gradient#General_coordinates
-rw-r--r-- | qutebrowser/browser/shared.py | 3 | ||||
-rw-r--r-- | tests/end2end/data/darkmode/mathml-display.html | 23 | ||||
-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.py | 5 |
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 0d49ff109..5a34d0357 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 |