Commit Graph

6664 Commits

Author SHA1 Message Date
toofar 26dcc4a7a9 Add a :window-only for some qt5 end2end tests
A couple of tests seem to be failing because there is two windows open and
they don't expect it. I haven't fixed the root cause, I looked through the
logs and couldn't see why a second window was open. But if this makes the
tests pass, I guess we can address that if someone reports it.

Also changed `_get_scroll_values()` to handle multiple tabs/windows being open
too while I was there.

Example logs: https://github.com/qutebrowser/qutebrowser/actions/runs/8548730512/job/23422922448
Sessions file from the test logs:

  Current session data:
  windows:
  - geometry: !!binary |
      AdnQywADAAAAAAAyAAAAMgAAA1EAAAKJAAAAMgAAADIAAANRAAACiQAAAAAAAAAAAyAAAAAyAAAA
      MgAAA1EAAAKJ
    tabs:
    - active: true
      history:
      - active: true
        last_visited: '2024-04-04T03:21:00'
        pinned: false
        scroll-pos:
          x: 0
          y: 0
        title: about:blank
        url: about:blank
        zoom: 1.0
  - active: true
    geometry: !!binary |
      AdnQywADAAAAAAAyAAAAMgAAA1EAAAKJAAAAMgAAADIAAANRAAACiQAAAAAAAAAAAyAAAAAyAAAA
      MgAAA1EAAAKJ
    tabs:
    - active: true
      history:
      - active: true
        last_visited: '2024-04-04T03:21:03'
        pinned: false
        scroll-pos:
          x: 0
          y: 40
        title: Scrolling
        url: http://localhost:39235/data/scroll/simple.html
        zoom: 1.0
2024-04-06 12:05:31 +13:00
Florian Bruhin 713a4e5ec2 Fix caret tests on Qt 6 and Windows 2024-03-27 19:49:09 +01:00
Florian Bruhin 7a969a2d54 Add caret browsing debug logging 2024-03-27 16:55:18 +01:00
Florian Bruhin 481542844d tests: Avoid using autofocus for click_element tests
Similarly to the last commit (982b8bdcec),
we run into a race between autofocus triggering and the test trying to
click the focused element.

This also affects the "when there is none" test, which loses the focus
before it has been set, thus ending up with a focused element but expecting
none.

We fix both in one go by manually focusing things with a tab keypress
instead of using autofocus.

See #8145 and #5390.
2024-03-27 13:05:28 +01:00
Florian Bruhin 982b8bdcec Fix input.insert_mode.auto_load race / test_auto_load flakiness
Fixes #8145, see #5390.

As long as we don't have a solution to get notified about focus happening
(#2471 possibly?), it looks like there is no better way to get notified
about this, so a delay will need to do for now.
2024-03-27 12:34:30 +01:00
Florian Bruhin 0b220117e2 tests: Fix glob matching 2024-03-26 14:30:20 +01:00
Florian Bruhin 6ee7a23c7e tests: Ignore new SSL error message
Seems to break in bleeding edge tests
2024-03-26 14:15:09 +01:00
Florian Bruhin 1ee138b681 qtutils: Handle QDataStream.Status.SizeLimitExceeded 2024-03-25 23:29:24 +01:00
Florian Bruhin a45cfb89cb tests: Add new ignored error messages 2024-03-25 23:05:25 +01:00
Florian Bruhin ad3ba9fe84 tests: Avoid accessing Qt statics at import time
With a Qt 6.7 developer build, the tests fail with:

    ASSERT failure in QtGlobalStatic::ApplicationHolder<QAS>::PlainType*
    QtGlobalStatic::ApplicationHolder<QAS>::pointer() [with QAS =
    {anonymous}::Q_QAS_qtlsbLoader; PlainType = QFactoryLoader]: "The
    application static was used without a QCoreApplication instance", file
    .../qtbase/src/corelib/kernel/qapplicationstatic.h, line 54

    Fatal Python error: Aborted

    [...]

    Current thread 0x00007c18bb3f3740 (most recent call first):
    File ".../tests/unit/browser/webkit/test_certificateerror.py", line 23 in <module>

See https://codereview.qt-project.org/c/qt/qtbase/+/495239
2024-03-25 23:05:16 +01:00
toofar 145bfe4de0 windows doesn't support SIGHUP
It gives an AttributeError for both signal.SIGHUP and
signal.Signals.SIGHUP. The Signals Enum is set up so you can use the
strings to key into it though, so that's nice. I was tempted to use a
walrus operator here but I think that's python 310 and I don't remember
what our minimum supported version is.
2024-02-25 15:56:34 +13:00
toofar f6c0e4ebc8 Add some basic tests for SignalHandler
It doesn't look like this class has any unit tests currently. And since
we are adding a new signal handler to it I took the opportunity to add a
few tests to it to establish a bit of a framework so that next time we
touch it it will be easier to add more.

I didn't go for full coverage here. It's an improvement over what was
there previously and it should make merging more palatable. I don't
think handling SIGHUP is a very risky feature.

I chose to use mocker.patch over monkeypatch.setattr because I think it
provides a more friendly and powerful API due to being more tightly
integrated with magic mocks. And with `mocker.patch.object` you can even
use actual object names instead of strings, the same as monkeypatch
allows.

One thing I'm less confident with here is mocking all multiple things in
a couple of fixtures. Writing one fixture for each little thing I mock
doesn't feel appealing to me right now, but for mocks that tests need to
access there isn't really any idiomatic way to let the tests access
them. I previously just had the one fixture but pulled out the read
config one for that purpose. It's a pattern I'll have to think on a bit
I think. Probably having to have developers thing about the balance of
boilerplate vs accessibility is cognitive load that we want to avoid.
Hmm.

Anyway, here are the options I was looking at to let test code access
mocks that where all shoved away into the one fixture:

1. group the tests into a class and put the mocks in class variables:
   could work fine but I don't think it's very idiomatic for pytest?
2. return some kind of meta object from the fixture that has the object
   under test as one attribute and the mocks as other ones: hmm,
   returning multiple values from a method always seemed a bit smelly to
   me
3. make one fixture for each of the mocks, have the main fixture depend
   on them all, tests that need to modify them can depend on them too:
   writing all those fixtures seems tedious and I don't think it would
   be a clear win in terms of readability. *sigh*, I suppose I should
   pull the ones I'm modifying out at least so other people don't copy
   my lazyness in the future
4. have the test code access the mocks from the real code, eg
   `configfiles.sys.exit.side_effect = ...`: this works fine but I feel
   like it's relying on an implementation detail and probably shouldn't
   be encouraged? Not sure

In case anyone is struggling with git blame and wondering what the
QSocketNotifier stuff is about, this commit should explain it: 210ce8ca7c
2024-02-24 23:23:42 +13:00
Florian Bruhin ee9aecda46 listcategory: Fix O(n^2) performance if no match
With the change in #7955, if the regex did not match, it ended up retrying the
lookahead at every position of the string (expected), but then *also* repeated
that process for every position in the string. Thus, a non-matching pattern
ended up in O(n^2) performance (with n = length of URL).

Instead, anchor the pattern at the beginning of the string. This doesn't change
behaviour as we use .* at the beginning of every lookahead anyways, but it means
we end up with O(n) instead of O(n^2) performance.

Co-authored-by: toofar <toofar@spalge.com>
2024-01-12 18:53:22 +01:00
Florian Bruhin f8df682b90 Reapply "Merge pull request #7955 from arza-zara/search_any_order"
This reverts commit 45d483479a.
2024-01-12 18:53:22 +01:00
Florian Bruhin 45d483479a Revert "Merge pull request #7955 from arza-zara/search_any_order"
This reverts commit fe1faa14b9, reversing
changes made to 04af4c657d.

For my setup with 310 quickmarks and 94 bookmarks, this makes qutebrowser hang
for around a minute on every keypress.
2024-01-11 17:30:27 +01:00
Florian Bruhin 4b11776f76 tests: Upgrade our hook implementation for pytest 7
https://docs.pytest.org/en/7.4.x/deprecations.html#py-path-local-arguments-for-hooks-replaced-with-pathlib-path
https://docs.pytest.org/en/7.4.x/reference/reference.html#std-hook-pytest_ignore_collect

8.0.0 removes the "path" compatibility alias we used.
2024-01-10 14:41:39 +01:00
Florian Bruhin 1ad6b68d33 tests: Ignore yet another mesa (?) warning
As shown in detail by toofar in dff25d10bc,
mesa 23.3 seems to trigger some new error messages.

On my setup locally, it also triggers the warning that's ignored here.

Why that's not the case on CI or for others is unclear to me, I gave up
trying to understand graphics stuff on Linux.

I'll just presume this is the same underlying cause, and refer to the
commit message of the commit above for more details.
2024-01-10 14:33:26 +01:00
toofar dff25d10bc Ignore mesa "error" logs
Mesa upgraded from 23.2.1-2 to 23.3.1-1 a couple of days ago. Since then
there has been some non-fatal InvalidLine errors in the CI jobs (eg
https://github.com/qutebrowser/qutebrowser/actions/runs/7281982007/job/19843511920)

Based on https://gitlab.freedesktop.org/mesa/mesa/-/issues/10293 I'm
assuming these log messages don't actually indicate errors and the tests
pass when they are ignore.

Weirdly, I'm only seeing these errors related to the
`tests/end2end/test_invocations.py::test_misconfigured_user_dirs` test,
I'm not sure why. It doesn't look much different from the ones around
it.

Possibly we could ignore these lines just for that test, or maybe play
round with it more to find out why it is different. But since the lines
are non fatal I'll just ignore them everywhere. I'm a little worried
about that because they are quite generic, but at least they are still
logged when they are ignored.

They might change these error logs messages to be warning log messages
based on that issue. But it'll probably still fail the tests since we
match on all log lines?

The "always try zink" change was introduced in https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25640
It looks like there might be a `LIBGL_KOPPER_DISABLE` which may skip
this behaviour. Not I'm not sure, the commit message says:

> don't load non-sw zink without dri3 support
> this is going to be broken, so don't bother trying
> also add LIBGL_KOPPER_DRI2 so people can continue to footgun if they
> really really want to

I assume we aren't trying to run with non-sw zink but with non-zink sw?
idk

Maybe we should be setting force_software_rendering=software-opengl or
LIBGL_ALWAYS_SOFTWARE instead so that it never tries to use the vulkan
backed zink?
2023-12-21 15:21:19 +13:00
toofar fe1faa14b9 Merge pull request #7955 from arza-zara/search_any_order
A few more completions will now match search terms in any order:
`:quickmark-*`, `:bookmark-*`, `:tab-take` and `:tab-select` (for the quick
and bookmark categories).
2023-12-21 12:28:22 +13:00
Florian Bruhin 9d8c263e9a Extend pakjoy to Qt 6.5.0/.1/.2 with dark mode
See #7837
2023-12-05 13:46:02 +01:00
Florian Bruhin b40e1861c3 Fix lint and tests 2023-12-04 19:55:06 +01:00
Florian Bruhin 21c7699eac Add content.javascript.legacy_touch_events setting
Closes #7814
2023-12-04 16:44:56 +01:00
Florian Bruhin 8cd06741bb Expose QtWebEngine 6.6 dark mode image classifier policy
Implemented as a separate setting in Chromium, but exposed to qutebrowser users
as a value for `policy.images`, as it's a simple toggle that does not have any
effect when `policy.images` is not set to `smart` anyways.

To support this, the _Settings.mapping value now supports None values,
which leads to _Setting.chromium_tuple to return None, which means that
no switch is added in this case.

See #7646
2023-12-04 14:28:22 +01:00
Florian Bruhin 2a10461ca4 Remove dark mode settings removed from Chromium
Closes #7929
2023-12-04 13:39:52 +01:00
Florian Bruhin 0aa57e4f72 Merge remote-tracking branch 'origin/pr/7935' 2023-12-04 12:46:51 +01:00
Florian Bruhin 1d29cf641b Simplify get_pdfjs test
Given that the two branches share rather little, it seems simpler to separate the two tests. Also use monkeypatch, since we don't use any of unittest.mock's complexity
2023-12-04 10:46:30 +01:00
toofar 23a1689262 Merge branch 'main' into pr/7992
This is just to get the CI to re-trigger.

Apparently the checkout action doesn't actually checkout the branch
being proposed for merge but checks out an actual merge commit. So if
you push a PR while main is broken it'll say changes from main are on
your branch. That's a little unexpected.

main is fixed now and I tried re-running the CI jobs from the web UI but
they are still failing with the same errors. Hence this merge of main
just to get a change on the branch. I could have gone and found a typo
to fix instead. I know I've left enough of them around.

ref: https://github.com/actions/checkout/issues/881
2023-12-02 13:36:14 +13:00
toofar 75c78cadc4 Always disable accelerated canvas if set to auto on Qt6
We thought #7489 would be fixed on chrome 112 but it appears to still be
an issue. As discussed on the issue, it's not clear how many workflows
would be affected by accelerated 2d canvas and we don't have enough data
to detect the affected graphics configurations. So lets just disable
accelerated 2d canvas by default and users who want it turned on can do
so via the setting.

If some major use case pops up to enable this by default where possible
we can revisit and think of more nuanced feature detection.

I've kept the handling of callable values of `_WEBENGINE_SETTINGS`
because I don't like have to have something like
`--disable-accelerated-2d-canvas` written in code twice. The setting
above this one could probably be changed to use it too.
2023-12-02 12:53:44 +13:00
toofar 1aa3c952ab pakjoy: fix happy path test
read back the manifest inside the context manager so we can find the
work dir.
2023-12-02 12:41:23 +13:00
toofar 7d5acb6970 Add test for get_pdfjs_js_path() 2023-12-02 12:22:31 +13:00
Florian Bruhin d77053b86c Remove unused fixture 2023-12-01 23:47:48 +01:00
Florian Bruhin b5f11558a6 pdfjs: Simplify logic
Makes things easier if we get build/ right with the return value
2023-12-01 23:38:11 +01:00
Florian Bruhin a2c74ec1bf Remove unused vars 2023-12-01 23:32:07 +01:00
Florian Bruhin eabbdb8ea3 pdfjs: Fix :version crash with no pdf.js
pdfjs.get_pdf_basename() returned None, causing in a TypeError. Instead of
throwing mocker.patch at it, fix the underlying issue.

Given we made the same mistake in three places:

- :version
- test_real_file for PDF.js
- is_available() in pdfjs.py (calls the function but doesn't use the result, so
  is a nop now, even if PDF.js wasn't found)

...evidently we need to change the API so it still raises an exception if no
PDF.js is available.

Amends 0144ae3576.
2023-12-01 23:31:34 +01:00
Florian Bruhin 302a8f582a pakjoy: Restore old QTWEBENGINE_RESOURCES_PATH value
Otherwise, doing :restart fails because it tries to copy quirk dir to quirk dir.

QtWebEngine reads the env var in resourcePath() in
src/core/web_engine_library_info.cpp. That only seems to be called from
WebEngineLibraryInfo::getPath(), and that in turn gets called from
ResourceBundle::LoadCommonResources() in src/core/resource_bundle_qt.cpp.

Finally, that only seems to be called during Chromium initialization, so it
seems alright for us to unset this as soon as we initialized the first profile.

It also seems to work fine in my testing on Google Meet, and indeed fixes
:restart.
2023-12-01 22:47:43 +01:00
toofar 0144ae3576 fix pdf.js detection in :version
Now that pdf.js could be shipped with either js or mjs file extensions we
shouldn't hardcode the filename. Call the function for detecting the filename
instead. And make it public.
2023-11-27 08:07:40 +13:00
toofar b643e7b411 Try getting sandbox page text again
On CI now the sandbox test is failing on windows when we pop the header
line with an index error. It looks like the only line present on the
page is "Sandbox Status". It was working on CI the other day! Grrr

Hopefully it's a timing issue and the JS just hasn't finished running
yet? Not sure if just loading it again is the most reliable. Ideally we
would be listening for some event...

Pretty low effort but if this makes the test stop being flaky and we
don't have to look at it again that's fine with me.
2023-11-24 21:47:01 +13:00
Florian Bruhin bd86577736 pakjoy: Add undocumented escape hatch 2023-11-22 22:23:53 +01:00
Florian Bruhin ea7fb86706 tests: Also disable PaintHoldingCrossOrigin for unit tests
See https://bugreports.qt.io/browse/QTBUG-112017 and #5390
2023-11-22 22:08:24 +01:00
Florian Bruhin 8a53e9b282 pakjoy: Use proper logic to discover resources dir 2023-11-22 20:14:33 +01:00
Florian Bruhin 2e2e0c8031 pakjoy: 100% test coverage 2023-11-22 18:02:18 +01:00
Florian Bruhin 6147cae901 pakjoy: Use existing tmp_cachedir 2023-11-22 18:02:18 +01:00
Florian Bruhin 6b7eb77c4d pakjoy: Run black 2023-11-22 18:02:18 +01:00
Florian Bruhin 9e3d421a15 pakjoy: Use declarative skipping in tests 2023-11-22 18:02:18 +01:00
Florian Bruhin 51dace7152 pakjoy: Use more constants 2023-11-22 18:02:18 +01:00
Florian Bruhin 50db87664d pakjoy: Remove existing work dir if unneeded 2023-11-22 18:02:18 +01:00
Florian Bruhin 23d6a331f7 pakjoy: Fix test_elf.py 2023-11-22 09:58:26 +01:00
Florian Bruhin 2787d2382a pakjoy: Separate _patch and patch_webengine 2023-11-22 09:32:23 +01:00
Florian Bruhin b4ad0c559d Fix another merge issue 2023-11-22 09:25:13 +01:00
Florian Bruhin ab198177bd Merge branch 'main' into pakjoy 2023-11-22 09:17:43 +01:00