Commit Graph

126 Commits

Author SHA1 Message Date
Florian Bruhin cd1be710de Fix lint with FindFlags change 2022-06-13 19:37:05 +02:00
Florian Bruhin bf045f7ec7 Add a helper dataclass for find flags
When e.g. doing:
- '?foo' (search with reverse=True -> FindBackwards)
- 'N' (prev_result -> no FindBackwards)
- 'n' (next_result -> FindBackwards again)

we need to take a copy of the flags so that we can temporarily clear
FindBackwards when pressing 'N'.

Relevant history:

- We originally did int(self._flags) in
  d450257485.
- In f0da508c21, we used
  QWebPage.FindFlags(int(self._flags)) instead.
- With 97bdcb8e674c8ff27ab92448effef263880ab3aa (picked from
  c349fbd180) we instead do:
  flags = QWebEnginePage.FindFlag(self._flags)

Using FindFlag instead of FindFlags seemed to work fine with PyQt6 and
enum.Flag. With PyQt5, however, later clearing a flag bit ends up with us
getting 0 as an integer, thus losing the type information about this being a
FindFlag instance, and resulting in a TypeError when calling into Qt.

We could use FindFlags() with PyQt 6 but FindFlag() with PyQt 5 to copy the
original flags, but that's getting rather cumbersome. Instead, let's have a
helper dataclass of bools, do away with the bit-twiddling, and only convert it
to a Qt flags when we actually need them. This solves the copying issue nicely,
and also makes the code a lot nicer.

Finally, this also adds a test case which fails when the flags are mutated in
place instead of copied.

We could do the same kind of change for QtWebKit as well, but given that it's
somewhat dead - and perhaps more importantly, won't run with Qt 6 - let's not
bother. To not break the end2end tests with QtWebKit, the output still is the
same as before.

(cherry picked from commit 96a0cc39512753445bc7a01b218b2f1290819ddd)
2022-06-13 18:40:08 +02:00
Florian Bruhin b0d3c8eee3 Greasemonkey: Make sure script names are unique
Fixes #6353
2021-06-11 19:14:14 +02:00
Florian Bruhin d2e69454ce notifications: Rename/consolidate settings 2021-03-27 15:30:02 +01:00
Florian Bruhin fb4a56318c Simplify TestWebengineScripts 2021-03-09 18:23:10 +01:00
Florian Bruhin 7eae8f0694 Fix @run-at default for GreaseMonkey 2021-03-09 18:10:51 +01:00
Lembrun e8b05af233 Qtbot methods changed to snake case,snake case check added 2021-02-26 22:07:08 +01:00
Lembrun 0a453396c1 Rename utils.py to testutils.py 2021-02-25 21:28:56 +01:00
Florian Bruhin c6ac39053f Update data: download URL workaround for QtWebEngine 5.15.3
See https://github.com/qutebrowser/qutebrowser/issues/6147#issuecomment-776558369
2021-02-13 11:09:50 +01:00
Florian Bruhin 94967ee979 Improve QtWebEngine version checking in qtargs.py
We now use versions.webengine_versions() to get the real QtWebEngine
version. This is more accurate and also allows us to drop the
InstalledApp workaround with QtWebEngine 5.15.3.

Also, we pass a WebEngineVersions object around instead of asking for
the versions multiple times. This also leads to less patching in tests.

See #3785
2021-02-11 16:06:15 +01:00
Florian Bruhin 9eabd09645 darkmode: Improve/fix various tests 2021-02-11 15:25:16 +01:00
Florian Bruhin f50a43d716 Change colors.webpage.prefers_color_scheme_dark to colors.webpage.preferred_color_scheme
See #6097
2021-02-11 14:18:30 +01:00
Florian Bruhin 4e3a6a1c60 darkmode: Pass through existing blink settings 2021-02-11 14:18:30 +01:00
Florian Bruhin 3ff51a62d5 darkmode: Fix/update unit tests 2021-02-11 14:18:30 +01:00
Florian Bruhin 8d94a33b0a Improve tests in various corner cases 2021-02-10 16:13:22 +01:00
Florian Bruhin f8692cb141 Add more tests 2021-02-10 16:13:22 +01:00
Florian Bruhin d52fa7442f Fix tests 2021-02-10 16:13:22 +01:00
Florian Bruhin 1a45325572 Make WebEngineVersions.webengine non-Optional
Instead, we try to infer based on Qt, or return None if QtWebEngine is unavailable.
2021-02-10 16:13:22 +01:00
Florian Bruhin e0a0e1797d Fix darkmode tests 2021-02-10 16:13:22 +01:00
Florian Bruhin 1a4fff1a42 doc: Switch URLs to https 2021-01-26 15:19:01 +01:00
Florian Bruhin 222f1f19a1 Bump copyright years
Closes #6015
2021-01-20 20:06:19 +01:00
Florian Bruhin b29a8c50de downloads: Handle data: URLs with explicit filename
This is a follow-up to 9ae08c0f15.

See #1099
Fixes #6041
2021-01-16 11:34:12 +01:00
Florian Bruhin fbe29a2a25 tests: Improve tests for data: URL workaround 2021-01-16 11:25:52 +01:00
Florian Bruhin 9ae08c0f15 Improve download filenames for data: URLs
With QtWebEngine, downloading a data: URL seems to give us the raw data:
URL as filename, similar to #1214 / #1321 but for QtWebEngine.

With QtWebKit, the logic is now also improved so that we get a proper
extension rather than a "binary blob" filename.

See #1099
2021-01-05 11:19:01 +01:00
Florian Bruhin f5353970d3 webenginesettings: Move _init_settings() 2020-12-04 18:41:01 +01:00
Florian Bruhin 77186e49d6 webenginesettings: Don't special-case set_dictionary_language 2020-12-04 18:41:00 +01:00
Florian Bruhin 5a1e4f1972 Fix lint 2020-12-04 18:05:17 +01:00
Florian Bruhin 1933081ad4 tests: Avoid calling webenginesettings.init()
Since #5813, we now do more work there - and there already is quite a
bit of odd patching, so this isn't really the right way forward.

For now, replicate the initialization steps we *actually* need inside
the tests. I'm not entirely happy with this solution, but it's likely we
can revisit this to find something nicer when refactoring profile
initialization in general, see #5935.

This unfortunately also means there's no good way we can do what
`test_default_user_agent_saved` did, so I ended up removing it.
2020-12-04 17:06:50 +01:00
Ted Morse 1f67527662 Only apply blink-settings on Qt 15.5.2
Turns out Qt 5.15.{0,1} also needs `--force-dark-mode`. This commit
fixes it to only use the blink-setting on Qt 5.15.2 and up. It also
parameterizes the tests better to test that the settings work on their
respective Qt versions.
2020-11-29 10:58:27 -08:00
Ted Morse 314c81b24e Use blink-setting for colorscheme on Qt 5.15+
On Qt 5.15+, `--force-dark-mode` does not set the preferred colorscheme.
A blink-setting is used instead to set the preferred colorscheme.

The `--force-dark-mode` flag is only set for Qt 5.14. All later versions
will use the blink-setting flag.
2020-11-28 22:58:32 -08:00
Florian Bruhin 3afdd9b946 Add override for darkmode variant 2020-11-23 14:42:25 +01:00
Florian Bruhin bcb8b5dd70 old qt: Remove unused imports 2020-11-04 18:30:04 +01:00
Florian Bruhin 9f9d4d7b5b old qt: Remove various test workarounds 2020-11-04 18:30:04 +01:00
Florian Bruhin 160831c5bd old qt: Remove conditional and old tests 2020-11-04 18:30:04 +01:00
Florian Bruhin 2929949d67 old qt: Remove conditionals for spell checks 2020-11-04 18:27:26 +01:00
Florian Bruhin 85832c76db old qt: Remove conditionals for cookie handling 2020-11-04 18:27:26 +01:00
Florian Bruhin 05111e8423 old qt: Adjust greasemonkey support 2020-11-04 11:30:54 +01:00
Florian Bruhin f369d0d7d2 old qt: Remove dark mode handling 2020-11-04 11:30:54 +01:00
Florian Bruhin c95b9637e1 old qt: Remove old inspector logic 2020-11-04 11:30:54 +01:00
Florian Bruhin c6d6ea532f old qt: Adjust configdata.yml and settings docs 2020-11-04 11:30:54 +01:00
Florian Bruhin c473a5063f Fix lint 2020-10-19 15:04:14 +02:00
Florian Bruhin 485f67b124 Replace darkmode version by variant 2020-10-19 15:04:14 +02:00
Florian Bruhin 711deea870 Move dark mode to its own file 2020-10-19 15:04:14 +02:00
Florian Bruhin 776f8b1913 Fix lint 2020-05-07 12:01:25 +02:00
Florian Bruhin f41c745ee6 Add more tests for cookie handling 2020-05-07 11:26:49 +02:00
Florian Bruhin dad8efa4b1 Handle invalid URLs in _accept_cookie 2020-05-06 21:01:43 +02:00
Florian Bruhin 62af757845 Merge remote-tracking branch 'origin/pr/4395' into cookies 2020-05-06 19:58:54 +02:00
Florian Bruhin 9e4276db9b Adjust copyrights for 2020 2020-01-04 18:21:17 +01:00
Florian Bruhin 4151680e93 Refactor user agent handling
We now use a format string for the user_agent setting and parse both backend's
default user agents to get the needed information.

Fixes #513
2019-12-20 16:53:17 +01:00
Florian Bruhin 18696e69de Fix test_resource_type_values with Qt 5.7 2019-12-20 12:17:38 +01:00