darkmode: Improve test for prefers-color-scheme

This commit is contained in:
Florian Bruhin 2021-02-11 12:16:33 +01:00
parent 4120a37953
commit 3c47736165
2 changed files with 67 additions and 2 deletions

View File

@ -0,0 +1,64 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Prefers colorscheme test</title>
<style>
body {
background: #aa0000;
}
#dark-text {
display: none;
}
#light-text {
display: none;
}
#no-preference-text {
display: none;
}
@media (prefers-color-scheme: dark) {
body {
background: #222222;
color: #ffffff;
}
#dark-text {
display: inline;
}
#missing-support-text {
display: none;
}
}
@media (prefers-color-scheme: light) {
body {
background: #dddddd;
}
#light-text {
display: inline;
}
#missing-support-text {
display: none;
}
}
@media (prefers-color-scheme: no-preference) {
body {
background: #00aa00;
}
#no-preference-text {
display: inline;
}
#missing-support-text {
display: none;
}
}
</style>
</head>
<body>
<p id="dark-text">Dark preference detected.</p>
<p id="light-text">Light preference detected.</p>
<p id="no-preference-text">No preference detected.</p>
<p id="missing-support-text">Preference support missing.</p>
</body>
</html>

View File

@ -436,8 +436,9 @@ def test_preferred_colorscheme(request, quteproc_new):
]
quteproc_new.start(args)
quteproc_new.send_cmd(':jseval matchMedia("(prefers-color-scheme: dark)").matches')
quteproc_new.wait_for(message='True')
quteproc_new.open_path('data/darkmode/prefers-color-scheme.html')
content = quteproc_new.get_content()
assert content == "Dark preference detected."
@pytest.mark.qtwebkit_skip