diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-03-12 18:12:45 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-03-12 18:18:59 +0100 |
commit | d38ee4effdd8a064654f9a3c3e654e58cd4f8748 (patch) | |
tree | 501e52dad52916682a1813d7c480dbb3264db57b | |
parent | 368ed9a4bb56c913c36e8031c59bbf46ec84017d (diff) | |
download | qutebrowser-d38ee4effdd8a064654f9a3c3e654e58cd4f8748.tar.gz qutebrowser-d38ee4effdd8a064654f9a3c3e654e58cd4f8748.zip |
Stabilize darkmode mathml test
(cherry picked from commit 54d2ca2a071d3d30266097d7c79e6b1bb82b4a95)
-rw-r--r-- | tests/end2end/data/darkmode/mathml.html | 13 | ||||
-rw-r--r-- | tests/end2end/test_invocations.py | 30 |
2 files changed, 37 insertions, 6 deletions
diff --git a/tests/end2end/data/darkmode/mathml.html b/tests/end2end/data/darkmode/mathml.html index 4a7cd548c..fa2371638 100644 --- a/tests/end2end/data/darkmode/mathml.html +++ b/tests/end2end/data/darkmode/mathml.html @@ -4,11 +4,20 @@ <meta charset="utf-8"> <title>MathML-like SVG</title> </head> - <body style="margin: 0"> + <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-inline" src="mathml.svg" alt="Pythagorean theorem"> + <img + class="mwe-math-fallback-image-inline" + src="mathml.svg" + alt="Pythagorean theorem" + onload="requestAnimationFrame(() => requestAnimationFrame(() => console.log('Image loaded')));" + > + <!-- --> </body> </html> diff --git a/tests/end2end/test_invocations.py b/tests/end2end/test_invocations.py index f55bfbd51..6875db452 100644 --- a/tests/end2end/test_invocations.py +++ b/tests/end2end/test_invocations.py @@ -645,8 +645,6 @@ def test_cookies_store(quteproc_new, request, short_tmpdir, store): ), ('yellow', 'lightness-hsl', {None: testutils.Color(204, 204, 0)}), ('yellow', 'brightness-rgb', {None: testutils.Color(0, 0, 204)}), - - ('mathml', None, {None: testutils.Color(255, 255, 255)}), ]) def test_dark_mode(webengine_versions, quteproc_new, request, filename, algorithm, colors): @@ -656,9 +654,8 @@ def test_dark_mode(webengine_versions, quteproc_new, request, args = _base_args(request.config) + [ '--temp-basedir', '-s', 'colors.webpage.darkmode.enabled', 'true', + '-s', 'colors.webpage.darkmode.algorithm', algorithm, ] - if algorithm is not None: - args += ['-s', 'colors.webpage.darkmode.algorithm', algorithm] quteproc_new.start(args) ver = webengine_versions.webengine @@ -677,6 +674,31 @@ def test_dark_mode(webengine_versions, quteproc_new, request, assert color == expected +def test_dark_mode_mathml(quteproc_new, request, qtbot): + if not request.config.webengine: + pytest.skip("Skipped with QtWebKit") + + args = _base_args(request.config) + [ + '--temp-basedir', + '-s', 'colors.webpage.darkmode.enabled', 'true', + '-s', 'colors.webpage.darkmode.algorithm', 'brightness-rgb', + ] + quteproc_new.start(args) + + quteproc_new.open_path('data/darkmode/mathml.html') + quteproc_new.wait_for_js('Image loaded') + + # First make sure loading finished by looking outside of the image + img = quteproc_new.get_screenshot( + probe_pos=QPoint(105, 0), + probe_color=testutils.Color(0, 0, 204), + ) + + # Then get the actual formula color + color = testutils.Color(img.pixelColor(QPoint(4, 4))) + assert color == testutils.Color(255, 255, 255) + + def test_unavailable_backend(request, quteproc_new): """Test starting with a backend which isn't available. |