Commit Graph

719 Commits

Author SHA1 Message Date
Florian Bruhin f57afa39e8 webenginetab: Improve _on_navigation_request workarounds
- Use QTimer.singleShot to avoid crashes with QtWebEngine 6.10:
  https://bugreports.qt.io/browse/QTBUG-140543
- Disable back/forward workaround for QtWebEngine >= 6.6,
  as the underlying issue seems to be fixed there.

See https://github.com/qutebrowser/qutebrowser/issues/8694#issuecomment-3276397840
and #8711.
2025-10-01 17:09:01 +02:00
Florian Bruhin da8428f9ba webenginetab: Move QtWebEngine specific workaround
See #8711
2025-10-01 16:31:30 +02:00
Florian Bruhin 9447182809 Add debug logging for failed WebEngineHistory deserialization
This sometimes fails with 'The data stream has read past the end of the data in
the underlying device', which turns up in crash reports around once a month.

This is somewhat similar to https://bugreports.qt.io/browse/QTBUG-117489 - but
without knowing the data and without being able to reproduce, it's unclear what
the culprit could be.
2025-05-14 08:47:08 +02:00
Florian Bruhin b16551548f Remove QtWebEngine/... from default UA
Good old https://webaim.org/blog/user-agent-string-history/ strikes yet again.
Let's just masquerade as Chromium instead of the constant pointless fight.
2025-04-08 20:28:15 +02:00
toofar c32f5afcc4 Fix crash when JS is run async on deleted tabs
My reproducer is this:

* open the browser with the auto insert mode JS primed, and two tabs:

    `python3 -m qutebrowser -T -s input.insert_mode.auto_load true about:blank?1 about:blank?2`

* close the second tab: `d`
* re-open the closed tab then close it again real quick: `u` then `d`

If you have trouble reproducing, try increasing the 65ms delay in
`handle_auto_insert_mode` to be bigger (like 500ms).

Closes: #3895
2025-04-05 18:18:10 +13:00
Florian Bruhin c4d8502872 Add site-specific quirk for Digitec/Galaxus madness 2025-03-25 13:04:26 +01:00
toofar 0192b58a6a Support 'ask' for clipboard permissions
WebEngine now supports prompting for permission when a web page tries to
access the clipboard. Previously we only supported fixed permissions that
applied globally.

This commit

1. adds support for permission requests with the new ClipboardReadWrite
   permission
2. tweaks the generic JS prompt handler in browser/shared.py to handle
   seeing a setting which isn't of type BoolAsk
3. adds end2end tests around clipboard permissions, both the existing
   global ones and the new per-URL ones

1. the ClipboardReadWrite permission

I added this as an int because the relevant PyQt isn't out yet and users
with 6.8 running with PyQt6.7 are already seeing this.

I added an "ask" value to the existing String type
`content.javascript.clipboard` setting and set the
default/global/fallback permissions to False if ask is set globally.
Hmm, maybe we should change the default actually... I'll have to check
what the other prompt supporting settings default to.

2. tweaked prompt handler

This was treating the string values that weren't "ask" (like "none" and
"access") as truthy and allowing the action. I've changed the bool
checks to be exact checks to add a warning if this happens again.

Then I added an exception to the warning logging for known cases like
this. I did try looking at adding a new setting type. Something that was
descended from String but had an `__eq__` method that understood bools
and would treat `access-paste` as True and everything else as False. But
that didn't work out because it looks like config values are stored as
python values and the config classes are just static and don't actually
hold values. Oh well, maybe a better pattern will emerge with time.

3. tests

Apparently there were no tests around the clipboard settings. Perhaps
not a coincidence given how confusing they are (what does access-paste
mean?).

I copied a test file from some random test site, tweaked it a little bit
and got to work. For the paste test it's a bit awkward because I don't
know if we have a way to fill the clipboard in a nice way for the tests.
So I'm just matching on "Text pasted: *", which is usually an empty
string.

The prompt tests require running against Qt6.8 to get the new prompt
behaviour (don't need pyqt68 though).
2024-10-28 15:26:25 +13:00
Florian Bruhin b9441cad45 Fix crash when the renderer process terminates for an unknown reason
With PyQt 6, this gets represented as
QWebEnginePage.RenderProcessTerminationStatus(-1)
which is != -1, thus leading to a KeyError.

Updating to a RendererProcessTerminationStatus
enum value works fine on both PyQt5 and PyQt6.
2024-08-04 21:00:50 +02:00
toofar f6e9295c50 remove unneeded QTimer imports 2024-05-25 09:34:01 +12:00
Florian Bruhin 38abfdb8a0 check more timers 2024-05-25 09:34:01 +12:00
Florian Bruhin 72d7e2327b Update for new pylint/astroid releases
- Add a couple new "raise utils.Unreachable" to avoid
  possibly-used-before-assignment issues.
- Simplify an "if" for the same reason
- Remove an unneeded "return"
- Use "NoReturn" to prepare for pylint knowing about it in the future:
  https://github.com/pylint-dev/pylint/issues/9674
- Add some ignores for used-before-assignment false-positives
- Ignore new undefined-variable messages for Qt wrapers
- Ignore a new no-member warning for KeySequence:
  https://github.com/pylint-dev/astroid/issues/2448#issuecomment-2130124755
2024-05-24 21:46:04 +02:00
Florian Bruhin 7a969a2d54 Add caret browsing debug logging 2024-03-27 16:55:18 +01:00
toofar cedef129f9 Change browsertab WidgetType to be our tab implementations
Changing the type to be our overridden implementation of the view means
we can push more common code down into the view class and make use of
overridden methods more consistently. In this case I'm adding some type
checking to some of the getters on the view.

`_set_widget()` should be being called from the concrete child tab
implementations. So the widget should always be our overridden version of
the Qt tab implementations.

Also change `_set_widget()` to use the common typevar.

Also change the _widget type in WebEngineTab to match what it is
actually being set to and to match all the _widgets in the other
concrete classes in that file.

ref: https://github.com/qutebrowser/qutebrowser/pull/7990
2023-11-13 18:45:18 +13:00
Florian Bruhin 88b2a7c871 Fix lint 2023-09-25 07:00:57 +02:00
Florian Bruhin 45e168f511 Fix and improve workaround
See #7913
2023-09-24 23:37:27 +02:00
Florian Bruhin 5a05a93e38 Work around QtWebEngine bug when serializing empty history
See https://bugreports.qt.io/browse/QTBUG-117489
Closes #7913
2023-09-24 21:11:43 +02:00
brightonanc ef18773a0d Satisfying flake8 linter. 2023-09-03 16:25:28 -04:00
brightonanc ba58ef4d55 Fixing two instances of timers accumulating duplicate slots over time 2023-09-03 14:19:16 -04:00
Florian Bruhin 0718b25796 reuse: Initial copyright text update for myself
git ls-files | \
    xargs sed -Ei 's/Copyright [0-9]{4}(-[0-9]{4}) Florian Bruhin \(The Compiler\) <mail@qutebrowser\.org>/SPDX-FileCopyrightText: Florian Bruhin (The Compiler) <mail@qutebrowser.org>/'
2023-07-23 12:49:05 +02:00
Florian Bruhin b2aaba6043 reuse: Adjust most license headers
git ls-files | xargs grep -l "is free software"  | xargs reuse annotate --license="GPL-3.0-or-later" --skip-unrecognised
2023-07-23 12:11:07 +02:00
Florian Bruhin a05579d255 qt6: Update selection comment 2023-06-30 19:29:28 +02:00
Florian Bruhin 8e024ee654
Merge pull request #7761 from pylbrecht/remove-vim-modelines
Remove vim modelines in favor of .editorconfig
2023-06-30 15:51:19 +02:00
Philipp Albrecht d9e8b638bf Remove vim modelines
We're deprecating vim modelines in favor of `.editorconfig`.

Removing vim modelines could be done using two one-liners. Most of the vim modelines
were followed by an empty line, so this one-liner took care of these ones:

```sh
rg '^# vim: .+\n\n' -l | xargs sed -i '/^# vim: /,+1d'
```

Then some of the vim modelines were followed by a pylint configuration line, so running
this one-liner afterwards took care of that:

```sh
rg '^# vim:' -l | xargs sed -i '/^# vim: /d'
```
2023-06-30 11:03:06 +02:00
Florian Bruhin 783963b4da Fix lint 2023-06-29 23:31:14 +02:00
Florian Bruhin 69e2bbd766 qt6 mypy: Fix PyQt5 QUrl issues with a more clever approach 2023-06-29 23:06:54 +02:00
Florian Bruhin 42f0ee36e3 qt6 mypy: Remove PyQt5 type ignores 2023-06-29 22:11:03 +02:00
Florian Bruhin c8744122f6 qt6 mypy: Fix unused-ignores with mypy-pyqt5 2023-06-29 21:56:08 +02:00
Florian Bruhin 6baa6dea26 Migrate :print --pdf to pathlib 2023-06-26 13:50:19 +02:00
Florian Bruhin ce51fc5226 Fix minimum version for Array.at quirk 2022-12-01 21:24:12 +01:00
Florian Bruhin eb5c019d07 Add tests to make sure quirk files/declaration/settings match 2022-11-29 09:26:49 +01:00
Florian Bruhin f837da40f2 qt 6: Remove old JS quirks
We don't support Qt 5.12 anymore, so those can go.
2022-11-29 09:21:34 +01:00
Florian Bruhin 68dbde61fd Add a quirk for Array.at
Trivial to polyfill, needed by various pages in the wild,
and only natively available with Qt 6.2.

Closes #7501
Also see #7237 and 726d5e614b

(cherry picked from commit ce64e5d899)
2022-11-29 08:57:29 +01:00
Florian Bruhin 9ad13fa508 Update Qt doc links to Qt 6 2022-11-24 14:12:38 +01:00
Florian Bruhin 2d4fe87075 mypy: Use annotation instead of assert
Follow-up to 9c193c18f0
2022-09-16 15:00:19 +02:00
Florian Bruhin 6ef015bfd8 mypy: Move around some comments 2022-09-16 15:00:19 +02:00
toofar 9c193c18f0 mypy: cast to subtype: WebEnginePrinting 2022-09-11 17:22:50 +12:00
toofar 046244b54d mypy: defer to machinery for conditional: QWebEngineScripts 2022-09-11 17:22:50 +12:00
toofar 3e9fd4ed7e mypy: defer to machinery for conditional: printing 2022-09-11 17:22:50 +12:00
Florian Bruhin 6c1ba9281f Workaround for clicking links in local URLs
Closes #7194
2022-08-23 18:31:41 +02:00
Florian Bruhin ec8eebf996 lint: Fix remaining pylint issues 2022-08-23 18:31:41 +02:00
Florian Bruhin 52f2b430e9 lint: Fix flake8 docstring issues 2022-08-23 18:31:41 +02:00
Florian Bruhin 80961cee6b lint: Fix flake8 whitespace issues 2022-08-23 18:31:41 +02:00
Florian Bruhin e658ce6acf lint: Remove unused imports
Via autoflake and git add -p
2022-08-23 18:31:41 +02:00
Florian Bruhin 377749c76f Refactor and fix printing
QWebEnginePage::print() changed to QWebEngineView with Qt 6, and emits a new
printFinished() signal instead of taking a callback. Adjust our API accordingly.

There also is a pdfPrintingFinished signal which we now use to get a bit more
feedback to the user.

TODO: Changelog entry for PDF feedback?
2022-08-23 18:31:41 +02:00
Florian Bruhin 0ace4a5fee Disable loadFinished workaround on unaffected versions
With QtWebEngine 5.15.5+, we shouldn't need the workaround anymore.

This also seems to fix flakiness in
tests/end2end/features/test_navigate_bdd.py::test_navigating_up_in_qutehelp
where sometimes no loadFinished signal was found.

Relevant commits: git log -G 65223
Partially reverts 1106d82591.

TODO: Changelog
TODO: Pick to master?
2022-08-23 18:31:41 +02:00
Florian Bruhin 6ce8ff1e71 Adjust :debug-webaction for new-style enums
With scoped enums, we don't need to check whether the member belongs to the enum
class anymore, we just get it directly from there.

Also needed for PyQt 6 because we can't access the members unscoped anymore.

TODO: Pick to master?
2022-08-23 18:31:41 +02:00
Florian Bruhin e5340c449f Refactor certificate error handling
- Make CertificateErrorWrapper responsible for accepting/rejecting certs
- Try to avoid dealing with unclear booleans
- Implement support for deferred errors (#4616) - disabled due to PyQt bug
- Implement support for Qt 6 API (#7086)
2022-08-23 18:31:41 +02:00
Florian Bruhin c327e33d31 qt 6: Update client certificate selection 2022-08-23 18:31:41 +02:00
Florian Bruhin c5a51eb0bc Drop Qt < 5.15
Fixes #7091

TODO: Add changelog
2022-08-23 18:31:41 +02:00
Florian Bruhin b56d604cfe Make notifications work
Based on d1eecf8b97.

Relevant parts from that commit message:

    `QVariant.Type` has moved to `QMetaType.Type`[1][] and QMeta.Type
    doesn't work with int().

    `QtWebEngineCore.QWebEnginePage.Feature` doesn't work with int(), so add
    it to the maps twice.

    [1]: https://www.qt.io/blog/whats-new-in-qmetatype-qvariant

Also:

    `QImage(':/icons/qutebrowser-64x64.png')` yields and empty QImage. This
    is not fixed but things don't crash because of it anymore. For instance
    the "Title & Body" test on https://web-push-book.gauntface.com/demos/notification-examples/

but that part seems to work fine now. I don't quite understand why the original
commit added an "or bool(icon.rect())", but I can't find anything breaking
things without.
2022-08-23 18:31:40 +02:00