summaryrefslogtreecommitdiff
path: root/tests/end2end/test_invocations.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/end2end/test_invocations.py')
-rw-r--r--tests/end2end/test_invocations.py175
1 files changed, 94 insertions, 81 deletions
diff --git a/tests/end2end/test_invocations.py b/tests/end2end/test_invocations.py
index 042089859..415aa5020 100644
--- a/tests/end2end/test_invocations.py
+++ b/tests/end2end/test_invocations.py
@@ -29,10 +29,10 @@ import json
import platform
import pytest
-from PyQt5.QtCore import QProcess, QPoint
+from qutebrowser.qt.core import QProcess, QPoint
from helpers import testutils
-from qutebrowser.utils import qtutils, utils
+from qutebrowser.utils import qtutils, utils, version
ascii_locale = pytest.mark.skipif(sys.hexversion >= 0x03070000,
@@ -262,7 +262,7 @@ def test_version(request):
# can't use quteproc_new here because it's confused by
# early process termination
proc = QProcess()
- proc.setProcessChannelMode(QProcess.SeparateChannels)
+ proc.setProcessChannelMode(QProcess.ProcessChannelMode.SeparateChannels)
proc.start(sys.executable, args)
ok = proc.waitForStarted(2000)
@@ -275,7 +275,7 @@ def test_version(request):
print(stderr)
assert ok
- assert proc.exitStatus() == QProcess.NormalExit
+ assert proc.exitStatus() == QProcess.ExitStatus.NormalExit
match = re.search(r'^qutebrowser\s+v\d+(\.\d+)', stdout, re.MULTILINE)
assert match is not None
@@ -412,7 +412,18 @@ def test_qute_settings_persistence(short_tmpdir, request, quteproc_new):
@pytest.mark.parametrize('value, expected', [
- ('always', 'http://localhost:(port2)/headers-link/(port)'),
+ # https://chromium-review.googlesource.com/c/chromium/src/+/2545444
+ pytest.param(
+ 'always',
+ 'http://localhost:(port2)/headers-link/(port)',
+ marks=pytest.mark.qt5_only,
+ ),
+ pytest.param(
+ 'always',
+ 'http://localhost:(port2)/',
+ marks=pytest.mark.qt6_only,
+ ),
+
('never', None),
('same-domain', 'http://localhost:(port2)/'), # None with QtWebKit
])
@@ -446,7 +457,7 @@ def test_referrer(quteproc_new, server, server2, request, value, expected):
def test_preferred_colorscheme_unsupported(request, quteproc_new):
"""Test versions without preferred-color-scheme support."""
- if request.config.webengine and qtutils.version_check('5.14'):
+ if request.config.webengine:
pytest.skip("preferred-color-scheme is supported")
args = _base_args(request.config) + ['--temp-basedir']
@@ -457,7 +468,6 @@ def test_preferred_colorscheme_unsupported(request, quteproc_new):
@pytest.mark.qtwebkit_skip
-@testutils.qt514
@pytest.mark.parametrize('value', ["dark", "light", "auto", None])
def test_preferred_colorscheme(request, quteproc_new, value):
"""Make sure the the preferred colorscheme is set."""
@@ -481,11 +491,7 @@ def test_preferred_colorscheme(request, quteproc_new, value):
None: [dark_text, light_text],
}
xfail = False
- if not qtutils.version_check('5.15.2', compiled=False):
- # On older versions, "light" is not supported, so the result will depend on the
- # environment.
- expected_values["light"].append(dark_text)
- elif qtutils.version_check('5.15.2', exact=True, compiled=False):
+ if qtutils.version_check('5.15.2', exact=True, compiled=False):
# Test the WORKAROUND https://bugreports.qt.io/browse/QTBUG-89753
# With that workaround, we should always get the light preference.
for key in ["auto", None]:
@@ -501,10 +507,13 @@ def test_preferred_colorscheme(request, quteproc_new, value):
pytest.xfail("QTBUG-89753")
-@testutils.qt514
def test_preferred_colorscheme_with_dark_mode(
request, quteproc_new, webengine_versions):
- """Test interaction between preferred-color-scheme and dark mode."""
+ """Test interaction between preferred-color-scheme and dark mode.
+
+ We would actually expect a color of 34, 34, 34 and 'Dark preference detected.'.
+ That was the behavior on Qt 5.14 and 5.15.0/.1.
+ """
if not request.config.webengine:
pytest.skip("Skipped with QtWebKit")
@@ -519,25 +528,26 @@ def test_preferred_colorscheme_with_dark_mode(
quteproc_new.open_path('data/darkmode/prefers-color-scheme.html')
content = quteproc_new.get_content()
- qtwe_version = webengine_versions.webengine
- xfail = None
- if utils.VersionNumber(5, 15, 3) <= qtwe_version <= utils.VersionNumber(6):
- # https://bugs.chromium.org/p/chromium/issues/detail?id=1177973
- # No workaround known.
- expected_text = 'Light preference detected.'
- # light website color, inverted by darkmode
- expected_color = (testutils.Color(123, 125, 123) if IS_ARM
- else testutils.Color(127, 127, 127))
- xfail = "Chromium bug 1177973"
- elif qtwe_version == utils.VersionNumber(5, 15, 2):
+ if webengine_versions.webengine == utils.VersionNumber(5, 15, 2):
# Our workaround breaks when dark mode is enabled...
# Also, for some reason, dark mode doesn't work on that page either!
expected_text = 'No preference detected.'
expected_color = testutils.Color(0, 170, 0) # green
xfail = "QTBUG-89753"
+ elif webengine_versions.webengine < utils.VersionNumber(6, 4):
+ # https://bugs.chromium.org/p/chromium/issues/detail?id=1177973
+ # No workaround known.
+ expected_text = 'Light preference detected.'
+ # light website color, inverted by darkmode
+ if webengine_versions.webengine >= utils.VersionNumber(6):
+ expected_color = (testutils.Color(148, 146, 148) if IS_ARM
+ else testutils.Color(144, 144, 144))
+ else:
+ expected_color = (testutils.Color(123, 125, 123) if IS_ARM
+ else testutils.Color(127, 127, 127))
+ xfail = "Chromium bug 1177973"
else:
- # Qt 5.14 and 5.15.0/.1 work correctly.
- # Hopefully, so does Qt 6.x in the future?
+ # Correct behavior on QtWebEngine 6.4 (and 5.14/5.15.0/5.15.1 in the past)
expected_text = 'Dark preference detected.'
expected_color = (testutils.Color(33, 32, 33) if IS_ARM
else testutils.Color(34, 34, 34)) # dark website color
@@ -557,7 +567,6 @@ def test_preferred_colorscheme_with_dark_mode(
@pytest.mark.qtwebkit_skip
@pytest.mark.parametrize('reason', [
'Explicitly enabled',
- pytest.param('Qt 5.14', marks=testutils.qt514),
'Qt version changed',
None,
])
@@ -582,9 +591,7 @@ def test_service_worker_workaround(
# Edit state file if needed
state_file = short_tmpdir / 'data' / 'state'
- if reason == 'Qt 5.14':
- state_file.remove()
- elif reason == 'Qt version changed':
+ if reason == 'Qt version changed':
parser = configparser.ConfigParser()
parser.read(state_file)
del parser['general']['qt_version']
@@ -608,7 +615,6 @@ def test_service_worker_workaround(
assert not service_worker_dir.exists()
-@testutils.qt513 # Qt 5.12 doesn't store cookies immediately
@pytest.mark.parametrize('store', [True, False])
def test_cookies_store(quteproc_new, request, short_tmpdir, store):
# Start test process
@@ -649,41 +655,57 @@ def test_cookies_store(quteproc_new, request, short_tmpdir, store):
'blank',
'lightness-cielab',
{
- ('5.15', None): testutils.Color(18, 18, 18),
- ('5.15', 'aarch64'): testutils.Color(16, 16, 16),
- ('5.14', None): testutils.Color(27, 27, 27),
- ('5.14', 'aarch64'): testutils.Color(24, 24, 24),
+ (None, None): testutils.Color(18, 18, 18),
+ (None, 'aarch64'): testutils.Color(16, 16, 16),
+ }
+ ),
+ (
+ 'blank',
+ 'lightness-hsl',
+ {
+ # FIXME:qt6 Why #121212 rather than #000000?
+ ('6.4', None): testutils.Color(18, 18, 18),
+ ('6.3', None): testutils.Color(18, 18, 18),
(None, None): testutils.Color(0, 0, 0),
}
),
- ('blank', 'lightness-hsl', {(None, None): testutils.Color(0, 0, 0)}),
- ('blank', 'brightness-rgb', {(None, None): testutils.Color(0, 0, 0)}),
+ (
+ 'blank',
+ 'brightness-rgb',
+ {
+ # FIXME:qt6 Why #121212 rather than #000000?
+ ('6.4', None): testutils.Color(18, 18, 18),
+ ('6.3', None): testutils.Color(18, 18, 18),
+ (None, None): testutils.Color(0, 0, 0)
+ }
+ ),
(
'yellow',
'lightness-cielab',
{
- ('5.15', None): testutils.Color(35, 34, 0),
- ('5.15', 'aarch64'): testutils.Color(33, 32, 0),
- ('5.14', None): testutils.Color(35, 34, 0),
- ('5.14', 'aarch64'): testutils.Color(33, 32, 0),
- (None, None): testutils.Color(204, 204, 0),
+ (None, None): testutils.Color(35, 34, 0),
+ (None, 'aarch64'): testutils.Color(33, 32, 0),
}
),
(
'yellow',
'lightness-hsl',
{
- (None, None): testutils.Color(204, 204, 0),
- (None, 'aarch64'): testutils.Color(206, 207, 0),
+ (None, None): testutils.Color(215, 215, 0),
+ (None, 'aarch64'): testutils.Color(214, 215, 0),
+ ('5.15', None): testutils.Color(204, 204, 0),
+ ('5.15', 'aarch64'): testutils.Color(206, 207, 0),
},
),
(
'yellow',
'brightness-rgb',
{
- (None, None): testutils.Color(0, 0, 204),
- (None, 'aarch64'): testutils.Color(0, 0, 206),
+ (None, None): testutils.Color(0, 0, 215),
+ (None, 'aarch64'): testutils.Color(0, 0, 214),
+ ('5.15', None): testutils.Color(0, 0, 204),
+ ('5.15', 'aarch64'): testutils.Color(0, 0, 206),
}
),
])
@@ -724,7 +746,7 @@ def test_dark_mode(webengine_versions, quteproc_new, request,
@pytest.mark.parametrize("suffix", ["inline", "display"])
-def test_dark_mode_mathml(quteproc_new, request, qtbot, suffix):
+def test_dark_mode_mathml(webengine_versions, quteproc_new, request, qtbot, suffix):
if not request.config.webengine:
pytest.skip("Skipped with QtWebKit")
@@ -739,7 +761,10 @@ def test_dark_mode_mathml(quteproc_new, request, qtbot, suffix):
quteproc_new.wait_for_js('Image loaded')
# First make sure loading finished by looking outside of the image
- expected = testutils.Color(0, 0, 206) if IS_ARM else testutils.Color(0, 0, 204)
+ if webengine_versions.webengine >= utils.VersionNumber(6):
+ expected = testutils.Color(0, 0, 214) if IS_ARM else testutils.Color(0, 0, 215)
+ else:
+ expected = testutils.Color(0, 0, 206) if IS_ARM else testutils.Color(0, 0, 204)
quteproc_new.get_screenshot(
probe_pos=QPoint(105, 0),
@@ -753,7 +778,6 @@ def test_dark_mode_mathml(quteproc_new, request, qtbot, suffix):
)
-@testutils.qt514
@pytest.mark.parametrize('value, preference', [
('true', 'Reduced motion'),
('false', 'No'),
@@ -787,8 +811,8 @@ def test_unavailable_backend(request, quteproc_new):
that the chosen backend is actually available - i.e., that the error message is
properly printed, rather than an unhandled exception.
"""
- qtwe_module = "PyQt5.QtWebEngineWidgets"
- qtwk_module = "PyQt5.QtWebKitWidgets"
+ qtwe_module = "qutebrowser.qt.webenginewidgets"
+ qtwk_module = "qutebrowser.qt.webkitwidgets"
# Note we want to try the *opposite* backend here.
if request.config.webengine:
pytest.importorskip(qtwe_module)
@@ -845,6 +869,13 @@ def test_sandboxing(
pytest.skip("Skipped with QtWebKit")
elif sandboxing == "enable-all" and testutils.disable_seccomp_bpf_sandbox():
pytest.skip("Full sandboxing not supported")
+ elif version.is_flatpak():
+ # https://github.com/flathub/io.qt.qtwebengine.BaseApp/pull/66
+ has_namespaces = False
+ expected_result = "You are NOT adequately sandboxed."
+ has_yama_non_broker = has_yama
+ else:
+ has_yama_non_broker = False
args = _base_args(request.config) + [
'--temp-basedir',
@@ -866,39 +897,21 @@ def test_sandboxing(
bpf_text = "Seccomp-BPF sandbox"
yama_text = "Ptrace Protection with Yama LSM"
- if "\n\n\n" in text:
- # Qt 5.12
- header, rest = text.split("\n", maxsplit=1)
- rest, result = rest.rsplit("\n\n", maxsplit=1)
- lines = rest.replace("\t\n", "\t").split("\n\n\n")
-
- expected_status = {
- "Namespace Sandbox": "Yes" if has_namespaces else "No",
- "Network namespaces": "Yes" if has_namespaces else "No",
- "PID namespaces": "Yes" if has_namespaces else "No",
- "SUID Sandbox": "No",
+ header, *lines, empty, result = text.split("\n")
+ assert not empty
- bpf_text: "Yes" if has_seccomp else "No",
- f"{bpf_text} supports TSYNC": "Yes" if has_seccomp else "No",
+ expected_status = {
+ "Layer 1 Sandbox": "Namespace" if has_namespaces else "None",
- "Yama LSM Enforcing": "Yes" if has_yama else "No",
- }
- else:
- header, *lines, empty, result = text.split("\n")
- assert not empty
+ "PID namespaces": "Yes" if has_namespaces else "No",
+ "Network namespaces": "Yes" if has_namespaces else "No",
- expected_status = {
- "Layer 1 Sandbox": "Namespace" if has_namespaces else "None",
+ bpf_text: "Yes" if has_seccomp else "No",
+ f"{bpf_text} supports TSYNC": "Yes" if has_seccomp else "No",
- "PID namespaces": "Yes" if has_namespaces else "No",
- "Network namespaces": "Yes" if has_namespaces else "No",
-
- bpf_text: "Yes" if has_seccomp else "No",
- f"{bpf_text} supports TSYNC": "Yes" if has_seccomp else "No",
-
- f"{yama_text} (Broker)": "Yes" if has_yama else "No",
- f"{yama_text} (Non-broker)": "No",
- }
+ f"{yama_text} (Broker)": "Yes" if has_yama else "No",
+ f"{yama_text} (Non-broker)": "Yes" if has_yama_non_broker else "No",
+ }
assert header == "Sandbox Status"
assert result == expected_result