Commit Graph

6841 Commits

Author SHA1 Message Date
Florian Bruhin 7315c34957 Add support for hinting elements inside shadow DOMs
Supersedes and closes #7617
See #3569 (fixed partially)
2025-07-01 16:49:10 +02:00
Florian Bruhin e7af54898e Add X11/Wayland information to version info
Unfortunately there is no way to get this information from Qt, so I had to
resort to some funny low-level C-like Python programming to directly use
libwayland-client and Xlib. Fun was had! Hopefully this avoids having to ask
for this information every time someone shows a bug/crash report, as there
are various subtleties that can be specific to the Wayland compositor in use.
2025-06-25 09:34:35 +02:00
Florian Bruhin 5e565f4dc7 Fix PermissionElement tests 2025-06-16 22:27:55 +02:00
Florian Bruhin a45d57feee tests: Adjust ignored log message for newer Chromium
QtWebEngine 6.9 seems to use webengine/DawnWebGPUCache/ instead of DawnCache/
2025-06-06 12:53:10 +02:00
Florian Bruhin eca17870ae tests: Extend Qt 6.9.0 workaround to .1
Still seems to be failing, see https://github.com/qutebrowser/qutebrowser/issues/8444#issuecomment-2569610110
2025-06-06 11:30:27 +02:00
Florian Bruhin 959dc5a9e5 tests: Correctly deactivate SignalHandler after tests
Otherwise, the python_hacks timer might continue running
and affects test_early_timeout_check, similiarly to what was fixed in
74c7ff2641.
2025-06-06 10:53:38 +02:00
Florian Bruhin 55ca67f3e2 tests: Stop hardcoding indices for module versions 2025-06-06 08:49:28 +02:00
Florian Bruhin 6b86a9072f version: Rely on importlib.metadata.version too
Packages are slowly migrating to not having a __version__ attribute anymore,
instead relying on importlib.metadata to query the installed version.

jinja2 now shows a deprecation warning when accessing the __version__
attribute: https://github.com/pallets/jinja/pull/2098

For now we keep accessing __version__ for other packages (we still need the
logic for PyQt and its special version attributes anyways), but we fall back on
importlib.metadata.version if we can't get a version that way, and we stop
trying __version__ for jinja2.
2025-06-06 08:47:00 +02:00
Florian Bruhin c1e7b6e8f3 tests: Ignore test_restart hang on Windows 2025-06-05 15:09:57 +02:00
Florian Bruhin 2e343403de tests: Ignore another bogus Chromium log message 2025-06-05 15:08:00 +02:00
Florian Bruhin 3f31a0005a Fix mimetype for PDF.js files on Windows
With windows-2022 and windows-2025 on GitHub Actions,
we get:

    qutescheme:data_for_url:128 url: qute://pdfjs/web/viewer.mjs, path: /web/viewer.mjs, host pdfjs
    webenginequtescheme:requestStarted:105 Returning text/plain data

which causes:

    JS: [qute://pdfjs/build/pdf.mjs:0] Failed to load module script: Expected a
    JavaScript module script but the server responded with a MIME type of
    "text/plain". Strict MIME type checking is enforced for module scripts per
    HTML spec.

It's unclear why we get text/plain back there in the first place (can't
reproduce on a local Windows 11 install), but it's definitely wrong, so let's
just override that problematic case.
2025-06-05 13:41:28 +02:00
Florian Bruhin 072b03a631 Avoid version warnings with PyQtWebEngine-Qt5 5.15.17
With PyQtWebEngine-Qt5 5.15.17 (Qt 5.15.19), we seem to run into similar issues
like we already did with Qt 6.5:

https://github.com/qutebrowser/qutebrowser/issues/7624#issuecomment-1474008470
9cb54b2099

However, skipping the ELF test is not enough, as we also get warnings
at runtime (as we don't have any API to get the version at runtime).

We don't care much about Qt 5 at this stage, so let's just not output
warnings in that case (and nothing in the code should care about the exact
QtWebEngine patch level beyond 5.15.2 anyways).

For most user-facing things, we *can* get the exact version number from
the user-agent, so this should not actually affect much.
2025-05-29 23:42:40 +02:00
Florian Bruhin c682ccb1b2 tests: Ignore more libEGL warnings 2025-05-08 10:17:03 +02:00
Florian Bruhin 74c7ff2641 tests: Properly delete webengine DownloadManager objects
We create the DownloadManager with parent=qapp, which means they will stick
around forever after the test finished.

While we disconnect the QWebEngineProfile::downloadRequested() signal,
we keep the DownloadManager around, which also keeps around its download-update
timers.

Those will then result in tests/unit/utils/usertypes/test_timer.py::test_early_timeout_check
being flaky, as their _validity_check_handler slot keeps getting called in the
background. Due to the globally mocked time.monotonic(), this results in
nonsensical error messages such as:

    Got logging message on logger misc with level WARNING:
    Timer download-update (id ...) triggered too early:
    interval 500 but only -1023.269s passed!

After this change, we now clean up those objects properly, thus fixing the
flakiness.

See #5390.
2025-05-07 14:06:03 +02:00
Florian Bruhin a4b3ca48df tests: Add sanity check for stray timer objects
This makes sure the test consistently fails if there is still some timer in the
background, instead of getting flaky.
2025-05-07 13:39:48 +02:00
Florian Bruhin 9f16a1f879 tests: Properly delete mode_manager instances
To fix a flaky tests/unit/utils/usertypes/test_timer.py::test_early_timeout_check
(where a download-update timer from an earlier test fails), I looked into what
usertypes.Timer instances where left over after a test finished.

It turns out that there were about 190 still existing "partial-match" and
"normal-inhibited" timers when breaking in test_timer.py, even when just running
tests in tests/unit/browser/ and tests/unit/utils/usertypes.

This is because we pass qapp as parent to the ModeManager we create, but that
means it will be forever alive if we don't take care of cleaning it up after a
test.

Perhaps our tests should have some sort of mechanism that checks whether there
are any "leftovers" after a test has finished (perhaps even as part of
pytest-qt?), but for now, let's just fix the issues we can directly see.
2025-05-07 13:22:10 +02:00
Florian Bruhin aa41b6719f tests: Ignore another message 2025-04-13 14:53:21 +02:00
Florian Bruhin 9aa53ea205 tests: Wait for tab-close being run properly
Leaks into the next test otherwise, making it flaky.
2025-04-12 21:28:30 +02:00
Florian Bruhin 7bc6c33bb5 Reapply "tests: Try to stabilize test_auto_leave_insert_mode"
This reverts commit 1d2faf2fa2.

This seems to be correct, the issue is the previous test not waiting until it's
finished properly.
2025-04-12 21:25:11 +02:00
Florian Bruhin 9e0f7ccc51 tests: Make sure we don't leave stale download managers behind
Speculative fix for test_early_timeout_handler in
tests/unit/utils/usertypes/test_timer.py failing:

    >  assert len(caplog.messages) == 1
    E  AssertionError: assert 5 == 1

due to:

    ------------------------------ Captured log call -------------------------------
    WARNING  misc:usertypes.py:467 Timer download-update (id 620757000) triggered too early: interval 500 but only -609.805s passed
    WARNING  misc:usertypes.py:467 Timer download-update (id 922746881) triggered too early: interval 500 but only -609.429s passed
    WARNING  misc:usertypes.py:467 Timer download-update (id 1056964613) triggered too early: interval 500 but only -609.537s passed
    WARNING  misc:usertypes.py:467 Timer download-update (id 1912602631) triggered too early: interval 500 but only -609.671s passed
    WARNING  misc:usertypes.py:467 Timer t (id -1) triggered too early: interval 3 but only 0.001s passed
2025-04-12 21:16:30 +02:00
Florian Bruhin 1d2faf2fa2 Revert "tests: Try to stabilize test_auto_leave_insert_mode"
This reverts commit f6f2a1252b.

Does more harm than good, for reasons I don't entirely understand yet.
2025-04-11 19:45:41 +02:00
Florian Bruhin f6f2a1252b tests: Try to stabilize test_auto_leave_insert_mode
We sometimes tried to use hints before the page was fully rendered (?), thus
causing no elements to be found.

It also doesn't make much sense to test leaving insert mode if we aren't in
insert mode yet, so make sure we entered it first.

See #5390
2025-04-11 17:28:31 +02:00
Florian Bruhin 86c89e00c5 Qt 6.9: Skip more qutescheme tests
If the renderer process crash happens, rerunning
doesn't seem to fix anything, even if the page is
opened in a new tab.

See #8536
2025-04-11 17:18:51 +02:00
Florian Bruhin 4f4ad4147a Revert "tests: Try to combat Qt 6.9 flakiness more"
This reverts commit 7204168684.

Doesn't actually help on CI...
2025-04-11 17:18:32 +02:00
Florian Bruhin 7204168684 tests: Try to combat Qt 6.9 flakiness more
See #8536
2025-04-11 16:00:45 +02:00
Florian Bruhin 4053249229 tests: Fix deprecated usage 2025-04-08 21:11:43 +02:00
Florian Bruhin afeb1ebbaa tests: Fix TestYamlMigrations.test_user_agent 2025-04-08 20:50:13 +02:00
Florian Bruhin 6b5ebe7187 Add a test for js_async crash
Follow-up to c32f5afcc4
See #3895 and #8400.
2025-04-08 20:47:54 +02:00
Florian Bruhin b5a399831b tests: Disable MAP_DISCARD workaround for fixed Qt versions 2025-04-08 19:42:16 +02:00
Florian Bruhin bbdf9faf5e Qt 6.9: Mark one more test as flaky 2025-04-08 14:37:51 +02:00
Florian Bruhin d9d8701696 Fix flake8 2025-04-08 14:36:34 +02:00
Florian Bruhin 3280c8dacc tests: Avoid CI issues with qutescheme and Qt 6.9
see #8536
2025-04-08 14:03:26 +02:00
Florian Bruhin 54b6c92713 Python 3.14: Skip newly added stdlib file test
See #8529
2025-04-08 12:35:51 +02:00
Florian Bruhin ef2ceccd29 Qt 6.9: Work around QtWebEngine not handling <permission> element
See #8539
2025-04-07 21:58:45 +02:00
Florian Bruhin 163bb9fa0c Python 3.14: Update cheroot workaround
https://github.com/cherrypy/cheroot/issues/734
https://github.com/python/cpython/issues/129354
Part of #8529
2025-04-02 12:52:24 +02:00
Florian Bruhin 1ab93bad33
Merge pull request #8329 from VitoMinheere/7966-tab-move-zero-division-error
Fix zero division bug in tab-move +
2025-03-31 13:39:35 +02:00
Florian Bruhin 69f0eae600 Drop unneeded nonlocal 2025-03-31 08:44:45 +02:00
Florian Bruhin b6d5a5cf14 Fix and simplify JS quirks tests 2025-03-25 14:23:48 +01:00
Florian Bruhin a460770414 tests: Adjust qt69_ci_flaky 2025-03-21 11:29:32 +01:00
Florian Bruhin b43c79989e pdfjs: Add new no-system-pdfjs debug flag
This can be used to easily test a different PDF.js version manually (which is
installed via update_3rdparty.py), without having to uninstall the system-wide
one first.
2025-03-21 10:42:17 +01:00
Florian Bruhin b0e05ee160 Qt 6.9: Only disable software rendering for darkmode tests
Looks like the "tests hanging" issue was fixed between Beta 3 and RC.

See #8444
2025-03-15 16:49:43 +01:00
Florian Bruhin e3db31e29e tests: Match message properly for invalid URL
pytest now warns about it, which fails bleeding tests:
2c8cd64d5f
2025-03-15 12:25:43 +01:00
Florian Bruhin 7ad4bb70fe Shorten Chromium version in UA by default
Fixes #8426
2025-03-12 15:25:55 +01:00
Florian Bruhin b271559f82 tests: Fix without explicit platform 2025-03-12 15:02:22 +01:00
Florian Bruhin 51541add20 Fix lint 2025-03-12 14:44:19 +01:00
Florian Bruhin 328b5966ef Add initial support for running tests offscreen
Makes

    QT_QPA_PLATFORM=offscreen pytest

pass.

See #4914
2025-03-12 14:41:50 +01:00
Florian Bruhin 4cc67d3603 Qt 6.9: Force software rendering for tests
Not yet quite sure what exactly is the culprit, but this seems to help for all
tests (!) to pass with Xvfb locally.

For now only scoped to Qt 6.9.0. Will probably already need to reevaluate with
the RC, but definitely with the final release.

See #8444
2025-03-12 14:41:32 +01:00
Florian Bruhin 8c2cfe8f7e tests: Fix handling of qapp_args
Until now, if the seccomp bpf sandbox needs to be disabled,
PaintHoldingCrossOrigin was not disabled anymore.
2025-03-12 11:32:22 +01:00
Florian Bruhin c35fc88211 tests: Disable BPF sandbox with glibc 2.41
Fixes #8507
2025-03-12 11:29:12 +01:00
Florian Bruhin 561986cad8 tests: Clear messages between test cases
Makes watching the UI (or screenshots) more useful as we don't have any
leftovers from previous tests.
2025-03-11 18:51:12 +01:00