summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bumpversion.cfg2
-rw-r--r--.github/ISSUE_TEMPLATE/4_Security_issue.md11
-rw-r--r--.github/SECURITY.md1
-rw-r--r--.gitignore3
-rw-r--r--.pylintrc2
-rw-r--r--.travis.yml4
-rw-r--r--MANIFEST.in8
-rw-r--r--README.asciidoc17
-rw-r--r--doc/changelog.asciidoc147
-rw-r--r--doc/contributing.asciidoc3
-rw-r--r--doc/faq.asciidoc20
-rw-r--r--doc/help/commands.asciidoc49
-rw-r--r--doc/help/configuring.asciidoc2
-rw-r--r--doc/help/settings.asciidoc301
-rw-r--r--doc/install.asciidoc4
-rw-r--r--misc/org.qutebrowser.qutebrowser.appdata.xml3
-rw-r--r--misc/requirements/requirements-check-manifest.txt6
-rw-r--r--misc/requirements/requirements-codecov.txt8
-rw-r--r--misc/requirements/requirements-dev.txt15
-rw-r--r--misc/requirements/requirements-dev.txt-raw1
-rw-r--r--misc/requirements/requirements-flake8.txt15
-rw-r--r--misc/requirements/requirements-mypy.txt8
-rw-r--r--misc/requirements/requirements-mypy.txt-raw5
-rw-r--r--misc/requirements/requirements-pip.txt10
-rw-r--r--misc/requirements/requirements-pyinstaller.txt2
-rw-r--r--misc/requirements/requirements-pylint.txt12
-rw-r--r--misc/requirements/requirements-pylint.txt-raw4
-rw-r--r--misc/requirements/requirements-pyqt-5.12.txt2
-rw-r--r--misc/requirements/requirements-pyqt-5.13.txt2
-rw-r--r--misc/requirements/requirements-pyqt-5.14.txt4
-rw-r--r--misc/requirements/requirements-pyqt.txt4
-rw-r--r--misc/requirements/requirements-sphinx.txt16
-rw-r--r--misc/requirements/requirements-tests.txt43
-rw-r--r--misc/requirements/requirements-tests.txt-raw14
-rw-r--r--misc/requirements/requirements-tox.txt14
-rw-r--r--misc/requirements/requirements-vulture.txt2
-rwxr-xr-xmisc/userscripts/getbib1
-rwxr-xr-xmisc/userscripts/password_fill2
-rwxr-xr-xmisc/userscripts/qute-bitwarden59
-rwxr-xr-xmisc/userscripts/qute-lastpass2
-rwxr-xr-xmisc/userscripts/readability-js14
-rw-r--r--mypy.ini43
-rw-r--r--pytest.ini4
-rw-r--r--qutebrowser/__init__.py2
-rw-r--r--qutebrowser/api/cmdutils.py6
-rw-r--r--qutebrowser/app.py13
-rw-r--r--qutebrowser/browser/browsertab.py81
-rw-r--r--qutebrowser/browser/commands.py57
-rw-r--r--qutebrowser/browser/downloads.py2
-rw-r--r--qutebrowser/browser/downloadview.py7
-rw-r--r--qutebrowser/browser/eventfilter.py67
-rw-r--r--qutebrowser/browser/hints.py14
-rw-r--r--qutebrowser/browser/history.py2
-rw-r--r--qutebrowser/browser/inspector.py2
-rw-r--r--qutebrowser/browser/navigate.py8
-rw-r--r--qutebrowser/browser/network/pac.py13
-rw-r--r--qutebrowser/browser/network/proxy.py32
-rw-r--r--qutebrowser/browser/pdfjs.py7
-rw-r--r--qutebrowser/browser/qutescheme.py63
-rw-r--r--qutebrowser/browser/webelem.py2
-rw-r--r--qutebrowser/browser/webengine/cookies.py35
-rw-r--r--qutebrowser/browser/webengine/tabhistory.py51
-rw-r--r--qutebrowser/browser/webengine/webenginedownloads.py15
-rw-r--r--qutebrowser/browser/webengine/webengineelem.py2
-rw-r--r--qutebrowser/browser/webengine/webenginequtescheme.py9
-rw-r--r--qutebrowser/browser/webengine/webenginesettings.py66
-rw-r--r--qutebrowser/browser/webengine/webenginetab.py229
-rw-r--r--qutebrowser/browser/webengine/webview.py3
-rw-r--r--qutebrowser/browser/webkit/cookies.py18
-rw-r--r--qutebrowser/browser/webkit/network/networkmanager.py7
-rw-r--r--qutebrowser/browser/webkit/network/networkreply.py21
-rw-r--r--qutebrowser/browser/webkit/webkitelem.py7
-rw-r--r--qutebrowser/browser/webkit/webkittab.py238
-rw-r--r--qutebrowser/browser/webkit/webpage.py37
-rw-r--r--qutebrowser/browser/webkit/webview.py9
-rw-r--r--qutebrowser/commands/command.py7
-rw-r--r--qutebrowser/commands/runners.py4
-rw-r--r--qutebrowser/commands/userscripts.py35
-rw-r--r--qutebrowser/completion/completiondelegate.py2
-rw-r--r--qutebrowser/completion/completionwidget.py2
-rw-r--r--qutebrowser/completion/models/completionmodel.py8
-rw-r--r--qutebrowser/completion/models/miscmodels.py34
-rw-r--r--qutebrowser/completion/models/urlmodel.py5
-rw-r--r--qutebrowser/components/caretcommands.py10
-rw-r--r--qutebrowser/components/misccommands.py6
-rw-r--r--qutebrowser/config/config.py2
-rw-r--r--qutebrowser/config/configcommands.py17
-rw-r--r--qutebrowser/config/configdata.yml286
-rw-r--r--qutebrowser/config/configfiles.py20
-rw-r--r--qutebrowser/config/configinit.py99
-rw-r--r--qutebrowser/config/configtypes.py101
-rw-r--r--qutebrowser/config/configutils.py5
-rw-r--r--qutebrowser/config/stylesheet.py2
-rw-r--r--qutebrowser/config/websettings.py13
-rw-r--r--qutebrowser/extensions/loader.py6
-rw-r--r--qutebrowser/html/warning-old-qt.html20
-rw-r--r--qutebrowser/html/warning-sessions.html22
-rw-r--r--qutebrowser/html/warning-webkit.html14
-rw-r--r--qutebrowser/javascript/.eslintrc.yaml1
-rw-r--r--qutebrowser/javascript/caret.js86
-rw-r--r--qutebrowser/javascript/pac_utils.js2
-rw-r--r--qutebrowser/javascript/whatsapp_web_quirk.user.js15
-rw-r--r--qutebrowser/keyinput/basekeyparser.py5
-rw-r--r--qutebrowser/keyinput/eventfilter.py29
-rw-r--r--qutebrowser/keyinput/keyutils.py36
-rw-r--r--qutebrowser/keyinput/modeman.py21
-rw-r--r--qutebrowser/mainwindow/mainwindow.py41
-rw-r--r--qutebrowser/mainwindow/prompt.py17
-rw-r--r--qutebrowser/mainwindow/statusbar/bar.py15
-rw-r--r--qutebrowser/mainwindow/statusbar/command.py9
-rw-r--r--qutebrowser/mainwindow/statusbar/url.py3
-rw-r--r--qutebrowser/mainwindow/tabbedbrowser.py26
-rw-r--r--qutebrowser/mainwindow/tabwidget.py18
-rw-r--r--qutebrowser/misc/autoupdate.py2
-rw-r--r--qutebrowser/misc/backendproblem.py19
-rw-r--r--qutebrowser/misc/checkpyver.py8
-rw-r--r--qutebrowser/misc/crashdialog.py6
-rw-r--r--qutebrowser/misc/crashsignal.py40
-rw-r--r--qutebrowser/misc/earlyinit.py7
-rw-r--r--qutebrowser/misc/editor.py2
-rw-r--r--qutebrowser/misc/guiprocess.py19
-rw-r--r--qutebrowser/misc/ipc.py13
-rw-r--r--qutebrowser/misc/miscwidgets.py37
-rw-r--r--qutebrowser/misc/msgbox.py2
-rw-r--r--qutebrowser/misc/sessions.py19
-rw-r--r--qutebrowser/misc/split.py3
-rw-r--r--qutebrowser/misc/sql.py3
-rw-r--r--qutebrowser/misc/utilcmds.py17
-rw-r--r--qutebrowser/qt.py2
-rw-r--r--qutebrowser/qutebrowser.py6
-rw-r--r--qutebrowser/utils/debug.py24
-rw-r--r--qutebrowser/utils/error.py1
-rw-r--r--qutebrowser/utils/jinja.py8
-rw-r--r--qutebrowser/utils/log.py30
-rw-r--r--qutebrowser/utils/message.py2
-rw-r--r--qutebrowser/utils/objreg.py6
-rw-r--r--qutebrowser/utils/qtutils.py108
-rw-r--r--qutebrowser/utils/standarddir.py5
-rw-r--r--qutebrowser/utils/urlutils.py25
-rw-r--r--qutebrowser/utils/usertypes.py5
-rw-r--r--qutebrowser/utils/utils.py12
-rw-r--r--qutebrowser/utils/version.py23
-rw-r--r--requirements.txt4
-rwxr-xr-xscripts/asciidoc2html.py11
-rw-r--r--scripts/dev/build_pyqt_wheel.py99
-rwxr-xr-xscripts/dev/build_release.py27
-rw-r--r--scripts/dev/check_coverage.py3
-rw-r--r--scripts/dev/misc_checks.py4
-rw-r--r--scripts/dev/recompile_requirements.py53
-rwxr-xr-xscripts/dev/src2asciidoc.py7
-rw-r--r--scripts/dev/update_version.py8
-rwxr-xr-xscripts/dictcli.py9
-rw-r--r--scripts/keytester.py29
-rw-r--r--scripts/mkvenv.py67
-rw-r--r--scripts/utils.py11
-rwxr-xr-xsetup.py1
-rw-r--r--tests/conftest.py4
-rw-r--r--tests/end2end/features/conftest.py3
-rw-r--r--tests/end2end/features/search.feature50
-rw-r--r--tests/end2end/features/spawn.feature8
-rw-r--r--tests/end2end/features/test_editor_bdd.py8
-rw-r--r--tests/end2end/features/test_open_bdd.py21
-rw-r--r--tests/end2end/features/test_prompts_bdd.py31
-rw-r--r--tests/end2end/features/yankpaste.feature13
-rw-r--r--tests/end2end/fixtures/quteprocess.py6
-rw-r--r--tests/end2end/fixtures/testprocess.py5
-rw-r--r--tests/end2end/fixtures/webserver.py3
-rw-r--r--tests/end2end/fixtures/webserver_sub.py9
-rw-r--r--tests/end2end/fixtures/webserver_sub_ssl.py5
-rw-r--r--tests/helpers/fixtures.py34
-rw-r--r--tests/helpers/stubs.py26
-rw-r--r--tests/unit/browser/test_caret.py144
-rw-r--r--tests/unit/browser/test_qutescheme.py2
-rw-r--r--tests/unit/browser/test_shared.py4
-rw-r--r--tests/unit/browser/webengine/test_webengine_cookies.py128
-rw-r--r--tests/unit/browser/webkit/test_cookies.py93
-rw-r--r--tests/unit/completion/test_models.py35
-rw-r--r--tests/unit/config/test_configcommands.py10
-rw-r--r--tests/unit/config/test_configdata.py14
-rw-r--r--tests/unit/config/test_configfiles.py12
-rw-r--r--tests/unit/config/test_configinit.py126
-rw-r--r--tests/unit/config/test_configtypes.py38
-rw-r--r--tests/unit/config/test_configutils.py7
-rw-r--r--tests/unit/mainwindow/test_messageview.py2
-rw-r--r--tests/unit/misc/test_editor.py2
-rw-r--r--tests/unit/misc/test_ipc.py2
-rw-r--r--tests/unit/misc/test_throttle.py2
-rw-r--r--tests/unit/utils/test_error.py13
-rw-r--r--tests/unit/utils/test_qtutils.py6
-rw-r--r--tests/unit/utils/test_standarddir.py59
-rw-r--r--tests/unit/utils/test_urlutils.py25
-rw-r--r--tests/unit/utils/test_version.py24
-rw-r--r--tox.ini32
-rw-r--r--www/header.asciidoc4
194 files changed, 3657 insertions, 1198 deletions
diff --git a/.bumpversion.cfg b/.bumpversion.cfg
index bac515da4..c5defd11a 100644
--- a/.bumpversion.cfg
+++ b/.bumpversion.cfg
@@ -1,5 +1,5 @@
[bumpversion]
-current_version = 1.10.1
+current_version = 1.11.1
commit = True
message = Release v{new_version}
tag = True
diff --git a/.github/ISSUE_TEMPLATE/4_Security_issue.md b/.github/ISSUE_TEMPLATE/4_Security_issue.md
deleted file mode 100644
index b8f7d25e4..000000000
--- a/.github/ISSUE_TEMPLATE/4_Security_issue.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-name: ⛔ Security Issue
-about: Contact mail@qutebrowser.org for security issues.
-
----
-
-⚠ PLEASE DON'T DISCLOSE SECURITY-RELATED ISSUES PUBLICLY, SEE BELOW.
-
-If you have found a security issue in qutebrowser, please send the details to
-mail [at] qutebrowser.org and don't disclose it publicly until we can provide a
-fix for it
diff --git a/.github/SECURITY.md b/.github/SECURITY.md
new file mode 100644
index 000000000..7df41b38e
--- /dev/null
+++ b/.github/SECURITY.md
@@ -0,0 +1 @@
+Please report security bugs to [security@qutebrowser.org](mailto:security@qutebrowser.org).
diff --git a/.gitignore b/.gitignore
index 6074de319..aa5b853f7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,7 +27,7 @@ __pycache__
/.pytest_cache
/.testmondata
/.hypothesis
-/.mypy_cache
+.mypy_cache
/prof
/venv
TODO
@@ -44,3 +44,4 @@ TODO
/doc/extapi/_build
/misc/nsis/include
/misc/nsis/plugins
+/wheels
diff --git a/.pylintrc b/.pylintrc
index c68b4ae3f..1fedefb6d 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -60,7 +60,7 @@ no-docstring-rgx=(^_|^main$)
[FORMAT]
max-line-length=79
-ignore-long-lines=(<?https?://|^# Copyright 201\d|link:)
+ignore-long-lines=(<?https?://|file://|^# Copyright 201\d|link:)
expected-line-ending-format=LF
[VARIABLES]
diff --git a/.travis.yml b/.travis.yml
index 54eab192e..4ca28c375 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,8 +19,8 @@ matrix:
services: docker
### Archlinux QtWebEngine with testing/KDE-Unstable
- # - env: DOCKER=archlinux-webengine-unstable QUTE_BDD_WEBENGINE=true
- # services: docker
+ - env: DOCKER=archlinux-webengine-unstable QUTE_BDD_WEBENGINE=true
+ services: docker
### PyQt 5.7.1 (Python 3.5)
- python: 3.5
diff --git a/MANIFEST.in b/MANIFEST.in
index c8c11c32e..e163bde9f 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,6 +1,7 @@
recursive-include qutebrowser *.py
recursive-include qutebrowser/img *.svg *.png
recursive-include qutebrowser/javascript *.js
+graft tests
graft qutebrowser/html
graft qutebrowser/3rdparty
graft icons
@@ -16,10 +17,10 @@ include misc/org.qutebrowser.qutebrowser.desktop
include misc/org.qutebrowser.qutebrowser.appdata.xml
include misc/Makefile
include requirements.txt
-include tox.ini
include qutebrowser.py
include misc/cheatsheet.svg
include qutebrowser/config/configdata.yml
+include pytest.ini
prune www
prune scripts/dev
@@ -29,16 +30,17 @@ exclude scripts/asciidoc2html.py
recursive-exclude doc *.asciidoc
include doc/qutebrowser.1.asciidoc
include doc/changelog.asciidoc
-prune tests
prune qutebrowser/3rdparty
-exclude pytest.ini
exclude mypy.ini
+exclude tox.ini
exclude qutebrowser/javascript/.eslintrc.yaml
exclude qutebrowser/javascript/.eslintignore
exclude doc/help
exclude .*
exclude misc/qutebrowser.spec
exclude misc/qutebrowser.rcc
+exclude tests/unit/scripts/test_run_vulture.py
+exclude tests/unit/scripts/test_check_coverage.py
prune doc/extapi
prune misc/nsis
diff --git a/README.asciidoc b/README.asciidoc
index 1f1bb5308..41d0e7f1b 100644
--- a/README.asciidoc
+++ b/README.asciidoc
@@ -28,9 +28,6 @@ time, your help is needed! See the
https://github.com/sponsors/The-Compiler/[GitHub Sponsors page] for more
information. Depending on your sign-up date and how long you keep a certain
level, you can get qutebrowser t-shirts, stickers and more!
-
-Thanks to the GitHub Sponsors Matching Fund, all donations done via GitHub
-Sponsors (up to a $5000 total) will be doubled until October 2020.
// QUTE_WEB_HIDE_END
Screenshots
@@ -108,9 +105,10 @@ Requirements
The following software and libraries are required to run qutebrowser:
-* https://www.python.org/[Python] 3.5.2 or newer (3.6 recommended)
-* https://www.qt.io/[Qt] 5.7.1 or newer (5.14 recommended; support for < 5.9
- will be dropped soon) with the following modules:
+* https://www.python.org/[Python] 3.5.2 or newer (3.6 - 3.8 recommended;
+ support for 3.5 will be dropped with qutebrowser v2.0.0)
+* https://www.qt.io/[Qt] 5.7.1 or newer (5.14 recommended; support for < 5.11
+ will be dropped with qutebrowser v2.0.0) with the following modules:
- QtCore / qtbase
- QtQuick (part of qtbase in some distributions)
- QtSQL (part of qtbase in some distributions)
@@ -123,7 +121,7 @@ The following software and libraries are required to run qutebrowser:
avoid visiting untrusted websites and using it for transmission of
sensitive data.**
* https://www.riverbankcomputing.com/software/pyqt/intro[PyQt] 5.7.0 or newer
- (5.14 recommended, support for < 5.9 will be dropped soon) for Python 3
+ (5.14 recommended, support for < 5.11 will be dropped soon) for Python 3
* https://pypi.python.org/pypi/setuptools/[pkg_resources/setuptools]
* https://fdik.org/pyPEG/[pyPEG2]
* http://jinja.pocoo.org/[jinja2]
@@ -153,9 +151,6 @@ https://github.com/sponsors/The-Compiler/[GitHub Sponsors page] for more
information. Depending on your sign-up date and how long you keep a certain
level, you can get qutebrowser t-shirts, stickers and more!
-Thanks to the GitHub Sponsors Matching Fund, all donations done via GitHub
-Sponsors (up to a $5000 total) will be doubled until October 2020!
-
Alternatively, the following donation methods are available -- note that
eligibility for swag (shirts/stickers/etc.) is handled on a case-by-case basis
for those, please mailto:mail@qutebrowser.org[get in touch] for details.
@@ -220,7 +215,7 @@ Active
* https://fanglingsu.github.io/vimb/[vimb] (C, GTK+ with WebKit2)
* https://luakit.github.io/luakit/[luakit] (C/Lua, GTK+ with WebKit2)
* https://surf.suckless.org/[surf] (C, GTK+ with WebKit1/WebKit2)
-* https://github.com/next-browser/next/[next] (Lisp, Emacs-like but also offers Vim bindings, various backends - note there was a http://jgkamat.gitlab.io/blog/next-rce.html[critical remote code execution] which was handled quite badly)
+* https://next.atlas.engineer/[next] (Lisp, Emacs-like but also offers Vim bindings, various backends - note there was a http://jgkamat.gitlab.io/blog/next-rce.html[critical remote code execution] which was handled quite badly)
* https://github.com/parkouss/webmacs/[webmacs] (Python, Emacs-like with QtWebEngine)
* Chrome/Chromium addons:
https://vimium.github.io/[Vimium],
diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc
index bd2698467..a6aead789 100644
--- a/doc/changelog.asciidoc
+++ b/doc/changelog.asciidoc
@@ -15,9 +15,132 @@ breaking changes (such as renamed commands) can happen in minor releases.
// `Fixed` for any bug fixes.
// `Security` to invite users to upgrade in case of vulnerabilities.
-v1.11.0 (unreleased)
+v1.12.0 (unreleased)
--------------------
+Removed
+~~~~~~~
+
+- `tox -e mkvenv` which was deprecated in qutebrowser v1.10.0 is now
+ removed. Use the `mkvenv.py` script instead.
+- Support for using `config.bind(key, None)` in `config.py` to unbind a
+ key was deprecated in v1.8.2 and is now removed. Use
+ `config.unbind(key)` instead.
+- `:yank markdown` was deprecated in v1.7.0 and is now removed. Use
+ `:yank inline [{title}]({url})` instead.
+
+Added
+~~~~~
+
+- New `:debug-keytester` command, which shows a "key tester" widget.
+ Previously, that was only available as a separate application via `python3 -m
+ scripts.keytester`.
+- New `:config-diff` command which opens the `qute://configdiff` page.
+- New `--debug-flag log-cookies` to log cokies to the debug log for
+ debugging.
+- New `colors.contextmenu.disabled.{fg,bg}` settings to customize colors for
+ disabled items in the context menu.
+- New line selection mode (`:toggle-selection --line`), bound to `Shift-V` in caret mode.
+- New `colors.webpage.darkmode.*` settings to control Chromium's dark mode.
+ Note that those settings only work with QtWebEngine on Qt >= 5.14 and require
+ a restart of qutebrowser.
+
+Changed
+~~~~~~~
+
+- The `content.cookies.accept` setting now accepts URL patterns.
+- Tests are now included in release tarballs. Note that only running them with
+ the exact dependencies listed in
+ `misc/requirements/requirements-tests.txt{,-raw}` is supported.
+- The `:tab-focus` command now has completion for tabs in the current window.
+- The `bindings.key_mappings` setting now maps `<Ctrl+I>` to the tab key by default.
+- `:tab-give --private` now detaches a tab into a new private window.
+
+Fixed
+~~~~~
+
+- Using `:open -s` now only rewrites `http://` in URLs to `https://`, not other
+ schemes like `qute://`.
+- When an unhandled exception happens in certain parts of the code (outside of
+ the main thread), qutebrowser did crash or freeze when trying to show its
+ exception handler. This is now fixed.
+- `:inspector` now works correctly when cookies are disabled globally.
+- Added workaround for a (Gentoo?) PyQt/packaging issue related to the
+ `QWebEngineFindTextResult` handling added in v1.11.0.
+- When entering caret selection mode (`v, v`) very early before a page is
+ loaded, an error is now shown instead of a crash happening.
+- The workaround for session loading with Qt 5.15 now handles
+ `sessions.lazy_restore` so that the saved page is loaded instead of the
+ "stub" page with no possibility to get to the web page.
+
+v1.11.1 (2020-05-07)
+--------------------
+
+Security
+~~~~~~~~
+
+- CVE-2020-11054: After a certificate error was overridden by the user,
+ qutebrowser displays the URL as yellow (`colors.statusbar.url.warn.fg`).
+ However, when the affected website was subsequently loaded again, the URL was
+ mistakenly displayed as green (`colors.statusbar.url.success_https`). While
+ the user already has seen a certificate error prompt at this point (or set
+ `content.ssl_strict` to `false` which is not recommended), this could still
+ provide a false sense of security. This is now fixed.
+
+v1.11.0 (2020-04-27)
+--------------------
+
+Added
+~~~~~
+
+- New settings:
+ * `search.wrap` which can be set to false to prevent wrapping around the page
+ when searching. With QtWebEngine, Qt 5.14 or newer is required.
+ * `content.unknown_url_scheme_policy` which allows controlling when an
+ external application is opened for external links (never, from user
+ interaction, always).
+ * `content.fullscreen.overlay_timeout` to configure how long the fullscreen
+ overlay should be displayed. If set to `0`, no overlay is displayed.
+ * `hints.padding` to add additional padding for hints.
+ * `hints.radius` to set a border radius for hints (set to `3` by default).
+- New placeholders for `url.searchengines` values:
+ * `{unquoted}` inserts the search term without any quoting.
+ * `{semiquoted}` (same as `{}`) quotes most special characters, but slashes
+ remain unquoted.
+ * `{quoted}` (same as `{}` in earlier releases) also quotes slashes.
+
+Changed
+~~~~~~~
+
+- First adaptions to Qt 5.15, including a stop-gap measure for session loading
+ not working properly with it.
+- Searching now wraps around the page by default with QtWebKit (where it didn't
+ before). Set `search.wrap` to `false` to restore the old behavior.
+- The `{}` placeholder for search engines (the `url.searchengines` setting) now
+ does not quote slashes anymore, but other characters typically encoded in
+ URLs still get encoded. This matches the behavior of search engines in
+ Chromium. To revert to the old behavior, use `{quoted}` instead.
+- The `content.windowed_fullscreen` setting got renamed to
+ `content.fullscreen.window`.
+- Mouse-wheel scrolling is now prevented while hints are active.
+- Changes to userscripts:
+ * `qute-bitwarden` now has an optional `--totp` flag which can be used
+ to copy TOTP codes to clipboard (requires the `pyperclip` module).
+ * `readability-js` now opens readability tabs next to the original
+ tab (using the `:open --related` flag).
+ * `readability-js` now displays a favicon for readability tabs.
+ * `password_fill` now triggers a `change` JavaScript event after filling the
+ data.
+- The `dictcli.py` script now shows better error messages.
+- Various improvements to the `mkvenv.py` script (mainly useful for development).
+- Minor performance improvements.
+
+Deprecated
+~~~~~~~~~~
+
+- A warning about old Qt versions is now also shown with Qt 5.9 and 5.10, as
+ support for Qt < 5.11 will be dropped in qutebrowser v2.0.
+
Fixed
~~~~~
@@ -25,6 +148,28 @@ Fixed
- The proxied `window` global is now shared between different
Greasemonkey scripts (but still separate from the page's `window`), to
match the original Greasemonkey implementation.
+- The `--output-messages` (`-m`) flag added in v1.9.0 now also works correctly
+ when using `:spawn --userscript`.
+- `:version` and `--version` now don't crash if there's an (invalid)
+ `/etc/os-release` file which has non-comment lines without a `=` character.
+- Scripts in `scripts/` now report errors to `stderr` correctly, instead of
+ using `stdout`.
+
+v1.10.2 (2020-04-17)
+--------------------
+
+Changed
+~~~~~~~
+
+- Windows and macOS releases now bundle Qt 5.14.2, including security fixes up
+ to Chromium 80.0.3987.132.
+
+Fixed
+~~~~~
+
+- The WhatsApp workaround now also works when using WhatsApp in languages other
+ than English.
+- The `mkvenv.py` script now also works properly on Windows.
v1.10.1 (2020-02-15)
--------------------
diff --git a/doc/contributing.asciidoc b/doc/contributing.asciidoc
index 8dfc94c4f..fdaf7dd37 100644
--- a/doc/contributing.asciidoc
+++ b/doc/contributing.asciidoc
@@ -707,6 +707,9 @@ qutebrowser release
* Make sure there are no unstaged changes and the tests are green.
* Make sure all issues with the related milestone are closed.
* Consider updating the completions for `content.headers.user_agent` in `configdata.yml`.
+* Minor release: Consider updating some files from master:
+ - `misc/requirements/` and `requirements.txt`
+ - `scripts/`
* Make sure Python is up-to-date on build machines.
* Mark the milestone at https://github.com/qutebrowser/qutebrowser/milestones as closed.
* Update changelog in master branch
diff --git a/doc/faq.asciidoc b/doc/faq.asciidoc
index 32861c87c..3df5b8e40 100644
--- a/doc/faq.asciidoc
+++ b/doc/faq.asciidoc
@@ -21,7 +21,7 @@ Why another browser?::
Read the next few questions to find out why I was unhappy with existing
software.
-What's wrong with link:https://bitbucket.org/portix/dwb/[dwb]/link:https://sourceforge.net/projects/vimprobable/[vimprobable]/link:https://mason-larobina.github.io/luakit/[luakit]/jumanji/... (projects based on WebKitGTK)?::
+What's wrong with link:https://bitbucket.org/portix/dwb/[dwb]/link:https://sourceforge.net/projects/vimprobable/[vimprobable]/link:https://luakit.github.io/[luakit]/jumanji/... (projects based on WebKitGTK)?::
Most of them are based on the https://webkitgtk.org/[WebKitGTK+]
https://webkitgtk.org/reference/webkitgtk/stable/index.html[WebKit1] API,
which causes a lot of crashes. As the GTK API using WebKit1 is
@@ -367,14 +367,15 @@ up for a monthly donation to The-Compiler (qutebrowser's main developer),
allowing him to work part-time on qutebrowser. If you keep your donation level
for long enough, you can get some qutebrowser stickers!
-Why GitHub Sponsors? What is the GitHub Matching Fund?::
- Thanks to the
- https://help.github.com/en/github/supporting-the-open-source-community-with-github-sponsors/about-github-sponsors#about-the-github-sponsors-matching-fund[GitHub Sponsors Matching Fund],
- all donations are doubled by GitHub in the first year, up to a $5000 total limit.
+Why GitHub Sponsors?::
+ GitHub Sponsors is a crowdfundign platform nicely integrated with
+ qutebrowser's existing GitHub page and a better offering than alternatives such
+ as Patreon or Liberapay.
+
-Even outside of the matching fund, GitHub Sponsors is nicely integrated with
-qutebrowser's existing GitHub page and a better offering than alternatives such
-as Patreon or Liberapay.
+It also offers a
+https://help.github.com/en/github/supporting-the-open-source-community-with-github-sponsors/about-github-sponsors#about-the-github-sponsors-matching-fund[Matching Fund]
+which matches all donations until a cap of $5000, which has already been
+reached by qutebrowser.
Is it possible to contribute via a one-time donation instead?::
If you prefer a one-time donation, there are various possibilities:
@@ -382,8 +383,7 @@ Is it possible to contribute via a one-time donation instead?::
- Select a tier which covers the total amount you'd like to donate (note that
payments are prorated based on the current date). After the payment is
processed, cancel your GitHub sponsors subscription again. This has a big
- benefit: Thanks to GitHub's matching fund, your donation will be doubled (and
- nothing will be lost to fees).
+ benefit: There are no fees deducted from your amount.
+
- Sign up for a lower recurring donation instead.
+
diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc
index bbe5a6f3d..dc40c76a6 100644
--- a/doc/help/commands.asciidoc
+++ b/doc/help/commands.asciidoc
@@ -44,6 +44,7 @@ possible to run or bind multiple commands by separating them with `;;`.
|<<config-cycle,config-cycle>>|Cycle an option between multiple values.
|<<config-dict-add,config-dict-add>>|Add a key/value pair to a dictionary option.
|<<config-dict-remove,config-dict-remove>>|Remove a key from a dict.
+|<<config-diff,config-diff>>|Show all customized options.
|<<config-edit,config-edit>>|Open the config.py file in the editor.
|<<config-list-add,config-list-add>>|Append a value to a config option that is a list.
|<<config-list-remove,config-list-remove>>|Remove a value from a list.
@@ -112,7 +113,7 @@ possible to run or bind multiple commands by separating them with `;;`.
|<<set,set>>|Set an option.
|<<set-cmd-text,set-cmd-text>>|Preset the statusbar to some text.
|<<set-mark,set-mark>>|Set a mark at the current scroll position in the current tab.
-|<<spawn,spawn>>|Spawn a command in a shell.
+|<<spawn,spawn>>|Spawn an external command.
|<<stop,stop>>|Stop loading in the current/[count]th tab.
|<<tab-clone,tab-clone>>|Duplicate the current tab.
|<<tab-close,tab-close>>|Close the current/[count]th tab.
@@ -285,8 +286,7 @@ Set all settings back to their default.
[[config-cycle]]
=== config-cycle
-Syntax: +:config-cycle [*--pattern* 'pattern'] [*--temp*] [*--print*]
- 'option' ['values' ['values' ...]]+
+Syntax: +:config-cycle [*--pattern* 'pattern'] [*--temp*] [*--print*] 'option' ['values' ['values' ...]]+
Cycle an option between multiple values.
@@ -328,6 +328,16 @@ Remove a key from a dict.
==== optional arguments
* +*-t*+, +*--temp*+: Remove value temporarily until qutebrowser is closed.
+[[config-diff]]
+=== config-diff
+Syntax: +:config-diff [*--old*]+
+
+Show all customized options.
+
+==== optional arguments
+* +*-o*+, +*--old*+: Show difference for the pre-v1.0 files (qutebrowser.conf/keys.conf).
+
+
[[config-edit]]
=== config-edit
Syntax: +:config-edit [*--no-source*]+
@@ -597,8 +607,7 @@ Show help about a command or setting.
[[hint]]
=== hint
-Syntax: +:hint [*--mode* 'mode'] [*--add-history*] [*--rapid*] [*--first*]
- ['group'] ['target'] ['args' ['args' ...]]+
+Syntax: +:hint [*--mode* 'mode'] [*--add-history*] [*--rapid*] [*--first*] ['group'] ['target'] ['args' ['args' ...]]+
Start hinting.
@@ -855,8 +864,7 @@ Do nothing.
[[open]]
=== open
-Syntax: +:open [*--related*] [*--bg*] [*--tab*] [*--window*] [*--secure*] [*--private*]
- ['url']+
+Syntax: +:open [*--related*] [*--bg*] [*--tab*] [*--window*] [*--secure*] [*--private*] ['url']+
Open a URL in the current/[count]th tab.
@@ -1186,9 +1194,7 @@ Load a session.
[[session-save]]
=== session-save
-Syntax: +:session-save [*--current*] [*--quiet*] [*--force*] [*--only-active-window*]
- [*--with-private*]
- ['name']+
+Syntax: +:session-save [*--current*] [*--quiet*] [*--force*] [*--only-active-window*] [*--with-private*] ['name']+
Save a session.
@@ -1252,11 +1258,11 @@ Set a mark at the current scroll position in the current tab.
[[spawn]]
=== spawn
-Syntax: +:spawn [*--userscript*] [*--verbose*] [*--output*] [*--output-messages*]
- [*--detach*]
- 'cmdline'+
+Syntax: +:spawn [*--userscript*] [*--verbose*] [*--output*] [*--output-messages*] [*--detach*] 'cmdline'+
-Spawn a command in a shell.
+Spawn an external command.
+
+Note that the command is *not* run in a shell, so things like `$VAR` or `> output` won't have the desired effect.
==== positional arguments
* +'cmdline'+: The commandline to execute.
@@ -1335,7 +1341,7 @@ The tab index to focus, starting with 1.
[[tab-give]]
=== tab-give
-Syntax: +:tab-give [*--keep*] ['win-id']+
+Syntax: +:tab-give [*--keep*] [*--private*] ['win-id']+
Give the current tab to a new or existing window if win_id given.
@@ -1346,6 +1352,7 @@ If no win_id is given, the tab will get detached into a new window.
==== optional arguments
* +*-k*+, +*--keep*+: If given, keep the old tab around.
+* +*-p*+, +*--private*+: If the tab should be detached into a private instance.
==== count
Overrides win_id (index starts at 1 for win_id=0).
@@ -1483,8 +1490,6 @@ Yank (copy) something to the clipboard or primary selection.
- `title`: The current page's title.
- `domain`: The current scheme, domain, and port number.
- `selection`: The selection under the cursor.
- - `markdown`: Yank title and URL in markdown format
- (deprecated, use `:yank inline [{title}]({url})` instead).
- `inline`: Yank the text contained in the 'inline' argument.
@@ -1892,8 +1897,13 @@ This acts like readline's yank.
[[toggle-selection]]
=== toggle-selection
+Syntax: +:toggle-selection [*--line*]+
+
Toggle caret selection mode.
+==== optional arguments
+* +*-l*+, +*--line*+: Enables line-selection.
+
== Debugging commands
These commands are mainly intended for debugging. They are hidden if qutebrowser was started without the `--debug`-flag.
@@ -1909,6 +1919,7 @@ These commands are mainly intended for debugging. They are hidden if qutebrowser
|<<debug-crash,debug-crash>>|Crash for debugging purposes.
|<<debug-dump-history,debug-dump-history>>|Dump the history to a file in the old pre-SQL format.
|<<debug-dump-page,debug-dump-page>>|Dump the current page's content to a file.
+|<<debug-keytester,debug-keytester>>|Show a keytester widget.
|<<debug-log-capacity,debug-log-capacity>>|Change the number of log lines to be stored in RAM.
|<<debug-log-filter,debug-log-filter>>|Change the log filter for console logging.
|<<debug-log-level,debug-log-level>>|Change the log level for console logging.
@@ -1963,6 +1974,10 @@ Dump the current page's content to a file.
==== optional arguments
* +*-p*+, +*--plain*+: Write plain text instead of HTML.
+[[debug-keytester]]
+=== debug-keytester
+Show a keytester widget.
+
[[debug-log-capacity]]
=== debug-log-capacity
Syntax: +:debug-log-capacity 'capacity'+
diff --git a/doc/help/configuring.asciidoc b/doc/help/configuring.asciidoc
index 575104fc1..02a77059c 100644
--- a/doc/help/configuring.asciidoc
+++ b/doc/help/configuring.asciidoc
@@ -108,7 +108,7 @@ c.completion.shrink = True
----
Note that qutebrowser does some Python magic so it's able to warn you about
-mistyped config settings. As an example, if you do `c.tabs.possition = "left"`,
+mistyped config settings. As an example, if you do `c.tabs.position = "left"`,
you'll get an error when starting.
See the link:settings{outfilesuffix}[settings help page] for all available settings. The
diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc
index 68667d75a..cc020ea88 100644
--- a/doc/help/settings.asciidoc
+++ b/doc/help/settings.asciidoc
@@ -32,6 +32,8 @@
|<<colors.completion.odd.bg,colors.completion.odd.bg>>|Background color of the completion widget for odd rows.
|<<colors.completion.scrollbar.bg,colors.completion.scrollbar.bg>>|Color of the scrollbar in the completion view.
|<<colors.completion.scrollbar.fg,colors.completion.scrollbar.fg>>|Color of the scrollbar handle in the completion view.
+|<<colors.contextmenu.disabled.bg,colors.contextmenu.disabled.bg>>|Background color of disabled items in the context menu.
+|<<colors.contextmenu.disabled.fg,colors.contextmenu.disabled.fg>>|Foreground color of disabled items in the context menu.
|<<colors.contextmenu.menu.bg,colors.contextmenu.menu.bg>>|Background color of the context menu.
|<<colors.contextmenu.menu.fg,colors.contextmenu.menu.fg>>|Foreground color of the context menu.
|<<colors.contextmenu.selected.bg,colors.contextmenu.selected.bg>>|Background color of the context menu's selected item.
@@ -109,6 +111,15 @@
|<<colors.tabs.selected.odd.bg,colors.tabs.selected.odd.bg>>|Background color of selected odd tabs.
|<<colors.tabs.selected.odd.fg,colors.tabs.selected.odd.fg>>|Foreground color of selected odd tabs.
|<<colors.webpage.bg,colors.webpage.bg>>|Background color for webpages if unset (or empty to use the theme's color).
+|<<colors.webpage.darkmode.algorithm,colors.webpage.darkmode.algorithm>>|Which algorithm to use for modifying how colors are rendered with darkmode.
+|<<colors.webpage.darkmode.contrast,colors.webpage.darkmode.contrast>>|Contrast for dark mode.
+|<<colors.webpage.darkmode.enabled,colors.webpage.darkmode.enabled>>|Render all web contents using a dark theme.
+|<<colors.webpage.darkmode.grayscale.all,colors.webpage.darkmode.grayscale.all>>|Render all colors as grayscale.
+|<<colors.webpage.darkmode.grayscale.images,colors.webpage.darkmode.grayscale.images>>|Desaturation factor for images in dark mode.
+|<<colors.webpage.darkmode.policy.images,colors.webpage.darkmode.policy.images>>|Which images to apply dark mode to.
+|<<colors.webpage.darkmode.policy.page,colors.webpage.darkmode.policy.page>>|Which pages to apply dark mode to.
+|<<colors.webpage.darkmode.threshold.background,colors.webpage.darkmode.threshold.background>>|Threshold for inverting background elements with dark mode.
+|<<colors.webpage.darkmode.threshold.text,colors.webpage.darkmode.threshold.text>>|Threshold for inverting text with dark mode.
|<<colors.webpage.prefers_color_scheme_dark,colors.webpage.prefers_color_scheme_dark>>|Force `prefers-color-scheme: dark` colors for websites.
|<<completion.cmd_history_max_items,completion.cmd_history_max_items>>|Number of commands to save in the command history.
|<<completion.delay,completion.delay>>|Delay (in milliseconds) before updating completions after typing a character.
@@ -136,6 +147,8 @@
|<<content.desktop_capture,content.desktop_capture>>|Allow websites to share screen content.
|<<content.dns_prefetch,content.dns_prefetch>>|Try to pre-fetch DNS entries to speed up browsing.
|<<content.frame_flattening,content.frame_flattening>>|Expand each subframe to its contents.
+|<<content.fullscreen.overlay_timeout,content.fullscreen.overlay_timeout>>|Set fullscreen notification overlay timeout in milliseconds.
+|<<content.fullscreen.window,content.fullscreen.window>>|Limit fullscreen to the browser window (does not expand to fill the screen).
|<<content.geolocation,content.geolocation>>|Allow websites to request geolocations.
|<<content.headers.accept_language,content.headers.accept_language>>|Value to send in the `Accept-Language` header.
|<<content.headers.custom,content.headers.custom>>|Custom headers for qutebrowser HTTP requests.
@@ -173,10 +186,10 @@
|<<content.register_protocol_handler,content.register_protocol_handler>>|Allow websites to register protocol handlers via `navigator.registerProtocolHandler`.
|<<content.site_specific_quirks,content.site_specific_quirks>>|Enable quirks (such as faked user agent headers) needed to get specific sites to work properly.
|<<content.ssl_strict,content.ssl_strict>>|Validate SSL handshakes.
+|<<content.unknown_url_scheme_policy,content.unknown_url_scheme_policy>>|How navigation requests to URLs with unknown schemes are handled.
|<<content.user_stylesheets,content.user_stylesheets>>|List of user stylesheet filenames to use.
|<<content.webgl,content.webgl>>|Enable WebGL.
|<<content.webrtc_ip_handling_policy,content.webrtc_ip_handling_policy>>|Which interfaces to expose via WebRTC.
-|<<content.windowed_fullscreen,content.windowed_fullscreen>>|Limit fullscreen to the browser window (does not expand to fill the screen).
|<<content.xss_auditing,content.xss_auditing>>|Monitor load requests for cross-site scripting attempts.
|<<downloads.location.directory,downloads.location.directory>>|Directory to save downloads to.
|<<downloads.location.prompt,downloads.location.prompt>>|Prompt the user for the download location.
@@ -223,7 +236,9 @@
|<<hints.min_chars,hints.min_chars>>|Minimum number of characters used for hint strings.
|<<hints.mode,hints.mode>>|Mode to use for hints.
|<<hints.next_regexes,hints.next_regexes>>|Comma-separated list of regular expressions to use for 'next' links.
+|<<hints.padding,hints.padding>>|Padding (in pixels) for hints.
|<<hints.prev_regexes,hints.prev_regexes>>|Comma-separated list of regular expressions to use for 'prev' links.
+|<<hints.radius,hints.radius>>|Rounding radius (in pixels) for the edges of hints.
|<<hints.scatter,hints.scatter>>|Scatter hint key chains (like Vimium) or not (like dwb).
|<<hints.selectors,hints.selectors>>|CSS selectors used to determine which elements on a page should have hints.
|<<hints.uppercase,hints.uppercase>>|Make characters in hint strings uppercase.
@@ -245,7 +260,7 @@
|<<messages.timeout,messages.timeout>>|Duration (in milliseconds) to show messages in the statusbar for.
|<<new_instance_open_target,new_instance_open_target>>|How to open links in an existing instance if a new one is launched.
|<<new_instance_open_target_window,new_instance_open_target_window>>|Which window to choose when opening links as new tabs.
-|<<prompt.filebrowser,prompt.filebrowser>>|Show a filebrowser in upload/download prompts.
+|<<prompt.filebrowser,prompt.filebrowser>>|Show a filebrowser in download prompts.
|<<prompt.radius,prompt.radius>>|Rounding radius (in pixels) for the edges of prompts.
|<<qt.args,qt.args>>|Additional arguments to pass to Qt, without leading `--`.
|<<qt.force_platform,qt.force_platform>>|Force a Qt platform to use.
@@ -258,6 +273,7 @@
|<<scrolling.smooth,scrolling.smooth>>|Enable smooth scrolling for web pages.
|<<search.ignore_case,search.ignore_case>>|When to find text on a page case-insensitively.
|<<search.incremental,search.incremental>>|Find text on a page incrementally, renewing the search for each typed character.
+|<<search.wrap,search.wrap>>|Wrap around at the top and bottom of the page when advancing through text matches using `:search-next` and `:search-prev`.
|<<session.default_name,session.default_name>>|Name of the session to save by default.
|<<session.lazy_restore,session.lazy_restore>>|Load a restored tab as soon as it takes focus.
|<<spellcheck.languages,spellcheck.languages>>|Languages to use for spell checking.
@@ -439,6 +455,7 @@ Default:
* +pass:[J]+: +pass:[scroll down]+
* +pass:[K]+: +pass:[scroll up]+
* +pass:[L]+: +pass:[scroll right]+
+* +pass:[V]+: +pass:[toggle-selection --line]+
* +pass:[Y]+: +pass:[yank selection -s]+
* +pass:[[]+: +pass:[move-to-start-of-prev-block]+
* +pass:[]]+: +pass:[move-to-start-of-next-block]+
@@ -583,6 +600,7 @@ Default:
* +pass:[Sq]+: +pass:[open qute://bookmarks]+
* +pass:[Ss]+: +pass:[open qute://settings]+
* +pass:[T]+: +pass:[tab-focus]+
+* +pass:[V]+: +pass:[enter-mode caret ;; toggle-selection --line]+
* +pass:[ZQ]+: +pass:[quit]+
* +pass:[ZZ]+: +pass:[quit --save]+
* +pass:[[[]+: +pass:[navigate prev]+
@@ -732,6 +750,7 @@ Default:
- +pass:[&lt;Ctrl-6&gt;]+: +pass:[&lt;Ctrl-^&gt;]+
- +pass:[&lt;Ctrl-Enter&gt;]+: +pass:[&lt;Ctrl-Return&gt;]+
+- +pass:[&lt;Ctrl-I&gt;]+: +pass:[&lt;Tab&gt;]+
- +pass:[&lt;Ctrl-J&gt;]+: +pass:[&lt;Return&gt;]+
- +pass:[&lt;Ctrl-M&gt;]+: +pass:[&lt;Return&gt;]+
- +pass:[&lt;Ctrl-[&gt;]+: +pass:[&lt;Escape&gt;]+
@@ -864,6 +883,24 @@ Type: <<types,QssColor>>
Default: +pass:[white]+
+[[colors.contextmenu.disabled.bg]]
+=== colors.contextmenu.disabled.bg
+Background color of disabled items in the context menu.
+If set to null, the Qt default is used.
+
+Type: <<types,QssColor>>
+
+Default: empty
+
+[[colors.contextmenu.disabled.fg]]
+=== colors.contextmenu.disabled.fg
+Foreground color of disabled items in the context menu.
+If set to null, the Qt default is used.
+
+Type: <<types,QssColor>>
+
+Default: empty
+
[[colors.contextmenu.menu.bg]]
=== colors.contextmenu.menu.bg
Background color of the context menu.
@@ -1506,6 +1543,160 @@ Type: <<types,QtColor>>
Default: +pass:[white]+
+[[colors.webpage.darkmode.algorithm]]
+=== colors.webpage.darkmode.algorithm
+Which algorithm to use for modifying how colors are rendered with darkmode.
+This setting requires a restart.
+
+Type: <<types,String>>
+
+Valid values:
+
+ * +lightness-cielab+: Modify colors by converting them to CIELAB color space and inverting the L value.
+ * +lightness-hsl+: Modify colors by converting them to the HSL color space and inverting the lightness (i.e. the "L" in HSL).
+ * +brightness-rgb+: Modify colors by subtracting each of r, g, and b from their maximum value.
+
+Default: +pass:[lightness-cielab]+
+
+On QtWebEngine, this setting requires Qt 5.14 or newer.
+
+On QtWebKit, this setting is unavailable.
+
+[[colors.webpage.darkmode.contrast]]
+=== colors.webpage.darkmode.contrast
+Contrast for dark mode.
+This only has an effect when `colors.webpage.darkmode.algorithm` is set to `lightness-hsl` or `brightness-rgb`.
+This setting requires a restart.
+
+Type: <<types,Float>>
+
+Default: +pass:[0.0]+
+
+On QtWebEngine, this setting requires Qt 5.14 or newer.
+
+On QtWebKit, this setting is unavailable.
+
+[[colors.webpage.darkmode.enabled]]
+=== colors.webpage.darkmode.enabled
+Render all web contents using a dark theme.
+Example configurations from Chromium's `chrome://flags`:
+
+- "With simple HSL/CIELAB/RGB-based inversion": Set
+ `colors.webpage.darkmode.algorithm` accordingly.
+
+- "With selective image inversion": Set
+ `colors.webpage.darkmode.policy.images` to `smart`.
+
+- "With selective inversion of non-image elements": Set
+ `colors.webpage.darkmode.threshold.text` to 150 and
+ `colors.webpage.darkmode.threshold.background` to 205.
+
+- "With selective inversion of everything": Combines the two variants
+ above.
+This setting requires a restart.
+
+Type: <<types,Bool>>
+
+Default: +pass:[false]+
+
+On QtWebEngine, this setting requires Qt 5.14 or newer.
+
+On QtWebKit, this setting is unavailable.
+
+[[colors.webpage.darkmode.grayscale.all]]
+=== colors.webpage.darkmode.grayscale.all
+Render all colors as grayscale.
+This only has an effect when `colors.webpage.darkmode.algorithm` is set to `lightness-hsl` or `brightness-rgb`.
+This setting requires a restart.
+
+Type: <<types,Bool>>
+
+Default: +pass:[false]+
+
+On QtWebEngine, this setting requires Qt 5.14 or newer.
+
+On QtWebKit, this setting is unavailable.
+
+[[colors.webpage.darkmode.grayscale.images]]
+=== colors.webpage.darkmode.grayscale.images
+Desaturation factor for images in dark mode.
+If set to 0, images are left as-is. If set to 1, images are completely grayscale. Values between 0 and 1 desaturate the colors accordingly.
+This setting requires a restart.
+
+Type: <<types,Float>>
+
+Default: +pass:[0.0]+
+
+On QtWebEngine, this setting requires Qt 5.14 or newer.
+
+On QtWebKit, this setting is unavailable.
+
+[[colors.webpage.darkmode.policy.images]]
+=== colors.webpage.darkmode.policy.images
+Which images to apply dark mode to.
+This setting requires a restart.
+
+Type: <<types,String>>
+
+Valid values:
+
+ * +always+: Apply dark mode filter to all images.
+ * +never+: Never apply dark mode filter to any images.
+ * +smart+: Apply dark mode based on image content.
+
+Default: +pass:[never]+
+
+On QtWebEngine, this setting requires Qt 5.14 or newer.
+
+On QtWebKit, this setting is unavailable.
+
+[[colors.webpage.darkmode.policy.page]]
+=== colors.webpage.darkmode.policy.page
+Which pages to apply dark mode to.
+This setting requires a restart.
+
+Type: <<types,String>>
+
+Valid values:
+
+ * +always+: Apply dark mode filter to all frames, regardless of content.
+ * +smart+: Apply dark mode filter to frames based on background color.
+
+Default: +pass:[smart]+
+
+On QtWebEngine, this setting requires Qt 5.14 or newer.
+
+On QtWebKit, this setting is unavailable.
+
+[[colors.webpage.darkmode.threshold.background]]
+=== colors.webpage.darkmode.threshold.background
+Threshold for inverting background elements with dark mode.
+Background elements with brightness above this threshold will be inverted, and below it will be left as in the original, non-dark-mode page. Set to 256 to never invert the color or to 0 to always invert it.
+Note: This behavior is the opposite of `colors.webpage.darkmode.threshold.text`!
+This setting requires a restart.
+
+Type: <<types,Int>>
+
+Default: +pass:[0]+
+
+On QtWebEngine, this setting requires Qt 5.14 or newer.
+
+On QtWebKit, this setting is unavailable.
+
+[[colors.webpage.darkmode.threshold.text]]
+=== colors.webpage.darkmode.threshold.text
+Threshold for inverting text with dark mode.
+Text colors with brightness below this threshold will be inverted, and above it will be left as in the original, non-dark-mode page. Set to 256 to always invert text color or to 0 to never invert text color.
+This setting requires a restart.
+
+Type: <<types,Int>>
+
+Default: +pass:[256]+
+
+On QtWebEngine, this setting requires Qt 5.14 or newer.
+
+On QtWebKit, this setting is unavailable.
+
[[colors.webpage.prefers_color_scheme_dark]]
=== colors.webpage.prefers_color_scheme_dark
Force `prefers-color-scheme: dark` colors for websites.
@@ -1735,6 +1926,10 @@ This setting is only available with the QtWebEngine backend.
[[content.cookies.accept]]
=== content.cookies.accept
Which cookies to accept.
+With QtWebEngine, this setting also controls other features with tracking capabilities similar to those of cookies; including IndexedDB, DOM storage, filesystem API, service workers, and AppCache.
+Note that with QtWebKit, only `all` and `never` are supported as per-domain values. Setting `no-3rdparty` or `no-unknown-3rdparty` per-domain on QtWebKit will have the same effect as `all`.
+
+This setting supports URL patterns.
Type: <<types,String>>
@@ -1809,6 +2004,23 @@ Default: +pass:[false]+
This setting is only available with the QtWebKit backend.
+[[content.fullscreen.overlay_timeout]]
+=== content.fullscreen.overlay_timeout
+Set fullscreen notification overlay timeout in milliseconds.
+If set to 0, no overlay will be displayed.
+
+Type: <<types,Int>>
+
+Default: +pass:[3000]+
+
+[[content.fullscreen.window]]
+=== content.fullscreen.window
+Limit fullscreen to the browser window (does not expand to fill the screen).
+
+Type: <<types,Bool>>
+
+Default: +pass:[false]+
+
[[content.geolocation]]
=== content.geolocation
Allow websites to request geolocations.
@@ -2283,6 +2495,26 @@ Valid values:
Default: +pass:[ask]+
+[[content.unknown_url_scheme_policy]]
+=== content.unknown_url_scheme_policy
+How navigation requests to URLs with unknown schemes are handled.
+
+This setting supports URL patterns.
+
+Type: <<types,String>>
+
+Valid values:
+
+ * +disallow+: Disallows all navigation requests to URLs with unknown schemes.
+ * +allow-from-user-interaction+: Allows navigation requests to URLs with unknown schemes that are issued from user-interaction (like a mouse-click), whereas other navigation requests (for example from JavaScript) are suppressed.
+ * +allow-all+: Allows all navigation requests to URLs with unknown schemes.
+
+Default: +pass:[allow-from-user-interaction]+
+
+On QtWebEngine, this setting requires Qt 5.11 or newer.
+
+On QtWebKit, this setting is unavailable.
+
[[content.user_stylesheets]]
=== content.user_stylesheets
List of user stylesheet filenames to use.
@@ -2322,14 +2554,6 @@ On QtWebEngine, this setting requires Qt 5.9.2 or newer.
On QtWebKit, this setting is unavailable.
-[[content.windowed_fullscreen]]
-=== content.windowed_fullscreen
-Limit fullscreen to the browser window (does not expand to fill the screen).
-
-Type: <<types,Bool>>
-
-Default: +pass:[false]+
-
[[content.xss_auditing]]
=== content.xss_auditing
Monitor load requests for cross-site scripting attempts.
@@ -2764,6 +2988,19 @@ Default:
- +pass:[\b(&gt;&gt;|»)\b]+
- +pass:[\bcontinue\b]+
+[[hints.padding]]
+=== hints.padding
+Padding (in pixels) for hints.
+
+Type: <<types,Padding>>
+
+Default:
+
+- +pass:[bottom]+: +pass:[0]+
+- +pass:[left]+: +pass:[3]+
+- +pass:[right]+: +pass:[3]+
+- +pass:[top]+: +pass:[0]+
+
[[hints.prev_regexes]]
=== hints.prev_regexes
Comma-separated list of regular expressions to use for 'prev' links.
@@ -2778,6 +3015,14 @@ Default:
- +pass:[\b[&lt;←≪]\b]+
- +pass:[\b(&lt;&lt;|«)\b]+
+[[hints.radius]]
+=== hints.radius
+Rounding radius (in pixels) for the edges of hints.
+
+Type: <<types,Int>>
+
+Default: +pass:[3]+
+
[[hints.scatter]]
=== hints.scatter
Scatter hint key chains (like Vimium) or not (like dwb).
@@ -3048,7 +3293,7 @@ Default: +pass:[last-focused]+
[[prompt.filebrowser]]
=== prompt.filebrowser
-Show a filebrowser in upload/download prompts.
+Show a filebrowser in download prompts.
Type: <<types,Bool>>
@@ -3209,6 +3454,16 @@ Type: <<types,Bool>>
Default: +pass:[true]+
+[[search.wrap]]
+=== search.wrap
+Wrap around at the top and bottom of the page when advancing through text matches using `:search-next` and `:search-prev`.
+
+Type: <<types,Bool>>
+
+Default: +pass:[true]+
+
+On QtWebEngine, this setting requires Qt 5.14 or newer.
+
[[session.default_name]]
=== session.default_name
Name of the session to save by default.
@@ -3754,8 +4009,28 @@ Default: +pass:[false]+
[[url.searchengines]]
=== url.searchengines
Search engines which can be used via the address bar.
-Maps a search engine name (such as `DEFAULT`, or `ddg`) to a URL with a `{}` placeholder. The placeholder will be replaced by the search term, use `{{` and `}}` for literal `{`/`}` signs.
-The search engine named `DEFAULT` is used when `url.auto_search` is turned on and something else than a URL was entered to be opened. Other search engines can be used by prepending the search engine name to the search term, e.g. `:open google qutebrowser`.
+
+Maps a search engine name (such as `DEFAULT`, or `ddg`) to a URL with a
+`{}` placeholder. The placeholder will be replaced by the search term, use
+`{{` and `}}` for literal `{`/`}` braces.
+
+The following further placeholds are defined to configure how special
+characters in the search terms are replaced by safe characters (called
+'quoting'):
+
+* `{}` and `{semiquoted}` quote everything except slashes; this is the most
+ sensible choice for almost all search engines (for the search term
+ `slash/and&amp` this placeholder expands to `slash/and%26amp`).
+* `{quoted}` quotes all characters (for `slash/and&amp` this placeholder
+ expands to `slash%2Fand%26amp`).
+* `{unquoted}` quotes nothing (for `slash/and&amp` this placeholder
+ expands to `slash/and&amp`).
+
+The search engine named `DEFAULT` is used when `url.auto_search` is turned
+on and something else than a URL was entered to be opened. Other search
+engines can be used by prepending the search engine name to the search
+term, e.g. `:open google qutebrowser`.
+
Type: <<types,Dict>>
diff --git a/doc/install.asciidoc b/doc/install.asciidoc
index 1e72b24fc..4355abc7b 100644
--- a/doc/install.asciidoc
+++ b/doc/install.asciidoc
@@ -256,7 +256,7 @@ mailinglist] to get notified on new releases). You can install a newer version
without uninstalling the older one.
The binary release ships with a QtWebEngine built without proprietary codec
-support. To get support for e.g. h264/h265 videos, you'll need to build
+support. To get support for e.g. h264/mp4 videos, you'll need to build
QtWebEngine from source yourself with support for that enabled.
https://chocolatey.org/packages/qutebrowser[Chocolatey package]
@@ -299,7 +299,7 @@ https://lists.schokokeks.org/mailman/listinfo.cgi/qutebrowser-announce[qutebrows
mailinglist] to get notified on new releases).
The binary release ships with a QtWebEngine built without proprietary codec
-support. To get support for e.g. h264/h265 videos, you'll need to build
+support. To get support for e.g. h264/mp4 videos, you'll need to build
QtWebEngine from source yourself with support for that enabled.
This binary is also available through the
diff --git a/misc/org.qutebrowser.qutebrowser.appdata.xml b/misc/org.qutebrowser.qutebrowser.appdata.xml
index d7c8162c0..ca58f4bd5 100644
--- a/misc/org.qutebrowser.qutebrowser.appdata.xml
+++ b/misc/org.qutebrowser.qutebrowser.appdata.xml
@@ -44,6 +44,9 @@
</content_rating>
<releases>
<!-- Add new releases here -->
+<release version="1.11.1" date="2020-05-07"/>
+<release version="1.11.0" date="2020-04-27"/>
+<release version="1.10.2" date="2020-04-17"/>
<release version="1.10.1" date="2020-02-15"/>
<release version="1.10.0" date="2020-02-02"/>
<release version="1.9.0" date="2020-01-08"/>
diff --git a/misc/requirements/requirements-check-manifest.txt b/misc/requirements/requirements-check-manifest.txt
index 8b18ce2a4..4cc00982d 100644
--- a/misc/requirements/requirements-check-manifest.txt
+++ b/misc/requirements/requirements-check-manifest.txt
@@ -1,5 +1,5 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
-check-manifest==0.41
-pep517==0.8.1
-toml==0.10.0
+check-manifest==0.42
+pep517==0.8.2
+toml==0.10.1
diff --git a/misc/requirements/requirements-codecov.txt b/misc/requirements/requirements-codecov.txt
index 8961ca2be..0a38e12b5 100644
--- a/misc/requirements/requirements-codecov.txt
+++ b/misc/requirements/requirements-codecov.txt
@@ -1,9 +1,9 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
-certifi==2019.11.28
+certifi==2020.4.5.1
chardet==3.0.4
-codecov==2.0.16
-coverage==5.0.3
+codecov==2.1.3
+coverage==5.1
idna==2.9
requests==2.23.0
-urllib3==1.25.8
+urllib3==1.25.9
diff --git a/misc/requirements/requirements-dev.txt b/misc/requirements/requirements-dev.txt
index 53634fb5b..620e5772c 100644
--- a/misc/requirements/requirements-dev.txt
+++ b/misc/requirements/requirements-dev.txt
@@ -1,22 +1,27 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
bump2version==1.0.0
-certifi==2019.11.28
+certifi==2020.4.5.1
cffi==1.14.0
chardet==3.0.4
colorama==0.4.3
-cryptography==2.8
+cryptography==2.9.2
cssutils==1.0.2
github3.py==1.3.0
hunter==3.1.3
idna==2.9
jwcrypto==0.7
-lxml==4.5.0
+lxml==4.5.1
manhole==1.6.0
+packaging==20.4
pycparser==2.20
Pympler==0.8
+pyparsing==2.4.7
+PyQt-builder==1.3.2
python-dateutil==2.8.1
requests==2.23.0
-six==1.14.0
+sip==5.2.0
+six==1.15.0
+toml==0.10.1
uritemplate==3.0.1
-urllib3==1.25.8
+urllib3==1.25.9
diff --git a/misc/requirements/requirements-dev.txt-raw b/misc/requirements/requirements-dev.txt-raw
index ab58a3fef..f75a837af 100644
--- a/misc/requirements/requirements-dev.txt-raw
+++ b/misc/requirements/requirements-dev.txt-raw
@@ -5,3 +5,4 @@ github3.py
bump2version
requests
lxml
+pyqt-builder
diff --git a/misc/requirements/requirements-flake8.txt b/misc/requirements/requirements-flake8.txt
index 8edadcb3f..d0292a4eb 100644
--- a/misc/requirements/requirements-flake8.txt
+++ b/misc/requirements/requirements-flake8.txt
@@ -1,10 +1,9 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
attrs==19.3.0
-entrypoints==0.3
-flake8==3.7.9
+flake8==3.8.2
flake8-bugbear==20.1.4
-flake8-builtins==1.4.2
+flake8-builtins==1.5.3
flake8-comprehensions==3.2.2
flake8-copyright==0.2.2
flake8-debugger==3.2.1
@@ -14,12 +13,12 @@ flake8-future-import==0.4.6
flake8-mock==0.3
flake8-polyfill==1.0.2
flake8-string-format==0.3.0
-flake8-tidy-imports==4.0.0
+flake8-tidy-imports==4.1.0
flake8-tuple==0.4.1
mccabe==0.6.1
-pep8-naming==0.9.1
-pycodestyle==2.5.0
+pep8-naming==0.10.0
+pycodestyle==2.6.0
pydocstyle==5.0.2
-pyflakes==2.1.1
-six==1.14.0
+pyflakes==2.2.0
+six==1.15.0
snowballstemmer==2.0.0
diff --git a/misc/requirements/requirements-mypy.txt b/misc/requirements/requirements-mypy.txt
index aa08cc2b7..3900a8c20 100644
--- a/misc/requirements/requirements-mypy.txt
+++ b/misc/requirements/requirements-mypy.txt
@@ -1,9 +1,7 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
-mypy==0.761
+mypy==0.770
mypy-extensions==0.4.3
-# PyQt5==5.11.3
-# PyQt5-sip==4.19.19
--e git+https://github.com/qutebrowser/PyQt5-stubs.git@wip#egg=PyQt5_stubs
+-e git+https://github.com/stlehmann/PyQt5-stubs.git@master#egg=PyQt5_stubs
typed-ast==1.4.1
-typing-extensions==3.7.4.1
+typing-extensions==3.7.4.2
diff --git a/misc/requirements/requirements-mypy.txt-raw b/misc/requirements/requirements-mypy.txt-raw
index 92a35ab74..777b288ba 100644
--- a/misc/requirements/requirements-mypy.txt-raw
+++ b/misc/requirements/requirements-mypy.txt-raw
@@ -1,6 +1,5 @@
mypy
--e git+https://github.com/qutebrowser/PyQt5-stubs.git@wip#egg=PyQt5-stubs
+-e git+https://github.com/stlehmann/PyQt5-stubs.git@master#egg=PyQt5-stubs
# remove @commit-id for scm installs
-#@ replace: @.*# @wip#
-#@ ignore: PyQt5, PyQt5-sip
+#@ replace: @.*# @master#
diff --git a/misc/requirements/requirements-pip.txt b/misc/requirements/requirements-pip.txt
index 2b7977bfc..3a71ad0a8 100644
--- a/misc/requirements/requirements-pip.txt
+++ b/misc/requirements/requirements-pip.txt
@@ -1,8 +1,8 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
-appdirs==1.4.3
-packaging==20.3
-pyparsing==2.4.6
-setuptools==46.0.0
-six==1.14.0
+appdirs==1.4.4
+packaging==20.4
+pyparsing==2.4.7
+setuptools==46.4.0
+six==1.15.0
wheel==0.34.2
diff --git a/misc/requirements/requirements-pyinstaller.txt b/misc/requirements/requirements-pyinstaller.txt
index 431673cce..d6fa5bc82 100644
--- a/misc/requirements/requirements-pyinstaller.txt
+++ b/misc/requirements/requirements-pyinstaller.txt
@@ -1,4 +1,4 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
altgraph==0.17
--e git+https://github.com/pyinstaller/pyinstaller.git@develop#egg=PyInstaller
+-e git+https://github.com/pyinstaller/pyinstaller.git@develop#egg=pyinstaller
diff --git a/misc/requirements/requirements-pylint.txt b/misc/requirements/requirements-pylint.txt
index 7b543b830..e80ddbf50 100644
--- a/misc/requirements/requirements-pylint.txt
+++ b/misc/requirements/requirements-pylint.txt
@@ -1,10 +1,10 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
-astroid==2.3.3
-certifi==2019.11.28
+astroid==2.3.3 # rq.filter: < 2.4
+certifi==2020.4.5.1
cffi==1.14.0
chardet==3.0.4
-cryptography==2.8
+cryptography==2.9.2
github3.py==1.3.0
idna==2.9
isort==4.3.21
@@ -12,12 +12,12 @@ jwcrypto==0.7
lazy-object-proxy==1.4.3
mccabe==0.6.1
pycparser==2.20
-pylint==2.4.4
+pylint==2.4.4 # rq.filter: < 2.5
python-dateutil==2.8.1
./scripts/dev/pylint_checkers
requests==2.23.0
-six==1.14.0
+six==1.15.0
typed-ast==1.4.1 ; python_version<"3.8"
uritemplate==3.0.1
-urllib3==1.25.8
+urllib3==1.25.9
wrapt==1.12.1
diff --git a/misc/requirements/requirements-pylint.txt-raw b/misc/requirements/requirements-pylint.txt-raw
index 8a1d36ffc..8e88c128d 100644
--- a/misc/requirements/requirements-pylint.txt-raw
+++ b/misc/requirements/requirements-pylint.txt-raw
@@ -1,4 +1,4 @@
-pylint
+pylint<2.5
./scripts/dev/pylint_checkers
requests
github3.py
@@ -6,3 +6,5 @@ github3.py
# fix qute-pylint location
#@ replace: qute-pylint==.* ./scripts/dev/pylint_checkers
#@ markers: typed-ast python_version<"3.8"
+#@ filter: pylint < 2.5
+#@ filter: astroid < 2.4
diff --git a/misc/requirements/requirements-pyqt-5.12.txt b/misc/requirements/requirements-pyqt-5.12.txt
index 51d019f6f..b1be83265 100644
--- a/misc/requirements/requirements-pyqt-5.12.txt
+++ b/misc/requirements/requirements-pyqt-5.12.txt
@@ -1,5 +1,5 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
PyQt5==5.12.3 # rq.filter: < 5.13
-PyQt5-sip==12.7.1
+PyQt5-sip==12.7.2
PyQtWebEngine==5.12.1 # rq.filter: < 5.13
diff --git a/misc/requirements/requirements-pyqt-5.13.txt b/misc/requirements/requirements-pyqt-5.13.txt
index e80cf79ee..dc2f0359a 100644
--- a/misc/requirements/requirements-pyqt-5.13.txt
+++ b/misc/requirements/requirements-pyqt-5.13.txt
@@ -1,5 +1,5 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
PyQt5==5.13.2 # rq.filter: < 5.14
-PyQt5-sip==12.7.1
+PyQt5-sip==12.7.2
PyQtWebEngine==5.13.2 # rq.filter: < 5.14
diff --git a/misc/requirements/requirements-pyqt-5.14.txt b/misc/requirements/requirements-pyqt-5.14.txt
index a0107262e..7640a8adb 100644
--- a/misc/requirements/requirements-pyqt-5.14.txt
+++ b/misc/requirements/requirements-pyqt-5.14.txt
@@ -1,5 +1,5 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
-PyQt5==5.14.1 # rq.filter: < 5.15
-PyQt5-sip==12.7.1
+PyQt5==5.14.2 # rq.filter: < 5.15
+PyQt5-sip==12.7.2
PyQtWebEngine==5.14.0 # rq.filter: < 5.15
diff --git a/misc/requirements/requirements-pyqt.txt b/misc/requirements/requirements-pyqt.txt
index b0aedce2b..90febc2e7 100644
--- a/misc/requirements/requirements-pyqt.txt
+++ b/misc/requirements/requirements-pyqt.txt
@@ -1,5 +1,5 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
-PyQt5==5.14.1
-PyQt5-sip==12.7.1
+PyQt5==5.14.2
+PyQt5-sip==12.7.2
PyQtWebEngine==5.14.0
diff --git a/misc/requirements/requirements-sphinx.txt b/misc/requirements/requirements-sphinx.txt
index b1935ded3..e4ca26a6a 100644
--- a/misc/requirements/requirements-sphinx.txt
+++ b/misc/requirements/requirements-sphinx.txt
@@ -2,25 +2,25 @@
alabaster==0.7.12
Babel==2.8.0
-certifi==2019.11.28
+certifi==2020.4.5.1
chardet==3.0.4
docutils==0.16
idna==2.9
imagesize==1.2.0
-Jinja2==2.11.1
+Jinja2==2.11.2
MarkupSafe==1.1.1
-packaging==20.3
+packaging==20.4
Pygments==2.6.1
-pyparsing==2.4.6
-pytz==2019.3
+pyparsing==2.4.7
+pytz==2020.1
requests==2.23.0
-six==1.14.0
+six==1.15.0
snowballstemmer==2.0.0
-Sphinx==2.4.4
+Sphinx==3.0.3
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==1.0.3
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.4
-urllib3==1.25.8
+urllib3==1.25.9
diff --git a/misc/requirements/requirements-tests.txt b/misc/requirements/requirements-tests.txt
index 870ea94f5..1c0c9acde 100644
--- a/misc/requirements/requirements-tests.txt
+++ b/misc/requirements/requirements-tests.txt
@@ -1,46 +1,47 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
attrs==19.3.0
-beautifulsoup4==4.8.2
+beautifulsoup4==4.9.1
cheroot==8.3.0
-click==7.1.1
+click==7.1.2
# colorama==0.4.3
-coverage==5.0.3
-EasyProcess==0.2.10
-Flask==1.1.1
+coverage==5.1
+EasyProcess==0.3
+Flask==1.1.2
glob2==0.7
hunter==3.1.3
-hypothesis==5.6.0
+hypothesis==5.15.1
itsdangerous==1.1.0
-jaraco.functools==3.0.0 ; python_version>="3.6"
-# Jinja2==2.11.1
+jaraco.functools==3.0.1 ; python_version>="3.6"
+# Jinja2==2.11.2
Mako==1.1.2
manhole==1.6.0
# MarkupSafe==1.1.1
-more-itertools==8.2.0
-packaging==20.3
+more-itertools==8.3.0
+packaging==20.4
parse==1.15.0
parse-type==0.5.2
pluggy==0.13.1
py==1.8.1
py-cpuinfo==5.0.0
-pyparsing==2.4.6
-pytest==5.3.5
-pytest-bdd==3.2.1
+Pygments==2.6.1
+pyparsing==2.4.7
+pytest==5.4.2
+pytest-bdd==3.3.0
pytest-benchmark==3.2.3
-pytest-cov==2.8.1
+pytest-cov==2.9.0
pytest-instafail==0.4.1.post0
-pytest-mock==2.0.0
+pytest-mock==3.1.0
pytest-qt==3.3.0
pytest-repeat==0.8.0
-pytest-rerunfailures==8.0
+pytest-rerunfailures==9.0
pytest-travis-fold==1.3.0
pytest-xvfb==1.2.0
PyVirtualDisplay==0.2.5
-six==1.14.0
+six==1.15.0
sortedcontainers==2.1.0
-soupsieve==2.0
-vulture==1.3
-wcwidth==0.1.8
-Werkzeug==1.0.0
+soupsieve==2.0.1
+vulture==1.4
+wcwidth==0.1.9
+Werkzeug==1.0.1
jaraco.functools==2.0; python_version<"3.6" # rq.filter: <= 2.0
diff --git a/misc/requirements/requirements-tests.txt-raw b/misc/requirements/requirements-tests.txt-raw
index 33880416c..4d6932c82 100644
--- a/misc/requirements/requirements-tests.txt-raw
+++ b/misc/requirements/requirements-tests.txt-raw
@@ -2,7 +2,6 @@ beautifulsoup4
cheroot
coverage
Flask
-hunter
hypothesis
pytest
pytest-bdd
@@ -11,11 +10,20 @@ pytest-cov
pytest-instafail
pytest-mock
pytest-qt
-pytest-repeat
pytest-rerunfailures
-pytest-travis-fold
pytest-xvfb
+
+## optional:
+# To test :debug-trace, gets skipped if hunter is not installed
+hunter
+# To test scripts/dev/run_vulture.py which is not part of the release tarball
vulture
+# For colored pytest output (though also a direct qutebrowser dependency))
+pygments
+# Output folding on Travis
+pytest-travis-fold
+# --repeat switch (used to manually repeat tests)
+pytest-repeat
#@ markers: jaraco.functools python_version>="3.6"
#@ add: jaraco.functools==2.0; python_version<"3.6" # rq.filter: <= 2.0
diff --git a/misc/requirements/requirements-tox.txt b/misc/requirements/requirements-tox.txt
index c4fdcac7f..3b4c93bb4 100644
--- a/misc/requirements/requirements-tox.txt
+++ b/misc/requirements/requirements-tox.txt
@@ -1,15 +1,15 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
-appdirs==1.4.3
+appdirs==1.4.4
distlib==0.3.0
filelock==3.0.12
-packaging==20.3
+packaging==20.4
pluggy==0.13.1
py==1.8.1
-pyparsing==2.4.6
-six==1.14.0
-toml==0.10.0
-tox==3.14.5
+pyparsing==2.4.7
+six==1.15.0
+toml==0.10.1
+tox==3.15.1
tox-pip-version==0.0.7
tox-venv==0.4.0
-virtualenv==20.0.10
+virtualenv==20.0.21
diff --git a/misc/requirements/requirements-vulture.txt b/misc/requirements/requirements-vulture.txt
index 501dcd973..c5c343f9e 100644
--- a/misc/requirements/requirements-vulture.txt
+++ b/misc/requirements/requirements-vulture.txt
@@ -1,3 +1,3 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
-vulture==1.3
+vulture==1.4
diff --git a/misc/userscripts/getbib b/misc/userscripts/getbib
index 22af7a8f9..33c516904 100755
--- a/misc/userscripts/getbib
+++ b/misc/userscripts/getbib
@@ -14,7 +14,6 @@ https://ocefpaf.github.io/python4oceanographers/blog/2014/05/19/doi2bibtex/
import os
import sys
-import shutil
import re
from collections import Counter
from urllib import parse as url_parse
diff --git a/misc/userscripts/password_fill b/misc/userscripts/password_fill
index 7d4be0467..4ebeebdc5 100755
--- a/misc/userscripts/password_fill
+++ b/misc/userscripts/password_fill
@@ -358,11 +358,13 @@ cat <<EOF
if (isVisible(input) && (input.type == "text" || input.type == "email")) {
input.focus();
input.value = "$(javascript_escape "${username}")";
+ input.dispatchEvent(new Event('change'));
input.blur();
}
if (input.type == "password") {
input.focus();
input.value = "$(javascript_escape "${password}")";
+ input.dispatchEvent(new Event('change'));
input.blur();
}
}
diff --git a/misc/userscripts/qute-bitwarden b/misc/userscripts/qute-bitwarden
index f6212d35a..d5c4b1e2d 100755
--- a/misc/userscripts/qute-bitwarden
+++ b/misc/userscripts/qute-bitwarden
@@ -27,6 +27,9 @@ USAGE = """The domain of the site has to be in the name of the Bitwarden entry,
"websites/github.com". The login information is inserted by emulating key events using qutebrowser's fake-key command in this manner:
[USERNAME]<Tab>[PASSWORD], which is compatible with almost all login forms.
+If enabled, with the `--totp` flag, it will also move the TOTP code to the
+clipboard, much like the Firefox add-on.
+
You must log into Bitwarden CLI using `bw login` prior to use of this script.
The session key will be stored using keyctl for the number of seconds passed to
the --auto-lock option.
@@ -34,18 +37,17 @@ the --auto-lock option.
To use in qutebrowser, run: `spawn --userscript qute-bitwarden`
"""
-EPILOG = """Dependencies: tldextract (Python 3 module), Bitwarden CLI (1.7.4 is
-known to work but older versions may well also work)
+EPILOG = """Dependencies: tldextract (Python 3 module), pyperclip (optional
+Python module, used for TOTP codes), Bitwarden CLI (1.7.4 is known to work
+but older versions may well also work)
WARNING: The login details are viewable as plaintext in qutebrowser's debug log
(qute://log) and might be shared if you decide to submit a crash report!"""
import argparse
import enum
-import fnmatch
import functools
import os
-import re
import shlex
import subprocess
import sys
@@ -62,6 +64,8 @@ argument_parser.add_argument('--dmenu-invocation', '-d', default='rofi -dmenu -i
help='Invocation used to execute a dmenu-provider')
argument_parser.add_argument('--no-insert-mode', '-n', dest='insert_mode', action='store_false',
help="Don't automatically enter insert mode")
+argument_parser.add_argument('--totp', '-t', action='store_true',
+ help="Copy TOTP key to clipboard")
argument_parser.add_argument('--io-encoding', '-i', default='UTF-8',
help='Encoding used to communicate with subprocesses')
argument_parser.add_argument('--merge-candidates', '-m', action='store_true',
@@ -73,6 +77,8 @@ group.add_argument('--username-only', '-e',
action='store_true', help='Only insert username')
group.add_argument('--password-only', '-w',
action='store_true', help='Only insert password')
+group.add_argument('--totp-only', '-T',
+ action='store_true', help='Only insert totp code')
stderr = functools.partial(print, file=sys.stderr)
@@ -158,6 +164,26 @@ def pass_(domain, encoding, auto_lock):
return out
+def get_totp_code(selection_id, domain_name, encoding, auto_lock):
+ session_key = get_session_key(auto_lock)
+ process = subprocess.run(
+ ['bw', 'get', 'totp', '--session', session_key, selection_id],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
+
+ err = process.stderr.decode(encoding).strip()
+ if err:
+ # domain_name instead of selection_id to make it more user-friendly
+ msg = 'Bitwarden CLI returned for {:s} - {:s}'.format(domain_name, err)
+ stderr(msg)
+ return '[]'
+
+ out = process.stdout.decode(encoding).strip()
+
+ return out
+
+
def dmenu(items, invocation, encoding):
command = shlex.split(invocation)
process = subprocess.run(command, input='\n'.join(
@@ -227,11 +253,22 @@ def main(arguments):
username = selection['login']['username']
password = selection['login']['password']
+ totp = selection['login']['totp']
if arguments.username_only:
fake_key_raw(username)
elif arguments.password_only:
fake_key_raw(password)
+ elif arguments.totp_only:
+ # No point in moving it to the clipboard in this case
+ fake_key_raw(
+ get_totp_code(
+ selection['id'],
+ selection['name'],
+ arguments.io_encoding,
+ arguments.auto_lock
+ )
+ )
else:
# Enter username and password using fake-key and <Tab> (which seems to work almost universally), then switch
# back into insert-mode, so the form can be directly submitted by
@@ -243,6 +280,20 @@ def main(arguments):
if arguments.insert_mode:
qute_command('enter-mode insert')
+ # If it finds a TOTP code, it copies it to the clipboard,
+ # which is the same behaviour as the Firefox add-on.
+ if not arguments.totp_only and totp and arguments.totp:
+ # The import is done here, to make pyperclip an optional dependency
+ import pyperclip
+ pyperclip.copy(
+ get_totp_code(
+ selection['id'],
+ selection['name'],
+ arguments.io_encoding,
+ arguments.auto_lock
+ )
+ )
+
return ExitCodes.SUCCESS
diff --git a/misc/userscripts/qute-lastpass b/misc/userscripts/qute-lastpass
index 6845a4cda..e58f4c817 100755
--- a/misc/userscripts/qute-lastpass
+++ b/misc/userscripts/qute-lastpass
@@ -39,10 +39,8 @@ you decide to submit a crash report!"""
import argparse
import enum
-import fnmatch
import functools
import os
-import re
import shlex
import subprocess
import sys
diff --git a/misc/userscripts/readability-js b/misc/userscripts/readability-js
index efd086ce0..6a1a96c84 100755
--- a/misc/userscripts/readability-js
+++ b/misc/userscripts/readability-js
@@ -46,10 +46,20 @@ const HEADER = `
line-height: 1.2;
}
</style>
+ <!-- This icon is licensed under the Mozilla Public License 2.0 (available at: https://www.mozilla.org/en-US/MPL/2.0/).
+ The original icon can be found here: https://dxr.mozilla.org/mozilla-central/source/browser/themes/shared/reader/readerMode.svg -->
+ <link rel="shortcut icon" href="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjRweCIgaGVpZ2h0PSI2NHB4IiB2ZXJzaW9uPSIxLjEiI
+ HZpZXdCb3g9IjAgMCA2NCA2NCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgZmlsbD0iI2ZmZiI+CjxwYXRoIGQ9Im01MiAwaC00
+ MGMtNC40MiAwLTggMy41OC04IDh2NDhjMCA0LjQyIDMuNTggOCA4IDhoNDBjNC40MiAwIDgtMy41OCA4LTh2LTQ4YzAtNC40Mi0zLjU4LTgtOC04em0wIDU
+ yYzAgMi4yMS0xLjc5IDQtNCA0aC0zMmMtMi4yMSAwLTQtMS43OS00LTR2LTQwYzAtMi4yMSAxLjc5LTQgNC00aDMyYzIuMjEgMCA0IDEuNzkgNCA0em0tMT
+ AtMzZoLTIwYy0xLjExIDAtMiAwLjg5NS0yIDJzMC44OTUgMiAyIDJoMjBjMS4xMSAwIDItMC44OTUgMi0ycy0wLjg5NS0yLTItMnptMCA4aC0yMGMtMS4xM
+ SAwLTIgMC44OTUtMiAyczAuODk1IDIgMiAyaDIwYzEuMTEgMCAyLTAuODk1IDItMnMtMC44OTUtMi0yLTJ6bTAgOGgtMjBjLTEuMTEgMC0yIDAuODk1LTIg
+ MnMwLjg5NSAyIDIgMmgyMGMxLjExIDAgMi0wLjg5NSAyLTJzLTAuODk1LTItMi0yem0tMTIgOGgtOGMtMS4xMSAwLTIgMC44OTUtMiAyczAuODk1IDIgMiA
+ yaDhjMS4xMSAwIDItMC44OTUgMi0ycy0wLjg5NS0yLTItMnoiIGZpbGw9IiNmZmYiLz4KPC9nPgo8L3N2Zz4K"/>
</head>`;
const scriptsDir = path.join(process.env.QUTE_DATA_DIR, 'userscripts');
const tmpFile = path.join(scriptsDir, '/readability.html');
-const domOpts = {url: process.env.QUTE_URL, contentType: "text/html; charset=utf-8"}
+const domOpts = {url: process.env.QUTE_URL, contentType: "text/html; charset=utf-8"};
if (!fs.existsSync(scriptsDir)){
fs.mkdirSync(scriptsDir);
@@ -66,6 +76,6 @@ JSDOM.fromFile(process.env.QUTE_HTML, domOpts).then(dom => {
return 1;
}
// Success
- qute.open(['-t', tmpFile]);
+ qute.open(['-t', '-r', tmpFile]);
})
});
diff --git a/mypy.ini b/mypy.ini
index 5d404f4b2..98150f002 100644
--- a/mypy.ini
+++ b/mypy.ini
@@ -4,23 +4,23 @@
python_version = 3.6
# --strict
-warn_redundant_casts = True
-warn_unused_ignores = True
+warn_unused_configs = True
+# disallow_any_generics = True
disallow_subclassing_any = True
-disallow_untyped_decorators = True
-## https://github.com/python/mypy/issues/5957
-# warn_unused_configs = True
# disallow_untyped_calls = True
# disallow_untyped_defs = True
-## https://github.com/python/mypy/issues/5954
-# disallow_incomplete_defs = True
+disallow_incomplete_defs = True
check_untyped_defs = True
+disallow_untyped_decorators = True
# no_implicit_optional = True
+warn_redundant_casts = True
+warn_unused_ignores = True
# warn_return_any = True
-warn_unreachable = True
+# no_implicit_reexport = True
+strict_equality = True
# Other strictness flags
-strict_equality = True
+warn_unreachable = True
# Output
show_error_codes = True
@@ -65,76 +65,51 @@ disallow_subclassing_any = False
[mypy-qutebrowser.browser.browsertab]
disallow_untyped_defs = True
-disallow_incomplete_defs = True
[mypy-qutebrowser.browser.hints]
disallow_untyped_defs = True
-disallow_incomplete_defs = True
[mypy-qutebrowser.misc.objects]
disallow_untyped_defs = True
-disallow_incomplete_defs = True
[mypy-qutebrowser.misc.debugcachestats]
disallow_untyped_defs = True
-disallow_incomplete_defs = True
[mypy-qutebrowser.misc.utilcmds]
disallow_untyped_defs = True
-disallow_incomplete_defs = True
[mypy-qutebrowser.misc.throttle]
disallow_untyped_defs = True
-disallow_incomplete_defs = True
[mypy-qutebrowser.misc.backendproblem]
disallow_untyped_defs = True
-disallow_incomplete_defs = True
-
-[mypy-qutebrowser.misc.eventfilter]
-disallow_untyped_defs = True
-disallow_incomplete_defs = True
-
-[mypy-qutebrowser.commands.cmdutils]
-disallow_untyped_defs = True
-disallow_incomplete_defs = True
[mypy-qutebrowser.config.*]
disallow_untyped_defs = True
-disallow_incomplete_defs = True
[mypy-qutebrowser.api.*]
disallow_untyped_defs = True
-disallow_incomplete_defs = True
[mypy-qutebrowser.components.*]
disallow_untyped_defs = True
-disallow_incomplete_defs = True
[mypy-qutebrowser.extensions.*]
disallow_untyped_defs = True
-disallow_incomplete_defs = True
[mypy-qutebrowser.browser.webelem]
disallow_untyped_defs = True
-disallow_incomplete_defs = True
[mypy-qutebrowser.browser.webkit.webkitelem]
disallow_untyped_defs = True
-disallow_incomplete_defs = True
[mypy-qutebrowser.browser.webengine.webengineelem]
disallow_untyped_defs = True
-disallow_incomplete_defs = True
[mypy-qutebrowser.keyinput.*]
disallow_untyped_defs = True
-disallow_incomplete_defs = True
[mypy-qutebrowser.utils.*]
disallow_untyped_defs = True
-disallow_incomplete_defs = True
[mypy-qutebrowser.mainwindow.statusbar.command]
disallow_untyped_defs = True
-disallow_incomplete_defs = True
diff --git a/pytest.ini b/pytest.ini
index 1b53cb559..e85f2b298 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -1,6 +1,6 @@
[pytest]
log_level = NOTSET
-addopts = --strict -rfEw --instafail --benchmark-columns=Min,Max,Median
+addopts = --strict --instafail --benchmark-columns=Min,Max,Median
testpaths = tests
markers =
gui: Tests using the GUI (e.g. spawning widgets)
@@ -71,5 +71,5 @@ xfail_strict = true
filterwarnings =
error
# See https://github.com/HypothesisWorks/hypothesis/issues/2370
- ignore:.*, but function-scoped fixtures:hypothesis.errors.HypothesisDeprecationWarning
+ ignore:.*which is reset between function calls but not between test cases generated by:hypothesis.errors.HypothesisDeprecationWarning
faulthandler_timeout = 90
diff --git a/qutebrowser/__init__.py b/qutebrowser/__init__.py
index cb50504af..6d684d6e3 100644
--- a/qutebrowser/__init__.py
+++ b/qutebrowser/__init__.py
@@ -26,7 +26,7 @@ __copyright__ = "Copyright 2014-2020 Florian Bruhin (The Compiler)"
__license__ = "GPL"
__maintainer__ = __author__
__email__ = "mail@qutebrowser.org"
-__version__ = "1.10.1"
+__version__ = "1.11.1"
__version_info__ = tuple(int(part) for part in __version__.split('.'))
__description__ = "A keyboard-driven, vim-like browser based on PyQt5."
diff --git a/qutebrowser/api/cmdutils.py b/qutebrowser/api/cmdutils.py
index 1498cc051..5d74991c1 100644
--- a/qutebrowser/api/cmdutils.py
+++ b/qutebrowser/api/cmdutils.py
@@ -208,12 +208,12 @@ class argument: # noqa: N801,N806 pylint: disable=invalid-name
raise ValueError("{} has no argument {}!".format(funcname,
self._argname))
if not hasattr(func, 'qute_args'):
- func.qute_args = {} # type: ignore
- elif func.qute_args is None: # type: ignore
+ func.qute_args = {} # type: ignore[attr-defined]
+ elif func.qute_args is None: # type: ignore[attr-defined]
raise ValueError("@cmdutils.argument got called above (after) "
"@cmdutils.register for {}!".format(funcname))
arginfo = command.ArgInfo(**self._kwargs)
- func.qute_args[self._argname] = arginfo # type: ignore
+ func.qute_args[self._argname] = arginfo # type: ignore[attr-defined]
return func
diff --git a/qutebrowser/app.py b/qutebrowser/app.py
index 445593706..6d01e0ddd 100644
--- a/qutebrowser/app.py
+++ b/qutebrowser/app.py
@@ -159,13 +159,13 @@ def init(*, args: argparse.Namespace) -> None:
eventfilter.init()
log.init.debug("Connecting signals...")
- q_app.focusChanged.connect(on_focus_changed) # type: ignore
+ q_app.focusChanged.connect(on_focus_changed)
_process_args(args)
for scheme in ['http', 'https', 'qute']:
QDesktopServices.setUrlHandler(
- scheme, open_desktopservices_url) # type: ignore
+ scheme, open_desktopservices_url)
log.init.debug("Init done!")
crashsignal.crash_handler.raise_crashdlg()
@@ -173,7 +173,6 @@ def init(*, args: argparse.Namespace) -> None:
def _init_icon():
"""Initialize the icon of qutebrowser."""
- icon = QIcon()
fallback_icon = QIcon()
for size in [16, 24, 32, 48, 64, 96, 128, 256, 512]:
filename = ':/icons/qutebrowser-{size}x{size}.png'.format(size=size)
@@ -334,8 +333,12 @@ def _open_special_pages(args):
'qute://warning/webkit'),
('old-qt-warning-shown',
- not qtutils.version_check('5.9'),
+ not qtutils.version_check('5.11'),
'qute://warning/old-qt'),
+
+ ('session-warning-shown',
+ qtutils.version_check('5.15', compiled=False),
+ 'qute://warning/sessions'),
]
for state, condition, url in pages:
@@ -479,7 +482,7 @@ class Application(QApplication):
log.init.debug("Initializing application...")
self.launch_time = datetime.datetime.now()
- self.focusObjectChanged.connect( # type: ignore
+ self.focusObjectChanged.connect( # type: ignore[attr-defined]
self.on_focus_object_changed)
self.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py
index 5a0f8cc27..b42ee1dac 100644
--- a/qutebrowser/browser/browsertab.py
+++ b/qutebrowser/browser/browsertab.py
@@ -21,8 +21,8 @@
import enum
import itertools
-import typing
import functools
+import typing
import attr
from PyQt5.QtCore import (pyqtSignal, pyqtSlot, QUrl, QObject, QSizeF, Qt,
@@ -71,7 +71,7 @@ def create(win_id: int,
mode_manager = modeman.instance(win_id)
if objects.backend == usertypes.Backend.QtWebEngine:
from qutebrowser.browser.webengine import webenginetab
- tab_class = webenginetab.WebEngineTab
+ tab_class = webenginetab.WebEngineTab # type: typing.Type[AbstractTab]
else:
from qutebrowser.browser.webkit import webkittab
tab_class = webkittab.WebKitTab
@@ -317,6 +317,7 @@ class AbstractSearch(QObject):
def search(self, text: str, *,
ignore_case: usertypes.IgnoreCase = usertypes.IgnoreCase.never,
reverse: bool = False,
+ wrap: bool = True,
result_cb: _Callback = None) -> None:
"""Find the given text on the page.
@@ -324,6 +325,7 @@ class AbstractSearch(QObject):
text: The text to search for.
ignore_case: Search case-insensitively.
reverse: Reverse search direction.
+ wrap: Allow wrapping at the top or bottom of the page.
result_cb: Called with a bool indicating whether a match was found.
"""
raise NotImplementedError
@@ -425,27 +427,36 @@ class AbstractZoom(QObject):
self._set_factor_internal(self._zoom_factor)
+class SelectionState(enum.Enum):
+
+ """Possible states of selection in caret mode.
+
+ NOTE: Names need to line up with SelectionState in caret.js!
+ """
+
+ none = 1
+ normal = 2
+ line = 3
+
+
class AbstractCaret(QObject):
"""Attribute ``caret`` of AbstractTab for caret browsing."""
#: Signal emitted when the selection was toggled.
- #: (argument - whether the selection is now active)
- selection_toggled = pyqtSignal(bool)
+ selection_toggled = pyqtSignal(SelectionState)
#: Emitted when a ``follow_selection`` action is done.
follow_selected_done = pyqtSignal()
def __init__(self,
- tab: 'AbstractTab',
mode_manager: modeman.ModeManager,
parent: QWidget = None) -> None:
super().__init__(parent)
- self._tab = tab
self._widget = typing.cast(QWidget, None)
- self.selection_enabled = False
self._mode_manager = mode_manager
mode_manager.entered.connect(self._on_mode_entered)
mode_manager.left.connect(self._on_mode_left)
+ # self._tab is set by subclasses so mypy knows its concrete type.
def _on_mode_entered(self, mode: usertypes.KeyMode) -> None:
raise NotImplementedError
@@ -498,7 +509,7 @@ class AbstractCaret(QObject):
def move_to_end_of_document(self) -> None:
raise NotImplementedError
- def toggle_selection(self) -> None:
+ def toggle_selection(self, line: bool = False) -> None:
raise NotImplementedError
def drop_selection(self) -> None:
@@ -540,7 +551,7 @@ class AbstractScroller(QObject):
@pyqtSlot()
def _log_scroll_pos_change(self) -> None:
- log.webview.vdebug( # type: ignore
+ log.webview.vdebug( # type: ignore[attr-defined]
"Scroll position changed to {}".format(self.pos_px()))
def _init_widget(self, widget: QWidget) -> None:
@@ -687,9 +698,9 @@ class AbstractElements:
[typing.Optional['webelem.AbstractWebElement']], None]
_ErrorCallback = typing.Callable[[Exception], None]
- def __init__(self, tab: 'AbstractTab') -> None:
+ def __init__(self) -> None:
self._widget = typing.cast(QWidget, None)
- self._tab = tab
+ # self._tab is set by subclasses so mypy knows its concrete type.
def find_css(self, selector: str,
callback: _MultiCallback,
@@ -824,6 +835,15 @@ class AbstractTabPrivate:
def shutdown(self) -> None:
raise NotImplementedError
+ def run_js_sync(self, code: str) -> None:
+ """Run javascript sync.
+
+ Result will be returned when running JS is complete.
+ This is only implemented for QtWebKit.
+ For QtWebEngine, always raises UnsupportedOperationError.
+ """
+ raise NotImplementedError
+
class AbstractTab(QWidget):
@@ -867,8 +887,18 @@ class AbstractTab(QWidget):
# arg 1: The exit code.
renderer_process_terminated = pyqtSignal(TerminationStatus, int)
- def __init__(self, *, win_id: int, private: bool,
+ # Hosts for which a certificate error happened. Shared between all tabs.
+ #
+ # Note that we remember hosts here, without scheme/port:
+ # QtWebEngine/Chromium also only remembers hostnames, and certificates are
+ # for a given hostname anyways.
+ _insecure_hosts = set() # type: typing.Set[str]
+
+ def __init__(self, *, win_id: int,
+ mode_manager: modeman.ModeManager,
+ private: bool,
parent: QWidget = None) -> None:
+ utils.unused(mode_manager) # needed for mypy
self.is_private = private
self.win_id = win_id
self.tab_id = next(tab_id_gen)
@@ -884,7 +914,6 @@ class AbstractTab(QWidget):
self._layout = miscwidgets.WrapperLayout(self)
self._widget = typing.cast(QWidget, None)
self._progress = 0
- self._has_ssl_errors = False
self._load_status = usertypes.LoadStatus.none
self._tab_event_filter = eventfilter.TabEventFilter(
self, parent=self)
@@ -946,7 +975,7 @@ class AbstractTab(QWidget):
log.webview.warning("Unable to find event target!")
return
- evt.posted = True
+ evt.posted = True # type: ignore[attr-defined]
QApplication.postEvent(recipient, evt)
def navigation_blocked(self) -> bool:
@@ -971,7 +1000,6 @@ class AbstractTab(QWidget):
@pyqtSlot()
def _on_load_started(self) -> None:
self._progress = 0
- self._has_ssl_errors = False
self.data.viewing_source = False
self._set_load_status(usertypes.LoadStatus.loading)
self.load_started.emit()
@@ -1030,15 +1058,19 @@ class AbstractTab(QWidget):
Needs to be called by subclasses to trigger a load status update, e.g.
as a response to a loadFinished signal.
"""
- if ok and not self._has_ssl_errors:
- if self.url().scheme() == 'https':
- self._set_load_status(usertypes.LoadStatus.success_https)
- else:
- self._set_load_status(usertypes.LoadStatus.success)
- elif ok:
- self._set_load_status(usertypes.LoadStatus.warn)
+ url = self.url()
+ is_https = url.scheme() == 'https'
+
+ if not ok:
+ loadstatus = usertypes.LoadStatus.error
+ elif is_https and url.host() in self._insecure_hosts:
+ loadstatus = usertypes.LoadStatus.warn
+ elif is_https:
+ loadstatus = usertypes.LoadStatus.success_https
else:
- self._set_load_status(usertypes.LoadStatus.error)
+ loadstatus = usertypes.LoadStatus.success
+
+ self._set_load_status(loadstatus)
@pyqtSlot()
def _on_history_trigger(self) -> None:
@@ -1126,7 +1158,8 @@ class AbstractTab(QWidget):
def __repr__(self) -> str:
try:
qurl = self.url()
- url = qurl.toDisplayString(QUrl.EncodeUnicode) # type: ignore
+ url = qurl.toDisplayString(
+ QUrl.EncodeUnicode) # type: ignore[arg-type]
except (AttributeError, RuntimeError) as exc:
url = '<{}>'.format(exc.__class__.__name__)
else:
diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py
index afa78df01..f115501d3 100644
--- a/qutebrowser/browser/commands.py
+++ b/qutebrowser/browser/commands.py
@@ -157,7 +157,7 @@ class CommandDispatcher:
else:
return None
- def _tab_focus_stack(self, mode: str, *, show_error=True):
+ def _tab_focus_stack(self, mode: str, *, show_error: bool = True) -> None:
"""Select the tab which was last focused."""
tab_deque = self._tabbed_browser.tab_deque
cur_tab = self._cntwidget()
@@ -308,8 +308,9 @@ class CommandDispatcher:
urls = self._parse_url_input(url)
for i, cur_url in enumerate(urls):
- if secure:
+ if secure and cur_url.scheme() == 'http':
cur_url.setScheme('https')
+
if not window and i > 0:
tab = False
bg = True
@@ -452,7 +453,7 @@ class CommandDispatcher:
@cmdutils.argument('win_id', completion=miscmodels.window)
@cmdutils.argument('count', value=cmdutils.Value.count)
def tab_give(self, win_id: int = None, keep: bool = False,
- count: int = None) -> None:
+ count: int = None, private: bool = False) -> None:
"""Give the current tab to a new or existing window if win_id given.
If no win_id is given, the tab will get detached into a new window.
@@ -461,6 +462,7 @@ class CommandDispatcher:
win_id: The window ID of the window to give the current tab to.
keep: If given, keep the old tab around.
count: Overrides win_id (index starts at 1 for win_id=0).
+ private: If the tab should be detached into a private instance.
"""
if config.val.tabs.tabs_are_windows:
raise cmdutils.CommandError("Can't give tabs when using "
@@ -478,7 +480,7 @@ class CommandDispatcher:
"only one tab")
tabbed_browser = self._new_tabbed_browser(
- private=self._tabbed_browser.is_private)
+ private=private or self._tabbed_browser.is_private)
else:
if win_id not in objreg.window_registry:
raise cmdutils.CommandError(
@@ -487,6 +489,10 @@ class CommandDispatcher:
tabbed_browser = objreg.get('tabbed-browser', scope='window',
window=win_id)
+ if private and not tabbed_browser.is_private:
+ raise cmdutils.CommandError(
+ "The window with id {} is not private".format(win_id))
+
tabbed_browser.tabopen(self._current_url())
if not keep:
self._tabbed_browser.close_tab(self._current_widget(),
@@ -645,12 +651,13 @@ class CommandDispatcher:
def _yank_url(self, what):
"""Helper method for yank() to get the URL to copy."""
- assert what in ['url', 'pretty-url', 'markdown'], what
- flags = QUrl.RemovePassword
+ assert what in ['url', 'pretty-url'], what
+
if what == 'pretty-url':
- flags |= QUrl.DecodeReserved # type: ignore
+ flags = QUrl.RemovePassword | QUrl.DecodeReserved
else:
- flags |= QUrl.FullyEncoded # type: ignore
+ flags = QUrl.RemovePassword | QUrl.FullyEncoded
+
url = QUrl(self._current_url())
url_query = QUrlQuery()
url_query_str = urlutils.query_string(url)
@@ -661,12 +668,11 @@ class CommandDispatcher:
if key in config.val.url.yank_ignored_parameters:
url_query.removeQueryItem(key)
url.setQuery(url_query)
- return url.toString(flags) # type: ignore
+ return url.toString(flags) # type: ignore[arg-type]
@cmdutils.register(instance='command-dispatcher', scope='window')
@cmdutils.argument('what', choices=['selection', 'url', 'pretty-url',
- 'title', 'domain', 'markdown',
- 'inline'])
+ 'title', 'domain', 'inline'])
def yank(self, what='url', inline=None,
sel=False, keep=False, quiet=False):
"""Yank (copy) something to the clipboard or primary selection.
@@ -679,8 +685,6 @@ class CommandDispatcher:
- `title`: The current page's title.
- `domain`: The current scheme, domain, and port number.
- `selection`: The selection under the cursor.
- - `markdown`: Yank title and URL in markdown format
- (deprecated, use `:yank inline [{title}]({url})` instead).
- `inline`: Yank the text contained in the 'inline' argument.
sel: Use the primary selection instead of the clipboard.
@@ -712,14 +716,6 @@ class CommandDispatcher:
caret = self._current_widget().caret
caret.selection(callback=_selection_callback)
return
- elif what == 'markdown':
- message.warning(":yank markdown is deprecated, use `:yank inline "
- "[{title}]({url})` instead.")
- idx = self._current_index()
- title = self._tabbed_browser.widget.page_title(idx)
- url = self._yank_url(what)
- s = '[{}]({})'.format(title, url)
- what = 'markdown URL' # For printing
else: # pragma: no cover
raise ValueError("Invalid value {!r} for `what'.".format(what))
@@ -909,7 +905,8 @@ class CommandDispatcher:
tabbed_browser.widget.setCurrentWidget(tab)
@cmdutils.register(instance='command-dispatcher', scope='window')
- @cmdutils.argument('index', choices=['last', 'stack-next', 'stack-prev'])
+ @cmdutils.argument('index', choices=['last', 'stack-next', 'stack-prev'],
+ completion=miscmodels.tab_focus)
@cmdutils.argument('count', value=cmdutils.Value.count)
def tab_focus(self, index: typing.Union[str, int] = None,
count: int = None, no_last: bool = False) -> None:
@@ -1005,7 +1002,10 @@ class CommandDispatcher:
@cmdutils.argument('output_messages', flag='m')
def spawn(self, cmdline, userscript=False, verbose=False,
output=False, output_messages=False, detach=False, count=None):
- """Spawn a command in a shell.
+ """Spawn an external command.
+
+ Note that the command is *not* run in a shell, so things like `$VAR` or
+ `> output` won't have the desired effect.
Args:
userscript: Run the command as a userscript. You can use an
@@ -1043,7 +1043,8 @@ class CommandDispatcher:
if userscript:
def _selection_callback(s):
try:
- runner = self._run_userscript(s, cmd, args, verbose, count)
+ runner = self._run_userscript(
+ s, cmd, args, verbose, output_messages, count)
runner.finished.connect(_on_proc_finished)
except cmdutils.CommandError as e:
message.error(str(e))
@@ -1069,13 +1070,15 @@ class CommandDispatcher:
proc.start(cmd, args)
proc.finished.connect(_on_proc_finished)
- def _run_userscript(self, selection, cmd, args, verbose, count):
+ def _run_userscript(self, selection, cmd, args, verbose, output_messages,
+ count):
"""Run a userscript given as argument.
Args:
cmd: The userscript to run.
args: Arguments to pass to the userscript.
verbose: Show notifications when the command started/exited.
+ output_messages: Show the output as messages.
count: Exposed to the userscript.
"""
env = {
@@ -1102,7 +1105,8 @@ class CommandDispatcher:
try:
runner = userscripts.run_async(
- tab, cmd, *args, win_id=self._win_id, env=env, verbose=verbose)
+ tab, cmd, *args, win_id=self._win_id, env=env, verbose=verbose,
+ output_messages=output_messages)
except userscripts.Error as e:
raise cmdutils.CommandError(e)
return runner
@@ -1500,6 +1504,7 @@ class CommandDispatcher:
options = {
'ignore_case': config.val.search.ignore_case,
'reverse': reverse,
+ 'wrap': config.val.search.wrap,
}
self._tabbed_browser.search_text = text
diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py
index d2991c40e..54445f011 100644
--- a/qutebrowser/browser/downloads.py
+++ b/qutebrowser/browser/downloads.py
@@ -860,7 +860,7 @@ class AbstractDownloadManager(QObject):
self.data_changed.emit(-1)
@pyqtSlot(str, QUrl)
- def _on_pdfjs_requested(self, filename: str, original_url: QUrl):
+ def _on_pdfjs_requested(self, filename: str, original_url: QUrl) -> None:
"""Open PDF.js when a download requests it."""
tabbed_browser = objreg.get('tabbed-browser', scope='window',
window='last-focused')
diff --git a/qutebrowser/browser/downloadview.py b/qutebrowser/browser/downloadview.py
index b16b44218..66416030d 100644
--- a/qutebrowser/browser/downloadview.py
+++ b/qutebrowser/browser/downloadview.py
@@ -105,7 +105,7 @@ class DownloadView(QListView):
def __repr__(self):
model = self.model()
if model is None:
- count = 'None' # type: ignore
+ count = 'None' # type: ignore[unreachable]
else:
count = model.rowCount()
return utils.get_repr(self, count=count)
@@ -132,7 +132,10 @@ class DownloadView(QListView):
item.open_file()
item.remove()
- def _get_menu_actions(self, item) -> _ActionListType:
+ def _get_menu_actions(
+ self,
+ item: downloads.AbstractDownloadItem
+ ) -> _ActionListType:
"""Get the available context menu actions for a given DownloadItem.
Args:
diff --git a/qutebrowser/browser/eventfilter.py b/qutebrowser/browser/eventfilter.py
index cb38cfbc6..f6901003e 100644
--- a/qutebrowser/browser/eventfilter.py
+++ b/qutebrowser/browser/eventfilter.py
@@ -108,7 +108,14 @@ class TabEventFilter(QObject):
self._check_insertmode_on_release = False
def _handle_mouse_press(self, e):
- """Handle pressing of a mouse button."""
+ """Handle pressing of a mouse button.
+
+ Args:
+ e: The QMouseEvent.
+
+ Return:
+ True if the event should be filtered, False otherwise.
+ """
is_rocker_gesture = (config.val.input.rocker_gestures and
e.buttons() == Qt.LeftButton | Qt.RightButton)
@@ -129,7 +136,14 @@ class TabEventFilter(QObject):
return False
def _handle_mouse_release(self, _e):
- """Handle releasing of a mouse button."""
+ """Handle releasing of a mouse button.
+
+ Args:
+ e: The QMouseEvent.
+
+ Return:
+ True if the event should be filtered, False otherwise.
+ """
# We want to make sure we check the focus element after the WebView is
# updated completely.
QTimer.singleShot(0, self._mouserelease_insertmode)
@@ -140,27 +154,39 @@ class TabEventFilter(QObject):
Args:
e: The QWheelEvent.
+
+ Return:
+ True if the event should be filtered, False otherwise.
"""
if self._ignore_wheel_event:
# See https://github.com/qutebrowser/qutebrowser/issues/395
self._ignore_wheel_event = False
return True
- if e.modifiers() & Qt.ControlModifier:
- mode = modeman.instance(self._tab.win_id).mode
+ # Don't allow scrolling while hinting
+ mode = modeman.instance(self._tab.win_id).mode
+ if mode == usertypes.KeyMode.hint:
+ return True
+
+ elif e.modifiers() & Qt.ControlModifier:
if mode == usertypes.KeyMode.passthrough:
return False
divider = config.val.zoom.mouse_divider
if divider == 0:
- return False
+ # Disable mouse zooming
+ return True
+
factor = self._tab.zoom.factor() + (e.angleDelta().y() / divider)
if factor < 0:
- return False
+ return True
+
perc = int(100 * factor)
message.info("Zoom level: {}%".format(perc), replace=True)
self._tab.zoom.set_factor(factor)
- elif e.modifiers() & Qt.ShiftModifier:
+ return True
+ elif (e.modifiers() & Qt.ShiftModifier and
+ not qtutils.version_check('5.9', compiled=False)):
if e.angleDelta().y() > 0:
self._tab.scroller.left()
else:
@@ -170,16 +196,30 @@ class TabEventFilter(QObject):
return False
def _handle_context_menu(self, _e):
- """Suppress context menus if rocker gestures are turned on."""
+ """Suppress context menus if rocker gestures are turned on.
+
+ Args:
+ e: The QContextMenuEvent.
+
+ Return:
+ True if the event should be filtered, False otherwise.
+ """
return config.val.input.rocker_gestures
def _handle_key_release(self, e):
"""Ignore repeated key release events going to the website.
WORKAROUND for https://bugreports.qt.io/browse/QTBUG-77208
+
+ Args:
+ e: The QKeyEvent.
+
+ Return:
+ True if the event should be filtered, False otherwise.
"""
return (e.isAutoRepeat() and
- qtutils.version_check('5.10') and
+ qtutils.version_check('5.10', compiled=False) and
+ not qtutils.version_check('5.14', compiled=False) and
objects.backend == usertypes.Backend.QtWebEngine)
def _mousepress_insertmode_cb(self, elem):
@@ -232,6 +272,9 @@ class TabEventFilter(QObject):
Args:
e: The QMouseEvent.
+
+ Return:
+ True if the event should be filtered, False otherwise.
"""
if e.button() in [Qt.XButton1, Qt.LeftButton]:
# Back button on mice which have it, or rocker gesture
@@ -247,7 +290,11 @@ class TabEventFilter(QObject):
message.error("At end of history.")
def eventFilter(self, obj, event):
- """Filter events going to a QWeb(Engine)View."""
+ """Filter events going to a QWeb(Engine)View.
+
+ Return:
+ True if the event should be filtered, False otherwise.
+ """
evtype = event.type()
if evtype not in self._handlers:
return False
diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py
index 08a850fc8..ba4aaac51 100644
--- a/qutebrowser/browser/hints.py
+++ b/qutebrowser/browser/hints.py
@@ -235,7 +235,7 @@ class HintActions:
flags = QUrl.FullyEncoded | QUrl.RemovePassword
if url.scheme() == 'mailto':
flags |= QUrl.RemoveScheme
- urlstr = url.toString(flags) # type: ignore
+ urlstr = url.toString(flags) # type: ignore[arg-type]
new_content = urlstr
@@ -256,14 +256,15 @@ class HintActions:
def run_cmd(self, url: QUrl, context: HintContext) -> None:
"""Run the command based on a hint URL."""
- urlstr = url.toString(QUrl.FullyEncoded) # type: ignore
+ urlstr = url.toString(QUrl.FullyEncoded) # type: ignore[arg-type]
args = context.get_args(urlstr)
commandrunner = runners.CommandRunner(self._win_id)
commandrunner.run_safely(' '.join(args))
def preset_cmd_text(self, url: QUrl, context: HintContext) -> None:
"""Preset a commandline text based on a hint URL."""
- urlstr = url.toDisplayString(QUrl.FullyEncoded) # type: ignore
+ flags = QUrl.FullyEncoded
+ urlstr = url.toDisplayString(flags) # type: ignore[arg-type]
args = context.get_args(urlstr)
text = ' '.join(args)
if text[0] not in modeparsers.STARTCHARS:
@@ -308,7 +309,8 @@ class HintActions:
}
url = elem.resolve_url(context.baseurl)
if url is not None:
- env['QUTE_URL'] = url.toString(QUrl.FullyEncoded) # type: ignore
+ flags = QUrl.FullyEncoded
+ env['QUTE_URL'] = url.toString(flags) # type: ignore[arg-type]
try:
userscripts.run_async(context.tab, cmd, *args, win_id=self._win_id,
@@ -328,7 +330,7 @@ class HintActions:
context: The HintContext to use.
"""
urlstr = url.toString(
- QUrl.FullyEncoded | QUrl.RemovePassword) # type: ignore
+ QUrl.FullyEncoded | QUrl.RemovePassword) # type: ignore[arg-type]
args = context.get_args(urlstr)
commandrunner = runners.CommandRunner(self._win_id)
commandrunner.run_safely('spawn ' + ' '.join(args))
@@ -893,7 +895,7 @@ class HintManager(QObject):
if self._context.hint_mode == 'number':
# renumber filtered hints
- strings = self._hint_strings(visible)
+ strings = self._hint_strings([label.elem for label in visible])
self._context.labels = {}
for label, string in zip(visible, strings):
label.update_text('', string)
diff --git a/qutebrowser/browser/history.py b/qutebrowser/browser/history.py
index d5165d364..cf0c1a59a 100644
--- a/qutebrowser/browser/history.py
+++ b/qutebrowser/browser/history.py
@@ -57,7 +57,7 @@ class HistoryProgress:
self._progress.setMinimumDuration(500)
self._progress.setLabelText(text)
self._progress.setMaximum(maximum)
- self._progress.setCancelButton(None) # type: ignore
+ self._progress.setCancelButton(None)
self._progress.show()
QApplication.processEvents()
diff --git a/qutebrowser/browser/inspector.py b/qutebrowser/browser/inspector.py
index 02e416f41..e7c8e2a7f 100644
--- a/qutebrowser/browser/inspector.py
+++ b/qutebrowser/browser/inspector.py
@@ -83,7 +83,7 @@ class AbstractWebInspector(QWidget):
def closeEvent(self, e):
"""Save the geometry when closed."""
- data = bytes(self.saveGeometry())
+ data = self.saveGeometry().data()
geom = base64.b64encode(data).decode('ASCII')
configfiles.state['geometry']['inspector'] = geom
diff --git a/qutebrowser/browser/navigate.py b/qutebrowser/browser/navigate.py
index db467aa56..11be02c67 100644
--- a/qutebrowser/browser/navigate.py
+++ b/qutebrowser/browser/navigate.py
@@ -162,8 +162,8 @@ def _find_prevnext(prev, elems):
# pylint: disable=bad-config-option
for regex in getattr(config.val.hints, option):
# pylint: enable=bad-config-option
- log.hints.vdebug("== Checking regex '{}'." # type: ignore
- .format(regex.pattern))
+ log.hints.vdebug( # type: ignore[attr-defined]
+ "== Checking regex '{}'.".format(regex.pattern))
for e in elems:
text = str(e)
if not text:
@@ -173,8 +173,8 @@ def _find_prevnext(prev, elems):
regex.pattern, text))
return e
else:
- log.hints.vdebug("No match on '{}'!" # type: ignore
- .format(text))
+ log.hints.vdebug( # type: ignore[attr-defined]
+ "No match on '{}'!".format(text))
return None
diff --git a/qutebrowser/browser/network/pac.py b/qutebrowser/browser/network/pac.py
index e330abf77..6ae01c7d8 100644
--- a/qutebrowser/browser/network/pac.py
+++ b/qutebrowser/browser/network/pac.py
@@ -65,7 +65,9 @@ def _js_slot(*args):
# pylint: disable=protected-access
return self._error_con.callAsConstructor([e])
# pylint: enable=protected-access
- return pyqtSlot(*args, result=QJSValue)(new_method)
+
+ deco = pyqtSlot(*args, result=QJSValue) # type: ignore[arg-type]
+ return deco(new_method)
return _decorator
@@ -215,10 +217,10 @@ class PACResolver:
if from_file:
string_flags = QUrl.PrettyDecoded
else:
- string_flags = QUrl.RemoveUserInfo # type: ignore
+ string_flags = QUrl.RemoveUserInfo # type: ignore[assignment]
if query.url().scheme() == 'https':
- string_flags |= QUrl.RemovePath # type: ignore
- string_flags |= QUrl.RemoveQuery # type: ignore
+ string_flags |= QUrl.RemovePath # type: ignore[assignment]
+ string_flags |= QUrl.RemoveQuery # type: ignore[assignment]
result = self._resolver.call([query.url().toString(string_flags),
query.peerHostName()])
@@ -266,7 +268,8 @@ class PACFetcher(QObject):
"""Fetch the proxy from the remote URL."""
assert self._manager is not None
self._reply = self._manager.get(QNetworkRequest(self._pac_url))
- self._reply.finished.connect(self._finish) # type: ignore
+ self._reply.finished.connect( # type: ignore[attr-defined]
+ self._finish)
@pyqtSlot()
def _finish(self):
diff --git a/qutebrowser/browser/network/proxy.py b/qutebrowser/browser/network/proxy.py
index 6bfd74d36..18d2f060b 100644
--- a/qutebrowser/browser/network/proxy.py
+++ b/qutebrowser/browser/network/proxy.py
@@ -19,8 +19,6 @@
"""Handling of proxies."""
-import typing
-
from PyQt5.QtCore import QUrl, pyqtSlot
from PyQt5.QtNetwork import QNetworkProxy, QNetworkProxyFactory
@@ -54,7 +52,8 @@ def _warn_for_pac():
@pyqtSlot()
def shutdown():
- QNetworkProxyFactory.setApplicationProxyFactory(None) # type: ignore
+ QNetworkProxyFactory.setApplicationProxyFactory(
+ None) # type: ignore[arg-type]
class ProxyFactory(QNetworkProxyFactory):
@@ -73,6 +72,18 @@ class ProxyFactory(QNetworkProxyFactory):
else:
return None
+ def _set_capabilities(self, proxy):
+ if proxy.type() == QNetworkProxy.NoProxy:
+ return
+
+ capabilities = proxy.capabilities()
+ lookup_cap = QNetworkProxy.HostNameLookupCapability
+ if config.val.content.proxy_dns_requests:
+ capabilities |= lookup_cap
+ else:
+ capabilities &= ~lookup_cap
+ proxy.setCapabilities(capabilities)
+
def queryProxy(self, query):
"""Get the QNetworkProxies for a query.
@@ -91,18 +102,13 @@ class ProxyFactory(QNetworkProxyFactory):
elif isinstance(proxy, pac.PACFetcher):
if objects.backend == usertypes.Backend.QtWebEngine:
# Looks like query.url() is always invalid on QtWebEngine...
- proxies = [urlutils.proxy_from_url(QUrl('direct://'))]
+ proxy = urlutils.proxy_from_url(QUrl('direct://'))
+ assert not isinstance(proxy, pac.PACFetcher)
+ proxies = [proxy]
else:
proxies = proxy.resolve(query)
else:
proxies = [proxy]
- for p in proxies:
- if p.type() != QNetworkProxy.NoProxy:
- capabilities = p.capabilities()
- lookup_cap = QNetworkProxy.HostNameLookupCapability
- if config.val.content.proxy_dns_requests:
- capabilities |= lookup_cap # type: ignore
- else:
- capabilities &= ~lookup_cap # type: ignore
- p.setCapabilities(capabilities)
+ for proxy in proxies:
+ self._set_capabilities(proxy)
return proxies
diff --git a/qutebrowser/browser/pdfjs.py b/qutebrowser/browser/pdfjs.py
index 7c696ac0b..cca21abcb 100644
--- a/qutebrowser/browser/pdfjs.py
+++ b/qutebrowser/browser/pdfjs.py
@@ -84,6 +84,9 @@ def _generate_pdfjs_script(filename):
url_query.addQueryItem('filename', filename)
url.setQuery(url_query)
+ js_url = javascript.to_js(
+ url.toString(QUrl.FullyEncoded)) # type: ignore[arg-type]
+
return jinja.js_environment.from_string("""
document.addEventListener("DOMContentLoaded", function() {
if (typeof window.PDFJS !== 'undefined') {
@@ -105,7 +108,7 @@ def _generate_pdfjs_script(filename):
viewer.open({{ url }});
});
""").render(
- url=javascript.to_js(url.toString(QUrl.FullyEncoded)), # type: ignore
+ url=js_url,
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-70420
disable_create_object_url=(
not qtutils.version_check('5.12') and
@@ -243,7 +246,7 @@ def get_main_url(filename: str, original_url: QUrl) -> QUrl:
query = QUrlQuery()
query.addQueryItem('filename', filename) # read from our JS
query.addQueryItem('file', '') # to avoid pdfjs opening the default PDF
- urlstr = original_url.toString(QUrl.FullyEncoded) # type: ignore
+ urlstr = original_url.toString(QUrl.FullyEncoded) # type: ignore[arg-type]
query.addQueryItem('source', urlstr)
url.setQuery(query)
return url
diff --git a/qutebrowser/browser/qutescheme.py b/qutebrowser/browser/qutescheme.py
index 3bc057796..53004e66a 100644
--- a/qutebrowser/browser/qutescheme.py
+++ b/qutebrowser/browser/qutescheme.py
@@ -39,7 +39,7 @@ try:
import secrets
except ImportError:
# New in Python 3.6
- secrets = None # type: ignore
+ secrets = None # type: ignore[assignment]
from PyQt5.QtCore import QUrlQuery, QUrl, qVersion
@@ -47,7 +47,7 @@ import qutebrowser
from qutebrowser.browser import pdfjs, downloads, history
from qutebrowser.config import config, configdata, configexc, configdiff
from qutebrowser.utils import (version, utils, jinja, log, message, docutils,
- objreg, urlutils)
+ objreg, urlutils, standarddir)
from qutebrowser.qt import sip
@@ -98,8 +98,8 @@ class Redirect(Exception):
# Return value: (mimetype, data) (encoded as utf-8 if a str is returned)
-_Handler = TypeVar('_Handler',
- bound=Callable[[QUrl], Tuple[str, Union[str, bytes]]])
+_HandlerRet = Tuple[str, Union[str, bytes]]
+_Handler = TypeVar('_Handler', bound=Callable[[QUrl], _HandlerRet])
class add_handler: # noqa: N801,N806 pylint: disable=invalid-name
@@ -125,7 +125,7 @@ class add_handler: # noqa: N801,N806 pylint: disable=invalid-name
return self._function(*args, **kwargs)
-def data_for_url(url):
+def data_for_url(url: QUrl) -> typing.Tuple[str, bytes]:
"""Get the data to show for the given URL.
Args:
@@ -134,8 +134,9 @@ def data_for_url(url):
Return:
A (mimetype, data) tuple.
"""
- norm_url = url.adjusted(QUrl.NormalizePathSegments |
- QUrl.StripTrailingSlash)
+ norm_url = url.adjusted(
+ QUrl.NormalizePathSegments | # type: ignore[arg-type]
+ QUrl.StripTrailingSlash)
if norm_url != url:
raise Redirect(norm_url)
@@ -181,7 +182,7 @@ def data_for_url(url):
@add_handler('bookmarks')
-def qute_bookmarks(_url):
+def qute_bookmarks(_url: QUrl) -> _HandlerRet:
"""Handler for qute://bookmarks. Display all quickmarks / bookmarks."""
bookmarks = sorted(objreg.get('bookmark-manager').marks.items(),
key=lambda x: x[1]) # Sort by title
@@ -196,7 +197,7 @@ def qute_bookmarks(_url):
@add_handler('tabs')
-def qute_tabs(_url):
+def qute_tabs(_url: QUrl) -> _HandlerRet:
"""Handler for qute://tabs. Display information about all open tabs."""
tabs = collections.defaultdict(
list) # type: typing.Dict[str, typing.List[typing.Tuple[str, str]]]
@@ -217,7 +218,10 @@ def qute_tabs(_url):
return 'text/html', src
-def history_data(start_time, offset=None):
+def history_data(
+ start_time: float,
+ offset: int = None
+) -> typing.Sequence[typing.Dict[str, typing.Union[str, int]]]:
"""Return history data.
Arguments:
@@ -240,7 +244,7 @@ def history_data(start_time, offset=None):
@add_handler('history')
-def qute_history(url):
+def qute_history(url: QUrl) -> _HandlerRet:
"""Handler for qute://history. Display and serve history."""
if url.path() == '/data':
q_offset = QUrlQuery(url).queryItemValue("offset")
@@ -266,7 +270,7 @@ def qute_history(url):
@add_handler('javascript')
-def qute_javascript(url):
+def qute_javascript(url: QUrl) -> _HandlerRet:
"""Handler for qute://javascript.
Return content of file given as query parameter.
@@ -280,14 +284,14 @@ def qute_javascript(url):
@add_handler('pyeval')
-def qute_pyeval(_url):
+def qute_pyeval(_url: QUrl) -> _HandlerRet:
"""Handler for qute://pyeval."""
src = jinja.render('pre.html', title='pyeval', content=pyeval_output)
return 'text/html', src
@add_handler('spawn-output')
-def qute_spawn_output(_url):
+def qute_spawn_output(_url: QUrl) -> _HandlerRet:
"""Handler for qute://spawn-output."""
src = jinja.render('pre.html', title='spawn output', content=spawn_output)
return 'text/html', src
@@ -304,7 +308,7 @@ def qute_version(_url):
@add_handler('plainlog')
-def qute_plainlog(url):
+def qute_plainlog(url: QUrl) -> _HandlerRet:
"""Handler for qute://plainlog.
An optional query parameter specifies the minimum log level to print.
@@ -323,7 +327,7 @@ def qute_plainlog(url):
@add_handler('log')
-def qute_log(url):
+def qute_log(url: QUrl) -> _HandlerRet:
"""Handler for qute://log.
An optional query parameter specifies the minimum log level to print.
@@ -343,12 +347,12 @@ def qute_log(url):
@add_handler('gpl')
-def qute_gpl(_url):
+def qute_gpl(_url: QUrl) -> _HandlerRet:
"""Handler for qute://gpl. Return HTML content as string."""
return 'text/html', utils.read_file('html/license.html')
-def _asciidoc_fallback_path(html_path):
+def _asciidoc_fallback_path(html_path: str) -> typing.Optional[str]:
"""Fall back to plaintext asciidoc if the HTML is unavailable."""
path = html_path.replace('.html', '.asciidoc')
try:
@@ -358,7 +362,7 @@ def _asciidoc_fallback_path(html_path):
@add_handler('help')
-def qute_help(url):
+def qute_help(url: QUrl) -> _HandlerRet:
"""Handler for qute://help."""
urlpath = url.path()
if not urlpath or urlpath == '/':
@@ -407,7 +411,7 @@ def qute_help(url):
return 'text/html', data
-def _qute_settings_set(url):
+def _qute_settings_set(url: QUrl) -> _HandlerRet:
"""Handler for qute://settings/set."""
query = QUrlQuery(url)
option = query.queryItemValue('option', QUrl.FullyDecoded)
@@ -429,7 +433,7 @@ def _qute_settings_set(url):
@add_handler('settings')
-def qute_settings(url):
+def qute_settings(url: QUrl) -> _HandlerRet:
"""Handler for qute://settings. View/change qute configuration."""
global csrf_token
@@ -457,7 +461,7 @@ def qute_settings(url):
@add_handler('bindings')
-def qute_bindings(_url):
+def qute_bindings(_url: QUrl) -> _HandlerRet:
"""Handler for qute://bindings. View keybindings."""
bindings = {}
defaults = config.val.bindings.default
@@ -475,7 +479,7 @@ def qute_bindings(_url):
@add_handler('back')
-def qute_back(url):
+def qute_back(url: QUrl) -> _HandlerRet:
"""Handler for qute://back.
Simple page to free ram / lazy load a site, goes back on focusing the tab.
@@ -487,7 +491,7 @@ def qute_back(url):
@add_handler('configdiff')
-def qute_configdiff(url):
+def qute_configdiff(url: QUrl) -> _HandlerRet:
"""Handler for qute://configdiff."""
if url.path() == '/old':
try:
@@ -502,7 +506,7 @@ def qute_configdiff(url):
@add_handler('pastebin-version')
-def qute_pastebin_version(_url):
+def qute_pastebin_version(_url: QUrl) -> _HandlerRet:
"""Handler that pastebins the version string."""
version.pastebin_version()
return 'text/plain', b'Paste called.'
@@ -515,7 +519,7 @@ def _pdf_path(filename: str) -> str:
@add_handler('pdfjs')
-def qute_pdfjs(url: QUrl):
+def qute_pdfjs(url: QUrl) -> _HandlerRet:
"""Handler for qute://pdfjs.
Return the pdf.js viewer or redirect to original URL if the file does not
@@ -566,7 +570,7 @@ def qute_pdfjs(url: QUrl):
@add_handler('warning')
-def qute_warning(url):
+def qute_warning(url: QUrl) -> _HandlerRet:
"""Handler for qute://warning."""
path = url.path()
if path == '/old-qt':
@@ -576,6 +580,11 @@ def qute_warning(url):
elif path == '/webkit':
src = jinja.render('warning-webkit.html',
title='QtWebKit backend warning')
+ elif path == '/sessions':
+ src = jinja.render('warning-sessions.html',
+ title='Qt 5.15 sessions warning',
+ datadir=standarddir.data(),
+ sep=os.sep)
else:
raise NotFoundError("Invalid warning page {}".format(path))
return 'text/html', src
diff --git a/qutebrowser/browser/webelem.py b/qutebrowser/browser/webelem.py
index ba3c1e226..a35549571 100644
--- a/qutebrowser/browser/webelem.py
+++ b/qutebrowser/browser/webelem.py
@@ -392,7 +392,7 @@ class AbstractWebElement(collections.abc.MutableMapping):
window.show()
# FIXME:typing Why can't mypy determine the type of
# window.tabbed_browser?
- window.tabbed_browser.tabopen(url) # type: ignore
+ window.tabbed_browser.tabopen(url) # type: ignore[has-type]
else:
raise ValueError("Unknown ClickTarget {}".format(click_target))
diff --git a/qutebrowser/browser/webengine/cookies.py b/qutebrowser/browser/webengine/cookies.py
index af743c3d1..697082830 100644
--- a/qutebrowser/browser/webengine/cookies.py
+++ b/qutebrowser/browser/webengine/cookies.py
@@ -20,21 +20,40 @@
"""Filter for QtWebEngine cookies."""
from qutebrowser.config import config
-from qutebrowser.utils import utils, qtutils
+from qutebrowser.utils import utils, qtutils, log
+from qutebrowser.misc import objects
+@utils.prevent_exceptions(False) # Runs in I/O thread
def _accept_cookie(request):
"""Check whether the given cookie should be accepted."""
- accept = config.val.content.cookies.accept
+ url = request.firstPartyUrl
+ if not url.isValid():
+ url = None
+
+ if qtutils.version_check('5.11.3', compiled=False):
+ third_party = request.thirdParty
+ else:
+ # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-71393
+ third_party = (request.thirdParty and
+ not request.firstPartyUrl.isEmpty())
+
+ accept = config.instance.get('content.cookies.accept',
+ url=url)
+
+ if 'log-cookies' in objects.debug_flags:
+ first_party_str = ("<unknown>" if not request.firstPartyUrl.isValid()
+ else request.firstPartyUrl.toDisplayString())
+ origin_str = ("<unknown>" if not request.origin.isValid()
+ else request.origin.toDisplayString())
+ log.network.debug('Cookie from origin {} on {} (third party: {}) '
+ '-> applying setting {}'
+ .format(origin_str, first_party_str, third_party,
+ accept))
+
if accept == 'all':
return True
elif accept in ['no-3rdparty', 'no-unknown-3rdparty']:
- if qtutils.version_check('5.11.3', compiled=False):
- third_party = request.thirdParty
- else:
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-71393
- third_party = (request.thirdParty and
- not request.firstPartyUrl.isEmpty())
return not third_party
elif accept == 'never':
return False
diff --git a/qutebrowser/browser/webengine/tabhistory.py b/qutebrowser/browser/webengine/tabhistory.py
index 2690b6dfd..f630e8873 100644
--- a/qutebrowser/browser/webengine/tabhistory.py
+++ b/qutebrowser/browser/webengine/tabhistory.py
@@ -26,6 +26,13 @@ from PyQt5.QtCore import QByteArray, QDataStream, QIODevice, QUrl
from qutebrowser.utils import qtutils
+# kHistoryStreamVersion = 3 was originally set when history serializing was
+# implemented in QtWebEngine:
+# https://codereview.qt-project.org/c/qt/qtwebengine/+/81529
+#
+# Qt 5.14 added version 4 which also serializes favicons:
+# https://codereview.qt-project.org/c/qt/qtwebengine/+/279407
+# However, we don't care about those, so let's keep it at 3.
HISTORY_STREAM_VERSION = 3
@@ -36,32 +43,63 @@ def _serialize_item(item, stream):
item: The WebHistoryItem to write.
stream: The QDataStream to write to.
"""
- ### Thanks to Otter Browser:
- ### https://github.com/OtterBrowser/otter-browser/blob/v0.9.10/src/modules/backends/web/qtwebengine/QtWebEngineWebWidget.cpp#L1210
- ### src/core/web_contents_adapter.cpp serializeNavigationHistory
+ # Thanks to Otter Browser:
+ # https://github.com/OtterBrowser/otter-browser/blob/v1.0.01/src/modules/backends/web/qtwebengine/QtWebEnginePage.cpp#L260
+ #
+ # Relevant QtWebEngine source:
+ # src/core/web_contents_adapter.cpp serializeNavigationHistory
+ #
+ # Sample data:
+ # [TabHistoryItem(active=True,
+ # original_url=QUrl('file:///home/florian/proj/qutebrowser/git/tests/end2end/data/numbers/1.txt'),
+ # title='1.txt',
+ # url=QUrl('file:///home/florian/proj/qutebrowser/git/tests/end2end/data/numbers/1.txt'),
+ # user_data={'zoom': 1.0, 'scroll-pos': QPoint()})]
+
## toQt(entry->GetVirtualURL());
+ # \x00\x00\x00Jfile:///home/florian/proj/qutebrowser/git/tests/end2end/data/numbers/1.txt
qtutils.serialize_stream(stream, item.url)
+
## toQt(entry->GetTitle());
+ # \x00\x00\x00\n\x001\x00.\x00t\x00x\x00t
stream.writeQString(item.title)
+
## QByteArray(encodedPageState.data(), encodedPageState.size());
+ # \xff\xff\xff\xff
qtutils.serialize_stream(stream, QByteArray())
+
## static_cast<qint32>(entry->GetTransitionType());
# chromium/ui/base/page_transition_types.h
+ # \x00\x00\x00\x00
stream.writeInt32(0) # PAGE_TRANSITION_LINK
+
## entry->GetHasPostData();
+ # \x00
stream.writeBool(False)
+
## toQt(entry->GetReferrer().url);
+ # \xff\xff\xff\xff
qtutils.serialize_stream(stream, QUrl())
+
## static_cast<qint32>(entry->GetReferrer().policy);
# chromium/third_party/WebKit/public/platform/WebReferrerPolicy.h
+ # \x00\x00\x00\x00
stream.writeInt32(0) # WebReferrerPolicyAlways
+
## toQt(entry->GetOriginalRequestURL());
+ # \x00\x00\x00Jfile:///home/florian/proj/qutebrowser/git/tests/end2end/data/numbers/1.txt
qtutils.serialize_stream(stream, item.original_url)
+
## entry->GetIsOverridingUserAgent();
+ # \x00
stream.writeBool(False)
+
## static_cast<qint64>(entry->GetTimestamp().ToInternalValue());
+ # \x00\x00\x00\x00^\x97$\xe7
stream.writeInt64(int(time.time()))
+
## entry->GetHttpStatusCode();
+ # \x00\x00\x00\xc8
stream.writeInt(200)
@@ -102,12 +140,13 @@ def serialize(items):
current_idx = -1
### src/core/web_contents_adapter.cpp serializeNavigationHistory
+ # sample data:
# kHistoryStreamVersion
- stream.writeInt(HISTORY_STREAM_VERSION)
+ stream.writeInt(HISTORY_STREAM_VERSION) # \x00\x00\x00\x03
# count
- stream.writeInt(len(items))
+ stream.writeInt(len(items)) # \x00\x00\x00\x01
# currentIndex
- stream.writeInt(current_idx)
+ stream.writeInt(current_idx) # \x00\x00\x00\x00
for item in items:
_serialize_item(item, stream)
diff --git a/qutebrowser/browser/webengine/webenginedownloads.py b/qutebrowser/browser/webengine/webenginedownloads.py
index 2e0129605..80266a1c8 100644
--- a/qutebrowser/browser/webengine/webenginedownloads.py
+++ b/qutebrowser/browser/webengine/webenginedownloads.py
@@ -24,7 +24,7 @@ import os.path
import urllib
import functools
-from PyQt5.QtCore import pyqtSlot, Qt, QUrl
+from PyQt5.QtCore import pyqtSlot, Qt, QUrl, QObject
from PyQt5.QtWebEngineWidgets import QWebEngineDownloadItem
from qutebrowser.browser import downloads, pdfjs
@@ -39,16 +39,18 @@ class DownloadItem(downloads.AbstractDownloadItem):
_qt_item: The wrapped item.
"""
- def __init__(self, qt_item: QWebEngineDownloadItem, parent=None):
+ def __init__(self, qt_item: QWebEngineDownloadItem,
+ parent: QObject = None) -> None:
super().__init__(parent)
self._qt_item = qt_item
- qt_item.downloadProgress.connect( # type: ignore
+ qt_item.downloadProgress.connect( # type: ignore[attr-defined]
self.stats.on_download_progress)
- qt_item.stateChanged.connect(self._on_state_changed) # type: ignore
+ qt_item.stateChanged.connect( # type: ignore[attr-defined]
+ self._on_state_changed)
# Ensure wrapped qt_item is deleted manually when the wrapper object
# is deleted. See https://github.com/qutebrowser/qutebrowser/issues/3373
- self.destroyed.connect(self._qt_item.deleteLater) # type: ignore
+ self.destroyed.connect(self._qt_item.deleteLater)
def _is_page_download(self):
"""Check if this item is a page (i.e. mhtml) download."""
@@ -93,7 +95,8 @@ class DownloadItem(downloads.AbstractDownloadItem):
"{}".format(state_name))
def _do_die(self):
- self._qt_item.downloadProgress.disconnect() # type: ignore
+ progress_signal = self._qt_item.downloadProgress
+ progress_signal.disconnect() # type: ignore[attr-defined]
if self._qt_item.state() != QWebEngineDownloadItem.DownloadInterrupted:
self._qt_item.cancel()
diff --git a/qutebrowser/browser/webengine/webengineelem.py b/qutebrowser/browser/webengine/webengineelem.py
index ffaaf346c..d765483fe 100644
--- a/qutebrowser/browser/webengine/webengineelem.py
+++ b/qutebrowser/browser/webengine/webengineelem.py
@@ -248,7 +248,7 @@ class WebEngineElement(webelem.AbstractWebElement):
# (it does so with a 0ms QTimer...)
# This is also used in Qt's tests:
# https://github.com/qt/qtwebengine/commit/5e572e88efa7ba7c2b9138ec19e606d3e345ac90
- QApplication.processEvents( # type: ignore
+ QApplication.processEvents( # type: ignore[call-overload]
QEventLoop.ExcludeSocketNotifiers |
QEventLoop.ExcludeUserInputEvents)
diff --git a/qutebrowser/browser/webengine/webenginequtescheme.py b/qutebrowser/browser/webengine/webenginequtescheme.py
index a1526b777..2c69b521f 100644
--- a/qutebrowser/browser/webengine/webenginequtescheme.py
+++ b/qutebrowser/browser/webengine/webenginequtescheme.py
@@ -23,10 +23,10 @@ from PyQt5.QtCore import QBuffer, QIODevice, QUrl
from PyQt5.QtWebEngineCore import (QWebEngineUrlSchemeHandler,
QWebEngineUrlRequestJob)
try:
- from PyQt5.QtWebEngineCore import QWebEngineUrlScheme # type: ignore
+ from PyQt5.QtWebEngineCore import QWebEngineUrlScheme
except ImportError:
# Added in Qt 5.12
- QWebEngineUrlScheme = None
+ QWebEngineUrlScheme = None # type: ignore[misc, assignment]
from qutebrowser.browser import qutescheme
from qutebrowser.utils import log, qtutils
@@ -165,6 +165,7 @@ def init():
if QWebEngineUrlScheme is not None:
assert not QWebEngineUrlScheme.schemeByName(b'qute').name()
scheme = QWebEngineUrlScheme(b'qute')
- scheme.setFlags(QWebEngineUrlScheme.LocalScheme |
- QWebEngineUrlScheme.LocalAccessAllowed)
+ scheme.setFlags(
+ QWebEngineUrlScheme.LocalScheme | # type: ignore[arg-type]
+ QWebEngineUrlScheme.LocalAccessAllowed)
QWebEngineUrlScheme.registerScheme(scheme)
diff --git a/qutebrowser/browser/webengine/webenginesettings.py b/qutebrowser/browser/webengine/webenginesettings.py
index a1c1a40f9..d5d654dbf 100644
--- a/qutebrowser/browser/webengine/webenginesettings.py
+++ b/qutebrowser/browser/webengine/webenginesettings.py
@@ -36,7 +36,7 @@ from qutebrowser.browser.webengine import spell, webenginequtescheme
from qutebrowser.config import config, websettings
from qutebrowser.config.websettings import AttributeInfo as Attr
from qutebrowser.utils import (utils, standarddir, qtutils, message, log,
- urlmatch)
+ urlmatch, usertypes)
# The default QWebEngineProfile
default_profile = typing.cast(QWebEngineProfile, None)
@@ -76,6 +76,10 @@ class _SettingsWrapper:
for settings in self._settings:
settings.setDefaultTextEncoding(encoding)
+ def setUnknownUrlSchemePolicy(self, policy):
+ for settings in self._settings:
+ settings.setUnknownUrlSchemePolicy(policy)
+
def testAttribute(self, attribute):
return self._settings[0].testAttribute(attribute)
@@ -88,6 +92,9 @@ class _SettingsWrapper:
def defaultTextEncoding(self):
return self._settings[0].defaultTextEncoding()
+ def unknownUrlSchemePolicy(self):
+ return self._settings[0].unknownUrlSchemePolicy()
+
class WebEngineSettings(websettings.AbstractSettings):
@@ -151,6 +158,19 @@ class WebEngineSettings(websettings.AbstractSettings):
'fonts.web.family.fantasy': QWebEngineSettings.FantasyFont,
}
+ # Only Qt >= 5.11 support UnknownUrlSchemePolicy
+ try:
+ _UNKNOWN_URL_SCHEME_POLICY = {
+ 'disallow':
+ QWebEngineSettings.DisallowUnknownUrlSchemes,
+ 'allow-from-user-interaction':
+ QWebEngineSettings.AllowUnknownUrlSchemesFromUserInteraction,
+ 'allow-all':
+ QWebEngineSettings.AllowAllUnknownUrlSchemes,
+ }
+ except AttributeError:
+ _UNKNOWN_URL_SCHEME_POLICY = None
+
# Mapping from WebEngineSettings::initDefaults in
# qtwebengine/src/core/web_engine_settings.cpp
_FONT_TO_QFONT = {
@@ -162,6 +182,33 @@ class WebEngineSettings(websettings.AbstractSettings):
QWebEngineSettings.FantasyFont: QFont.Fantasy,
}
+ def set_unknown_url_scheme_policy(
+ self, policy: typing.Union[str, usertypes.Unset]) -> bool:
+ """Set the UnknownUrlSchemePolicy to use.
+
+ Return:
+ True if there was a change, False otherwise.
+ """
+ old_value = self._settings.unknownUrlSchemePolicy()
+ if isinstance(policy, usertypes.Unset):
+ self._settings.resetUnknownUrlSchemePolicy()
+ new_value = self._settings.unknownUrlSchemePolicy()
+ else:
+ new_value = self._UNKNOWN_URL_SCHEME_POLICY[policy]
+ self._settings.setUnknownUrlSchemePolicy(new_value)
+ return old_value != new_value
+
+ def _update_setting(self, setting, value):
+ if setting == 'content.unknown_url_scheme_policy':
+ if self._UNKNOWN_URL_SCHEME_POLICY:
+ return self.set_unknown_url_scheme_policy(value)
+ return False
+ return super()._update_setting(setting, value)
+
+ def init_settings(self):
+ super().init_settings()
+ self.update_setting('content.unknown_url_scheme_policy')
+
def __init__(self, settings):
super().__init__(settings)
# Attributes which don't exist in all Qt versions.
@@ -315,7 +362,8 @@ def _init_profiles():
default_profile = QWebEngineProfile.defaultProfile()
init_user_agent()
- default_profile.setter = ProfileSetter(default_profile)
+ default_profile.setter = ProfileSetter( # type: ignore[attr-defined]
+ default_profile)
default_profile.setCachePath(
os.path.join(standarddir.cache(), 'webengine'))
default_profile.setPersistentStoragePath(
@@ -325,7 +373,8 @@ def _init_profiles():
if not qtutils.is_single_process():
private_profile = QWebEngineProfile()
- private_profile.setter = ProfileSetter(private_profile)
+ private_profile.setter = ProfileSetter( # type: ignore[attr-defined]
+ private_profile)
assert private_profile.isOffTheRecord()
private_profile.setter.init_profile()
@@ -367,9 +416,16 @@ def _init_site_specific_quirks():
def _init_devtools_settings():
"""Make sure the devtools always get images/JS permissions."""
- for setting in ['content.javascript.enabled', 'content.images']:
+ settings = [
+ ('content.javascript.enabled', True),
+ ('content.images', True)
+ ] # type: typing.List[typing.Tuple[str, typing.Any]]
+ if qtutils.version_check('5.11'):
+ settings.append(('content.cookies.accept', 'all'))
+
+ for setting, value in settings:
for pattern in ['chrome-devtools://*', 'devtools://*']:
- config.instance.set_obj(setting, True,
+ config.instance.set_obj(setting, value,
pattern=urlmatch.UrlPattern(pattern),
hide_userconfig=True)
diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py
index f79b3c86b..5fd4a9e11 100644
--- a/qutebrowser/browser/webengine/webenginetab.py
+++ b/qutebrowser/browser/webengine/webenginetab.py
@@ -24,7 +24,6 @@ import functools
import re
import html as html_utils
import typing
-import textwrap
from PyQt5.QtCore import (pyqtSignal, pyqtSlot, Qt, QPoint, QPointF, QUrl,
QTimer, QObject)
@@ -42,6 +41,7 @@ from qutebrowser.browser.webengine import (webview, webengineelem, tabhistory,
from qutebrowser.misc import miscwidgets, objects
from qutebrowser.utils import (usertypes, qtutils, log, javascript, utils,
message, objreg, jinja, debug)
+from qutebrowser.keyinput import modeman
from qutebrowser.qt import sip
@@ -125,7 +125,7 @@ class WebEngineAction(browsertab.AbstractAction):
tb = objreg.get('tabbed-browser', scope='window',
window=self._tab.win_id)
urlstr = self._tab.url().toString(
- QUrl.RemoveUserInfo) # type: ignore
+ QUrl.RemoveUserInfo) # type: ignore[arg-type]
# The original URL becomes the path of a view-source: URL
# (without a host), but query/fragment should stay.
url = QUrl('view-source:' + urlstr)
@@ -157,6 +157,92 @@ class WebEnginePrinting(browsertab.AbstractPrinting):
self._widget.page().print(printer, callback)
+class _WebEngineSearchWrapHandler:
+
+ """QtWebEngine implementations related to wrapping when searching.
+
+ Attributes:
+ flag_wrap: An additional flag indicating whether the last search
+ used wrapping.
+ _active_match: The 1-based index of the currently active match
+ on the page.
+ _total_matches: The total number of search matches on the page.
+ _nowrap_available: Whether the functionality to prevent wrapping
+ is available.
+ """
+
+ def __init__(self):
+ self._active_match = 0
+ self._total_matches = 0
+ self.flag_wrap = True
+ self._nowrap_available = False
+
+ def connect_signal(self, page):
+ """Connect to the findTextFinished signal of the page.
+
+ Args:
+ page: The QtWebEnginePage to connect to this handler.
+ """
+ if not qtutils.version_check("5.14"):
+ return
+
+ try:
+ # pylint: disable=unused-import
+ from PyQt5.QtWebEngineCore import QWebEngineFindTextResult
+ except ImportError:
+ # WORKAROUND for some odd PyQt/packaging bug where the
+ # findTextResult signal is available, but QWebEngineFindTextResult
+ # is not. Seems to happen on e.g. Gentoo.
+ log.webview.warning("Could not import QWebEngineFindTextResult "
+ "despite running on Qt 5.14. You might need "
+ "to rebuild PyQtWebEngine.")
+ return
+
+ page.findTextFinished.connect(self._store_match_data)
+ self._nowrap_available = True
+
+ def _store_match_data(self, result):
+ """Store information on the last match.
+
+ The information will be checked against when wrapping is turned off.
+
+ Args:
+ result: A FindTextResult passed by the findTextFinished signal.
+ """
+ self._active_match = result.activeMatch()
+ self._total_matches = result.numberOfMatches()
+ log.webview.debug("Active search match: {}/{}"
+ .format(self._active_match, self._total_matches))
+
+ def reset_match_data(self):
+ """Reset match information.
+
+ Stale information could lead to next_result or prev_result misbehaving.
+ """
+ self._active_match = 0
+ self._total_matches = 0
+
+ def prevent_wrapping(self, *, going_up):
+ """Prevent wrapping if possible and required.
+
+ Returns True if a wrap was prevented and False if not.
+
+ Args:
+ going_up: Whether the search would scroll the page up or down.
+ """
+ if (not self._nowrap_available or
+ self.flag_wrap or self._total_matches == 0):
+ return False
+ elif going_up and self._active_match == 1:
+ message.info("Search hit TOP")
+ return True
+ elif not going_up and self._active_match == self._total_matches:
+ message.info("Search hit BOTTOM")
+ return True
+ else:
+ return False
+
+
class WebEngineSearch(browsertab.AbstractSearch):
"""QtWebEngine implementations related to searching on the page.
@@ -169,8 +255,16 @@ class WebEngineSearch(browsertab.AbstractSearch):
def __init__(self, tab, parent=None):
super().__init__(tab, parent)
- self._flags = QWebEnginePage.FindFlags(0) # type: ignore
+ self._flags = self._empty_flags()
self._pending_searches = 0
+ # The API necessary to stop wrapping was added in this version
+ self._wrap_handler = _WebEngineSearchWrapHandler()
+
+ def _empty_flags(self):
+ return QWebEnginePage.FindFlags(0) # type: ignore[call-overload]
+
+ def connect_signals(self):
+ self._wrap_handler.connect_signal(self._widget.page())
def _find(self, text, flags, callback, caller):
"""Call findText on the widget."""
@@ -208,10 +302,10 @@ class WebEngineSearch(browsertab.AbstractSearch):
callback(found)
self.finished.emit(found)
- self._widget.findText(text, flags, wrapped_callback)
+ self._widget.page().findText(text, flags, wrapped_callback)
def search(self, text, *, ignore_case=usertypes.IgnoreCase.never,
- reverse=False, result_cb=None):
+ reverse=False, wrap=True, result_cb=None):
# Don't go to next entry on duplicate search
if self.text == text and self.search_displayed:
log.webview.debug("Ignoring duplicate search request"
@@ -219,7 +313,9 @@ class WebEngineSearch(browsertab.AbstractSearch):
return
self.text = text
- self._flags = QWebEnginePage.FindFlags(0) # type: ignore
+ self._flags = self._empty_flags()
+ self._wrap_handler.reset_match_data()
+ self._wrap_handler.flag_wrap = wrap
if self._is_case_sensitive(ignore_case):
self._flags |= QWebEnginePage.FindCaseSensitively
if reverse:
@@ -231,18 +327,27 @@ class WebEngineSearch(browsertab.AbstractSearch):
if self.search_displayed:
self.cleared.emit()
self.search_displayed = False
- self._widget.findText('')
+ self._wrap_handler.reset_match_data()
+ self._widget.page().findText('')
def prev_result(self, *, result_cb=None):
# The int() here makes sure we get a copy of the flags.
- flags = QWebEnginePage.FindFlags(int(self._flags)) # type: ignore
+ flags = QWebEnginePage.FindFlags(
+ int(self._flags)) # type: ignore[call-overload]
if flags & QWebEnginePage.FindBackward:
+ if self._wrap_handler.prevent_wrapping(going_up=False):
+ return
flags &= ~QWebEnginePage.FindBackward
else:
+ if self._wrap_handler.prevent_wrapping(going_up=True):
+ return
flags |= QWebEnginePage.FindBackward
self._find(self.text, flags, result_cb, 'prev_result')
def next_result(self, *, result_cb=None):
+ going_up = self._flags & QWebEnginePage.FindBackward
+ if self._wrap_handler.prevent_wrapping(going_up=going_up):
+ return
self._find(self.text, self._flags, result_cb, 'next_result')
@@ -250,6 +355,13 @@ class WebEngineCaret(browsertab.AbstractCaret):
"""QtWebEngine implementations related to moving the cursor/selection."""
+ def __init__(self,
+ tab: 'WebEngineTab',
+ mode_manager: modeman.ModeManager,
+ parent: QWidget = None) -> None:
+ super().__init__(mode_manager, parent)
+ self._tab = tab
+
def _flags(self):
"""Get flags to pass to JS."""
flags = set()
@@ -283,7 +395,10 @@ class WebEngineCaret(browsertab.AbstractCaret):
if enabled is None:
log.webview.debug("Ignoring selection status None")
return
- self.selection_toggled.emit(enabled)
+ if enabled:
+ self.selection_toggled.emit(browsertab.SelectionState.normal)
+ else:
+ self.selection_toggled.emit(browsertab.SelectionState.none)
@pyqtSlot(usertypes.KeyMode)
def _on_mode_left(self, mode):
@@ -338,8 +453,9 @@ class WebEngineCaret(browsertab.AbstractCaret):
def move_to_end_of_document(self):
self._js_call('moveToEndOfDocument')
- def toggle_selection(self):
- self._js_call('toggleSelection', callback=self.selection_toggled.emit)
+ def toggle_selection(self, line=False):
+ self._js_call('toggleSelection', line,
+ callback=self._toggle_sel_translate)
def drop_selection(self):
self._js_call('dropSelection')
@@ -414,6 +530,13 @@ class WebEngineCaret(browsertab.AbstractCaret):
code = javascript.assemble('caret', command, *args)
self._tab.run_js_async(code, callback)
+ def _toggle_sel_translate(self, state_str):
+ if state_str is None:
+ message.error("Error toggling caret selection")
+ return
+ state = browsertab.SelectionState[state_str]
+ self.selection_toggled.emit(state)
+
class WebEngineScroller(browsertab.AbstractScroller):
@@ -559,6 +682,16 @@ class WebEngineHistoryPrivate(browsertab.AbstractHistoryPrivate):
qtutils.deserialize(data, self._history)
def load_items(self, items):
+ if qtutils.version_check('5.15', compiled=False):
+ # WORKAROUND for https://github.com/qutebrowser/qutebrowser/issues/5359
+ if items:
+ url = items[-1].url
+ if ((url.scheme(), url.host()) == ('qute', 'back') and
+ len(items) >= 2):
+ url = items[-2].url
+ self._tab.load_url(url)
+ return
+
if items:
self._tab.before_load_started.emit(items[-1].url)
@@ -621,6 +754,10 @@ class WebEngineElements(browsertab.AbstractElements):
"""QtWebEngine implemementations related to elements on the page."""
+ def __init__(self, tab: 'WebEngineTab') -> None:
+ super().__init__()
+ self._tab = tab
+
def _js_cb_multiple(self, callback, error_cb, js_elems):
"""Handle found elements coming from JS and call the real callback.
@@ -724,7 +861,7 @@ class WebEngineAudio(browsertab.AbstractAudio):
@pyqtSlot(QUrl)
def _on_url_changed(self, url):
- if self._overridden:
+ if self._overridden or not url.isValid():
return
mute = config.instance.get('content.mute', url=url)
self.set_muted(mute)
@@ -815,9 +952,11 @@ class _WebEnginePermissions(QObject):
self._tab.data.fullscreen = on
self._tab.fullscreen_requested.emit(on)
if on:
- notification = miscwidgets.FullscreenNotification(self._widget)
- notification.show()
- notification.set_timeout(3000)
+ timeout = config.val.content.fullscreen.overlay_timeout
+ if timeout != 0:
+ notification = miscwidgets.FullscreenNotification(self._widget)
+ notification.set_timeout(timeout)
+ notification.show()
@pyqtSlot(QUrl, 'QWebEnginePage::Feature')
def _on_feature_permission_requested(self, url, feature):
@@ -1104,25 +1243,16 @@ class _WebEngineScripts(QObject):
if not config.val.content.site_specific_quirks:
return
- # WhatsApp Web, based on:
- # https://github.com/jiahaog/nativefier/issues/719#issuecomment-443809630
- script = QWebEngineScript()
- script.setName('quirk-whatsapp')
- script.setWorldId(QWebEngineScript.ApplicationWorld)
- script.setInjectionPoint(QWebEngineScript.DocumentReady)
- script.setSourceCode(textwrap.dedent(r"""
- // ==UserScript==
- // @include https://web.whatsapp.com/
- // ==/UserScript==
- if (document.body.innerText.replace(/\n/g, ' ').search(
- /whatsapp works with.*to use whatsapp.*update/i) !== -1) {
- navigator.serviceWorker.getRegistration().then(function (r) {
- r.unregister();
- document.location.reload();
- });
- }
- """))
- self._widget.page().scripts().insert(script)
+ page_scripts = self._widget.page().scripts()
+
+ for filename in ['whatsapp_web_quirk']:
+ script = QWebEngineScript()
+ script.setName(filename)
+ script.setWorldId(QWebEngineScript.ApplicationWorld)
+ script.setInjectionPoint(QWebEngineScript.DocumentReady)
+ src = utils.read_file("javascript/{}.user.js".format(filename))
+ script.setSourceCode(src)
+ page_scripts.insert(script)
class WebEngineTabPrivate(browsertab.AbstractTabPrivate):
@@ -1146,6 +1276,9 @@ class WebEngineTabPrivate(browsertab.AbstractTabPrivate):
self._tab.action.exit_fullscreen()
self._widget.shutdown()
+ def run_js_sync(self, code):
+ raise browsertab.UnsupportedOperationError
+
class WebEngineTab(browsertab.AbstractTab):
@@ -1159,7 +1292,10 @@ class WebEngineTab(browsertab.AbstractTab):
abort_questions = pyqtSignal()
def __init__(self, *, win_id, mode_manager, private, parent=None):
- super().__init__(win_id=win_id, private=private, parent=parent)
+ super().__init__(win_id=win_id,
+ mode_manager=mode_manager,
+ private=private,
+ parent=parent)
widget = webview.WebEngineView(tabdata=self.data, win_id=win_id,
private=private)
self.history = WebEngineHistory(tab=self)
@@ -1311,7 +1447,7 @@ class WebEngineTab(browsertab.AbstractTab):
title_url = QUrl(url)
title_url.setScheme('')
title_url_str = title_url.toDisplayString(
- QUrl.RemoveScheme) # type: ignore
+ QUrl.RemoveScheme) # type: ignore[arg-type]
if title == title_url_str.strip('/'):
title = ""
@@ -1333,12 +1469,15 @@ class WebEngineTab(browsertab.AbstractTab):
title="Proxy authentication required", text=msg,
mode=usertypes.PromptMode.user_pwd,
abort_on=[self.abort_questions], url=urlstr)
+
if answer is not None:
authenticator.setUser(answer.user)
authenticator.setPassword(answer.password)
else:
try:
- sip.assign(authenticator, QAuthenticator()) # type: ignore
+ sip.assign( # type: ignore[attr-defined]
+ authenticator,
+ QAuthenticator())
except AttributeError:
self._show_error_page(url, "Proxy authentication required")
@@ -1359,7 +1498,8 @@ class WebEngineTab(browsertab.AbstractTab):
if not netrc_success and answer is None:
log.network.debug("Aborting auth")
try:
- sip.assign(authenticator, QAuthenticator()) # type: ignore
+ sip.assign( # type: ignore[attr-defined]
+ authenticator, QAuthenticator())
except AttributeError:
# WORKAROUND for
# https://www.riverbankcomputing.com/pipermail/pyqt/2016-December/038400.html
@@ -1464,9 +1604,9 @@ class WebEngineTab(browsertab.AbstractTab):
@pyqtSlot(certificateerror.CertificateErrorWrapper)
def _on_ssl_errors(self, error):
- self._has_ssl_errors = True
-
url = error.url()
+ self._insecure_hosts.add(url.host())
+
log.webview.debug("Certificate error: {}".format(error))
if error.is_overridable():
@@ -1629,7 +1769,7 @@ class WebEngineTab(browsertab.AbstractTab):
try:
# pylint: disable=unused-import
- from PyQt5.QtWebEngineWidgets import ( # type: ignore
+ from PyQt5.QtWebEngineWidgets import (
QWebEngineClientCertificateSelection)
except ImportError:
pass
@@ -1648,10 +1788,13 @@ class WebEngineTab(browsertab.AbstractTab):
page.loadFinished.connect(self._on_load_finished)
self.before_load_started.connect(self._on_before_load_started)
- self.shutting_down.connect(self.abort_questions) # type: ignore
- self.load_started.connect(self.abort_questions) # type: ignore
+ self.shutting_down.connect(
+ self.abort_questions) # type: ignore[arg-type]
+ self.load_started.connect(
+ self.abort_questions) # type: ignore[arg-type]
# pylint: disable=protected-access
self.audio._connect_signals()
+ self.search.connect_signals()
self._permissions.connect_signals()
self._scripts.connect_signals()
diff --git a/qutebrowser/browser/webengine/webview.py b/qutebrowser/browser/webengine/webview.py
index c41c61f7f..2b197323b 100644
--- a/qutebrowser/browser/webengine/webview.py
+++ b/qutebrowser/browser/webengine/webview.py
@@ -216,8 +216,7 @@ class WebEnginePage(QWebEnginePage):
self.shutting_down],
escape_msg=escape_msg)
except shared.CallSuper:
- return super().javaScriptPrompt( # type: ignore
- url, js_msg, default)
+ return super().javaScriptPrompt(url, js_msg, default)
def javaScriptAlert(self, url, js_msg):
"""Override javaScriptAlert to use qutebrowser prompts."""
diff --git a/qutebrowser/browser/webkit/cookies.py b/qutebrowser/browser/webkit/cookies.py
index e51350331..4b2070f1d 100644
--- a/qutebrowser/browser/webkit/cookies.py
+++ b/qutebrowser/browser/webkit/cookies.py
@@ -25,8 +25,8 @@ from PyQt5.QtNetwork import QNetworkCookie, QNetworkCookieJar
from PyQt5.QtCore import pyqtSignal, QDateTime
from qutebrowser.config import config
-from qutebrowser.utils import utils, standarddir, objreg
-from qutebrowser.misc import lineparser
+from qutebrowser.utils import utils, standarddir, objreg, log
+from qutebrowser.misc import lineparser, objects
cookie_jar = None
@@ -56,7 +56,13 @@ class RAMCookieJar(QNetworkCookieJar):
Return:
True if one or more cookies are set for 'url', otherwise False.
"""
- if config.val.content.cookies.accept == 'never':
+ accept = config.instance.get('content.cookies.accept', url=url)
+
+ if 'log-cookies' in objects.debug_flags:
+ log.network.debug('Cookie on {} -> applying setting {}'
+ .format(url.toDisplayString(), accept))
+
+ if accept == 'never':
return False
else:
self.changed.emit()
@@ -89,7 +95,8 @@ class CookieJar(RAMCookieJar):
"""Parse cookies from lineparser and store them."""
cookies = [] # type: typing.Sequence[QNetworkCookie]
for line in self._lineparser:
- cookies += QNetworkCookie.parseCookies(line)
+ line_cookies = QNetworkCookie.parseCookies(line)
+ cookies += line_cookies # type: ignore[operator]
self.setAllCookies(cookies)
def purge_old_cookies(self):
@@ -98,7 +105,8 @@ class CookieJar(RAMCookieJar):
# http://doc.qt.io/qt-5/qtwebkitexamples-webkitwidgets-browser-cookiejar-cpp.html
now = QDateTime.currentDateTime()
cookies = [c for c in self.allCookies()
- if c.isSessionCookie() or c.expirationDate() >= now]
+ if c.isSessionCookie() or
+ c.expirationDate() >= now] # type: ignore[operator]
self.setAllCookies(cookies)
def save(self):
diff --git a/qutebrowser/browser/webkit/network/networkmanager.py b/qutebrowser/browser/webkit/network/networkmanager.py
index 66b5132c4..039ed0dba 100644
--- a/qutebrowser/browser/webkit/network/networkmanager.py
+++ b/qutebrowser/browser/webkit/network/networkmanager.py
@@ -169,14 +169,15 @@ class NetworkManager(QNetworkAccessManager):
}
self._set_cookiejar()
self._set_cache()
- self.sslErrors.connect(self.on_ssl_errors) # type: ignore
+ self.sslErrors.connect( # type: ignore[attr-defined]
+ self.on_ssl_errors)
self._rejected_ssl_errors = collections.defaultdict(
list) # type: _SavedErrorsType
self._accepted_ssl_errors = collections.defaultdict(
list) # type: _SavedErrorsType
- self.authenticationRequired.connect( # type: ignore
+ self.authenticationRequired.connect( # type: ignore[attr-defined]
self.on_authentication_required)
- self.proxyAuthenticationRequired.connect( # type: ignore
+ self.proxyAuthenticationRequired.connect( # type: ignore[attr-defined]
self.on_proxy_authentication_required)
self.netrc_used = False
diff --git a/qutebrowser/browser/webkit/network/networkreply.py b/qutebrowser/browser/webkit/network/networkreply.py
index ff2c1ece5..182292ac1 100644
--- a/qutebrowser/browser/webkit/network/networkreply.py
+++ b/qutebrowser/browser/webkit/network/networkreply.py
@@ -59,12 +59,15 @@ class FixedDataNetworkReply(QNetworkReply):
# For some reason, a segfault will be triggered if these lambdas aren't
# there.
# pylint: disable=unnecessary-lambda
- QTimer.singleShot(0, lambda:
- self.metaDataChanged.emit()) # type: ignore
- QTimer.singleShot(0, lambda:
- self.readyRead.emit()) # type: ignore
- QTimer.singleShot(0, lambda:
- self.finished.emit()) # type: ignore
+ QTimer.singleShot(
+ 0,
+ lambda: self.metaDataChanged.emit()) # type: ignore[attr-defined]
+ QTimer.singleShot(
+ 0,
+ lambda: self.readyRead.emit()) # type: ignore[attr-defined]
+ QTimer.singleShot(
+ 0,
+ lambda: self.finished.emit()) # type: ignore[attr-defined]
@pyqtSlot()
def abort(self):
@@ -120,9 +123,9 @@ class ErrorNetworkReply(QNetworkReply):
self.setOpenMode(QIODevice.ReadOnly)
self.setError(error, errorstring)
QTimer.singleShot(0, lambda:
- self.error.emit(error)) # type: ignore
+ self.error.emit(error)) # type: ignore[attr-defined]
QTimer.singleShot(0, lambda:
- self.finished.emit()) # type: ignore
+ self.finished.emit()) # type: ignore[attr-defined]
def abort(self):
"""Do nothing since it's a fake reply."""
@@ -150,7 +153,7 @@ class RedirectNetworkReply(QNetworkReply):
super().__init__(parent)
self.setAttribute(QNetworkRequest.RedirectionTargetAttribute, new_url)
QTimer.singleShot(0, lambda:
- self.finished.emit()) # type: ignore
+ self.finished.emit()) # type: ignore[attr-defined]
def abort(self):
"""Called when there's e.g. a redirection limit."""
diff --git a/qutebrowser/browser/webkit/webkitelem.py b/qutebrowser/browser/webkit/webkitelem.py
index 1000a9965..de4fbd860 100644
--- a/qutebrowser/browser/webkit/webkitelem.py
+++ b/qutebrowser/browser/webkit/webkitelem.py
@@ -175,6 +175,11 @@ class WebKitElement(webelem.AbstractWebElement):
self._elem.parent())
if elem is None or elem.isNull():
return None
+
+ if typing.TYPE_CHECKING:
+ # pylint: disable=used-before-assignment
+ assert isinstance(self._tab, webkittab.WebKitTab)
+
return WebKitElement(elem, tab=self._tab)
def _rect_on_view_js(self) -> typing.Optional[QRect]:
@@ -189,7 +194,7 @@ class WebKitElement(webelem.AbstractWebElement):
return None
text = utils.compact_text(self._elem.toOuterXml(), 500)
- log.webelem.vdebug( # type: ignore
+ log.webelem.vdebug( # type: ignore[attr-defined]
"Client rectangles of element '{}': {}".format(text, rects))
for i in range(int(rects.get("length", 0))):
diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py
index 4aa0abcf5..1e9276265 100644
--- a/qutebrowser/browser/webkit/webkittab.py
+++ b/qutebrowser/browser/webkit/webkittab.py
@@ -25,6 +25,7 @@ import xml.etree.ElementTree
from PyQt5.QtCore import pyqtSlot, Qt, QUrl, QPoint, QTimer, QSizeF, QSize
from PyQt5.QtGui import QIcon
+from PyQt5.QtWidgets import QWidget
from PyQt5.QtWebKitWidgets import QWebPage, QWebFrame
from PyQt5.QtWebKit import QWebSettings
from PyQt5.QtPrintSupport import QPrinter
@@ -33,6 +34,7 @@ from qutebrowser.browser import browsertab, shared
from qutebrowser.browser.webkit import (webview, tabhistory, webkitelem,
webkitsettings)
from qutebrowser.utils import qtutils, usertypes, utils, log, debug
+from qutebrowser.keyinput import modeman
from qutebrowser.qt import sip
@@ -85,7 +87,10 @@ class WebKitSearch(browsertab.AbstractSearch):
def __init__(self, tab, parent=None):
super().__init__(tab, parent)
- self._flags = QWebPage.FindFlags(0) # type: ignore
+ self._flags = self._empty_flags()
+
+ def _empty_flags(self):
+ return QWebPage.FindFlags(0) # type: ignore[call-overload]
def _call_cb(self, callback, found, text, flags, caller):
"""Call the given callback if it's non-None.
@@ -125,7 +130,7 @@ class WebKitSearch(browsertab.AbstractSearch):
self._widget.findText('', QWebPage.HighlightAllOccurrences)
def search(self, text, *, ignore_case=usertypes.IgnoreCase.never,
- reverse=False, result_cb=None):
+ reverse=False, wrap=True, result_cb=None):
# Don't go to next entry on duplicate search
if self.text == text and self.search_displayed:
log.webview.debug("Ignoring duplicate search request"
@@ -137,11 +142,13 @@ class WebKitSearch(browsertab.AbstractSearch):
self.text = text
self.search_displayed = True
- self._flags = QWebPage.FindWrapsAroundDocument
+ self._flags = self._empty_flags()
if self._is_case_sensitive(ignore_case):
self._flags |= QWebPage.FindCaseSensitively
if reverse:
self._flags |= QWebPage.FindBackward
+ if wrap:
+ self._flags |= QWebPage.FindWrapsAroundDocument
# We actually search *twice* - once to highlight everything, then again
# to get a mark so we can navigate.
found = self._widget.findText(text, self._flags)
@@ -157,7 +164,8 @@ class WebKitSearch(browsertab.AbstractSearch):
def prev_result(self, *, result_cb=None):
self.search_displayed = True
# The int() here makes sure we get a copy of the flags.
- flags = QWebPage.FindFlags(int(self._flags)) # type: ignore
+ flags = QWebPage.FindFlags(
+ int(self._flags)) # type: ignore[call-overload]
if flags & QWebPage.FindBackward:
flags &= ~QWebPage.FindBackward
else:
@@ -170,13 +178,24 @@ class WebKitCaret(browsertab.AbstractCaret):
"""QtWebKit implementations related to moving the cursor/selection."""
+ def __init__(self,
+ tab: 'WebKitTab',
+ mode_manager: modeman.ModeManager,
+ parent: QWidget = None) -> None:
+ super().__init__(mode_manager, parent)
+ self._tab = tab
+ self._selection_state = browsertab.SelectionState.none
+
@pyqtSlot(usertypes.KeyMode)
def _on_mode_entered(self, mode):
if mode != usertypes.KeyMode.caret:
return
- self.selection_enabled = self._widget.hasSelection()
- self.selection_toggled.emit(self.selection_enabled)
+ if self._widget.hasSelection():
+ self._selection_state = browsertab.SelectionState.normal
+ else:
+ self._selection_state = browsertab.SelectionState.none
+ self.selection_toggled.emit(self._selection_state)
settings = self._widget.settings()
settings.setAttribute(QWebSettings.CaretBrowsingEnabled, True)
@@ -191,7 +210,7 @@ class WebKitCaret(browsertab.AbstractCaret):
#
# Note: We can't use hasSelection() here, as that's always
# true in caret mode.
- if not self.selection_enabled:
+ if self._selection_state is browsertab.SelectionState.none:
self._widget.page().currentFrame().evaluateJavaScript(
utils.read_file('javascript/position_caret.js'))
@@ -199,151 +218,189 @@ class WebKitCaret(browsertab.AbstractCaret):
def _on_mode_left(self, _mode):
settings = self._widget.settings()
if settings.testAttribute(QWebSettings.CaretBrowsingEnabled):
- if self.selection_enabled and self._widget.hasSelection():
+ if (self._selection_state is not browsertab.SelectionState.none and
+ self._widget.hasSelection()):
# Remove selection if it exists
self._widget.triggerPageAction(QWebPage.MoveToNextChar)
settings.setAttribute(QWebSettings.CaretBrowsingEnabled, False)
- self.selection_enabled = False
+ self._selection_state = browsertab.SelectionState.none
def move_to_next_line(self, count=1):
- if not self.selection_enabled:
- act = QWebPage.MoveToNextLine
- else:
+ if self._selection_state is not browsertab.SelectionState.none:
act = QWebPage.SelectNextLine
+ else:
+ act = QWebPage.MoveToNextLine
for _ in range(count):
self._widget.triggerPageAction(act)
+ if self._selection_state is browsertab.SelectionState.line:
+ self._select_line_to_end()
def move_to_prev_line(self, count=1):
- if not self.selection_enabled:
- act = QWebPage.MoveToPreviousLine
- else:
+ if self._selection_state is not browsertab.SelectionState.none:
act = QWebPage.SelectPreviousLine
+ else:
+ act = QWebPage.MoveToPreviousLine
for _ in range(count):
self._widget.triggerPageAction(act)
+ if self._selection_state is browsertab.SelectionState.line:
+ self._select_line_to_start()
def move_to_next_char(self, count=1):
- if not self.selection_enabled:
- act = QWebPage.MoveToNextChar
- else:
+ if self._selection_state is browsertab.SelectionState.normal:
act = QWebPage.SelectNextChar
+ elif self._selection_state is browsertab.SelectionState.line:
+ return
+ else:
+ act = QWebPage.MoveToNextChar
for _ in range(count):
self._widget.triggerPageAction(act)
def move_to_prev_char(self, count=1):
- if not self.selection_enabled:
- act = QWebPage.MoveToPreviousChar
- else:
+ if self._selection_state is browsertab.SelectionState.normal:
act = QWebPage.SelectPreviousChar
+ elif self._selection_state is browsertab.SelectionState.line:
+ return
+ else:
+ act = QWebPage.MoveToPreviousChar
for _ in range(count):
self._widget.triggerPageAction(act)
def move_to_end_of_word(self, count=1):
- if not self.selection_enabled:
- act = [QWebPage.MoveToNextWord]
- if utils.is_windows: # pragma: no cover
- act.append(QWebPage.MoveToPreviousChar)
- else:
+ if self._selection_state is browsertab.SelectionState.normal:
act = [QWebPage.SelectNextWord]
if utils.is_windows: # pragma: no cover
act.append(QWebPage.SelectPreviousChar)
+ elif self._selection_state is browsertab.SelectionState.line:
+ return
+ else:
+ act = [QWebPage.MoveToNextWord]
+ if utils.is_windows: # pragma: no cover
+ act.append(QWebPage.MoveToPreviousChar)
for _ in range(count):
for a in act:
self._widget.triggerPageAction(a)
def move_to_next_word(self, count=1):
- if not self.selection_enabled:
- act = [QWebPage.MoveToNextWord]
- if not utils.is_windows: # pragma: no branch
- act.append(QWebPage.MoveToNextChar)
- else:
+ if self._selection_state is browsertab.SelectionState.normal:
act = [QWebPage.SelectNextWord]
if not utils.is_windows: # pragma: no branch
act.append(QWebPage.SelectNextChar)
+ elif self._selection_state is browsertab.SelectionState.line:
+ return
+ else:
+ act = [QWebPage.MoveToNextWord]
+ if not utils.is_windows: # pragma: no branch
+ act.append(QWebPage.MoveToNextChar)
for _ in range(count):
for a in act:
self._widget.triggerPageAction(a)
def move_to_prev_word(self, count=1):
- if not self.selection_enabled:
- act = QWebPage.MoveToPreviousWord
- else:
+ if self._selection_state is browsertab.SelectionState.normal:
act = QWebPage.SelectPreviousWord
+ elif self._selection_state is browsertab.SelectionState.line:
+ return
+ else:
+ act = QWebPage.MoveToPreviousWord
for _ in range(count):
self._widget.triggerPageAction(act)
def move_to_start_of_line(self):
- if not self.selection_enabled:
- act = QWebPage.MoveToStartOfLine
- else:
+ if self._selection_state is browsertab.SelectionState.normal:
act = QWebPage.SelectStartOfLine
+ elif self._selection_state is browsertab.SelectionState.line:
+ return
+ else:
+ act = QWebPage.MoveToStartOfLine
self._widget.triggerPageAction(act)
def move_to_end_of_line(self):
- if not self.selection_enabled:
- act = QWebPage.MoveToEndOfLine
- else:
+ if self._selection_state is browsertab.SelectionState.normal:
act = QWebPage.SelectEndOfLine
+ elif self._selection_state is browsertab.SelectionState.line:
+ return
+ else:
+ act = QWebPage.MoveToEndOfLine
self._widget.triggerPageAction(act)
def move_to_start_of_next_block(self, count=1):
- if not self.selection_enabled:
- act = [QWebPage.MoveToNextLine,
- QWebPage.MoveToStartOfBlock]
- else:
+ if self._selection_state is not browsertab.SelectionState.none:
act = [QWebPage.SelectNextLine,
QWebPage.SelectStartOfBlock]
+ else:
+ act = [QWebPage.MoveToNextLine,
+ QWebPage.MoveToStartOfBlock]
for _ in range(count):
for a in act:
self._widget.triggerPageAction(a)
+ if self._selection_state is browsertab.SelectionState.line:
+ self._select_line_to_end()
def move_to_start_of_prev_block(self, count=1):
- if not self.selection_enabled:
- act = [QWebPage.MoveToPreviousLine,
- QWebPage.MoveToStartOfBlock]
- else:
+ if self._selection_state is not browsertab.SelectionState.none:
act = [QWebPage.SelectPreviousLine,
QWebPage.SelectStartOfBlock]
+ else:
+ act = [QWebPage.MoveToPreviousLine,
+ QWebPage.MoveToStartOfBlock]
for _ in range(count):
for a in act:
self._widget.triggerPageAction(a)
+ if self._selection_state is browsertab.SelectionState.line:
+ self._select_line_to_start()
def move_to_end_of_next_block(self, count=1):
- if not self.selection_enabled:
- act = [QWebPage.MoveToNextLine,
- QWebPage.MoveToEndOfBlock]
- else:
+ if self._selection_state is not browsertab.SelectionState.none:
act = [QWebPage.SelectNextLine,
QWebPage.SelectEndOfBlock]
+ else:
+ act = [QWebPage.MoveToNextLine,
+ QWebPage.MoveToEndOfBlock]
for _ in range(count):
for a in act:
self._widget.triggerPageAction(a)
+ if self._selection_state is browsertab.SelectionState.line:
+ self._select_line_to_end()
def move_to_end_of_prev_block(self, count=1):
- if not self.selection_enabled:
- act = [QWebPage.MoveToPreviousLine, QWebPage.MoveToEndOfBlock]
- else:
+ if self._selection_state is not browsertab.SelectionState.none:
act = [QWebPage.SelectPreviousLine, QWebPage.SelectEndOfBlock]
+ else:
+ act = [QWebPage.MoveToPreviousLine, QWebPage.MoveToEndOfBlock]
for _ in range(count):
for a in act:
self._widget.triggerPageAction(a)
+ if self._selection_state is browsertab.SelectionState.line:
+ self._select_line_to_start()
def move_to_start_of_document(self):
- if not self.selection_enabled:
- act = QWebPage.MoveToStartOfDocument
- else:
+ if self._selection_state is not browsertab.SelectionState.none:
act = QWebPage.SelectStartOfDocument
+ else:
+ act = QWebPage.MoveToStartOfDocument
self._widget.triggerPageAction(act)
+ if self._selection_state is browsertab.SelectionState.line:
+ self._select_line()
def move_to_end_of_document(self):
- if not self.selection_enabled:
- act = QWebPage.MoveToEndOfDocument
- else:
+ if self._selection_state is not browsertab.SelectionState.none:
act = QWebPage.SelectEndOfDocument
+ else:
+ act = QWebPage.MoveToEndOfDocument
self._widget.triggerPageAction(act)
- def toggle_selection(self):
- self.selection_enabled = not self.selection_enabled
- self.selection_toggled.emit(self.selection_enabled)
+ def toggle_selection(self, line=False):
+ if line:
+ self._selection_state = browsertab.SelectionState.line
+ self._select_line()
+ self.reverse_selection()
+ self._select_line()
+ self.reverse_selection()
+ elif self._selection_state is not browsertab.SelectionState.normal:
+ self._selection_state = browsertab.SelectionState.normal
+ else:
+ self._selection_state = browsertab.SelectionState.none
+ self.selection_toggled.emit(self._selection_state)
def drop_selection(self):
self._widget.triggerPageAction(QWebPage.MoveToNextChar)
@@ -360,6 +417,32 @@ class WebKitCaret(browsertab.AbstractCaret):
);
}""")
+ def _select_line(self):
+ self._widget.triggerPageAction(QWebPage.SelectStartOfLine)
+ self.reverse_selection()
+ self._widget.triggerPageAction(QWebPage.SelectEndOfLine)
+ self.reverse_selection()
+
+ def _select_line_to_end(self):
+ # direction of selection (if anchor is to the left or right
+ # of focus) has to be checked before moving selection
+ # to the end of line
+ if self._js_selection_left_to_right():
+ self._widget.triggerPageAction(QWebPage.SelectEndOfLine)
+
+ def _select_line_to_start(self):
+ if not self._js_selection_left_to_right():
+ self._widget.triggerPageAction(QWebPage.SelectStartOfLine)
+
+ def _js_selection_left_to_right(self):
+ """Return True iff the selection's direction is left to right."""
+ return self._tab.private_api.run_js_sync("""
+ var sel = window.getSelection();
+ var position = sel.anchorNode.compareDocumentPosition(sel.focusNode);
+ (!position && sel.anchorOffset < sel.focusOffset ||
+ position === Node.DOCUMENT_POSITION_FOLLOWING);
+ """)
+
def _follow_selected(self, *, tab=False):
if QWebSettings.globalSettings().testAttribute(
QWebSettings.JavascriptEnabled):
@@ -391,11 +474,11 @@ class WebKitCaret(browsertab.AbstractCaret):
if selected_element is not None:
try:
- url = selected_element.attrib['href']
+ href = selected_element.attrib['href']
except KeyError:
raise browsertab.WebTabError('Anchor element without '
'href!')
- url = self._tab.url().resolved(QUrl(url))
+ url = self._tab.url().resolved(QUrl(href))
if tab:
self._tab.new_tab_requested.emit(url)
else:
@@ -580,6 +663,10 @@ class WebKitElements(browsertab.AbstractElements):
"""QtWebKit implemementations related to elements on the page."""
+ def __init__(self, tab: 'WebKitTab') -> None:
+ super().__init__()
+ self._tab = tab
+
def find_css(self, selector, callback, error_cb, *, only_visible=False):
utils.unused(error_cb)
mainframe = self._widget.page().mainFrame()
@@ -691,13 +778,21 @@ class WebKitTabPrivate(browsertab.AbstractTabPrivate):
def shutdown(self):
self._widget.shutdown()
+ def run_js_sync(self, code):
+ document_element = self._widget.page().mainFrame().documentElement()
+ result = document_element.evaluateJavaScript(code)
+ return result
+
class WebKitTab(browsertab.AbstractTab):
"""A QtWebKit tab in the browser."""
def __init__(self, *, win_id, mode_manager, private, parent=None):
- super().__init__(win_id=win_id, private=private, parent=parent)
+ super().__init__(win_id=win_id,
+ mode_manager=mode_manager,
+ private=private,
+ parent=parent)
widget = webview.WebView(win_id=win_id, tab_id=self.tab_id,
private=private, tab=self)
if private:
@@ -749,8 +844,7 @@ class WebKitTab(browsertab.AbstractTab):
def run_js_async(self, code, callback=None, *, world=None):
if world is not None and world != usertypes.JsWorld.jseval:
log.webview.warning("Ignoring world ID {}".format(world))
- document_element = self._widget.page().mainFrame().documentElement()
- result = document_element.evaluateJavaScript(code)
+ result = self.private_api.run_js_sync(code)
if callback is not None:
callback(result)
@@ -847,9 +941,9 @@ class WebKitTab(browsertab.AbstractTab):
if navigation.is_main_frame:
self.settings.update_for_url(navigation.url)
- @pyqtSlot()
- def _on_ssl_errors(self):
- self._has_ssl_errors = True
+ @pyqtSlot('QNetworkReply*')
+ def _on_ssl_errors(self, reply):
+ self._insecure_hosts.add(reply.url().host())
def _connect_signals(self):
view = self._widget
diff --git a/qutebrowser/browser/webkit/webpage.py b/qutebrowser/browser/webkit/webpage.py
index d8a61a041..9055bff24 100644
--- a/qutebrowser/browser/webkit/webpage.py
+++ b/qutebrowser/browser/webkit/webpage.py
@@ -21,6 +21,7 @@
import html
import functools
+import typing
from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QUrl, QPoint
from PyQt5.QtGui import QDesktopServices
@@ -77,22 +78,24 @@ class BrowserPage(QWebPage):
self.setNetworkAccessManager(self._networkmanager)
self.setForwardUnsupportedContent(True)
self.reloading.connect(self._networkmanager.clear_rejected_ssl_errors)
- self.printRequested.connect( # type: ignore
+ self.printRequested.connect( # type: ignore[attr-defined]
self.on_print_requested)
- self.downloadRequested.connect( # type: ignore
+ self.downloadRequested.connect( # type: ignore[attr-defined]
self.on_download_requested)
- self.unsupportedContent.connect( # type: ignore
+ self.unsupportedContent.connect( # type: ignore[attr-defined]
self.on_unsupported_content)
- self.loadStarted.connect(self.on_load_started) # type: ignore
- self.featurePermissionRequested.connect( # type: ignore
+ self.loadStarted.connect( # type: ignore[attr-defined]
+ self.on_load_started)
+ self.featurePermissionRequested.connect( # type: ignore[attr-defined]
self._on_feature_permission_requested)
- self.saveFrameStateRequested.connect( # type: ignore
+ self.saveFrameStateRequested.connect( # type: ignore[attr-defined]
self.on_save_frame_state_requested)
- self.restoreFrameStateRequested.connect( # type: ignore
+ self.restoreFrameStateRequested.connect( # type: ignore[attr-defined]
self.on_restore_frame_state_requested)
- self.loadFinished.connect( # type: ignore
+ self.loadFinished.connect( # type: ignore[attr-defined]
functools.partial(self._inject_userjs, self.mainFrame()))
- self.frameCreated.connect(self._connect_userjs_signals) # type: ignore
+ self.frameCreated.connect( # type: ignore[attr-defined]
+ self._connect_userjs_signals)
@pyqtSlot('QWebFrame*')
def _connect_userjs_signals(self, frame):
@@ -205,8 +208,10 @@ class BrowserPage(QWebPage):
suggested_file = ""
if info.suggestedFileNames:
suggested_file = info.suggestedFileNames[0]
+
files.fileNames, _ = QFileDialog.getOpenFileNames(
- None, None, suggested_file) # type: ignore
+ None, None, suggested_file) # type: ignore[arg-type]
+
return True
def shutdown(self):
@@ -348,11 +353,11 @@ class BrowserPage(QWebPage):
self.setFeaturePermission, frame, feature,
QWebPage.PermissionDeniedByUser)
- url = frame.url().adjusted(QUrl.RemoveUserInfo |
- QUrl.RemovePath |
- QUrl.RemoveQuery |
- QUrl.RemoveFragment)
-
+ url = frame.url().adjusted(typing.cast(QUrl.FormattingOptions,
+ QUrl.RemoveUserInfo |
+ QUrl.RemovePath |
+ QUrl.RemoveQuery |
+ QUrl.RemoveFragment))
question = shared.feature_permission(
url=url,
option=options[feature], msg=messages[feature],
@@ -411,6 +416,8 @@ class BrowserPage(QWebPage):
def userAgentForUrl(self, url):
"""Override QWebPage::userAgentForUrl to customize the user agent."""
+ if not url.isValid():
+ url = None
return websettings.user_agent(url)
def supportsExtension(self, ext):
diff --git a/qutebrowser/browser/webkit/webview.py b/qutebrowser/browser/webkit/webview.py
index e200e4b6a..6706848dd 100644
--- a/qutebrowser/browser/webkit/webview.py
+++ b/qutebrowser/browser/webkit/webview.py
@@ -87,7 +87,8 @@ class WebView(QWebView):
stylesheet.set_register(self)
def __repr__(self):
- urlstr = self.url().toDisplayString(QUrl.EncodeUnicode) # type: ignore
+ flags = QUrl.EncodeUnicode
+ urlstr = self.url().toDisplayString(flags) # type: ignore[arg-type]
url = utils.elide(urlstr, 100)
return utils.get_repr(self, tab_id=self._tab_id, url=url)
@@ -97,7 +98,7 @@ class WebView(QWebView):
# Copied from:
# https://code.google.com/p/webscraping/source/browse/webkit.py#325
try:
- self.setPage(None) # type: ignore
+ self.setPage(None) # type: ignore[arg-type]
except RuntimeError:
# It seems sometimes Qt has already deleted the QWebView and we
# get: RuntimeError: wrapped C/C++ object of type WebView has been
@@ -180,9 +181,9 @@ class WebView(QWebView):
This is not needed for QtWebEngine, so it's in here.
"""
menu = self.page().createStandardContextMenu()
- self.shutting_down.connect(menu.close) # type: ignore
+ self.shutting_down.connect(menu.close) # type: ignore[arg-type]
mm = modeman.instance(self.win_id)
- mm.entered.connect(menu.close) # type: ignore
+ mm.entered.connect(menu.close) # type: ignore[arg-type]
menu.exec_(e.globalPos())
def showEvent(self, e):
diff --git a/qutebrowser/commands/command.py b/qutebrowser/commands/command.py
index 44d639e0a..4eefe481c 100644
--- a/qutebrowser/commands/command.py
+++ b/qutebrowser/commands/command.py
@@ -244,7 +244,7 @@ class Command:
args = self._param_to_argparse_args(param, is_bool)
callsig = debug_utils.format_call(self.parser.add_argument, args,
kwargs, full=False)
- log.commands.vdebug( # type: ignore
+ log.commands.vdebug( # type: ignore[attr-defined]
'Adding arg {} of type {} -> {}'
.format(param.name, typ, callsig))
self.parser.add_argument(*args, **kwargs)
@@ -409,7 +409,8 @@ class Command:
if hasattr(typing, 'UnionMeta'):
# Python 3.5.2
# pylint: disable=no-member,useless-suppression
- is_union = isinstance(typ, typing.UnionMeta) # type: ignore
+ is_union = isinstance(
+ typ, typing.UnionMeta) # type: ignore[attr-defined]
else:
is_union = getattr(typ, '__origin__', None) is typing.Union
@@ -575,7 +576,7 @@ class Command:
def register(self):
"""Register this command in objects.commands."""
- log.commands.vdebug( # type: ignore
+ log.commands.vdebug( # type: ignore[attr-defined]
"Registering command {} (from {}:{})".format(
self.name, self.handler.__module__, self.handler.__qualname__))
if self.name in objects.commands:
diff --git a/qutebrowser/commands/runners.py b/qutebrowser/commands/runners.py
index 2537e1d9c..76ae1d64f 100644
--- a/qutebrowser/commands/runners.py
+++ b/qutebrowser/commands/runners.py
@@ -94,7 +94,7 @@ def _init_variable_replacements() -> typing.Mapping[str, _ReplacementFunction]:
modified_key = '{' + key + '}'
# x = modified_key is to avoid binding x as a closure
replacements[modified_key] = (
- lambda _, x=modified_key: x) # type: ignore
+ lambda _, x=modified_key: x) # type: ignore[misc]
return replacements
@@ -332,7 +332,7 @@ class CommandRunner(AbstractCommandRunner):
self._win_id = win_id
@contextlib.contextmanager
- def _handle_error(self, safely) -> typing.Iterator[None]:
+ def _handle_error(self, safely: bool) -> typing.Iterator[None]:
"""Show exceptions as errors if safely=True is given."""
try:
yield
diff --git a/qutebrowser/commands/userscripts.py b/qutebrowser/commands/userscripts.py
index 9d9ce3c52..b9ef41f01 100644
--- a/qutebrowser/commands/userscripts.py
+++ b/qutebrowser/commands/userscripts.py
@@ -31,6 +31,7 @@ from qutebrowser.commands import runners
from qutebrowser.config import websettings
from qutebrowser.misc import guiprocess
from qutebrowser.browser import downloads
+from qutebrowser.qt import sip
class _QtFIFOReader(QObject):
@@ -59,8 +60,10 @@ class _QtFIFOReader(QObject):
fd = os.open(filepath, os.O_RDWR | os.O_NONBLOCK)
# pylint: enable=no-member,useless-suppression
self._fifo = os.fdopen(fd, 'r')
- self._notifier = QSocketNotifier(fd, QSocketNotifier.Read, self)
- self._notifier.activated.connect(self.read_line) # type: ignore
+ self._notifier = QSocketNotifier(typing.cast(sip.voidptr, fd),
+ QSocketNotifier.Read, self)
+ self._notifier.activated.connect( # type: ignore[attr-defined]
+ self.read_line)
@pyqtSlot()
def read_line(self):
@@ -148,7 +151,8 @@ class _BaseUserscriptRunner(QObject):
log.procs.debug("Both text/HTML stored, kicking off userscript!")
self._run_process(*self._args, **self._kwargs)
- def _run_process(self, cmd, *args, env=None, verbose=False):
+ def _run_process(self, cmd, *args, env=None, verbose=False,
+ output_messages=False):
"""Start the given command.
Args:
@@ -156,15 +160,16 @@ class _BaseUserscriptRunner(QObject):
*args: The arguments to hand to the command
env: A dictionary of environment variables to add.
verbose: Show notifications when the command started/exited.
+ output_messages: Show the output as messages.
"""
assert self._filepath is not None
self._env['QUTE_FIFO'] = self._filepath
if env is not None:
self._env.update(env)
- self._proc = guiprocess.GUIProcess('userscript',
- additional_env=self._env,
- verbose=verbose, parent=self)
+ self._proc = guiprocess.GUIProcess(
+ 'userscript', additional_env=self._env,
+ output_messages=output_messages, verbose=verbose, parent=self)
self._proc.finished.connect(self.on_proc_finished)
self._proc.error.connect(self.on_proc_error)
self._proc.start(cmd, args)
@@ -261,7 +266,7 @@ class _POSIXUserscriptRunner(_BaseUserscriptRunner):
return
self._reader = _QtFIFOReader(self._filepath)
- self._reader.got_line.connect(self.got_cmd) # type: ignore
+ self._reader.got_line.connect(self.got_cmd) # type: ignore[arg-type]
@pyqtSlot()
def on_proc_finished(self):
@@ -398,7 +403,8 @@ def _lookup_path(cmd):
raise NotFoundError(cmd, directories)
-def run_async(tab, cmd, *args, win_id, env, verbose=False):
+def run_async(tab, cmd, *args, win_id, env, verbose=False,
+ output_messages=False):
"""Run a userscript after dumping page html/source.
Raises:
@@ -413,15 +419,15 @@ def run_async(tab, cmd, *args, win_id, env, verbose=False):
win_id: The window id the userscript is executed in.
env: A dictionary of variables to add to the process environment.
verbose: Show notifications when the command started/exited.
+ output_messages: Show the output as messages.
"""
- tabbed_browser = objreg.get('tabbed-browser', scope='window',
- window=win_id)
- commandrunner = runners.CommandRunner(win_id, parent=tabbed_browser)
+ tb = objreg.get('tabbed-browser', scope='window', window=win_id)
+ commandrunner = runners.CommandRunner(win_id, parent=tb)
if utils.is_posix:
- runner = _POSIXUserscriptRunner(tabbed_browser)
+ runner = _POSIXUserscriptRunner(tb) # type: _BaseUserscriptRunner
elif utils.is_windows: # pragma: no cover
- runner = _WindowsUserscriptRunner(tabbed_browser)
+ runner = _WindowsUserscriptRunner(tb)
else: # pragma: no cover
raise UnsupportedError
@@ -451,7 +457,8 @@ def run_async(tab, cmd, *args, win_id, env, verbose=False):
runner.finished.connect(commandrunner.deleteLater)
runner.finished.connect(runner.deleteLater)
- runner.prepare_run(cmd_path, *args, env=env, verbose=verbose)
+ runner.prepare_run(cmd_path, *args, env=env, verbose=verbose,
+ output_messages=output_messages)
tab.dump_async(runner.store_html)
tab.dump_async(runner.store_text, plain=True)
return runner
diff --git a/qutebrowser/completion/completiondelegate.py b/qutebrowser/completion/completiondelegate.py
index b80c81654..11e7c96d8 100644
--- a/qutebrowser/completion/completiondelegate.py
+++ b/qutebrowser/completion/completiondelegate.py
@@ -290,7 +290,7 @@ class CompletionItemDelegate(QStyledItemDelegate):
size = self._style.sizeFromContents(QStyle.CT_ItemViewItem, self._opt,
docsize, self._opt.widget)
qtutils.ensure_valid(size)
- return size + QSize(10, 3)
+ return size + QSize(10, 3) # type: ignore[operator]
def paint(self, painter, option, index):
"""Override the QStyledItemDelegate paint function.
diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py
index 4187ee28e..b9be0bd9d 100644
--- a/qutebrowser/completion/completionwidget.py
+++ b/qutebrowser/completion/completionwidget.py
@@ -278,7 +278,7 @@ class CompletionView(QTreeView):
selmodel.setCurrentIndex(
idx,
- QItemSelectionModel.ClearAndSelect | # type: ignore
+ QItemSelectionModel.ClearAndSelect | # type: ignore[arg-type]
QItemSelectionModel.Rows)
# if the last item is focused, try to fetch more
diff --git a/qutebrowser/completion/models/completionmodel.py b/qutebrowser/completion/models/completionmodel.py
index d28ca8907..e5f28e0e7 100644
--- a/qutebrowser/completion/models/completionmodel.py
+++ b/qutebrowser/completion/models/completionmodel.py
@@ -183,11 +183,13 @@ class CompletionModel(QAbstractItemModel):
# WORKAROUND:
# layoutChanged is broken in PyQt 5.7.1, so we must use metaObject
# https://www.riverbankcomputing.com/pipermail/pyqt/2017-January/038483.html
- self.metaObject().invokeMethod(self, # type: ignore
- "layoutAboutToBeChanged")
+ meta = self.metaObject()
+ meta.invokeMethod(self, # type: ignore[misc, call-overload]
+ "layoutAboutToBeChanged")
for cat in self._categories:
cat.set_pattern(pattern)
- self.metaObject().invokeMethod(self, "layoutChanged") # type: ignore
+ meta.invokeMethod(self, # type: ignore[misc, call-overload]
+ "layoutChanged")
def first_item(self):
"""Return the index of the first child (non-category) in the model."""
diff --git a/qutebrowser/completion/models/miscmodels.py b/qutebrowser/completion/models/miscmodels.py
index 14f9a1163..5ce9c56d2 100644
--- a/qutebrowser/completion/models/miscmodels.py
+++ b/qutebrowser/completion/models/miscmodels.py
@@ -97,11 +97,13 @@ def session(*, info=None): # pylint: disable=unused-argument
return model
-def _buffer(skip_win_id=None):
+def _buffer(*, win_id_filter=lambda _win_id: True, add_win_id=True):
"""Helper to get the completion model for buffer/other_buffer.
Args:
- skip_win_id: The id of the window to skip, or None to include all.
+ win_id_filter: A filter function for window IDs to include.
+ Should return True for all included windows.
+ add_win_id: Whether to add the window ID to the completion items.
"""
def delete_buffer(data):
"""Close the selected tab."""
@@ -117,8 +119,9 @@ def _buffer(skip_win_id=None):
windows = [] # type: typing.List[typing.Tuple[str, str, str]]
for win_id in objreg.window_registry:
- if skip_win_id is not None and win_id == skip_win_id:
+ if not win_id_filter(win_id):
continue
+
tabbed_browser = objreg.get('tabbed-browser', scope='window',
window=win_id)
if tabbed_browser.shutting_down:
@@ -126,14 +129,18 @@ def _buffer(skip_win_id=None):
tabs = [] # type: typing.List[typing.Tuple[str, str, str]]
for idx in range(tabbed_browser.widget.count()):
tab = tabbed_browser.widget.widget(idx)
- tabs.append(("{}/{}".format(win_id, idx + 1),
+ tab_str = ("{}/{}".format(win_id, idx + 1) if add_win_id
+ else str(idx + 1))
+ tabs.append((tab_str,
tab.url().toDisplayString(),
tabbed_browser.widget.page_title(idx)))
+
if tabs_are_windows:
windows += tabs
else:
+ title = str(win_id) if add_win_id else "Tabs"
cat = listcategory.ListCategory(
- str(win_id), tabs, delete_func=delete_buffer, sort=False)
+ title, tabs, delete_func=delete_buffer, sort=False)
model.add_category(cat)
if tabs_are_windows:
@@ -157,7 +164,22 @@ def other_buffer(*, info):
Used for the tab-take command.
"""
- return _buffer(skip_win_id=info.win_id)
+ return _buffer(win_id_filter=lambda win_id: win_id != info.win_id)
+
+
+def tab_focus(*, info):
+ """A model to complete on open tabs in the current window."""
+ model = _buffer(win_id_filter=lambda win_id: win_id == info.win_id,
+ add_win_id=False)
+
+ special = [
+ ("last", "Focus the last-focused tab"),
+ ("stack-next", "Go forward through a stack of focused tabs"),
+ ("stack-prev", "Go backward through a stack of focused tabs"),
+ ]
+ model.add_category(listcategory.ListCategory("Special", special))
+
+ return model
def window(*, info):
diff --git a/qutebrowser/completion/models/urlmodel.py b/qutebrowser/completion/models/urlmodel.py
index 3e9b26aaa..ff83a598a 100644
--- a/qutebrowser/completion/models/urlmodel.py
+++ b/qutebrowser/completion/models/urlmodel.py
@@ -21,6 +21,9 @@
import typing
+if typing.TYPE_CHECKING:
+ from PyQt5.QtCore import QAbstractItemModel
+
from qutebrowser.completion.models import (completionmodel, listcategory,
histcategory)
from qutebrowser.browser import history
@@ -74,7 +77,7 @@ def url(*, info):
if k != 'DEFAULT']
# pylint: enable=bad-config-option
categories = config.val.completion.open_categories
- models = {}
+ models = {} # type: typing.Dict[str, QAbstractItemModel]
if searchengines and 'searchengines' in categories:
models['searchengines'] = listcategory.ListCategory(
diff --git a/qutebrowser/components/caretcommands.py b/qutebrowser/components/caretcommands.py
index 173653bd9..966b193de 100644
--- a/qutebrowser/components/caretcommands.py
+++ b/qutebrowser/components/caretcommands.py
@@ -185,9 +185,13 @@ def move_to_end_of_document(tab: apitypes.Tab) -> None:
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
-def toggle_selection(tab: apitypes.Tab) -> None:
- """Toggle caret selection mode."""
- tab.caret.toggle_selection()
+def toggle_selection(tab: apitypes.Tab, line: bool = False) -> None:
+ """Toggle caret selection mode.
+
+ Args:
+ line: Enables line-selection.
+ """
+ tab.caret.toggle_selection(line)
@cmdutils.register(modes=[cmdutils.KeyMode.caret])
diff --git a/qutebrowser/components/misccommands.py b/qutebrowser/components/misccommands.py
index e3fecab5a..b8c4b98b4 100644
--- a/qutebrowser/components/misccommands.py
+++ b/qutebrowser/components/misccommands.py
@@ -71,8 +71,10 @@ def _print_preview(tab: apitypes.Tab) -> None:
tab.printing.check_preview_support()
diag = QPrintPreviewDialog(tab)
diag.setAttribute(Qt.WA_DeleteOnClose)
- diag.setWindowFlags(diag.windowFlags() | Qt.WindowMaximizeButtonHint |
- Qt.WindowMinimizeButtonHint)
+ diag.setWindowFlags(
+ diag.windowFlags() | # type: ignore[operator, arg-type]
+ Qt.WindowMaximizeButtonHint |
+ Qt.WindowMinimizeButtonHint)
diag.paintRequested.connect(functools.partial(
tab.printing.to_printer, callback=print_callback))
diag.exec_()
diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py
index a38001e75..007b44404 100644
--- a/qutebrowser/config/config.py
+++ b/qutebrowser/config/config.py
@@ -206,7 +206,7 @@ class KeyConfig:
'mode'.format(key, mode))
self._validate(key, mode)
- log.keyboard.vdebug( # type: ignore
+ log.keyboard.vdebug( # type: ignore[attr-defined]
"Adding binding {} -> {} in mode {}.".format(key, command, mode))
bindings = self._config.get_mutable_obj('bindings.commands')
diff --git a/qutebrowser/config/configcommands.py b/qutebrowser/config/configcommands.py
index 1d6bb563c..25b49055c 100644
--- a/qutebrowser/config/configcommands.py
+++ b/qutebrowser/config/configcommands.py
@@ -262,6 +262,23 @@ class ConfigCommands:
self._config.unset(option, save_yaml=not temp)
@cmdutils.register(instance='config-commands')
+ @cmdutils.argument('win_id', value=cmdutils.Value.win_id)
+ def config_diff(self, win_id: int, old: bool = False) -> None:
+ """Show all customized options.
+
+ Args:
+ old: Show difference for the pre-v1.0 files
+ (qutebrowser.conf/keys.conf).
+ """
+ url = QUrl('qute://configdiff')
+ if old:
+ url.setPath('/old')
+
+ tabbed_browser = objreg.get('tabbed-browser',
+ scope='window', window=win_id)
+ tabbed_browser.load_url(url, newtab=False)
+
+ @cmdutils.register(instance='config-commands')
@cmdutils.argument('option', completion=configmodel.list_option)
def config_list_add(self, option: str, value: str,
temp: bool = False) -> None:
diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml
index 895ef4ae6..664f9facf 100644
--- a/qutebrowser/config/configdata.yml
+++ b/qutebrowser/config/configdata.yml
@@ -48,6 +48,16 @@ search.incremental:
default: True
desc: Find text on a page incrementally, renewing the search for each typed character.
+search.wrap:
+ type: Bool
+ default: True
+ backend:
+ QtWebEngine: Qt 5.14
+ QtWebKit: true
+ desc: >-
+ Wrap around at the top and bottom of the page when advancing through text matches
+ using `:search-next` and `:search-prev`.
+
new_instance_open_target:
type:
name: String
@@ -341,6 +351,7 @@ content.cookies.accept:
backend:
QtWebKit: true
QtWebEngine: Qt 5.11
+ supports_pattern: true
type:
name: String
valid_values:
@@ -351,7 +362,16 @@ content.cookies.accept:
a cookie is already set for the domain. On QtWebEngine, this is the
same as no-3rdparty."
- never: "Don't accept cookies at all."
- desc: Which cookies to accept.
+ desc: >-
+ Which cookies to accept.
+
+ With QtWebEngine, this setting also controls other features with tracking
+ capabilities similar to those of cookies; including IndexedDB, DOM storage,
+ filesystem API, service workers, and AppCache.
+
+ Note that with QtWebKit, only `all` and `never` are supported as per-domain
+ values. Setting `no-3rdparty` or `no-unknown-3rdparty` per-domain on
+ QtWebKit will have the same effect as `all`.
content.cookies.store:
default: true
@@ -370,12 +390,46 @@ content.default_encoding:
The encoding must be a string describing an encoding such as _utf-8_,
_iso-8859-1_, etc.
+content.unknown_url_scheme_policy:
+ type:
+ name: String
+ valid_values:
+ - disallow: "Disallows all navigation requests to URLs with unknown
+ schemes."
+ - allow-from-user-interaction: "Allows navigation requests to URLs with
+ unknown schemes that are issued from user-interaction (like a
+ mouse-click), whereas other navigation requests (for example from
+ JavaScript) are suppressed."
+ - allow-all: "Allows all navigation requests to URLs with unknown
+ schemes."
+ default: allow-from-user-interaction
+ backend:
+ QtWebEngine: Qt 5.11
+ QtWebKit: false
+ supports_pattern: true
+ desc: >-
+ How navigation requests to URLs with unknown schemes are handled.
+
content.windowed_fullscreen:
+ renamed: content.fullscreen.window
+
+content.fullscreen.window:
type: Bool
default: false
desc: >-
Limit fullscreen to the browser window (does not expand to fill the screen).
+content.fullscreen.overlay_timeout:
+ type:
+ name: Int
+ minval: 0
+ maxval: maxint
+ default: 3000
+ desc: >-
+ Set fullscreen notification overlay timeout in milliseconds.
+
+ If set to 0, no overlay will be displayed.
+
content.desktop_capture:
type: BoolAsk
default: ask
@@ -508,11 +562,11 @@ content.headers.user_agent:
completions:
# See https://techblog.willshouse.com/2012/01/03/most-common-user-agents/
- - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,
- like Gecko) Chrome/79.0.3945.117 Safari/537.36"
- - Chrome 79 Win10
+ like Gecko) Chrome/81.0.4044.129 Safari/537.36"
+ - Chrome 80 Win10
- - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like
- Gecko) Chrome/79.0.3945.117 Safari/537.36"
- - Chrome 79 Linux
+ Gecko) Chrome/81.0.4044.138 Safari/537.36"
+ - Chrome 80 Linux
supports_pattern: true
desc: |
User agent to send.
@@ -1091,6 +1145,22 @@ hints.border:
type: String
desc: CSS border value for hints.
+hints.padding:
+ default:
+ top: 0
+ bottom: 0
+ left: 3
+ right: 3
+ type: Padding
+ desc: Padding (in pixels) for hints.
+
+hints.radius:
+ default: 3
+ type:
+ name: Int
+ minval: 0
+ desc: Rounding radius (in pixels) for the edges of hints.
+
hints.chars:
default: asdfghjkl
type:
@@ -1394,7 +1464,7 @@ messages.unfocused:
prompt.filebrowser:
type: Bool
default: true
- desc: Show a filebrowser in upload/download prompts.
+ desc: Show a filebrowser in download prompts.
prompt.radius:
type:
@@ -1883,17 +1953,29 @@ url.searchengines:
name: String
forbidden: ' '
valtype: SearchEngineUrl
- desc: >-
+ desc: |
Search engines which can be used via the address bar.
Maps a search engine name (such as `DEFAULT`, or `ddg`) to a URL with a
`{}` placeholder. The placeholder will be replaced by the search term, use
- `{{` and `}}` for literal `{`/`}` signs.
+ `{{` and `}}` for literal `{`/`}` braces.
+
+ The following further placeholds are defined to configure how special
+ characters in the search terms are replaced by safe characters (called
+ 'quoting'):
+
+ * `{}` and `{semiquoted}` quote everything except slashes; this is the most
+ sensible choice for almost all search engines (for the search term
+ `slash/and&amp` this placeholder expands to `slash/and%26amp`).
+ * `{quoted}` quotes all characters (for `slash/and&amp` this placeholder
+ expands to `slash%2Fand%26amp`).
+ * `{unquoted}` quotes nothing (for `slash/and&amp` this placeholder
+ expands to `slash/and&amp`).
The search engine named `DEFAULT` is used when `url.auto_search` is turned
on and something else than a URL was entered to be opened. Other search
engines can be used by prepending the search engine name to the search
- term, e.g. `:open google qutebrowser`.
+ term, e.g. `:open google qutebrowser`.
url.start_pages:
type:
@@ -2126,6 +2208,26 @@ colors.contextmenu.selected.fg:
If set to null, the Qt default is used.
+colors.contextmenu.disabled.bg:
+ type:
+ name: QssColor
+ none_ok: true
+ default: null
+ desc: >-
+ Background color of disabled items in the context menu.
+
+ If set to null, the Qt default is used.
+
+colors.contextmenu.disabled.fg:
+ type:
+ name: QssColor
+ none_ok: true
+ default: null
+ desc: >-
+ Foreground color of disabled items in the context menu.
+
+ If set to null, the Qt default is used.
+
colors.downloads.bar.bg:
default: black
type: QssColor
@@ -2510,6 +2612,169 @@ colors.webpage.prefers_color_scheme_dark:
QtWebEngine: Qt 5.14
QtWebKit: false
+## dark mode
+
+# darkModeClassifierType is not exposed, as the icon classifier isn't actually
+# implemented in Chromium:
+#
+# https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/platform/graphics/dark_mode_icon_classifier.cc
+
+colors.webpage.darkmode.enabled:
+ default: false
+ type: Bool
+ desc: >-
+ Render all web contents using a dark theme.
+
+ Example configurations from Chromium's `chrome://flags`:
+
+
+ - "With simple HSL/CIELAB/RGB-based inversion": Set
+ `colors.webpage.darkmode.algorithm` accordingly.
+
+ - "With selective image inversion": Set
+ `colors.webpage.darkmode.policy.images` to `smart`.
+
+ - "With selective inversion of non-image elements": Set
+ `colors.webpage.darkmode.threshold.text` to 150 and
+ `colors.webpage.darkmode.threshold.background` to 205.
+
+ - "With selective inversion of everything": Combines the two variants
+ above.
+ restart: true
+ backend:
+ QtWebEngine: Qt 5.14
+ QtWebKit: false
+
+colors.webpage.darkmode.algorithm:
+ default: lightness-cielab
+ desc: "Which algorithm to use for modifying how colors are rendered with
+ darkmode."
+ type:
+ name: String
+ valid_values:
+ - lightness-cielab: Modify colors by converting them to CIELAB color
+ space and inverting the L value.
+ - lightness-hsl: Modify colors by converting them to the HSL color space
+ and inverting the lightness (i.e. the "L" in HSL).
+ - brightness-rgb: Modify colors by subtracting each of r, g, and b from
+ their maximum value.
+ # kSimpleInvertForTesting is not exposed, as it's equivalent to
+ # kInvertBrightness without gamma correction, and only available for
+ # Chromium's automated tests
+ restart: true
+ backend:
+ QtWebEngine: Qt 5.14
+ QtWebKit: false
+
+colors.webpage.darkmode.contrast:
+ default: 0.0
+ type:
+ name: Float
+ minval: -1.0
+ maxval: 1.0
+ desc: >-
+ Contrast for dark mode.
+
+ This only has an effect when `colors.webpage.darkmode.algorithm` is set to
+ `lightness-hsl` or `brightness-rgb`.
+ restart: true
+ backend:
+ QtWebEngine: Qt 5.14
+ QtWebKit: false
+
+colors.webpage.darkmode.policy.images:
+ default: never
+ type:
+ name: String
+ valid_values:
+ - always: Apply dark mode filter to all images.
+ - never: Never apply dark mode filter to any images.
+ - smart: Apply dark mode based on image content.
+ desc: Which images to apply dark mode to.
+ restart: true
+ backend:
+ QtWebEngine: Qt 5.14
+ QtWebKit: false
+
+colors.webpage.darkmode.policy.page:
+ default: smart
+ type:
+ name: String
+ valid_values:
+ - always: Apply dark mode filter to all frames, regardless of content.
+ - smart: Apply dark mode filter to frames based on background color.
+ desc: Which pages to apply dark mode to.
+ restart: true
+ backend:
+ QtWebEngine: Qt 5.14
+ QtWebKit: false
+
+colors.webpage.darkmode.threshold.text:
+ default: 256
+ type:
+ name: Int
+ minval: 0
+ maxval: 256
+ desc: >-
+ Threshold for inverting text with dark mode.
+
+ Text colors with brightness below this threshold will be inverted, and
+ above it will be left as in the original, non-dark-mode page. Set to 256
+ to always invert text color or to 0 to never invert text color.
+ restart: true
+ backend:
+ QtWebEngine: Qt 5.14
+ QtWebKit: false
+
+colors.webpage.darkmode.threshold.background:
+ default: 0
+ type:
+ name: Int
+ minval: 0
+ maxval: 256
+ desc: >-
+ Threshold for inverting background elements with dark mode.
+
+ Background elements with brightness above this threshold will be inverted,
+ and below it will be left as in the original, non-dark-mode page. Set to
+ 256 to never invert the color or to 0 to always invert it.
+
+ Note: This behavior is the opposite of
+ `colors.webpage.darkmode.threshold.text`!
+ restart: true
+ backend:
+ QtWebEngine: Qt 5.14
+ QtWebKit: false
+
+colors.webpage.darkmode.grayscale.all:
+ default: false
+ type: Bool
+ desc: >-
+ Render all colors as grayscale.
+
+ This only has an effect when `colors.webpage.darkmode.algorithm` is set to
+ `lightness-hsl` or `brightness-rgb`.
+ restart: true
+ backend:
+ QtWebEngine: Qt 5.14
+ QtWebKit: false
+
+colors.webpage.darkmode.grayscale.images:
+ default: 0.0
+ type:
+ name: Float
+ minval: 0.0
+ maxval: 1.0
+ desc: >-
+ Desaturation factor for images in dark mode.
+
+ If set to 0, images are left as-is. If set to 1, images are completely
+ grayscale. Values between 0 and 1 desaturate the colors accordingly.
+ restart: true
+ backend:
+ QtWebEngine: Qt 5.14
+ QtWebKit: false
+
# emacs: '
## fonts
@@ -2701,6 +2966,7 @@ bindings.key_mappings:
<Ctrl-6>: <Ctrl-^>
<Ctrl-M>: <Return>
<Ctrl-J>: <Return>
+ <Ctrl-I>: <Tab>
<Shift-Return>: <Return>
<Enter>: <Return>
<Shift-Enter>: <Return>
@@ -2798,6 +3064,7 @@ bindings.default:
N: search-prev
i: enter-mode insert
v: enter-mode caret
+ V: enter-mode caret ;; toggle-selection --line
"`": enter-mode set_mark
"'": enter-mode jump_mark
yy: yank
@@ -2979,6 +3246,7 @@ bindings.default:
<Escape>: leave-mode
caret:
v: toggle-selection
+ V: toggle-selection --line
<Space>: toggle-selection
<Ctrl-Space>: drop-selection
c: enter-mode normal
diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py
index 63cab9377..7d567ebd3 100644
--- a/qutebrowser/config/configfiles.py
+++ b/qutebrowser/config/configfiles.py
@@ -161,7 +161,7 @@ class YamlConfig(QObject):
# Instead, create a config.py - see :help for details.
""".lstrip('\n')))
- utils.yaml_dump(data, f) # type: ignore
+ utils.yaml_dump(data, f)
def _pop_object(self,
yaml_data: typing.Any,
@@ -400,7 +400,7 @@ class YamlMigrations(QObject):
except KeyError:
continue
- if not isinstance(opt.typ, configtypes.Font):
+ if not isinstance(opt.typ, configtypes.FontBase):
continue
for scope, val in self._settings[name].items():
@@ -530,14 +530,10 @@ class ConfigAPI:
with self._handle_error('binding', key):
seq = keyutils.KeySequence.parse(key)
if command is None:
- text = ("Unbinding commands with config.bind('{key}', None) "
- "is deprecated. Use config.unbind('{key}') instead."
- .format(key=key))
- self.errors.append(configexc.ConfigErrorDesc(
- "While unbinding '{}'".format(key), text))
- self._keyconfig.unbind(seq, mode=mode)
- else:
- self._keyconfig.bind(seq, command, mode=mode)
+ raise configexc.Error("Can't bind {key} to None (maybe you "
+ "want to use config.unbind('{key}') "
+ "instead?)".format(key=key))
+ self._keyconfig.bind(seq, command, mode=mode)
def unbind(self, key: str, mode: str = 'normal') -> None:
"""Unbind a key from a command, with an optional key mode."""
@@ -696,8 +692,8 @@ def read_config_py(filename: str, raising: bool = False) -> None:
basename = os.path.basename(filename)
module = types.ModuleType('config')
- module.config = api # type: ignore
- module.c = container # type: ignore
+ module.config = api # type: ignore[attr-defined]
+ module.c = container # type: ignore[attr-defined]
module.__file__ = filename
try:
diff --git a/qutebrowser/config/configinit.py b/qutebrowser/config/configinit.py
index 351030789..3c80cfe1b 100644
--- a/qutebrowser/config/configinit.py
+++ b/qutebrowser/config/configinit.py
@@ -121,11 +121,11 @@ def _update_font_defaults(setting: str) -> None:
if setting not in {'fonts.default_family', 'fonts.default_size'}:
return
- configtypes.Font.set_defaults(config.val.fonts.default_family,
- config.val.fonts.default_size)
+ configtypes.FontBase.set_defaults(config.val.fonts.default_family,
+ config.val.fonts.default_size)
for name, opt in configdata.DATA.items():
- if not isinstance(opt.typ, configtypes.Font):
+ if not isinstance(opt.typ, configtypes.FontBase):
continue
value = config.instance.get_obj(name)
@@ -165,8 +165,8 @@ def late_init(save_manager: savemanager.SaveManager) -> None:
_init_errors = None
- configtypes.Font.set_defaults(config.val.fonts.default_family,
- config.val.fonts.default_size)
+ configtypes.FontBase.set_defaults(config.val.fonts.default_family,
+ config.val.fonts.default_size)
config.instance.changed.connect(_update_font_defaults)
config.instance.init_save_manager(save_manager)
@@ -199,6 +199,90 @@ def qt_args(namespace: argparse.Namespace) -> typing.List[str]:
return argv
+def _darkmode_settings() -> typing.Iterator[typing.Tuple[str, str]]:
+ """Get necessary blink settings to configure dark mode for QtWebEngine."""
+ if not config.val.colors.webpage.darkmode.enabled:
+ return
+
+ # Mapping from a colors.webpage.darkmode.algorithm setting value to
+ # Chromium's DarkModeInversionAlgorithm enum values.
+ algorithms = {
+ # 0: kOff (not exposed)
+ # 1: kSimpleInvertForTesting (not exposed)
+ 'brightness-rgb': 2, # kInvertBrightness
+ 'lightness-hsl': 3, # kInvertLightness
+ 'lightness-cielab': 4, # kInvertLightnessLAB
+ }
+
+ # Mapping from a colors.webpage.darkmode.policy.images setting value to
+ # Chromium's DarkModeImagePolicy enum values.
+ image_policies = {
+ 'always': 0, # kFilterAll
+ 'never': 1, # kFilterNone
+ 'smart': 2, # kFilterSmart
+ }
+
+ # Mapping from a colors.webpage.darkmode.policy.page setting value to
+ # Chromium's DarkModePagePolicy enum values.
+ page_policies = {
+ 'always': 0, # kFilterAll
+ 'smart': 1, # kFilterByBackground
+ }
+
+ bools = {
+ True: 'true',
+ False: 'false',
+ }
+
+ _setting_description_type = typing.Tuple[
+ str, # qutebrowser option name
+ str, # darkmode setting name
+ # Mapping from the config value to a string (or something convertable
+ # to a string) which gets passed to Chromium.
+ typing.Optional[typing.Mapping[typing.Any, typing.Union[str, int]]],
+ ]
+ if qtutils.version_check('5.15', compiled=False):
+ settings = [
+ ('enabled', 'Enabled', bools),
+ ('algorithm', 'InversionAlgorithm', algorithms),
+ ] # type: typing.List[_setting_description_type]
+ mandatory_setting = 'enabled'
+ else:
+ settings = [
+ ('algorithm', '', algorithms),
+ ]
+ mandatory_setting = 'algorithm'
+
+ settings += [
+ ('contrast', 'Contrast', None),
+ ('policy.images', 'ImagePolicy', image_policies),
+ ('policy.page', 'PagePolicy', page_policies),
+ ('threshold.text', 'TextBrightnessThreshold', None),
+ ('threshold.background', 'BackgroundBrightnessThreshold', None),
+ ('grayscale.all', 'Grayscale', bools),
+ ('grayscale.images', 'ImageGrayscale', None),
+ ]
+
+ for setting, key, mapping in settings:
+ # To avoid blowing up the commandline length, we only pass modified
+ # settings to Chromium, as our defaults line up with Chromium's.
+ # However, we always pass enabled/algorithm to make sure dark mode gets
+ # actually turned on.
+ value = config.instance.get(
+ 'colors.webpage.darkmode.' + setting,
+ fallback=setting == mandatory_setting)
+ if isinstance(value, usertypes.Unset):
+ continue
+
+ if mapping is not None:
+ value = mapping[value]
+
+ # FIXME: This is "forceDarkMode" starting with Chromium 83
+ prefix = 'darkMode'
+
+ yield prefix + key, str(value)
+
+
def _qtwebengine_args(namespace: argparse.Namespace) -> typing.Iterator[str]:
"""Get the QtWebEngine arguments to use based on the config."""
if not qtutils.version_check('5.11', compiled=False):
@@ -224,6 +308,11 @@ def _qtwebengine_args(namespace: argparse.Namespace) -> typing.Iterator[str]:
yield '--enable-logging'
yield '--v=1'
+ blink_settings = list(_darkmode_settings())
+ if blink_settings:
+ yield '--blink-settings=' + ','.join('{}={}'.format(k, v)
+ for k, v in blink_settings)
+
settings = {
'qt.force_software_rendering': {
'software-opengl': None,
diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py
index befc43806..61284c34e 100644
--- a/qutebrowser/config/configtypes.py
+++ b/qutebrowser/config/configtypes.py
@@ -65,6 +65,7 @@ from qutebrowser.config import configexc, configutils
from qutebrowser.utils import (standarddir, utils, qtutils, urlutils, urlmatch,
usertypes)
from qutebrowser.keyinput import keyutils
+from qutebrowser.browser.network import pac
class _SystemProxy:
@@ -81,7 +82,8 @@ BOOLEAN_STATES = {'1': True, 'yes': True, 'true': True, 'on': True,
_Completions = typing.Optional[typing.Iterable[typing.Tuple[str, str]]]
_StrUnset = typing.Union[str, usertypes.Unset]
-_StrUnsetNone = typing.Union[None, str, usertypes.Unset]
+_UnsetNone = typing.Union[None, usertypes.Unset]
+_StrUnsetNone = typing.Union[str, _UnsetNone]
class ValidValues:
@@ -702,8 +704,10 @@ class Bool(BaseType):
super().__init__(none_ok)
self.valid_values = ValidValues('true', 'false', generate_docs=False)
- def to_py(self, value: typing.Optional[bool]) -> typing.Optional[bool]:
+ def to_py(self,
+ value: typing.Union[bool, str, None]) -> typing.Optional[bool]:
self._basic_py_validation(value, bool)
+ assert not isinstance(value, str)
return value
def from_str(self, value: str) -> typing.Optional[bool]:
@@ -733,15 +737,15 @@ class BoolAsk(Bool):
super().__init__(none_ok)
self.valid_values = ValidValues('true', 'false', 'ask')
- def to_py(self, # type: ignore
+ def to_py(self, # type: ignore[override]
value: typing.Union[bool, str]) -> typing.Union[bool, str, None]:
# basic validation unneeded if it's == 'ask' and done by Bool if we
# call super().to_py
if isinstance(value, str) and value.lower() == 'ask':
return 'ask'
- return super().to_py(value) # type: ignore
+ return super().to_py(value)
- def from_str(self, # type: ignore
+ def from_str(self, # type: ignore[override]
value: str) -> typing.Union[bool, str, None]:
# basic validation unneeded if it's == 'ask' and done by Bool if we
# call super().from_str
@@ -794,11 +798,14 @@ class _Numeric(BaseType): # pylint: disable=abstract-method
assert isinstance(bound, (int, float)), bound
return bound
- def _validate_bounds(self, value: typing.Union[None, int, float],
+ def _validate_bounds(self,
+ value: typing.Union[int, float, _UnsetNone],
suffix: str = '') -> None:
"""Validate self.minval and self.maxval."""
if value is None:
return
+ elif isinstance(value, usertypes.Unset):
+ return
elif self.minval is not None and value < self.minval:
raise configexc.ValidationError(
value, "must be {}{} or bigger!".format(self.minval, suffix))
@@ -834,7 +841,10 @@ class Int(_Numeric):
self.to_py(intval)
return intval
- def to_py(self, value: typing.Optional[int]) -> typing.Optional[int]:
+ def to_py(
+ self,
+ value: typing.Union[int, _UnsetNone]
+ ) -> typing.Union[int, _UnsetNone]:
self._basic_py_validation(value, int)
self._validate_bounds(value)
return value
@@ -858,8 +868,8 @@ class Float(_Numeric):
def to_py(
self,
- value: typing.Union[None, int, float],
- ) -> typing.Union[None, int, float]:
+ value: typing.Union[int, float, _UnsetNone],
+ ) -> typing.Union[int, float, _UnsetNone]:
self._basic_py_validation(value, (int, float))
self._validate_bounds(value)
return value
@@ -871,8 +881,8 @@ class Perc(_Numeric):
def to_py(
self,
- value: typing.Union[None, float, int, str, usertypes.Unset]
- ) -> typing.Union[None, float, int, usertypes.Unset]:
+ value: typing.Union[float, int, str, _UnsetNone]
+ ) -> typing.Union[float, int, _UnsetNone]:
self._basic_py_validation(value, (float, int, str))
if isinstance(value, usertypes.Unset):
return value
@@ -1067,8 +1077,7 @@ class QtColor(BaseType):
except ValueError:
raise configexc.ValidationError(val, "must be a valid color value")
- def to_py(self, value: _StrUnset) -> typing.Union[usertypes.Unset,
- None, QColor]:
+ def to_py(self, value: _StrUnset) -> typing.Union[_UnsetNone, QColor]:
self._basic_py_validation(value, str)
if isinstance(value, usertypes.Unset):
return value
@@ -1146,14 +1155,9 @@ class QssColor(BaseType):
return value
-class Font(BaseType):
+class FontBase(BaseType):
- """A font family, with optional style/weight/size.
-
- * Style: `normal`/`italic`/`oblique`
- * Weight: `normal`, `bold`, `100`..`900`
- * Size: _number_ `px`/`pt`
- """
+ """Base class for Font/QtFont/FontFamily."""
# Gets set when the config is initialized.
default_family = None # type: str
@@ -1229,6 +1233,19 @@ class Font(BaseType):
cls.default_family = families.to_str(quote=True)
cls.default_size = default_size
+ def to_py(self, value: typing.Any) -> typing.Any:
+ raise NotImplementedError
+
+
+class Font(FontBase):
+
+ """A font family, with optional style/weight/size.
+
+ * Style: `normal`/`italic`/`oblique`
+ * Weight: `normal`, `bold`, `100`..`900`
+ * Size: _number_ `px`/`pt`
+ """
+
def to_py(self, value: _StrUnset) -> _StrUnsetNone:
self._basic_py_validation(value, str)
if isinstance(value, usertypes.Unset):
@@ -1251,7 +1268,7 @@ class Font(BaseType):
return value
-class FontFamily(Font):
+class FontFamily(FontBase):
"""A Qt font family."""
@@ -1275,7 +1292,7 @@ class FontFamily(Font):
return value
-class QtFont(Font):
+class QtFont(FontBase):
"""A Font which gets converted to a QFont."""
@@ -1338,13 +1355,12 @@ class QtFont(Font):
families = self._parse_families(family_str)
if hasattr(font, 'setFamilies'):
# Added in Qt 5.13
- font.setFamily(families.family) # type: ignore
+ font.setFamily(families.family) # type: ignore[arg-type]
font.setFamilies(list(families))
else: # pragma: no cover
font.setFamily(families.to_str(quote=False))
- def to_py(self, value: _StrUnset) -> typing.Union[usertypes.Unset,
- None, QFont]:
+ def to_py(self, value: _StrUnset) -> typing.Union[_UnsetNone, QFont]:
self._basic_py_validation(value, str)
if isinstance(value, usertypes.Unset):
return value
@@ -1423,7 +1439,7 @@ class Regex(BaseType):
def to_py(
self,
value: typing.Union[str, typing.Pattern[str], usertypes.Unset]
- ) -> typing.Union[usertypes.Unset, None, typing.Pattern[str]]:
+ ) -> typing.Union[_UnsetNone, typing.Pattern[str]]:
"""Get a compiled regex from either a string or a regex object."""
self._basic_py_validation(value, (str, self._regex_type))
if isinstance(value, usertypes.Unset):
@@ -1514,7 +1530,7 @@ class Dict(BaseType):
def to_py(
self,
- value: typing.Union[typing.Dict, usertypes.Unset, None]
+ value: typing.Union[typing.Dict, _UnsetNone]
) -> typing.Union[typing.Dict, usertypes.Unset]:
self._basic_py_validation(value, dict)
if isinstance(value, usertypes.Unset):
@@ -1713,7 +1729,7 @@ class Proxy(BaseType):
def to_py(
self,
value: _StrUnset
- ) -> typing.Union[usertypes.Unset, None, QNetworkProxy, _SystemProxy]:
+ ) -> typing.Union[_UnsetNone, QNetworkProxy, _SystemProxy, pac.PACFetcher]:
self._basic_py_validation(value, str)
if isinstance(value, usertypes.Unset):
return value
@@ -1760,22 +1776,22 @@ class SearchEngineUrl(BaseType):
elif not value:
return None
- if not ('{}' in value or '{0}' in value):
+ if not re.search('{(|0|semiquoted|unquoted|quoted)}', value):
raise configexc.ValidationError(value, "must contain \"{}\"")
try:
- value.format("")
+ format_keys = {
+ 'quoted': "",
+ 'unquoted': "",
+ 'semiquoted': "",
+ }
+ value.format("", **format_keys)
except (KeyError, IndexError):
raise configexc.ValidationError(
value, "may not contain {...} (use {{ and }} for literal {/})")
except ValueError as e:
raise configexc.ValidationError(value, str(e))
- url = QUrl(value.replace('{}', 'foobar'))
- if not url.isValid():
- raise configexc.ValidationError(
- value, "invalid url, {}".format(url.errorString()))
-
return value
@@ -1783,7 +1799,7 @@ class FuzzyUrl(BaseType):
"""A URL which gets interpreted as search if needed."""
- def to_py(self, value: _StrUnset) -> _StrUnsetNone:
+ def to_py(self, value: _StrUnset) -> typing.Union[QUrl, _UnsetNone]:
self._basic_py_validation(value, str)
if isinstance(value, usertypes.Unset):
return value
@@ -1819,9 +1835,9 @@ class Padding(Dict):
fixed_keys=['top', 'bottom', 'left', 'right'],
none_ok=none_ok)
- def to_py( # type: ignore
+ def to_py( # type: ignore[override]
self,
- value: typing.Union[usertypes.Unset, typing.Dict, None],
+ value: typing.Union[typing.Dict, _UnsetNone],
) -> typing.Union[usertypes.Unset, PaddingValues]:
d = super().to_py(value)
if isinstance(d, usertypes.Unset):
@@ -1893,10 +1909,7 @@ class Url(BaseType):
"""A URL as a string."""
- def to_py(
- self,
- value: _StrUnset
- ) -> typing.Union[usertypes.Unset, None, QUrl]:
+ def to_py(self, value: _StrUnset) -> typing.Union[_UnsetNone, QUrl]:
self._basic_py_validation(value, str)
if isinstance(value, usertypes.Unset):
return value
@@ -2010,7 +2023,7 @@ class Key(BaseType):
def to_py(
self,
value: _StrUnset
- ) -> typing.Union[usertypes.Unset, None, keyutils.KeySequence]:
+ ) -> typing.Union[_UnsetNone, keyutils.KeySequence]:
self._basic_py_validation(value, str)
if isinstance(value, usertypes.Unset):
return value
@@ -2034,7 +2047,7 @@ class UrlPattern(BaseType):
def to_py(
self,
value: _StrUnset
- ) -> typing.Union[usertypes.Unset, None, urlmatch.UrlPattern]:
+ ) -> typing.Union[_UnsetNone, urlmatch.UrlPattern]:
self._basic_py_validation(value, str)
if isinstance(value, usertypes.Unset):
return value
diff --git a/qutebrowser/config/configutils.py b/qutebrowser/config/configutils.py
index bfc460bea..3f7823772 100644
--- a/qutebrowser/config/configutils.py
+++ b/qutebrowser/config/configutils.py
@@ -28,7 +28,7 @@ import operator
from PyQt5.QtCore import QUrl
-from qutebrowser.utils import utils, urlmatch, usertypes
+from qutebrowser.utils import utils, urlmatch, usertypes, qtutils
from qutebrowser.config import configexc
if typing.TYPE_CHECKING:
@@ -151,7 +151,7 @@ class Values:
return bool(self._vmap)
def _check_pattern_support(
- self, arg: typing.Optional[urlmatch.UrlPattern]) -> None:
+ self, arg: typing.Union[urlmatch.UrlPattern, QUrl, None]) -> None:
"""Make sure patterns are supported if one was given."""
if arg is not None and not self.opt.supports_pattern:
raise configexc.NoPatternError(self.opt.name)
@@ -223,6 +223,7 @@ class Values:
self._check_pattern_support(url)
if url is None:
return self._get_fallback(fallback)
+ qtutils.ensure_valid(url)
candidates = [] # type: typing.List[ScopedValue]
# Urls trailing with '.' are equivalent to non-trailing types.
diff --git a/qutebrowser/config/stylesheet.py b/qutebrowser/config/stylesheet.py
index 276d37094..10e6e4e52 100644
--- a/qutebrowser/config/stylesheet.py
+++ b/qutebrowser/config/stylesheet.py
@@ -109,7 +109,7 @@ class _StyleSheetObserver(QObject):
def register(self) -> None:
"""Do a first update and listen for more."""
qss = self._get_stylesheet()
- log.config.vdebug( # type: ignore
+ log.config.vdebug( # type: ignore[attr-defined]
"stylesheet for {}: {}".format(self._obj.__class__.__name__, qss))
self._obj.setStyleSheet(qss)
if self._update:
diff --git a/qutebrowser/config/websettings.py b/qutebrowser/config/websettings.py
index 03c85a71a..007758254 100644
--- a/qutebrowser/config/websettings.py
+++ b/qutebrowser/config/websettings.py
@@ -103,6 +103,9 @@ class AbstractSettings:
def __init__(self, settings: typing.Any) -> None:
self._settings = settings
+ def _assert_not_unset(self, value: typing.Any) -> None:
+ assert value is not usertypes.UNSET
+
def set_attribute(self, name: str, value: typing.Any) -> bool:
"""Set the given QWebSettings/QWebEngineSettings attribute.
@@ -139,7 +142,7 @@ class AbstractSettings:
Return:
True if there was a change, False otherwise.
"""
- assert value is not usertypes.UNSET # type: ignore
+ self._assert_not_unset(value)
family = self._FONT_SIZES[name]
old_value = self._settings.fontSize(family)
self._settings.setFontSize(family, value)
@@ -154,7 +157,7 @@ class AbstractSettings:
Return:
True if there was a change, False otherwise.
"""
- assert value is not usertypes.UNSET # type: ignore
+ self._assert_not_unset(value)
family = self._FONT_FAMILIES[name]
if value is None:
font = QFont()
@@ -172,7 +175,7 @@ class AbstractSettings:
Return:
True if there was a change, False otherwise.
"""
- assert encoding is not usertypes.UNSET # type: ignore
+ self._assert_not_unset(encoding)
old_value = self._settings.defaultTextEncoding()
self._settings.setDefaultTextEncoding(encoding)
return old_value != encoding
@@ -253,6 +256,10 @@ def _format_user_agent(template: str, backend: usertypes.Backend) -> str:
def user_agent(url: QUrl = None) -> str:
+ """Get the user agent for the given URL, or the global one if URL is None.
+
+ Note that the given URL should always be valid.
+ """
template = config.instance.get('content.headers.user_agent', url=url)
return _format_user_agent(template=template, backend=objects.backend)
diff --git a/qutebrowser/extensions/loader.py b/qutebrowser/extensions/loader.py
index 928f2856c..41b9c63fd 100644
--- a/qutebrowser/extensions/loader.py
+++ b/qutebrowser/extensions/loader.py
@@ -82,8 +82,8 @@ def add_module_info(module: types.ModuleType) -> ModuleInfo:
"""Add ModuleInfo to a module (if not added yet)."""
# pylint: disable=protected-access
if not hasattr(module, '__qute_module_info'):
- module.__qute_module_info = ModuleInfo() # type: ignore
- return module.__qute_module_info # type: ignore
+ module.__qute_module_info = ModuleInfo() # type: ignore[attr-defined]
+ return module.__qute_module_info # type: ignore[attr-defined]
def load_components(*, skip_hooks: bool = False) -> None:
@@ -109,7 +109,7 @@ def _walk_normal() -> typing.Iterator[ExtensionInfo]:
for _finder, name, ispkg in pkgutil.walk_packages(
# Only packages have a __path__ attribute,
# but we're sure this is one.
- path=components.__path__, # type: ignore
+ path=components.__path__, # type: ignore[attr-defined]
prefix=components.__name__ + '.',
onerror=_on_walk_error):
if ispkg:
diff --git a/qutebrowser/html/warning-old-qt.html b/qutebrowser/html/warning-old-qt.html
index 157d50714..e5da57548 100644
--- a/qutebrowser/html/warning-old-qt.html
+++ b/qutebrowser/html/warning-old-qt.html
@@ -7,18 +7,26 @@ qute://warning/old-qt</span> to show it again at a later time.</span>
<p>You're using qutebrowser with Qt {{qt_version}}.</p>
+{% if qt_version.startswith('5.7.') %}
<p>Qt 5.7 was released in June 2016, with the 5.7.1 patch release in December
2016. It is based on Chromium 49 (March 2016) with (some) security fixes up to
-Chromium 54 (October 2016). It is also
-<a href="https://www.debian.org/releases/stable/amd64/release-notes/ch-information.en.html#browser-security">not covered</a>
-by Debian security updates.</p>
-
+Chromium 54 (October 2016).</p>
+{% elif qt_version.startswith('5.8.') %}
<p>Qt 5.8 has had various bugs, and has been unsupported (but working to some
degree) in qutebrowser for a while.</p>
+{% elif qt_version.startswith('5.9.') %}
+<p>Qt 5.9 LTS was released in May 2017 and is based on Chromium 56 (January 2017). It is a long term support release with the 5.9.9 patch release in December 2019 including (some) security fixes up to Chromium 78 (November 2019). However, its usage was found to be low, and the next LTS (Qt 5.12) was released in December 2018.</p>
+{% elif qt_version.startswith('5.10.') %}
+<p>Qt 5.10 was released in December 2017, with the 5.10.1 patch release in February
+2018. It is based on Chromium 65 (March 2018) with (some) security fixes up to
+Chromium 70 (November 2018).</p>
+{% endif %}
+
+Also, note that QtWebEngine is <a href="https://www.debian.org/releases/stable/amd64/release-notes/ch-information.en.html#browser-security">not covered</a> by Debian security updates.
<p>Because of those security issues and the maintaince burden coming with
-supporting old versions, support for Qt < 5.9 will be dropped in a future
-qutebrowser release. You might want to check
+supporting old versions, support for Qt < 5.11 will be dropped in qutebrowser
+v2.0. You might want to check
<a href="https://qutebrowser.org/doc/install.html">alternate installation methods</a>
which allow you to get a newer Qt.</p>
{% endblock %}
diff --git a/qutebrowser/html/warning-sessions.html b/qutebrowser/html/warning-sessions.html
new file mode 100644
index 000000000..dd0c4127b
--- /dev/null
+++ b/qutebrowser/html/warning-sessions.html
@@ -0,0 +1,22 @@
+{% extends "styled.html" %}
+
+{% block content %}
+<h1>{{ title }}</h1>
+<span class="note">Note this warning will only appear once. Use <span class="mono">:open
+qute://warning/sessions</span> to show it again at a later time.</span>
+
+<p>You're using qutebrowser with Qt 5.15.</p>
+
+<p>Since Qt doesn't provide an API to load the history of a tab, qutebrowser relies on a reverse-engineered binary serialization format to load tab history from session files. With Qt 5.15, unfortunately that format changed (due to the underlying Chromium upgrade), in a way which makes it impossible for qutebrowser to load tab history from existing session data.</p>
+
+<p>At the time of writing (April 2020), a new session format which stores part of the needed binary data in saved sessions is <a href="https://github.com/qutebrowser/qutebrowser/issues/5359">in development</a> and will be released with qutebrowser v1.12.0.</p>
+
+<p>As a stop-gap measure:</p>
+
+<ul>
+ <li>Loading a session with this release will <b>only load the most recently opened page</b> for every tab. As a result, the back/forward-history of every tab <b>will be lost</b> as soon as the session is saved again.</li>
+ <li>Due to that, the <span class="mono">session.lazy_restore</span> setting does not have any effect.</li>
+ <li>A one-time backup of the session folder has been created at <span class="mono">{{ datadir }}{{ sep }}sessions{{ sep }}before-qt-515</span>.</li>
+</ul>
+
+{% endblock %}
diff --git a/qutebrowser/html/warning-webkit.html b/qutebrowser/html/warning-webkit.html
index 7fc22903a..a46871089 100644
--- a/qutebrowser/html/warning-webkit.html
+++ b/qutebrowser/html/warning-webkit.html
@@ -10,12 +10,14 @@ qute://warning/webkit</span> to show it again at a later time.</span>
<p>While QtWebKit has gained some traction again recently, its latest release
(5.212.0 Alpha 3) is still based on an old upstream WebKit. It also lacks
various security features (process isolation/sandboxing) present in
-QtWebEngine. From the upstream release notes:</p>
-
-<blockquote>WARNING: This release is based on old WebKit revision with known
-unpatched vulnerabilities. Please use it carefully and avoid visiting untrusted
-websites and using it for transmission of sensitive data. Wait for new release
-from qtwebkit-dev branch to use it with untrusted content.</blockquote>
+QtWebEngine. From the
+<a href="https://github.com/qtwebkit/qtwebkit/releases">QtWebKit release
+notes</a>:</p>
+
+<blockquote><i>WARNING:</i> This release [of QtWebKit] is based on [an] <i>old
+WebKit revision</i> with known unpatched vulnerabilities. <i>Please use it
+carefully and avoid visiting untrusted websites and using it for
+transmission of sensitive data.</i></blockquote>
<p>It's recommended that you use QtWebEngine instead.</p>
diff --git a/qutebrowser/javascript/.eslintrc.yaml b/qutebrowser/javascript/.eslintrc.yaml
index 4fdd43854..23456e801 100644
--- a/qutebrowser/javascript/.eslintrc.yaml
+++ b/qutebrowser/javascript/.eslintrc.yaml
@@ -62,3 +62,4 @@ rules:
max-params: "off"
prefer-named-capture-group: "off"
function-call-argument-newline: "off"
+ no-negated-condition: "off"
diff --git a/qutebrowser/javascript/caret.js b/qutebrowser/javascript/caret.js
index 55ff6a8b5..d7ba88fe6 100644
--- a/qutebrowser/javascript/caret.js
+++ b/qutebrowser/javascript/caret.js
@@ -706,6 +706,18 @@ window._qutebrowser.caret = (function() {
CaretBrowsing.isCaretVisible = false;
/**
+ * Selection modes.
+ * NOTE: Values need to line up with SelectionState in browsertab.py!
+ *
+ * @type {enum}
+ */
+ CaretBrowsing.SelectionState = {
+ "NONE": "none",
+ "NORMAL": "normal",
+ "LINE": "line",
+ };
+
+ /**
* The actual caret element, an absolute-positioned flashing line.
* @type {Element}
*/
@@ -887,7 +899,11 @@ window._qutebrowser.caret = (function() {
CaretBrowsing.injectCaretStyles();
CaretBrowsing.toggle();
CaretBrowsing.initiated = true;
- CaretBrowsing.selectionEnabled = selectionRange > 0;
+ if (selectionRange > 0) {
+ CaretBrowsing.selectionState = CaretBrowsing.SelectionState.NORMAL;
+ } else {
+ CaretBrowsing.selectionState = CaretBrowsing.SelectionState.NONE;
+ }
};
/**
@@ -1145,16 +1161,45 @@ window._qutebrowser.caret = (function() {
}
};
+ CaretBrowsing.reverseSelection = () => {
+ const sel = window.getSelection();
+ sel.setBaseAndExtent(
+ sel.extentNode, sel.extentOffset, sel.baseNode,
+ sel.baseOffset
+ );
+ };
+
+ CaretBrowsing.selectLine = function() {
+ const sel = window.getSelection();
+ sel.modify("extend", "right", "lineboundary");
+ CaretBrowsing.reverseSelection();
+ sel.modify("extend", "left", "lineboundary");
+ CaretBrowsing.reverseSelection();
+ };
+
+ CaretBrowsing.updateLineSelection = function(direction, granularity) {
+ if (granularity !== "character" && granularity !== "word") {
+ window.
+ getSelection().
+ modify("extend", direction, granularity);
+ CaretBrowsing.selectLine();
+ }
+ };
+
CaretBrowsing.move = function(direction, granularity, count = 1) {
let action = "move";
- if (CaretBrowsing.selectionEnabled) {
+ if (CaretBrowsing.selectionState !== CaretBrowsing.SelectionState.NONE) {
action = "extend";
}
for (let i = 0; i < count; i++) {
- window.
- getSelection().
- modify(action, direction, granularity);
+ if (CaretBrowsing.selectionState === CaretBrowsing.SelectionState.LINE) {
+ CaretBrowsing.updateLineSelection(direction, granularity);
+ } else {
+ window.
+ getSelection().
+ modify(action, direction, granularity);
+ }
}
if (CaretBrowsing.isWindows &&
@@ -1174,7 +1219,7 @@ window._qutebrowser.caret = (function() {
CaretBrowsing.moveToBlock = function(paragraph, boundary, count = 1) {
let action = "move";
- if (CaretBrowsing.selectionEnabled) {
+ if (CaretBrowsing.selectionState !== CaretBrowsing.SelectionState.NONE) {
action = "extend";
}
for (let i = 0; i < count; i++) {
@@ -1185,6 +1230,10 @@ window._qutebrowser.caret = (function() {
window.
getSelection().
modify(action, boundary, "paragraphboundary");
+
+ if (CaretBrowsing.selectionState === CaretBrowsing.SelectionState.LINE) {
+ CaretBrowsing.selectLine();
+ }
}
};
@@ -1294,14 +1343,14 @@ window._qutebrowser.caret = (function() {
funcs.setInitialCursor = () => {
if (!CaretBrowsing.initiated) {
CaretBrowsing.setInitialCursor();
- return CaretBrowsing.selectionEnabled;
+ return CaretBrowsing.selectionState !== CaretBrowsing.SelectionState.NONE;
}
if (window.getSelection().toString().length === 0) {
positionCaret();
}
CaretBrowsing.toggle();
- return CaretBrowsing.selectionEnabled;
+ return CaretBrowsing.selectionState !== CaretBrowsing.SelectionState.NONE;
};
funcs.setFlags = (flags) => {
@@ -1399,17 +1448,22 @@ window._qutebrowser.caret = (function() {
funcs.getSelection = () => window.getSelection().toString();
- funcs.toggleSelection = () => {
- CaretBrowsing.selectionEnabled = !CaretBrowsing.selectionEnabled;
- return CaretBrowsing.selectionEnabled;
+ funcs.toggleSelection = (line) => {
+ if (line) {
+ CaretBrowsing.selectionState =
+ CaretBrowsing.SelectionState.LINE;
+ CaretBrowsing.selectLine();
+ CaretBrowsing.finishMove();
+ } else if (CaretBrowsing.selectionState !== CaretBrowsing.SelectionState.NORMAL) {
+ CaretBrowsing.selectionState = CaretBrowsing.SelectionState.NORMAL;
+ } else {
+ CaretBrowsing.selectionState = CaretBrowsing.SelectionState.NONE;
+ }
+ return CaretBrowsing.selectionState;
};
funcs.reverseSelection = () => {
- const sel = window.getSelection();
- sel.setBaseAndExtent(
- sel.extentNode, sel.extentOffset, sel.baseNode,
- sel.baseOffset
- );
+ CaretBrowsing.reverseSelection();
};
return funcs;
diff --git a/qutebrowser/javascript/pac_utils.js b/qutebrowser/javascript/pac_utils.js
index 0aba4c070..a7ac2d414 100644
--- a/qutebrowser/javascript/pac_utils.js
+++ b/qutebrowser/javascript/pac_utils.js
@@ -241,7 +241,7 @@ function timeRange() {
}
break;
default:
- throw 'timeRange: bad number of arguments'
+ throw 'timeRange: bad number of arguments';
}
}
diff --git a/qutebrowser/javascript/whatsapp_web_quirk.user.js b/qutebrowser/javascript/whatsapp_web_quirk.user.js
new file mode 100644
index 000000000..b8979d15e
--- /dev/null
+++ b/qutebrowser/javascript/whatsapp_web_quirk.user.js
@@ -0,0 +1,15 @@
+// ==UserScript==
+// @include https://web.whatsapp.com/
+// ==/UserScript==
+
+// Quirk for WhatsApp Web, based on:
+// https://github.com/jiahaog/nativefier/issues/719#issuecomment-443809630
+
+"use strict";
+
+if (document.querySelector("a[href='https://support.google.com/chrome/answer/95414']")) {
+ navigator.serviceWorker.getRegistration().then((registration) => {
+ registration.unregister();
+ document.location.reload();
+ });
+}
diff --git a/qutebrowser/keyinput/basekeyparser.py b/qutebrowser/keyinput/basekeyparser.py
index 0f8ec421a..3c4adee49 100644
--- a/qutebrowser/keyinput/basekeyparser.py
+++ b/qutebrowser/keyinput/basekeyparser.py
@@ -26,7 +26,6 @@ import typing
import attr
from PyQt5.QtCore import pyqtSignal, QObject, Qt
from PyQt5.QtGui import QKeySequence, QKeyEvent
-from PyQt5.QtWidgets import QWidget
from qutebrowser.config import config
from qutebrowser.utils import usertypes, log, utils
@@ -174,7 +173,7 @@ class BaseKeyParser(QObject):
passthrough = False
supports_count = True
- def __init__(self, win_id: int, parent: QWidget = None) -> None:
+ def __init__(self, win_id: int, parent: QObject = None) -> None:
super().__init__(parent)
self._win_id = win_id
self._modename = None
@@ -208,7 +207,6 @@ class BaseKeyParser(QObject):
- The found binding with Match.definitive.
"""
assert sequence
- assert not isinstance(sequence, str)
return self.bindings.matches(sequence)
def _match_without_modifiers(
@@ -340,7 +338,6 @@ class BaseKeyParser(QObject):
self.bindings = BindingTrie()
for key, cmd in config.key_instance.get_bindings_for(modename).items():
- assert not isinstance(key, str), key
assert cmd
self.bindings[key] = cmd
diff --git a/qutebrowser/keyinput/eventfilter.py b/qutebrowser/keyinput/eventfilter.py
index 7916f16fe..6ef0dd201 100644
--- a/qutebrowser/keyinput/eventfilter.py
+++ b/qutebrowser/keyinput/eventfilter.py
@@ -19,6 +19,8 @@
"""Global Qt event filter which dispatches key events."""
+import typing
+
from PyQt5.QtCore import pyqtSlot, QObject, QEvent
from PyQt5.QtGui import QKeyEvent, QWindow
from PyQt5.QtWidgets import QApplication
@@ -85,19 +87,22 @@ class EventFilter(QObject):
Return:
True if the event should be filtered, False if it's passed through.
"""
+ if not isinstance(obj, QWindow):
+ # We already handled this same event at some point earlier, so
+ # we're not interested in it anymore.
+ return False
+
+ typ = event.type()
+
+ if typ not in self._handlers:
+ return False
+
+ if not self._activated:
+ return False
+
+ handler = self._handlers[typ]
try:
- if not self._activated:
- return False
- if not isinstance(obj, QWindow):
- # We already handled this same event at some point earlier, so
- # we're not interested in it anymore.
- return False
- try:
- handler = self._handlers[event.type()]
- except KeyError:
- return False
- else:
- return handler(event)
+ return handler(typing.cast(QKeyEvent, event))
except:
# If there is an exception in here and we leave the eventfilter
# activated, we'll get an infinite loop and a stack overflow.
diff --git a/qutebrowser/keyinput/keyutils.py b/qutebrowser/keyinput/keyutils.py
index b738ad190..142bedd2f 100644
--- a/qutebrowser/keyinput/keyutils.py
+++ b/qutebrowser/keyinput/keyutils.py
@@ -53,6 +53,8 @@ _MODIFIER_MAP = {
_NIL_KEY = Qt.Key(0)
+_ModifierType = typing.Union[Qt.KeyboardModifier, Qt.KeyboardModifiers]
+
def _build_special_names() -> typing.Mapping[Qt.Key, str]:
"""Build _SPECIAL_NAMES dict from the special_names_str mapping below.
@@ -167,9 +169,10 @@ def _assert_plain_key(key: Qt.Key) -> None:
assert not key & Qt.KeyboardModifierMask, hex(key)
-def _assert_plain_modifier(key: Qt.KeyboardModifier) -> None:
+def _assert_plain_modifier(key: _ModifierType) -> None:
"""Make sure this is a modifier without a key mixed in."""
- assert not key & ~Qt.KeyboardModifierMask, hex(key)
+ mask = Qt.KeyboardModifierMask
+ assert not key & ~mask, hex(key) # type: ignore[operator]
def _is_printable(key: Qt.Key) -> bool:
@@ -177,7 +180,7 @@ def _is_printable(key: Qt.Key) -> bool:
return key <= 0xff and key not in [Qt.Key_Space, _NIL_KEY]
-def is_special_hint_mode(key: Qt.Key, modifiers: Qt.KeyboardModifier) -> bool:
+def is_special_hint_mode(key: Qt.Key, modifiers: _ModifierType) -> bool:
"""Check whether this key should clear the keychain in hint mode.
When we press "s<Escape>", we don't want <Escape> to be handled as part of
@@ -192,7 +195,7 @@ def is_special_hint_mode(key: Qt.Key, modifiers: Qt.KeyboardModifier) -> bool:
Qt.KeypadModifier])
-def is_special(key: Qt.Key, modifiers: Qt.KeyboardModifier) -> bool:
+def is_special(key: Qt.Key, modifiers: _ModifierType) -> bool:
"""Check whether this key requires special key syntax."""
_assert_plain_key(key)
_assert_plain_modifier(modifiers)
@@ -244,7 +247,7 @@ def _remap_unicode(key: Qt.Key, text: str) -> Qt.Key:
def _check_valid_utf8(s: str,
- data: typing.Union[Qt.Key, Qt.KeyboardModifier]) -> None:
+ data: typing.Union[Qt.Key, _ModifierType]) -> None:
"""Make sure the given string is valid UTF-8.
Makes sure there are no chars where Qt did fall back to weird UTF-16
@@ -254,7 +257,7 @@ def _check_valid_utf8(s: str,
s.encode('utf-8')
except UnicodeEncodeError as e: # pragma: no cover
raise ValueError("Invalid encoding in 0x{:x} -> {}: {}"
- .format(data, s, e))
+ .format(int(data), s, e))
def _key_to_string(key: Qt.Key) -> str:
@@ -276,15 +279,16 @@ def _key_to_string(key: Qt.Key) -> str:
return result
-def _modifiers_to_string(modifiers: Qt.KeyboardModifier) -> str:
+def _modifiers_to_string(modifiers: _ModifierType) -> str:
"""Convert the given Qt::KeyboardModifiers to a string.
Handles Qt.GroupSwitchModifier because Qt doesn't handle that as a
modifier.
"""
_assert_plain_modifier(modifiers)
- if modifiers & Qt.GroupSwitchModifier:
- modifiers &= ~Qt.GroupSwitchModifier # type: ignore
+ altgr = Qt.GroupSwitchModifier
+ if modifiers & altgr: # type: ignore[operator]
+ modifiers &= ~altgr # type: ignore[operator, assignment]
result = 'AltGr+'
else:
result = ''
@@ -375,7 +379,7 @@ class KeyInfo:
"""
key = attr.ib() # type: Qt.Key
- modifiers = attr.ib() # type: Qt.KeyboardModifier
+ modifiers = attr.ib() # type: _ModifierType
@classmethod
def from_event(cls, e: QKeyEvent) -> 'KeyInfo':
@@ -388,7 +392,7 @@ class KeyInfo:
modifiers = e.modifiers()
_assert_plain_key(key)
_assert_plain_modifier(modifiers)
- return cls(key, modifiers)
+ return cls(key, typing.cast(Qt.KeyboardModifier, modifiers))
def __hash__(self) -> int:
"""Convert KeyInfo to int before hashing.
@@ -451,7 +455,7 @@ class KeyInfo:
return ''
text = QKeySequence(self.key).toString()
- if not self.modifiers & Qt.ShiftModifier:
+ if not self.modifiers & Qt.ShiftModifier: # type: ignore[operator]
text = text.lower()
return text
@@ -508,7 +512,7 @@ class KeySequence:
"""Iterate over KeyInfo objects."""
for key_and_modifiers in self._iter_keys():
key = Qt.Key(int(key_and_modifiers) & ~Qt.KeyboardModifierMask)
- modifiers = Qt.KeyboardModifiers( # type: ignore
+ modifiers = Qt.KeyboardModifiers( # type: ignore[call-overload]
int(key_and_modifiers) & Qt.KeyboardModifierMask)
yield KeyInfo(key=key, modifiers=modifiers)
@@ -565,7 +569,9 @@ class KeySequence:
return infos[item]
def _iter_keys(self) -> typing.Iterator[int]:
- return itertools.chain.from_iterable(self._sequences)
+ sequences = typing.cast(typing.Iterable[typing.Iterable[int]],
+ self._sequences)
+ return itertools.chain.from_iterable(sequences)
def _validate(self, keystr: str = None) -> None:
for info in self:
@@ -646,7 +652,7 @@ class KeySequence:
if (modifiers == Qt.ShiftModifier and
_is_printable(key) and
not ev.text().isupper()):
- modifiers = Qt.KeyboardModifiers()
+ modifiers = Qt.KeyboardModifiers() # type: ignore[assignment]
# On macOS, swap Ctrl and Meta back
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-51293
diff --git a/qutebrowser/keyinput/modeman.py b/qutebrowser/keyinput/modeman.py
index 7e29ac3f5..880b1ec93 100644
--- a/qutebrowser/keyinput/modeman.py
+++ b/qutebrowser/keyinput/modeman.py
@@ -20,7 +20,7 @@
"""Mode manager singleton which handles the current keyboard mode."""
import functools
-import typing
+from typing import Mapping, Callable, MutableMapping, Union, Set, cast
import attr
from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QObject, QEvent
@@ -37,8 +37,7 @@ from qutebrowser.browser import hints
INPUT_MODES = [usertypes.KeyMode.insert, usertypes.KeyMode.passthrough]
PROMPT_MODES = [usertypes.KeyMode.prompt, usertypes.KeyMode.yesno]
-ParserDictType = typing.MutableMapping[
- usertypes.KeyMode, basekeyparser.BaseKeyParser]
+ParserDictType = MutableMapping[usertypes.KeyMode, basekeyparser.BaseKeyParser]
@attr.s(frozen=True)
@@ -169,7 +168,7 @@ def init(win_id: int, parent: QObject) -> 'ModeManager':
return modeman
-def instance(win_id: typing.Union[int, str]) -> 'ModeManager':
+def instance(win_id: Union[int, str]) -> 'ModeManager':
"""Get a modemanager object."""
return objreg.get('mode-manager', scope='window', window=win_id)
@@ -223,7 +222,7 @@ class ModeManager(QObject):
self.parsers = {} # type: ParserDictType
self._prev_mode = usertypes.KeyMode.normal
self.mode = usertypes.KeyMode.normal
- self._releaseevents_to_pass = set() # type: typing.Set[KeyEvent]
+ self._releaseevents_to_pass = set() # type: Set[KeyEvent]
def __repr__(self) -> str:
return utils.get_repr(self, mode=self.mode)
@@ -246,9 +245,11 @@ class ModeManager(QObject):
"{}".format(curmode, utils.qualname(parser)))
match = parser.handle(event, dry_run=dry_run)
- is_non_alnum = (
- event.modifiers() not in [Qt.NoModifier, Qt.ShiftModifier] or
- not event.text().strip())
+ has_modifier = event.modifiers() not in [
+ Qt.NoModifier,
+ Qt.ShiftModifier,
+ ] # type: ignore[comparison-overlap]
+ is_non_alnum = has_modifier or not event.text().strip()
forward_unbound_keys = config.cache['input.forward_unbound_keys']
@@ -416,9 +417,9 @@ class ModeManager(QObject):
QEvent.KeyRelease: self._handle_keyrelease,
QEvent.ShortcutOverride:
functools.partial(self._handle_keypress, dry_run=True),
- } # type: typing.Mapping[QEvent.Type, typing.Callable[[QEvent], bool]]
+ } # type: Mapping[QEvent.Type, Callable[[QKeyEvent], bool]]
handler = handlers[event.type()]
- return handler(event)
+ return handler(cast(QKeyEvent, event))
@cmdutils.register(instance='mode-manager', scope='window')
def clear_keychain(self) -> None:
diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py
index 2cdf64e1f..41f97868c 100644
--- a/qutebrowser/mainwindow/mainwindow.py
+++ b/qutebrowser/mainwindow/mainwindow.py
@@ -102,7 +102,7 @@ def raise_window(window, alert=True):
window.setWindowState(window.windowState() | Qt.WindowActive)
window.raise_()
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-69568
- QCoreApplication.processEvents( # type: ignore
+ QCoreApplication.processEvents( # type: ignore[call-overload]
QEventLoop.ExcludeUserInputEvents | QEventLoop.ExcludeSocketNotifiers)
window.activateWindow()
@@ -157,8 +157,11 @@ class MainWindow(QWidget):
color: {{ conf.colors.hints.fg }};
font: {{ conf.fonts.hints }};
border: {{ conf.hints.border }};
- padding-left: 3px;
- padding-right: 3px;
+ border-radius: {{ conf.hints.radius }}px;
+ padding-top: {{ conf.hints.padding['top'] }}px;
+ padding-left: {{ conf.hints.padding['left'] }}px;
+ padding-right: {{ conf.hints.padding['right'] }}px;
+ padding-bottom: {{ conf.hints.padding['bottom'] }}px;
}
QMenu {
@@ -181,6 +184,15 @@ class MainWindow(QWidget):
color: {{ conf.colors.contextmenu.selected.fg }};
{% endif %}
}
+
+ QMenu::item:disabled {
+ {% if conf.colors.contextmenu.disabled.bg %}
+ background-color: {{ conf.colors.contextmenu.disabled.bg }};
+ {% endif %}
+ {% if conf.colors.contextmenu.disabled.fg %}
+ color: {{ conf.colors.contextmenu.disabled.fg }};
+ {% endif %}
+ }
"""
def __init__(self, *, private, geometry=None, parent=None):
@@ -381,7 +393,9 @@ class MainWindow(QWidget):
self._command_dispatcher,
command_only=True,
scope='window', window=self.win_id)
- self.tabbed_browser.widget.destroyed.connect( # type: ignore
+
+ widget = self.tabbed_browser.widget
+ widget.destroyed.connect(
functools.partial(objreg.delete, 'command-dispatcher',
scope='window', window=self.win_id))
@@ -406,7 +420,7 @@ class MainWindow(QWidget):
self._vbox.removeWidget(self.tabbed_browser.widget)
self._vbox.removeWidget(self._downloadview)
self._vbox.removeWidget(self.status)
- widgets = [self.tabbed_browser.widget]
+ widgets = [self.tabbed_browser.widget] # type: typing.List[QWidget]
downloads_position = config.val.downloads.position
if downloads_position == 'top':
@@ -443,7 +457,7 @@ class MainWindow(QWidget):
def _save_geometry(self):
"""Save the window geometry to the state config."""
- data = bytes(self.saveGeometry())
+ data = self.saveGeometry().data()
geom = base64.b64encode(data).decode('ASCII')
configfiles.state['geometry']['mainwindow'] = geom
@@ -488,15 +502,15 @@ class MainWindow(QWidget):
mode_manager.left.connect(self.status.on_mode_left)
mode_manager.left.connect(self.status.cmd.on_mode_left)
mode_manager.left.connect(
- message.global_bridge.mode_left) # type: ignore
+ message.global_bridge.mode_left) # type: ignore[arg-type]
# commands
normal_parser = mode_manager.parsers[usertypes.KeyMode.normal]
normal_parser.keystring_updated.connect(
self.status.keystring.setText)
- self.status.cmd.got_cmd[str].connect( # type: ignore
+ self.status.cmd.got_cmd[str].connect( # type: ignore[index]
self._commandrunner.run_safely)
- self.status.cmd.got_cmd[str, int].connect( # type: ignore
+ self.status.cmd.got_cmd[str, int].connect( # type: ignore[index]
self._commandrunner.run_safely)
self.status.cmd.returnPressed.connect(
self.tabbed_browser.on_cmd_return_pressed)
@@ -571,17 +585,18 @@ class MainWindow(QWidget):
refresh_window = self.isVisible()
if hidden:
window_flags |= Qt.CustomizeWindowHint | Qt.NoDropShadowWindowHint
- self.setWindowFlags(window_flags)
+ self.setWindowFlags(typing.cast(Qt.WindowFlags, window_flags))
if refresh_window:
self.show()
@pyqtSlot(bool)
def _on_fullscreen_requested(self, on):
- if not config.val.content.windowed_fullscreen:
+ if not config.val.content.fullscreen.window:
if on:
self.state_before_fullscreen = self.windowState()
- self.setWindowState(Qt.WindowFullScreen | # type: ignore
- self.state_before_fullscreen)
+ self.setWindowState(
+ Qt.WindowFullScreen | # type: ignore[arg-type]
+ self.state_before_fullscreen) # type: ignore[operator]
elif self.isFullScreen():
self.setWindowState(self.state_before_fullscreen)
log.misc.debug('on: {}, state before fullscreen: {}'.format(
diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py
index bfe6fb812..a929d6428 100644
--- a/qutebrowser/mainwindow/prompt.py
+++ b/qutebrowser/mainwindow/prompt.py
@@ -192,12 +192,13 @@ class PromptQueue(QObject):
if blocking:
loop = qtutils.EventLoop()
self._loops.append(loop)
- loop.destroyed.connect( # type: ignore
- lambda: self._loops.remove(loop))
+ loop.destroyed.connect(lambda: self._loops.remove(loop))
question.completed.connect(loop.quit)
question.completed.connect(loop.deleteLater)
log.prompt.debug("Starting loop.exec_() for {}".format(question))
- loop.exec_(QEventLoop.ExcludeSocketNotifiers)
+ flags = typing.cast(QEventLoop.ProcessEventsFlags,
+ QEventLoop.ExcludeSocketNotifiers)
+ loop.exec_(flags)
log.prompt.debug("Ending loop.exec_() for {}".format(question))
log.prompt.debug("Restoring old question {}".format(old_question))
@@ -329,7 +330,7 @@ class PromptContainer(QWidget):
usertypes.PromptMode.alert: AlertPrompt,
}
klass = classes[question.mode]
- prompt = typing.cast(_BasePrompt, klass(question))
+ prompt = klass(question)
log.prompt.debug("Displaying prompt {}".format(prompt))
self._prompt = prompt
@@ -707,7 +708,7 @@ class FilenamePrompt(_BasePrompt):
# Nothing selected initially
self._file_view.setCurrentIndex(QModelIndex())
# The model needs to be sorted so we get the correct first/last index
- self._file_model.directoryLoaded.connect( # type: ignore
+ self._file_model.directoryLoaded.connect(
lambda: self._file_model.sort(0))
def accept(self, value=None, save=False):
@@ -755,7 +756,7 @@ class FilenamePrompt(_BasePrompt):
selmodel.setCurrentIndex(
idx,
- QItemSelectionModel.ClearAndSelect | # type: ignore
+ QItemSelectionModel.ClearAndSelect | # type: ignore[arg-type]
QItemSelectionModel.Rows)
self._insert_path(idx, clicked=False)
@@ -782,7 +783,7 @@ class DownloadFilenamePrompt(FilenamePrompt):
def __init__(self, question, parent=None):
super().__init__(question, parent)
self._file_model.setFilter(
- QDir.AllDirs | QDir.Drives | QDir.NoDot) # type: ignore
+ QDir.AllDirs | QDir.Drives | QDir.NoDot) # type: ignore[arg-type]
def accept(self, value=None, save=False):
done = super().accept(value, save)
@@ -960,5 +961,5 @@ def init():
"""Initialize global prompt objects."""
global prompt_queue
prompt_queue = PromptQueue()
- message.global_bridge.ask_question.connect( # type: ignore
+ message.global_bridge.ask_question.connect( # type: ignore[call-arg]
prompt_queue.ask_question, Qt.DirectConnection)
diff --git a/qutebrowser/mainwindow/statusbar/bar.py b/qutebrowser/mainwindow/statusbar/bar.py
index b1aa4da38..91bdb0b6e 100644
--- a/qutebrowser/mainwindow/statusbar/bar.py
+++ b/qutebrowser/mainwindow/statusbar/bar.py
@@ -21,7 +21,8 @@
import enum
import attr
-from PyQt5.QtCore import pyqtSignal, pyqtSlot, pyqtProperty, Qt, QSize, QTimer
+from PyQt5.QtCore import (pyqtSignal, pyqtSlot, # type: ignore[attr-defined]
+ pyqtProperty, Qt, QSize, QTimer)
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QStackedLayout, QSizePolicy
from qutebrowser.browser import browsertab
@@ -372,13 +373,17 @@ class StatusBar(QWidget):
self.maybe_hide()
assert tab.is_private == self._color_flags.private
- @pyqtSlot(bool)
- def on_caret_selection_toggled(self, selection):
+ @pyqtSlot(browsertab.SelectionState)
+ def on_caret_selection_toggled(self, selection_state):
"""Update the statusbar when entering/leaving caret selection mode."""
- log.statusbar.debug("Setting caret selection {}".format(selection))
- if selection:
+ log.statusbar.debug("Setting caret selection {}"
+ .format(selection_state))
+ if selection_state is browsertab.SelectionState.normal:
self._set_mode_text("caret selection")
self._color_flags.caret = ColorFlags.CaretMode.selection
+ elif selection_state is browsertab.SelectionState.line:
+ self._set_mode_text("caret line selection")
+ self._color_flags.caret = ColorFlags.CaretMode.selection
else:
self._set_mode_text("caret")
self._color_flags.caret = ColorFlags.CaretMode.on
diff --git a/qutebrowser/mainwindow/statusbar/command.py b/qutebrowser/mainwindow/statusbar/command.py
index 7ead6936a..ebd9d3921 100644
--- a/qutebrowser/mainwindow/statusbar/command.py
+++ b/qutebrowser/mainwindow/statusbar/command.py
@@ -72,8 +72,9 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Ignored)
self.cursorPositionChanged.connect(
- self.update_completion) # type: ignore
- self.textChanged.connect(self.update_completion) # type: ignore
+ self.update_completion) # type: ignore[arg-type]
+ self.textChanged.connect(
+ self.update_completion) # type: ignore[arg-type]
self.textChanged.connect(self.updateGeometry)
self.textChanged.connect(self._incremental_search)
@@ -148,7 +149,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
raise cmdutils.CommandError(
"Invalid command text '{}'.".format(text))
if run_on_count and count is not None:
- self.got_cmd[str, int].emit(text, count) # type: ignore
+ self.got_cmd[str, int].emit(text, count) # type: ignore[index]
else:
self.set_cmd_text(text)
@@ -198,7 +199,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
'cmd accept')
if not was_search:
- self.got_cmd[str].emit(text[1:]) # type: ignore
+ self.got_cmd[str].emit(text[1:]) # type: ignore[index]
@cmdutils.register(instance='status-command', scope='window')
def edit_command(self, run: bool = False) -> None:
diff --git a/qutebrowser/mainwindow/statusbar/url.py b/qutebrowser/mainwindow/statusbar/url.py
index b48f0005f..c8300dc97 100644
--- a/qutebrowser/mainwindow/statusbar/url.py
+++ b/qutebrowser/mainwindow/statusbar/url.py
@@ -21,7 +21,8 @@
import enum
-from PyQt5.QtCore import pyqtSlot, pyqtProperty, QUrl
+from PyQt5.QtCore import (pyqtSlot, pyqtProperty, # type: ignore[attr-defined]
+ QUrl)
from qutebrowser.mainwindow.statusbar import textbase
from qutebrowser.config import stylesheet
diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py
index f5dc3277b..25b05a036 100644
--- a/qutebrowser/mainwindow/tabbedbrowser.py
+++ b/qutebrowser/mainwindow/tabbedbrowser.py
@@ -97,7 +97,7 @@ class TabDeque:
self._ignore_next = True
return tab
- def next(self, cur_tab: QWidget, *, keep_overflow=True) -> QWidget:
+ def next(self, cur_tab: QWidget, *, keep_overflow: bool = True) -> QWidget:
"""Get the 'next' tab in the stack.
Throws IndexError on failure.
@@ -189,7 +189,7 @@ class TabbedBrowser(QWidget):
cur_scroll_perc_changed = pyqtSignal(int, int)
cur_load_status_changed = pyqtSignal(usertypes.LoadStatus)
cur_fullscreen_requested = pyqtSignal(bool)
- cur_caret_selection_toggled = pyqtSignal(bool)
+ cur_caret_selection_toggled = pyqtSignal(browsertab.SelectionState)
close_window = pyqtSignal()
resized = pyqtSignal('QRect')
current_tab_changed = pyqtSignal(browsertab.AbstractTab)
@@ -204,11 +204,10 @@ class TabbedBrowser(QWidget):
self._tab_insert_idx_left = 0
self._tab_insert_idx_right = -1
self.shutting_down = False
- self.widget.tabCloseRequested.connect( # type: ignore
- self.on_tab_close_requested)
- self.widget.new_tab_requested.connect(self.tabopen)
- self.widget.currentChanged.connect( # type: ignore
- self._on_current_changed)
+ self.widget.tabCloseRequested.connect(self.on_tab_close_requested)
+ self.widget.new_tab_requested.connect(
+ self.tabopen) # type: ignore[arg-type]
+ self.widget.currentChanged.connect(self._on_current_changed)
self.cur_fullscreen_requested.connect(self.widget.tabBar().maybe_hide)
self.widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
@@ -286,7 +285,7 @@ class TabbedBrowser(QWidget):
for i in range(self.widget.count()):
widget = self.widget.widget(i)
if widget is None:
- log.webview.debug( # type: ignore
+ log.webview.debug( # type: ignore[unreachable]
"Got None-widget in tabbedbrowser!")
else:
widgets.append(widget)
@@ -506,10 +505,7 @@ class TabbedBrowser(QWidget):
newtab = self.widget.widget(0)
use_current_tab = False
else:
- # FIXME:typing mypy thinks this is None due to @pyqtSlot
- newtab = typing.cast(
- browsertab.AbstractTab,
- self.tabopen(background=False, idx=entry.index))
+ newtab = self.tabopen(background=False, idx=entry.index)
newtab.history.private_api.deserialize(entry.history)
self.widget.set_tab_pinned(newtab, entry.pinned)
@@ -533,7 +529,7 @@ class TabbedBrowser(QWidget):
"""Close a tab via an index."""
tab = self.widget.widget(idx)
if tab is None:
- log.webview.debug( # type: ignore
+ log.webview.debug( # type: ignore[unreachable]
"Got invalid tab {} for index {}!".format(tab, idx))
return
self.tab_close_prompt_if_pinned(
@@ -805,7 +801,7 @@ class TabbedBrowser(QWidget):
"""Give focus to current tab if command mode was left."""
widget = self.widget.currentWidget()
if widget is None:
- return # type: ignore
+ return # type: ignore[unreachable]
if mode in [usertypes.KeyMode.command] + modeman.PROMPT_MODES:
log.modes.debug("Left status-input mode, focusing {!r}".format(
widget))
@@ -822,7 +818,7 @@ class TabbedBrowser(QWidget):
return
tab = self.widget.widget(idx)
if tab is None:
- log.webview.debug( # type: ignore
+ log.webview.debug( # type: ignore[unreachable]
"on_current_changed got called with invalid index {}"
.format(idx))
return
diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py
index ca4014b28..558713fdf 100644
--- a/qutebrowser/mainwindow/tabwidget.py
+++ b/qutebrowser/mainwindow/tabwidget.py
@@ -60,10 +60,11 @@ class TabWidget(QTabWidget):
bar = TabBar(win_id, self)
self.setStyle(TabBarStyle())
self.setTabBar(bar)
- bar.tabCloseRequested.connect(self.tabCloseRequested) # type: ignore
- bar.tabMoved.connect(functools.partial( # type: ignore
+ bar.tabCloseRequested.connect(
+ self.tabCloseRequested) # type: ignore[arg-type]
+ bar.tabMoved.connect(functools.partial(
QTimer.singleShot, 0, self.update_tab_titles))
- bar.currentChanged.connect(self._on_current_changed) # type: ignore
+ bar.currentChanged.connect(self._on_current_changed)
bar.new_tab_requested.connect(self._on_new_tab_requested)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.setDocumentMode(True)
@@ -82,7 +83,8 @@ class TabWidget(QTabWidget):
position = config.val.tabs.position
selection_behavior = config.val.tabs.select_on_remove
self.setTabPosition(position)
- tabbar.vertical = position in [QTabWidget.West, QTabWidget.East]
+ tabbar.vertical = position in [ # type: ignore[attr-defined]
+ QTabWidget.West, QTabWidget.East]
tabbar.setSelectionBehaviorOnRemove(selection_behavior)
tabbar.refresh()
@@ -163,7 +165,7 @@ class TabWidget(QTabWidget):
"""Get the tab field data."""
tab = self.widget(idx)
if tab is None:
- log.misc.debug( # type: ignore
+ log.misc.debug( # type: ignore[unreachable]
"Got None-tab in get_tab_fields!")
page_title = self.page_title(idx)
@@ -330,7 +332,7 @@ class TabWidget(QTabWidget):
"""
tab = self.widget(idx)
if tab is None:
- url = QUrl() # type: ignore
+ url = QUrl() # type: ignore[unreachable]
else:
url = tab.url()
# It's possible for url to be invalid, but the caller will handle that.
@@ -350,7 +352,7 @@ class TabWidget(QTabWidget):
if config.val.tabs.tabs_are_windows:
self.window().setWindowIcon(self.window().windowIcon())
- def setTabIcon(self, idx: int, icon: QIcon):
+ def setTabIcon(self, idx: int, icon: QIcon) -> None:
"""Always show tab icons for pinned tabs in some circumstances."""
tab = typing.cast(typing.Optional[browsertab.AbstractTab],
self.widget(idx))
@@ -544,7 +546,7 @@ class TabBar(QTabBar):
idx = self.currentIndex()
elif action == 'close-last':
idx = self.count() - 1
- self.tabCloseRequested.emit(idx) # type: ignore
+ self.tabCloseRequested.emit(idx)
return
super().mousePressEvent(e)
diff --git a/qutebrowser/misc/autoupdate.py b/qutebrowser/misc/autoupdate.py
index e51ecfb19..4838d55ed 100644
--- a/qutebrowser/misc/autoupdate.py
+++ b/qutebrowser/misc/autoupdate.py
@@ -55,7 +55,7 @@ class PyPIVersionClient(QObject):
self._client = httpclient.HTTPClient(self)
else:
self._client = client
- self._client.error.connect(self.error) # type: ignore
+ self._client.error.connect(self.error) # type: ignore[arg-type]
self._client.success.connect(self.on_client_success)
def get_version(self, package='qutebrowser'):
diff --git a/qutebrowser/misc/backendproblem.py b/qutebrowser/misc/backendproblem.py
index 6aab87ea6..2ed273547 100644
--- a/qutebrowser/misc/backendproblem.py
+++ b/qutebrowser/misc/backendproblem.py
@@ -353,14 +353,23 @@ class _BackendProblemChecker:
If "fatal" is given, show an error and exit.
"""
- text = ("Could not initialize QtNetwork SSL support. If you use "
- "OpenSSL 1.1 with a PyQt package from PyPI (e.g. on Archlinux "
- "or Debian Stretch), you need to set LD_LIBRARY_PATH to the "
- "path of OpenSSL 1.0. This only affects downloads.")
-
if QSslSocket.supportsSsl():
return
+ if qtutils.version_check('5.12.4'):
+ version_text = ("If you use OpenSSL 1.0 with a PyQt package from "
+ "PyPI (e.g. on Ubuntu 16.04), you will need to "
+ "build OpenSSL 1.1 from sources and set "
+ "LD_LIBRARY_PATH accordingly.")
+ else:
+ version_text = ("If you use OpenSSL 1.1 with a PyQt package from "
+ "PyPI (e.g. on Archlinux or Debian Stretch), you "
+ "need to set LD_LIBRARY_PATH to the path of "
+ "OpenSSL 1.0 or use Qt >= 5.12.4.")
+
+ text = ("Could not initialize QtNetwork SSL support. {} This only "
+ "affects downloads and :adblock-update.".format(version_text))
+
if fatal:
errbox = msgbox.msgbox(parent=None,
title="SSL error",
diff --git a/qutebrowser/misc/checkpyver.py b/qutebrowser/misc/checkpyver.py
index d3829a0bf..8283dd13e 100644
--- a/qutebrowser/misc/checkpyver.py
+++ b/qutebrowser/misc/checkpyver.py
@@ -30,12 +30,12 @@ try:
except ImportError: # pragma: no cover
try:
# Python2
- from Tkinter import Tk # type: ignore
+ from Tkinter import Tk # type: ignore[import, no-redef]
import tkMessageBox as messagebox # type: ignore # noqa: N813
except ImportError:
# Some Python without Tk
- Tk = None # type: ignore
- messagebox = None # type: ignore
+ Tk = None # type: ignore[misc, assignment]
+ messagebox = None # type: ignore[assignment]
# First we check the version of Python. This code should run fine with python2
@@ -49,7 +49,7 @@ def check_python_version():
version_str = '.'.join(map(str, sys.version_info[:3]))
text = ("At least Python 3.5.2 is required to run qutebrowser, but " +
"it's running with " + version_str + ".\n")
- if (Tk and # type: ignore
+ if (Tk and # type: ignore[unreachable]
'--no-err-windows' not in sys.argv): # pragma: no cover
root = Tk()
root.withdraw()
diff --git a/qutebrowser/misc/crashdialog.py b/qutebrowser/misc/crashdialog.py
index f80004a92..6bd6ec325 100644
--- a/qutebrowser/misc/crashdialog.py
+++ b/qutebrowser/misc/crashdialog.py
@@ -345,7 +345,7 @@ class _CrashDialog(QDialog):
text: The paste text to show.
"""
error_dlg = ReportErrorDialog(text, self._paste_text, self)
- error_dlg.finished.connect(self.finish) # type: ignore
+ error_dlg.finished.connect(self.finish)
error_dlg.show()
@pyqtSlot(str)
@@ -532,7 +532,7 @@ class FatalCrashDialog(_CrashDialog):
if self._chk_history.isChecked():
try:
if history.web_history is None:
- history_data = '<unavailable>' # type: ignore
+ history_data = '<unavailable>' # type: ignore[unreachable]
else:
history_data = '\n'.join(str(e) for e in
history.web_history.get_recent())
@@ -629,7 +629,7 @@ class ReportErrorDialog(QDialog):
hbox = QHBoxLayout()
hbox.addStretch()
btn = QPushButton("Close")
- btn.clicked.connect(self.close) # type: ignore
+ btn.clicked.connect(self.close) # type: ignore[arg-type]
hbox.addWidget(btn)
vbox.addLayout(hbox)
diff --git a/qutebrowser/misc/crashsignal.py b/qutebrowser/misc/crashsignal.py
index 20e805c24..5d8bd0ff5 100644
--- a/qutebrowser/misc/crashsignal.py
+++ b/qutebrowser/misc/crashsignal.py
@@ -27,6 +27,7 @@ import pdb # noqa: T002
import signal
import argparse
import functools
+import threading
import faulthandler
import typing
try:
@@ -43,6 +44,7 @@ from PyQt5.QtWidgets import QApplication
from qutebrowser.api import cmdutils
from qutebrowser.misc import earlyinit, crashdialog, ipc, objects
from qutebrowser.utils import usertypes, standarddir, log, objreg, debug, utils
+from qutebrowser.qt import sip
if typing.TYPE_CHECKING:
from qutebrowser.misc import quitter
@@ -183,7 +185,7 @@ class CrashHandler(QObject):
if sys.__stderr__ is not None:
faulthandler.enable(sys.__stderr__)
else:
- faulthandler.disable() # type: ignore
+ faulthandler.disable() # type: ignore[unreachable]
try:
self._crash_log_file.close()
os.remove(self._crash_log_file.name)
@@ -215,18 +217,19 @@ class CrashHandler(QObject):
all_objects = ""
return ExceptionInfo(pages, cmd_history, all_objects)
- def exception_hook(self, exctype, excvalue, tb):
- """Handle uncaught python exceptions.
+ def _handle_early_exits(self, exc):
+ """Handle some special cases for the exception hook.
- It'll try very hard to write all open tabs to a file, and then exit
- gracefully.
+ Return value:
+ True: Exception hook should be aborted.
+ False: Continue handling exception.
"""
- exc = (exctype, excvalue, tb)
+ exctype, _excvalue, tb = exc
if not self._quitter.quit_status['crash']:
log.misc.error("ARGH, there was an exception while the crash "
"dialog is already shown:", exc_info=exc)
- return
+ return True
log.misc.error("Uncaught exception", exc_info=exc)
@@ -243,6 +246,24 @@ class CrashHandler(QObject):
# pdb exit, KeyboardInterrupt, ...
sys.exit(usertypes.Exit.exception)
+ if threading.current_thread() != threading.main_thread():
+ log.misc.error("Ignoring exception outside of main thread... "
+ "Please report this as a bug.")
+ return True
+
+ return False
+
+ def exception_hook(self, exctype, excvalue, tb):
+ """Handle uncaught python exceptions.
+
+ It'll try very hard to write all open tabs to a file, and then exit
+ gracefully.
+ """
+ exc = (exctype, excvalue, tb)
+
+ if self._handle_early_exits(exc):
+ return
+
self._quitter.quit_status['crash'] = False
info = self._get_exception_info()
@@ -331,9 +352,10 @@ class SignalHandler(QObject):
for fd in [read_fd, write_fd]:
flags = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
- self._notifier = QSocketNotifier(read_fd, QSocketNotifier.Read,
+ self._notifier = QSocketNotifier(typing.cast(sip.voidptr, read_fd),
+ QSocketNotifier.Read,
self)
- self._notifier.activated.connect( # type: ignore
+ self._notifier.activated.connect( # type: ignore[attr-defined]
self.handle_signal_wakeup)
self._orig_wakeup_fd = signal.set_wakeup_fd(write_fd)
# pylint: enable=import-error,no-member,useless-suppression
diff --git a/qutebrowser/misc/earlyinit.py b/qutebrowser/misc/earlyinit.py
index 99ddd3701..c02b2f03c 100644
--- a/qutebrowser/misc/earlyinit.py
+++ b/qutebrowser/misc/earlyinit.py
@@ -38,7 +38,7 @@ import datetime
try:
import tkinter
except ImportError:
- tkinter = None # type: ignore
+ tkinter = None # type: ignore[assignment]
# NOTE: No qutebrowser or PyQt import should be done here, as some early
# initialization needs to take place before that!
@@ -251,7 +251,8 @@ def configure_pyqt():
from PyQt5 import QtCore
QtCore.pyqtRemoveInputHook()
try:
- QtCore.pyqt5_enable_new_onexit_scheme(True) # type: ignore
+ QtCore.pyqt5_enable_new_onexit_scheme( # type: ignore[attr-defined]
+ True)
except AttributeError:
# Added in PyQt 5.13 somewhere, going to be the default in 5.14
pass
@@ -259,7 +260,7 @@ def configure_pyqt():
from qutebrowser.qt import sip
try:
# Added in sip 4.19.4
- sip.enableoverflowchecking(True) # type: ignore
+ sip.enableoverflowchecking(True) # type: ignore[attr-defined]
except AttributeError:
pass
diff --git a/qutebrowser/misc/editor.py b/qutebrowser/misc/editor.py
index 1dcc3a532..5ef451e4e 100644
--- a/qutebrowser/misc/editor.py
+++ b/qutebrowser/misc/editor.py
@@ -187,7 +187,7 @@ class ExternalEditor(QObject):
if not ok:
log.procs.error("Failed to watch path: {}"
.format(self._filename))
- self._watcher.fileChanged.connect( # type: ignore
+ self._watcher.fileChanged.connect( # type: ignore[attr-defined]
self._on_file_changed)
args = [self._sub_placeholder(arg, line, column) for arg in editor[1:]]
diff --git a/qutebrowser/misc/guiprocess.py b/qutebrowser/misc/guiprocess.py
index 7fc598191..3702715c4 100644
--- a/qutebrowser/misc/guiprocess.py
+++ b/qutebrowser/misc/guiprocess.py
@@ -62,12 +62,12 @@ class GUIProcess(QObject):
self.args = None
self._proc = QProcess(self)
- self._proc.errorOccurred.connect(self._on_error) # type: ignore
- self._proc.errorOccurred.connect(self.error) # type: ignore
- self._proc.finished.connect(self._on_finished) # type: ignore
- self._proc.finished.connect(self.finished) # type: ignore
- self._proc.started.connect(self._on_started) # type: ignore
- self._proc.started.connect(self.started) # type: ignore
+ self._proc.errorOccurred.connect(self._on_error)
+ self._proc.errorOccurred.connect(self.error) # type: ignore[arg-type]
+ self._proc.finished.connect(self._on_finished)
+ self._proc.finished.connect(self.finished) # type: ignore[arg-type]
+ self._proc.started.connect(self._on_started)
+ self._proc.started.connect(self.started) # type: ignore[arg-type]
if additional_env is not None:
procenv = QProcessEnvironment.systemEnvironment()
@@ -89,9 +89,9 @@ class GUIProcess(QObject):
code, status))
encoding = locale.getpreferredencoding(do_setlocale=False)
- stderr = bytes(self._proc.readAllStandardError()).decode(
+ stderr = self._proc.readAllStandardError().data().decode(
encoding, 'replace')
- stdout = bytes(self._proc.readAllStandardOutput()).decode(
+ stdout = self._proc.readAllStandardOutput().data().decode(
encoding, 'replace')
if self._output_messages:
@@ -163,7 +163,8 @@ class GUIProcess(QObject):
"""Convenience wrapper around QProcess::startDetached."""
log.procs.debug("Starting detached.")
self._pre_start(cmd, args)
- ok, _pid = self._proc.startDetached(cmd, args, None) # type: ignore
+ ok, _pid = self._proc.startDetached(
+ cmd, args, None) # type: ignore[call-arg]
if not ok:
message.error("Error while spawning {}".format(self._what))
diff --git a/qutebrowser/misc/ipc.py b/qutebrowser/misc/ipc.py
index ad1d3eb56..2cceb2df1 100644
--- a/qutebrowser/misc/ipc.py
+++ b/qutebrowser/misc/ipc.py
@@ -178,7 +178,7 @@ class IPCServer(QObject):
self._atime_timer.setTimerType(Qt.VeryCoarseTimer)
self._server = QLocalServer(self)
- self._server.newConnection.connect( # type: ignore
+ self._server.newConnection.connect( # type: ignore[attr-defined]
self.handle_connection)
self._socket = None
@@ -252,21 +252,24 @@ class IPCServer(QObject):
return
socket = self._server.nextPendingConnection()
if socket is None:
- log.ipc.debug("No new connection to handle.") # type: ignore
+ log.ipc.debug( # type: ignore[unreachable]
+ "No new connection to handle.")
return
log.ipc.debug("Client connected (socket 0x{:x}).".format(id(socket)))
self._timer.start()
self._socket = socket
- socket.readyRead.connect(self.on_ready_read) # type: ignore
+ socket.readyRead.connect( # type: ignore[attr-defined]
+ self.on_ready_read)
if socket.canReadLine():
log.ipc.debug("We can read a line immediately.")
self.on_ready_read()
- socket.error.connect(self.on_error) # type: ignore
+ socket.error.connect(self.on_error) # type: ignore[attr-defined]
if socket.error() not in [QLocalSocket.UnknownSocketError,
QLocalSocket.PeerClosedError]:
log.ipc.debug("We got an error immediately.")
self.on_error(socket.error())
- socket.disconnected.connect(self.on_disconnected) # type: ignore
+ socket.disconnected.connect( # type: ignore[attr-defined]
+ self.on_disconnected)
if socket.state() == QLocalSocket.UnconnectedState:
log.ipc.debug("Socket was disconnected immediately.")
self.on_disconnected()
diff --git a/qutebrowser/misc/miscwidgets.py b/qutebrowser/misc/miscwidgets.py
index 69bce56f5..2d72af780 100644
--- a/qutebrowser/misc/miscwidgets.py
+++ b/qutebrowser/misc/miscwidgets.py
@@ -29,6 +29,7 @@ from PyQt5.QtGui import QValidator, QPainter
from qutebrowser.config import config
from qutebrowser.utils import utils
from qutebrowser.misc import cmdhistory
+from qutebrowser.keyinput import keyutils
class MinimalLineEditMixin:
@@ -36,7 +37,7 @@ class MinimalLineEditMixin:
"""A mixin to give a QLineEdit a minimal look and nicer repr()."""
def __init__(self):
- self.setStyleSheet( # type: ignore
+ self.setStyleSheet( # type: ignore[attr-defined]
"""
QLineEdit {
border: 0px;
@@ -45,7 +46,8 @@ class MinimalLineEditMixin:
}
"""
)
- self.setAttribute(Qt.WA_MacShowFocusRect, False) # type: ignore
+ self.setAttribute( # type: ignore[attr-defined]
+ Qt.WA_MacShowFocusRect, False)
def keyPressEvent(self, e):
"""Override keyPressEvent to paste primary selection on Shift + Ins."""
@@ -56,9 +58,9 @@ class MinimalLineEditMixin:
e.ignore()
else:
e.accept()
- self.insert(text) # type: ignore
+ self.insert(text) # type: ignore[attr-defined]
return
- super().keyPressEvent(e) # type: ignore
+ super().keyPressEvent(e) # type: ignore[misc]
def __repr__(self):
return utils.get_repr(self)
@@ -259,7 +261,7 @@ class WrapperLayout(QLayout):
widget.setParent(container)
def unwrap(self):
- self._widget.setParent(None) # type: ignore
+ self._widget.setParent(None) # type: ignore[call-overload]
self._widget.deleteLater()
@@ -326,7 +328,7 @@ class FullscreenNotification(QLabel):
self.setText("Page is now fullscreen.")
self.resize(self.sizeHint())
- if config.val.content.windowed_fullscreen:
+ if config.val.content.fullscreen.window:
geom = self.parentWidget().geometry()
else:
geom = QApplication.desktop().screenGeometry(self)
@@ -341,3 +343,26 @@ class FullscreenNotification(QLabel):
"""Hide and delete the widget."""
self.hide()
self.deleteLater()
+
+
+class KeyTesterWidget(QWidget):
+
+ """Widget displaying key presses."""
+
+ def __init__(self, parent=None):
+ super().__init__(parent)
+ self.setAttribute(Qt.WA_DeleteOnClose)
+ self._layout = QHBoxLayout(self)
+ self._label = QLabel(text="Waiting for keypress...")
+ self._layout.addWidget(self._label)
+
+ def keyPressEvent(self, e):
+ """Show pressed keys."""
+ lines = [
+ str(keyutils.KeyInfo.from_event(e)),
+ '',
+ 'key: 0x{:x}'.format(int(e.key())),
+ 'modifiers: 0x{:x}'.format(int(e.modifiers())),
+ 'text: {!r}'.format(e.text()),
+ ]
+ self._label.setText('\n'.join(lines))
diff --git a/qutebrowser/misc/msgbox.py b/qutebrowser/misc/msgbox.py
index 89ade19e6..f06eccd92 100644
--- a/qutebrowser/misc/msgbox.py
+++ b/qutebrowser/misc/msgbox.py
@@ -60,7 +60,7 @@ def msgbox(parent, title, text, *, icon, buttons=QMessageBox.Ok,
box.setIcon(icon)
box.setStandardButtons(buttons)
if on_finished is not None:
- box.finished.connect(on_finished) # type: ignore
+ box.finished.connect(on_finished)
if plain_text:
box.setTextFormat(Qt.PlainText)
elif plain_text is not None:
diff --git a/qutebrowser/misc/sessions.py b/qutebrowser/misc/sessions.py
index 1bcd42baf..52a66b1a0 100644
--- a/qutebrowser/misc/sessions.py
+++ b/qutebrowser/misc/sessions.py
@@ -24,6 +24,8 @@ import os.path
import itertools
import urllib
import typing
+import glob
+import shutil
from PyQt5.QtCore import QUrl, QObject, QPoint, QTimer, pyqtSlot
from PyQt5.QtWidgets import QApplication
@@ -59,6 +61,16 @@ def init(parent=None):
parent: The parent to use for the SessionManager.
"""
base_path = os.path.join(standarddir.data(), 'sessions')
+
+ # WORKAROUND for https://github.com/qutebrowser/qutebrowser/issues/5359
+ backup_path = os.path.join(base_path, 'before-qt-515')
+ if (os.path.exists(base_path) and
+ not os.path.exists(backup_path) and
+ qtutils.version_check('5.15', compiled=False)):
+ os.mkdir(backup_path)
+ for filename in glob.glob(os.path.join(base_path, '*.yml')):
+ shutil.copy(filename, backup_path)
+
try:
os.mkdir(base_path)
except FileExistsError:
@@ -311,10 +323,11 @@ class SessionManager(QObject):
else:
data = self._save_all(only_window=only_window,
with_private=with_private)
- log.sessions.vdebug("Saving data: {}".format(data)) # type: ignore
+ log.sessions.vdebug( # type: ignore[attr-defined]
+ "Saving data: {}".format(data))
try:
with qtutils.savefile_open(path) as f:
- utils.yaml_dump(data, f) # type: ignore
+ utils.yaml_dump(data, f)
except (OSError, UnicodeEncodeError, yaml.YAMLError) as e:
raise SessionError(e)
@@ -574,7 +587,7 @@ def session_save(name: ArgType = default, *,
@cmdutils.register()
@cmdutils.argument('name', completion=miscmodels.session)
-def session_delete(name, *, force: bool = False) -> None:
+def session_delete(name: str, *, force: bool = False) -> None:
"""Delete a session.
Args:
diff --git a/qutebrowser/misc/split.py b/qutebrowser/misc/split.py
index dc46a28d7..b08d34cae 100644
--- a/qutebrowser/misc/split.py
+++ b/qutebrowser/misc/split.py
@@ -138,7 +138,8 @@ def split(s, keep=False):
out = []
spaces = ""
- log.shlexer.vdebug("{!r} -> {!r}".format(s, tokens)) # type: ignore
+ log.shlexer.vdebug( # type: ignore[attr-defined]
+ "{!r} -> {!r}".format(s, tokens))
for t in tokens:
if t.isspace():
diff --git a/qutebrowser/misc/sql.py b/qutebrowser/misc/sql.py
index 39208819d..8f9265419 100644
--- a/qutebrowser/misc/sql.py
+++ b/qutebrowser/misc/sql.py
@@ -190,7 +190,8 @@ class Query:
raise BugError("Cannot iterate inactive query")
rec = self.query.record()
fields = [rec.fieldName(i) for i in range(rec.count())]
- rowtype = collections.namedtuple('ResultRow', fields) # type: ignore
+ rowtype = collections.namedtuple( # type: ignore[misc]
+ 'ResultRow', fields)
while self.query.next():
rec = self.query.record()
diff --git a/qutebrowser/misc/utilcmds.py b/qutebrowser/misc/utilcmds.py
index 328e77531..fa8b97628 100644
--- a/qutebrowser/misc/utilcmds.py
+++ b/qutebrowser/misc/utilcmds.py
@@ -24,6 +24,7 @@
import functools
import os
import traceback
+import typing
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication
@@ -34,7 +35,7 @@ from qutebrowser.keyinput import modeman
from qutebrowser.commands import runners
from qutebrowser.api import cmdutils
from qutebrowser.misc import ( # pylint: disable=unused-import
- consolewidget, debugcachestats, objects)
+ consolewidget, debugcachestats, objects, miscwidgets)
from qutebrowser.utils.version import pastebin_version
from qutebrowser.qt import sip
@@ -293,3 +294,17 @@ def version(win_id: int, paste: bool = False) -> None:
if paste:
pastebin_version()
+
+
+_keytester_widget = None # type: typing.Optional[miscwidgets.KeyTesterWidget]
+
+
+@cmdutils.register(debug=True)
+def debug_keytester() -> None:
+ """Show a keytester widget."""
+ global _keytester_widget
+ if _keytester_widget and _keytester_widget.isVisible():
+ _keytester_widget.close()
+ else:
+ _keytester_widget = miscwidgets.KeyTesterWidget()
+ _keytester_widget.show()
diff --git a/qutebrowser/qt.py b/qutebrowser/qt.py
index cc6197982..5b44530bb 100644
--- a/qutebrowser/qt.py
+++ b/qutebrowser/qt.py
@@ -25,4 +25,4 @@
try:
from PyQt5 import sip
except ImportError:
- import sip # type: ignore
+ import sip # type: ignore[import, no-redef]
diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py
index 129e8f745..0ffdb5567 100644
--- a/qutebrowser/qutebrowser.py
+++ b/qutebrowser/qutebrowser.py
@@ -167,14 +167,16 @@ def debug_flag_error(flag):
no-sql-history: Don't store history items.
no-scroll-filtering: Process all scrolling updates.
log-requests: Log all network requests.
+ log-cookies: Log cookies in cookie filter.
log-scroll-pos: Log all scrolling changes.
stack: Enable Chromium stack logging.
chromium: Enable Chromium logging.
werror: Turn Python warnings into errors.
"""
valid_flags = ['debug-exit', 'pdb-postmortem', 'no-sql-history',
- 'no-scroll-filtering', 'log-requests', 'lost-focusproxy',
- 'log-scroll-pos', 'stack', 'chromium', 'werror']
+ 'no-scroll-filtering', 'log-requests', 'log-cookies',
+ 'lost-focusproxy', 'log-scroll-pos', 'stack', 'chromium',
+ 'werror']
if flag in valid_flags:
return flag
diff --git a/qutebrowser/utils/debug.py b/qutebrowser/utils/debug.py
index 395f41a1b..66cfeed9e 100644
--- a/qutebrowser/utils/debug.py
+++ b/qutebrowser/utils/debug.py
@@ -31,6 +31,7 @@ from PyQt5.QtCore import Qt, QEvent, QMetaMethod, QObject, pyqtSignal
from PyQt5.QtWidgets import QApplication
from qutebrowser.utils import log, utils, qtutils, objreg
+from qutebrowser.qt import sip
def log_events(klass: typing.Type) -> typing.Type:
@@ -69,7 +70,7 @@ def log_signals(obj: QObject) -> QObject:
meta_method = metaobj.method(i)
qtutils.ensure_valid(meta_method)
if meta_method.methodType() == QMetaMethod.Signal:
- name = bytes(meta_method.name()).decode('ascii')
+ name = meta_method.name().data().decode('ascii')
if name != 'destroyed':
signal = getattr(obj, name)
try:
@@ -79,7 +80,7 @@ def log_signals(obj: QObject) -> QObject:
pass
if inspect.isclass(obj):
- old_init = obj.__init__ # type: ignore
+ old_init = obj.__init__ # type: ignore[misc]
@functools.wraps(old_init)
def new_init(self: typing.Any,
@@ -89,7 +90,7 @@ def log_signals(obj: QObject) -> QObject:
old_init(self, *args, **kwargs)
connect_log_slot(self)
- obj.__init__ = new_init # type: ignore
+ obj.__init__ = new_init # type: ignore[misc]
else:
connect_log_slot(obj)
@@ -97,7 +98,7 @@ def log_signals(obj: QObject) -> QObject:
def qenum_key(base: typing.Type,
- value: int,
+ value: typing.Union[int, sip.simplewrapper],
add_base: bool = False,
klass: typing.Type = None) -> str:
"""Convert a Qt Enum value to its key as a string.
@@ -121,7 +122,7 @@ def qenum_key(base: typing.Type,
try:
idx = base.staticMetaObject.indexOfEnumerator(klass.__name__)
meta_enum = base.staticMetaObject.enumerator(idx)
- ret = meta_enum.valueToKey(int(value))
+ ret = meta_enum.valueToKey(int(value)) # type: ignore[arg-type]
except AttributeError:
ret = None
@@ -131,7 +132,7 @@ def qenum_key(base: typing.Type,
ret = name
break
else:
- ret = '0x{:04x}'.format(int(value))
+ ret = '0x{:04x}'.format(int(value)) # type: ignore[arg-type]
if add_base and hasattr(base, '__name__'):
return '.'.join([base.__name__, ret])
@@ -140,7 +141,7 @@ def qenum_key(base: typing.Type,
def qflags_key(base: typing.Type,
- value: int,
+ value: typing.Union[int, sip.simplewrapper],
add_base: bool = False,
klass: typing.Type = None) -> str:
"""Convert a Qt QFlags value to its keys as string.
@@ -174,7 +175,7 @@ def qflags_key(base: typing.Type,
bits = []
names = []
mask = 0x01
- value = int(value)
+ value = int(value) # type: ignore[arg-type]
while mask <= value:
if value & mask:
bits.append(mask)
@@ -182,7 +183,8 @@ def qflags_key(base: typing.Type,
for bit in bits:
# We have to re-convert to an enum type here or we'll sometimes get an
# empty string back.
- names.append(qenum_key(base, klass(bit), add_base))
+ enum_value = klass(bit) # type: ignore[call-arg]
+ names.append(qenum_key(base, enum_value, add_base))
return '|'.join(names)
@@ -208,14 +210,14 @@ def signal_name(sig: pyqtSignal) -> str:
# sig.signal == '2signal1'
# sig.signal == '2signal2(QString,QString)'
m = re.fullmatch(r'[0-9]+(?P<name>.*)\(.*\)',
- sig.signal) # type: ignore
+ sig.signal) # type: ignore[attr-defined]
elif hasattr(sig, 'signatures'):
# Unbound signal, PyQt >= 5.11
# Examples:
# sig.signatures == ('signal1()',)
# sig.signatures == ('signal2(QString,QString)',)
m = re.fullmatch(r'(?P<name>.*)\(.*\)',
- sig.signatures[0]) # type: ignore
+ sig.signatures[0]) # type: ignore[attr-defined]
else: # pragma: no cover
# Unbound signal, PyQt < 5.11
# Examples:
diff --git a/qutebrowser/utils/error.py b/qutebrowser/utils/error.py
index cfc3c3f5a..4cba06a10 100644
--- a/qutebrowser/utils/error.py
+++ b/qutebrowser/utils/error.py
@@ -63,6 +63,7 @@ def handle_fatal_exc(exc: BaseException,
]
log.misc.exception('\n'.join(lines))
else:
+ log.misc.exception("Fatal exception:")
if pre_text:
msg_text = '{}: {}'.format(pre_text, exc)
else:
diff --git a/qutebrowser/utils/jinja.py b/qutebrowser/utils/jinja.py
index a7bb1f686..78663645d 100644
--- a/qutebrowser/utils/jinja.py
+++ b/qutebrowser/utils/jinja.py
@@ -112,7 +112,7 @@ class Environment(jinja2.Environment):
"""
image = utils.resource_filename(path)
url = QUrl.fromLocalFile(image)
- urlstr = url.toString(QUrl.FullyEncoded) # type: ignore
+ urlstr = url.toString(QUrl.FullyEncoded) # type: ignore[arg-type]
return urlstr
def _data_url(self, path: str) -> str:
@@ -156,11 +156,11 @@ def template_config_variables(template: str) -> typing.FrozenSet[str]:
# For example it's ['ab', 'c', 'd'] for 'conf.d.c.ab'.
attrlist = [] # type: typing.List[str]
while isinstance(node, jinja2.nodes.Getattr):
- attrlist.append(node.attr) # type: ignore
- node = node.node # type: ignore
+ attrlist.append(node.attr) # type: ignore[attr-defined]
+ node = node.node # type: ignore[attr-defined]
if isinstance(node, jinja2.nodes.Name):
- if node.name == 'conf': # type: ignore
+ if node.name == 'conf': # type: ignore[attr-defined]
result.add('.'.join(reversed(attrlist)))
# otherwise, the node is a Name node so it doesn't have any
# child nodes
diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py
index 30a399773..2718f10ba 100644
--- a/qutebrowser/utils/log.py
+++ b/qutebrowser/utils/log.py
@@ -81,10 +81,10 @@ LOG_COLORS = {
# mypy doesn't know about this, so we need to ignore it.
VDEBUG_LEVEL = 9
logging.addLevelName(VDEBUG_LEVEL, 'VDEBUG')
-logging.VDEBUG = VDEBUG_LEVEL # type: ignore
+logging.VDEBUG = VDEBUG_LEVEL # type: ignore[attr-defined]
LOG_LEVELS = {
- 'VDEBUG': logging.VDEBUG, # type: ignore
+ 'VDEBUG': logging.VDEBUG, # type: ignore[attr-defined]
'DEBUG': logging.DEBUG,
'INFO': logging.INFO,
'WARNING': logging.WARNING,
@@ -105,11 +105,11 @@ def vdebug(self: logging.Logger,
"""
if self.isEnabledFor(VDEBUG_LEVEL):
# pylint: disable=protected-access
- self._log(VDEBUG_LEVEL, msg, args, **kwargs) # type: ignore
+ self._log(VDEBUG_LEVEL, msg, args, **kwargs)
# pylint: enable=protected-access
-logging.Logger.vdebug = vdebug # type: ignore
+logging.Logger.vdebug = vdebug # type: ignore[attr-defined]
# The different loggers used.
@@ -216,7 +216,7 @@ def init_log(args: argparse.Namespace) -> None:
root.setLevel(logging.NOTSET)
logging.captureWarnings(True)
_init_py_warnings()
- QtCore.qInstallMessageHandler(qt_message_handler) # type: ignore
+ QtCore.qInstallMessageHandler(qt_message_handler)
_log_inited = True
@@ -278,7 +278,7 @@ def _init_handlers(
level, color, force_color, json_logging)
if sys.stderr is None:
- console_handler = None # type: ignore
+ console_handler = None # type: ignore[unreachable]
else:
strip = False if force_color else None
if use_colorama:
@@ -337,14 +337,17 @@ def _init_formatters(
use_colors=False)
html_formatter = HTMLFormatter(EXTENDED_FMT_HTML, DATEFMT,
log_colors=LOG_COLORS)
+
+ use_colorama = False
+
if sys.stderr is None:
- return None, ram_formatter, html_formatter, False # type: ignore
+ console_formatter = None # type: ignore[unreachable]
+ return console_formatter, ram_formatter, html_formatter, use_colorama
if json_logging:
json_formatter = JSONFormatter()
- return json_formatter, ram_formatter, html_formatter, False
+ return json_formatter, ram_formatter, html_formatter, use_colorama
- use_colorama = False
color_supported = os.name == 'posix' or colorama
if color_supported and (sys.stderr.isatty() or force_color) and color:
@@ -481,13 +484,13 @@ def qt_message_handler(msg_type: QtCore.QtMsgType,
level = qt_to_logging[msg_type]
if context.function is None:
- func = 'none' # type: ignore
+ func = 'none' # type: ignore[unreachable]
elif ':' in context.function:
func = '"{}"'.format(context.function)
else:
func = context.function
- if (context.category is None or # type: ignore
+ if (context.category is None or # type: ignore[unreachable]
context.category == 'default'):
name = 'qt'
else:
@@ -692,9 +695,10 @@ class HTMLFormatter(logging.Formatter):
record_clone.__dict__.update(self._colordict)
if record_clone.levelname in self._log_colors:
color = self._log_colors[record_clone.levelname]
- record_clone.log_color = self._colordict[color] # type: ignore
+ color_str = self._colordict[color]
+ record_clone.log_color = color_str # type: ignore[attr-defined]
else:
- record_clone.log_color = '' # type: ignore
+ record_clone.log_color = '' # type: ignore[attr-defined]
for field in ['msg', 'filename', 'funcName', 'levelname', 'module',
'name', 'pathname', 'processName', 'threadName']:
data = str(getattr(record_clone, field))
diff --git a/qutebrowser/utils/message.py b/qutebrowser/utils/message.py
index 3413b5e0e..a8c7c8d85 100644
--- a/qutebrowser/utils/message.py
+++ b/qutebrowser/utils/message.py
@@ -88,7 +88,7 @@ def _build_question(title: str,
mode: usertypes.PromptMode,
default: typing.Union[None, bool, str] = None,
abort_on: typing.Iterable[pyqtSignal] = (),
- url: QUrl = None,
+ url: str = None,
option: bool = None) -> usertypes.Question:
"""Common function for ask/ask_async."""
question = usertypes.Question()
diff --git a/qutebrowser/utils/objreg.py b/qutebrowser/utils/objreg.py
index fa6097586..908caac6a 100644
--- a/qutebrowser/utils/objreg.py
+++ b/qutebrowser/utils/objreg.py
@@ -86,7 +86,7 @@ class ObjectRegistry(collections.UserDict):
if isinstance(obj, QObject):
func = functools.partial(self.on_destroyed, name)
- obj.destroyed.connect(func) # type: ignore
+ obj.destroyed.connect(func)
self._partial_objs[name] = func
super().__setitem__(name, obj)
@@ -170,9 +170,7 @@ def _get_tab_registry(win_id: _WindowTab,
if window is None or not hasattr(window, 'win_id'):
raise RegistryUnavailableError('tab')
win_id = window.win_id
- elif win_id is not None:
- window = window_registry[win_id]
- else:
+ elif win_id is None:
raise TypeError("window is None with scope tab!")
if tab_id == 'current':
diff --git a/qutebrowser/utils/qtutils.py b/qutebrowser/utils/qtutils.py
index eb123e634..109d2dfed 100644
--- a/qutebrowser/utils/qtutils.py
+++ b/qutebrowser/utils/qtutils.py
@@ -17,8 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
-# FIXME:typing Can we have less "# type: ignore" in here?
-
"""Misc. utilities related to Qt.
Module attributes:
@@ -37,14 +35,14 @@ import typing
import pkg_resources
from PyQt5.QtCore import (qVersion, QEventLoop, QDataStream, QByteArray,
- QIODevice, QSaveFile, QT_VERSION_STR,
- PYQT_VERSION_STR, QFileDevice, QObject)
+ QIODevice, QFileDevice, QSaveFile, QT_VERSION_STR,
+ PYQT_VERSION_STR, QObject, QUrl)
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import QApplication
try:
from PyQt5.QtWebKit import qWebKitVersion
except ImportError: # pragma: no cover
- qWebKitVersion = None # type: ignore # noqa: N816
+ qWebKitVersion = None # type: ignore[assignment] # noqa: N816
from qutebrowser.misc import objects
from qutebrowser.utils import usertypes
@@ -63,23 +61,27 @@ MINVALS = {
class QtOSError(OSError):
- """An OSError triggered by a QFileDevice.
+ """An OSError triggered by a QIODevice.
Attributes:
qt_errno: The error attribute of the given QFileDevice, if applicable.
"""
- def __init__(self, dev: QFileDevice, msg: str = None) -> None:
+ def __init__(self, dev: QIODevice, msg: str = None) -> None:
if msg is None:
msg = dev.errorString()
+ self.qt_errno = None # type: typing.Optional[QFileDevice.FileError]
+ if isinstance(dev, QFileDevice):
+ msg = self._init_filedev(dev, msg)
+
super().__init__(msg)
- self.qt_errno = None # type: typing.Optional[QFileDevice.FileError]
- try:
- self.qt_errno = dev.error()
- except AttributeError:
- pass
+ def _init_filedev(self, dev: QFileDevice, msg: str) -> str:
+ self.qt_errno = dev.error()
+ filename = dev.fileName()
+ msg += ": {!r}".format(filename)
+ return msg
def version_check(version: str,
@@ -152,7 +154,16 @@ def check_overflow(arg: int, ctype: str, fatal: bool = True) -> int:
return arg
-def ensure_valid(obj: QObject) -> None:
+if typing.TYPE_CHECKING:
+ class Validatable(typing.Protocol):
+
+ """An object with an isValid() method (e.g. QUrl)."""
+
+ def isValid(self) -> bool:
+ ...
+
+
+def ensure_valid(obj: 'Validatable') -> None:
"""Ensure a Qt object with an .isValid() method is valid."""
if not obj.isValid():
raise QtValueError(obj)
@@ -172,7 +183,10 @@ def check_qdatastream(stream: QDataStream) -> None:
raise OSError(status_to_str[stream.status()])
-def serialize(obj: QObject) -> QByteArray:
+_QtSerializableType = typing.Union[QObject, QByteArray, QUrl]
+
+
+def serialize(obj: _QtSerializableType) -> QByteArray:
"""Serialize an object into a QByteArray."""
data = QByteArray()
stream = QDataStream(data, QIODevice.WriteOnly)
@@ -180,23 +194,25 @@ def serialize(obj: QObject) -> QByteArray:
return data
-def deserialize(data: QByteArray, obj: QObject) -> None:
+def deserialize(data: QByteArray, obj: _QtSerializableType) -> None:
"""Deserialize an object from a QByteArray."""
stream = QDataStream(data, QIODevice.ReadOnly)
deserialize_stream(stream, obj)
-def serialize_stream(stream: QDataStream, obj: QObject) -> None:
+def serialize_stream(stream: QDataStream, obj: _QtSerializableType) -> None:
"""Serialize an object into a QDataStream."""
+ # pylint: disable=pointless-statement
check_qdatastream(stream)
- stream << obj # pylint: disable=pointless-statement
+ stream << obj # type: ignore[operator]
check_qdatastream(stream)
-def deserialize_stream(stream: QDataStream, obj: QObject) -> None:
+def deserialize_stream(stream: QDataStream, obj: _QtSerializableType) -> None:
"""Deserialize a QDataStream into an object."""
+ # pylint: disable=pointless-statement
check_qdatastream(stream)
- stream >> obj # pylint: disable=pointless-statement
+ stream >> obj # type: ignore[operator]
check_qdatastream(stream)
@@ -205,7 +221,7 @@ def savefile_open(
filename: str,
binary: bool = False,
encoding: str = 'utf-8'
-) -> typing.Iterator[typing.Union['PyQIODevice', io.TextIOWrapper]]:
+) -> typing.Iterator[typing.IO]:
"""Context manager to easily use a QSaveFile."""
f = QSaveFile(filename)
cancelled = False
@@ -214,12 +230,12 @@ def savefile_open(
if not open_ok:
raise QtOSError(f)
+ dev = typing.cast(typing.IO[bytes], PyQIODevice(f))
+
if binary:
- new_f = PyQIODevice(
- f) # type: typing.Union[PyQIODevice, io.TextIOWrapper]
+ new_f = dev # type: typing.IO
else:
- new_f = io.TextIOWrapper(PyQIODevice(f), # type: ignore
- encoding=encoding)
+ new_f = io.TextIOWrapper(dev, encoding=encoding)
yield new_f
@@ -335,28 +351,34 @@ class PyQIODevice(io.BufferedIOBase):
def readable(self) -> bool:
return self.dev.isReadable()
- def readline(self, size: int = -1) -> QByteArray:
+ def readline(self, size: int = -1) -> bytes:
self._check_open()
self._check_readable()
if size < 0:
qt_size = 0 # no maximum size
elif size == 0:
- return QByteArray()
+ return b''
else:
qt_size = size + 1 # Qt also counts the NUL byte
+ buf = None # type: typing.Union[QByteArray, bytes, None]
if self.dev.canReadLine():
buf = self.dev.readLine(qt_size)
+ elif size < 0:
+ buf = self.dev.readAll()
else:
- if size < 0:
- buf = self.dev.readAll()
- else:
- buf = self.dev.read(size)
+ buf = self.dev.read(size)
if buf is None:
raise QtOSError(self.dev)
- return buf # type: ignore
+
+ if isinstance(buf, QByteArray):
+ # The type (bytes or QByteArray) seems to depend on what data we
+ # feed in...
+ buf = buf.data()
+
+ return buf
def seekable(self) -> bool:
return not self.dev.isSequential()
@@ -369,26 +391,33 @@ class PyQIODevice(io.BufferedIOBase):
def writable(self) -> bool:
return self.dev.isWritable()
- def write(self, data: str) -> int: # type: ignore
+ def write(self, data: typing.Union[bytes, bytearray]) -> int:
self._check_open()
self._check_writable()
- num = self.dev.write(data) # type: ignore
+ num = self.dev.write(data)
if num == -1 or num < len(data):
raise QtOSError(self.dev)
return num
- def read(self, size: typing.Optional[int] = None) -> QByteArray:
+ def read(self, size: typing.Optional[int] = None) -> bytes:
self._check_open()
self._check_readable()
+ buf = None # type: typing.Union[QByteArray, bytes, None]
if size in [None, -1]:
buf = self.dev.readAll()
else:
- buf = self.dev.read(size) # type: ignore
+ assert size is not None
+ buf = self.dev.read(size)
if buf is None:
raise QtOSError(self.dev)
+ if isinstance(buf, QByteArray):
+ # The type (bytes or QByteArray) seems to depend on what data we
+ # feed in...
+ buf = buf.data()
+
return buf
@@ -396,9 +425,9 @@ class QtValueError(ValueError):
"""Exception which gets raised by ensure_valid."""
- def __init__(self, obj: QObject) -> None:
+ def __init__(self, obj: 'Validatable') -> None:
try:
- self.reason = obj.errorString()
+ self.reason = obj.errorString() # type: ignore[attr-defined]
except AttributeError:
self.reason = None
err = "{} is not valid".format(obj)
@@ -420,12 +449,13 @@ class EventLoop(QEventLoop):
def exec_(
self,
- flags: QEventLoop.ProcessEventsFlag = QEventLoop.AllEvents
+ flags: QEventLoop.ProcessEventsFlags =
+ typing.cast(QEventLoop.ProcessEventsFlags, QEventLoop.AllEvents)
) -> int:
"""Override exec_ to raise an exception when re-running."""
if self._executing:
raise AssertionError("Eventloop is already running!")
self._executing = True
- status = super().exec_(flags) # type: ignore
+ status = super().exec_(flags)
self._executing = False
return status
diff --git a/qutebrowser/utils/standarddir.py b/qutebrowser/utils/standarddir.py
index ce5a20634..8e5a91c30 100644
--- a/qutebrowser/utils/standarddir.py
+++ b/qutebrowser/utils/standarddir.py
@@ -68,7 +68,7 @@ def _unset_organization() -> typing.Iterator[None]:
qapp = QApplication.instance()
if qapp is not None:
orgname = qapp.organizationName()
- qapp.setOrganizationName(None) # type: ignore
+ qapp.setOrganizationName(None) # type: ignore[arg-type]
try:
yield
finally:
@@ -314,6 +314,9 @@ def _create(path: str) -> None:
0700. If the destination directory exists already the permissions
should not be changed.
"""
+ if APPNAME == 'qute_test' and path.startswith('/home'): # pragma: no cover
+ raise Exception("Trying to create directory inside /home during "
+ "tests, this should not happen.")
os.makedirs(path, 0o700, exist_ok=True)
diff --git a/qutebrowser/utils/urlutils.py b/qutebrowser/utils/urlutils.py
index b0013c195..7c8cec7a5 100644
--- a/qutebrowser/utils/urlutils.py
+++ b/qutebrowser/utils/urlutils.py
@@ -116,13 +116,18 @@ def _get_search_url(txt: str) -> QUrl:
engine = 'DEFAULT'
if term:
template = config.val.url.searchengines[engine]
+ semiquoted_term = urllib.parse.quote(term)
quoted_term = urllib.parse.quote(term, safe='')
- url = qurl_from_user_input(template.format(quoted_term))
+ evaluated = template.format(semiquoted_term,
+ unquoted=term,
+ quoted=quoted_term,
+ semiquoted=semiquoted_term)
+ url = qurl_from_user_input(evaluated)
else:
url = qurl_from_user_input(config.val.url.searchengines[engine])
- url.setPath(None) # type: ignore
- url.setFragment(None) # type: ignore
- url.setQuery(None) # type: ignore
+ url.setPath(None) # type: ignore[arg-type]
+ url.setFragment(None) # type: ignore[arg-type]
+ url.setQuery(None) # type: ignore[call-overload]
qtutils.ensure_valid(url)
return url
@@ -514,17 +519,17 @@ def encoded_url(url: QUrl) -> str:
Args:
url: The url to encode as QUrl.
"""
- return bytes(url.toEncoded()).decode('ascii')
+ return url.toEncoded().data().decode('ascii')
-def file_url(path: str) -> QUrl:
+def file_url(path: str) -> str:
"""Return a file:// url (as string) to the given local path.
Arguments:
path: The absolute path to the local file
"""
url = QUrl.fromLocalFile(path)
- return url.toString(QUrl.FullyEncoded) # type: ignore
+ return url.toString(QUrl.FullyEncoded) # type: ignore[arg-type]
def data_url(mimetype: str, data: bytes) -> QUrl:
@@ -546,13 +551,13 @@ def safe_display_string(qurl: QUrl) -> str:
"""
ensure_valid(qurl)
- host = qurl.host(QUrl.FullyEncoded) # type: ignore
+ host = qurl.host(QUrl.FullyEncoded)
if '..' in host: # pragma: no cover
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-60364
return '(unparseable URL!) {}'.format(qurl.toDisplayString())
for part in host.split('.'):
- url_host = qurl.host(QUrl.FullyDecoded) # type: ignore
+ url_host = qurl.host(QUrl.FullyDecoded)
if part.startswith('xn--') and host != url_host:
return '({}) {}'.format(host, qurl.toDisplayString())
@@ -579,7 +584,7 @@ class InvalidProxyTypeError(Exception):
super().__init__("Invalid proxy type {}!".format(typ))
-def proxy_from_url(url: QUrl) -> QNetworkProxy:
+def proxy_from_url(url: QUrl) -> typing.Union[QNetworkProxy, pac.PACFetcher]:
"""Create a QNetworkProxy from QUrl and a proxy type.
Args:
diff --git a/qutebrowser/utils/usertypes.py b/qutebrowser/utils/usertypes.py
index 3df2593ad..247946497 100644
--- a/qutebrowser/utils/usertypes.py
+++ b/qutebrowser/utils/usertypes.py
@@ -91,7 +91,7 @@ class NeighborList(typing.Sequence[_T]):
self._mode = mode
self.fuzzyval = None # type: typing.Optional[int]
- def __getitem__(self, key: int) -> _T: # type: ignore
+ def __getitem__(self, key: int) -> _T: # type: ignore[override]
return self._items[key]
def __len__(self) -> int:
@@ -120,7 +120,8 @@ class NeighborList(typing.Sequence[_T]):
if items:
item = min(
items,
- key=lambda tpl: abs(self.fuzzyval - tpl[1])) # type: ignore
+ key=lambda tpl:
+ abs(self.fuzzyval - tpl[1])) # type: ignore[operator]
else:
sorted_items = sorted(enumerate(self.items), key=lambda e: e[1])
idx = 0 if offset < 0 else -1
diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py
index 58e89c2a1..368cb0ab6 100644
--- a/qutebrowser/utils/utils.py
+++ b/qutebrowser/utils/utils.py
@@ -47,7 +47,7 @@ try:
CSafeDumper as YamlDumper)
YAML_C_EXT = True
except ImportError: # pragma: no cover
- from yaml import (SafeLoader as YamlLoader, # type: ignore
+ from yaml import (SafeLoader as YamlLoader, # type: ignore[misc]
SafeDumper as YamlDumper)
YAML_C_EXT = False
@@ -324,7 +324,7 @@ class FakeIOStream(io.TextIOBase):
def __init__(self, write_func: typing.Callable[[str], int]) -> None:
super().__init__()
- self.write = write_func # type: ignore
+ self.write = write_func # type: ignore[assignment]
@contextlib.contextmanager
@@ -338,16 +338,16 @@ def fake_io(write_func: typing.Callable[[str], int]) -> typing.Iterator[None]:
old_stderr = sys.stderr
fake_stderr = FakeIOStream(write_func)
fake_stdout = FakeIOStream(write_func)
- sys.stderr = fake_stderr # type: ignore
- sys.stdout = fake_stdout # type: ignore
+ sys.stderr = fake_stderr # type: ignore[assignment]
+ sys.stdout = fake_stdout # type: ignore[assignment]
try:
yield
finally:
# If the code we did run did change sys.stdout/sys.stderr, we leave it
# unchanged. Otherwise, we reset it.
- if sys.stdout is fake_stdout: # type: ignore
+ if sys.stdout is fake_stdout: # type: ignore[comparison-overlap]
sys.stdout = old_stdout
- if sys.stderr is fake_stderr: # type: ignore
+ if sys.stderr is fake_stderr: # type: ignore[comparison-overlap]
sys.stderr = old_stderr
diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py
index 5b0a05c9f..1ad8b22cf 100644
--- a/qutebrowser/utils/version.py
+++ b/qutebrowser/utils/version.py
@@ -43,7 +43,7 @@ from PyQt5.QtWidgets import QApplication
try:
from PyQt5.QtWebKit import qWebKitVersion
except ImportError: # pragma: no cover
- qWebKitVersion = None # type: ignore # noqa: N816
+ qWebKitVersion = None # type: ignore[assignment] # noqa: N816
import qutebrowser
from qutebrowser.utils import log, utils, standarddir, usertypes, message
@@ -54,7 +54,7 @@ from qutebrowser.config import config
try:
from qutebrowser.browser.webengine import webenginesettings
except ImportError: # pragma: no cover
- webenginesettings = None # type: ignore
+ webenginesettings = None # type: ignore[assignment]
@attr.s
@@ -90,7 +90,7 @@ def distribution() -> typing.Optional[DistributionInfo]:
with open(filename, 'r', encoding='utf-8') as f:
for line in f:
line = line.strip()
- if (not line) or line.startswith('#'):
+ if (not line) or line.startswith('#') or '=' not in line:
continue
k, v = line.split("=", maxsplit=1)
info[k] = v.strip('"')
@@ -287,7 +287,7 @@ def _os_info() -> typing.Sequence[str]:
versioninfo = ''
else:
versioninfo = '.'.join(info_tpl)
- osver = ', '.join([e for e in [release, versioninfo, machine] if e])
+ osver = ', '.join(e for e in [release, versioninfo, machine] if e)
elif utils.is_posix:
osver = ' '.join(platform.uname())
else:
@@ -343,7 +343,7 @@ def _chromium_version() -> str:
Qt 5.9: Chromium 56
(LTS) 56.0.2924.122 (2017-01-25)
- 5.9.8: Security fixes up to 72.0.3626.121 (2019-03-01)
+ 5.9.9: Security fixes up to 78.0.3904.108 (2019-11-18)
Qt 5.10: Chromium 61
61.0.3163.140 (2017-09-05)
@@ -355,8 +355,7 @@ def _chromium_version() -> str:
Qt 5.12: Chromium 69
(LTS) 69.0.3497.113 (2018-09-27)
- 5.12.6: Security fixes up to 76.0.3809.87 (2019-07-30)
- plus fix for CVE-2019-13720 from Chrome 78
+ 5.12.8: Security fixes up to 80.0.3987.149 (2020-03-18)
Qt 5.13: Chromium 73
73.0.3683.105 (~2019-02-28)
@@ -364,13 +363,17 @@ def _chromium_version() -> str:
Qt 5.14: Chromium 77
77.0.3865.129 (~2019-10-10)
- 5.14.1: Security fixes up to 79.0.3945.117 (2020-01-07)
+ 5.14.2: Security fixes up to 80.0.3987.132 (2020-03-03)
+
+ Qt 5.15: Chromium 80
+ 80.0.3987.163 (2020-04-02)
+ 5.15.0: Security fixes up to 81.0.4044.138 (2020-05-05)
Also see https://www.chromium.org/developers/calendar
and https://chromereleases.googleblog.com/
"""
if webenginesettings is None:
- return 'unavailable' # type: ignore
+ return 'unavailable' # type: ignore[unreachable]
if webenginesettings.parsed_user_agent is None:
webenginesettings.init_user_agent()
@@ -439,6 +442,8 @@ def version() -> str:
if qapp:
style = qapp.style()
lines.append('Style: {}'.format(style.metaObject().className()))
+ platform_name = qapp.platformName()
+ lines.append('Platform plugin: {}'.format(platform_name))
importpath = os.path.dirname(os.path.abspath(qutebrowser.__file__))
diff --git a/requirements.txt b/requirements.txt
index 7f0decf9f..59b6bb414 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,8 +3,8 @@
attrs==19.3.0
colorama==0.4.3
cssutils==1.0.2
-Jinja2==2.11.1
+Jinja2==2.11.2
MarkupSafe==1.1.1
Pygments==2.6.1
pyPEG2==2.15.2
-PyYAML==5.3
+PyYAML==5.3.1
diff --git a/scripts/asciidoc2html.py b/scripts/asciidoc2html.py
index 2f64eac52..e7e7f680b 100755
--- a/scripts/asciidoc2html.py
+++ b/scripts/asciidoc2html.py
@@ -259,8 +259,9 @@ class AsciiDoc:
subprocess.run(cmdline, check=True, env=env)
except (subprocess.CalledProcessError, OSError) as e:
self._failed = True
- utils.print_col(str(e), 'red')
- print("Keeping modified sources in {}.".format(self._homedir))
+ utils.print_error(str(e))
+ print("Keeping modified sources in {}.".format(self._homedir),
+ file=sys.stderr)
sys.exit(1)
@@ -284,9 +285,9 @@ def run(**kwargs) -> None:
try:
asciidoc.prepare()
except FileNotFoundError:
- utils.print_col("Could not find asciidoc! Please install it, or use "
- "the --asciidoc argument to point this script to the "
- "correct python/asciidoc.py location!", 'red')
+ utils.print_error("Could not find asciidoc! Please install it, or use "
+ "the --asciidoc argument to point this script to "
+ "the correct python/asciidoc.py location!")
sys.exit(1)
try:
diff --git a/scripts/dev/build_pyqt_wheel.py b/scripts/dev/build_pyqt_wheel.py
new file mode 100644
index 000000000..9a36c8129
--- /dev/null
+++ b/scripts/dev/build_pyqt_wheel.py
@@ -0,0 +1,99 @@
+#!/usr/bin/env python3
+# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
+
+# Copyright 2020 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
+#
+# This file is part of qutebrowser.
+#
+# qutebrowser is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# qutebrowser is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
+
+"""Build updated PyQt wheels."""
+
+import os
+import subprocess
+import argparse
+import sys
+import pathlib
+
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir,
+ os.pardir))
+from scripts import utils
+
+
+def find_pyqt_bundle():
+ """Try to find the pyqt-bundle executable next to the current Python.
+
+ We do this instead of using $PATH so that the script can be used via
+ .venv/bin/python.
+ """
+ bin_path = pathlib.Path(sys.executable).parent
+ path = bin_path / 'pyqt-bundle'
+
+ if not path.exists():
+ raise FileNotFoundError("Can't find pyqt-bundle at {}".format(path))
+
+ return path
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('qt_location', help='Qt compiler directory')
+ parser.add_argument('--wheels-dir', help='Directory to use for wheels',
+ default='wheels')
+ args = parser.parse_args()
+
+ old_cwd = pathlib.Path.cwd()
+
+ try:
+ pyqt_bundle = find_pyqt_bundle()
+ except FileNotFoundError as e:
+ utils.print_error(str(e))
+ sys.exit(1)
+
+ qt_dir = pathlib.Path(args.qt_location)
+ bin_dir = qt_dir / 'bin'
+ if not bin_dir.exists():
+ utils.print_error("Can't find {}".format(bin_dir))
+ sys.exit(1)
+
+ wheels_dir = pathlib.Path(args.wheels_dir).resolve()
+ wheels_dir.mkdir(exist_ok=True)
+
+ if list(wheels_dir.glob('*')):
+ utils.print_col("Wheels directory is not empty, "
+ "unexpected behavior might occur!", 'yellow')
+
+ os.chdir(wheels_dir)
+
+ utils.print_title("Downloading wheels")
+ subprocess.run([sys.executable, '-m', 'pip', 'download',
+ '--no-deps', '--only-binary', 'PyQt5,PyQtWebEngine',
+ 'PyQt5', 'PyQtWebEngine'], check=True)
+
+ utils.print_title("Patching wheels")
+ input_files = wheels_dir.glob('*.whl')
+ for wheel in input_files:
+ utils.print_subtitle(wheel.stem.split('-')[0])
+ subprocess.run([str(pyqt_bundle),
+ '--qt-dir', args.qt_location, str(wheel)],
+ check=True)
+ wheel.unlink()
+
+ print("Done, output files:")
+ for wheel in wheels_dir.glob('*.whl'):
+ print(wheel.relative_to(old_cwd))
+
+
+if __name__ == '__main__':
+ main()
diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py
index 95ce66473..2f037ac68 100755
--- a/scripts/dev/build_release.py
+++ b/scripts/dev/build_release.py
@@ -44,7 +44,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir,
import qutebrowser
from scripts import utils
-from scripts.dev import update_3rdparty
+from scripts.dev import update_3rdparty, misc_checks
def call_script(name, *args, python=sys.executable):
@@ -275,7 +275,7 @@ def build_windows():
utils.print_title("Running pyinstaller 32bit")
_maybe_remove(out_32)
- call_tox('pyinstaller', '-r', python=python_x86)
+ call_tox('pyinstaller32', '-r', python=python_x86)
shutil.move(out_pyinstaller, out_32)
utils.print_title("Running pyinstaller 64bit")
@@ -410,13 +410,21 @@ def github_upload(artifacts, tag):
for filename, mimetype, description in artifacts:
while True:
print("Uploading {}".format(filename))
+
+ basename = os.path.basename(filename)
+ assets = [asset for asset in release.assets()
+ if asset.name == basename]
+ if assets:
+ print("Assets already exist: {}".format(assets))
+ print("Press enter to continue anyways or Ctrl-C to abort.")
+ input()
+
try:
with open(filename, 'rb') as f:
- basename = os.path.basename(filename)
release.upload_asset(mimetype, basename, f, description)
except github3.exceptions.ConnectionError as e:
- utils.print_col('Failed to upload: {}'.format(e), 'red')
- print("Press Enter to retry...")
+ utils.print_error('Failed to upload: {}'.format(e))
+ print("Press Enter to retry...", file=sys.stderr)
input()
print("Retrying!")
@@ -465,6 +473,10 @@ def main():
import github3 # pylint: disable=unused-import
read_github_token()
+ if not misc_checks.check_git():
+ utils.print_error("Refusing to do a release with a dirty git tree")
+ sys.exit(1)
+
if args.no_asciidoc:
os.makedirs(os.path.join('qutebrowser', 'html', 'doc'), exist_ok=True)
else:
@@ -481,10 +493,9 @@ def main():
upload_to_pypi = True
if args.upload:
- utils.print_title("Press enter to release...")
- input()
-
version_tag = "v" + qutebrowser.__version__
+ utils.print_title("Press enter to release {}...".format(version_tag))
+ input()
github_upload(artifacts, version_tag)
if upload_to_pypi:
diff --git a/scripts/dev/check_coverage.py b/scripts/dev/check_coverage.py
index 9e8f9cda4..7fa45dd90 100644
--- a/scripts/dev/check_coverage.py
+++ b/scripts/dev/check_coverage.py
@@ -202,7 +202,8 @@ PERFECT_FILES = [
('tests/unit/browser/webengine/test_spell.py',
'browser/webengine/spell.py'),
-
+ ('tests/unit/browser/webengine/test_webengine_cookies.py',
+ 'browser/webengine/cookies.py'),
]
diff --git a/scripts/dev/misc_checks.py b/scripts/dev/misc_checks.py
index 64864df8f..6bf411bba 100644
--- a/scripts/dev/misc_checks.py
+++ b/scripts/dev/misc_checks.py
@@ -83,7 +83,7 @@ def check_spelling():
"""Check commonly misspelled words."""
# Words which I often misspell
words = {'[Bb]ehaviour', '[Qq]uitted', 'Ll]ikelyhood', '[Ss]ucessfully',
- '[Oo]ccur[^rs .]', '[Ss]eperator', '[Ee]xplicitely',
+ '[Oo]ccur[^rs .!]', '[Ss]eperator', '[Ee]xplicitely',
'[Aa]uxillary', '[Aa]ccidentaly', '[Aa]mbigious', '[Ll]oosly',
'[Ii]nitialis', '[Cc]onvienence', '[Ss]imiliar', '[Uu]ncommited',
'[Rr]eproducable', '[Aa]n [Uu]ser', '[Cc]onvienience',
@@ -91,7 +91,7 @@ def check_spelling():
'[Mm]ininum', '[Rr]esett?ed', '[Rr]ecieved', '[Rr]egularily',
'[Uu]nderlaying', '[Ii]nexistant', '[Ee]lipsis', 'commiting',
'existant', '[Rr]esetted', '[Ss]imilarily', '[Ii]nformations',
- '[Aa]n [Uu][Rr][Ll]'}
+ '[Aa]n [Uu][Rr][Ll]', '[Tt]reshold'}
# Words which look better when splitted, but might need some fine tuning.
words |= {'[Ww]ebelements', '[Mm]ouseevent', '[Kk]eysequence',
diff --git a/scripts/dev/recompile_requirements.py b/scripts/dev/recompile_requirements.py
index 84cc155e3..3e7db0c9a 100644
--- a/scripts/dev/recompile_requirements.py
+++ b/scripts/dev/recompile_requirements.py
@@ -81,12 +81,18 @@ def read_comments(fobj):
'ignore': [],
'add': [],
'replace': {},
+ 'pre': False,
}
for line in fobj:
if line.startswith('#@'):
- command, args = line[2:].split(':', maxsplit=1)
- command = command.strip()
- args = args.strip()
+ if ':' in line:
+ command, args = line[2:].split(':', maxsplit=1)
+ command = command.strip()
+ args = args.strip()
+ else:
+ command = line[2:].strip()
+ args = None
+
if command == 'filter':
pkg, filt = args.split(' ', maxsplit=1)
comments['filter'][pkg] = filt
@@ -103,6 +109,8 @@ def read_comments(fobj):
comments['markers'][pkg] = markers
elif command == 'add':
comments['add'].append(args)
+ elif command == 'pre':
+ comments['pre'] = True
return comments
@@ -113,6 +121,22 @@ def get_all_names():
yield basename[len('requirements-'):-len('.txt-raw')]
+def init_venv(host_python, venv_dir, requirements, pre=False):
+ """Initialize a new virtualenv and install the given packages."""
+ subprocess.run([host_python, '-m', 'venv', venv_dir], check=True)
+
+ venv_python = os.path.join(venv_dir, 'bin', 'python')
+ subprocess.run([venv_python, '-m', 'pip',
+ 'install', '-U', 'pip'], check=True)
+
+ install_command = [venv_python, '-m', 'pip', 'install', '-r', requirements]
+ if pre:
+ install_command.append('--pre')
+ subprocess.run(install_command, check=True)
+ subprocess.run([venv_python, '-m', 'pip', 'check'], check=True)
+ return venv_python
+
+
def main():
"""Re-compile the given (or all) requirement files."""
names = sys.argv[1:] if len(sys.argv) > 1 else sorted(get_all_names())
@@ -136,22 +160,20 @@ def main():
else:
host_python = sys.executable
- with tempfile.TemporaryDirectory() as tmpdir:
- subprocess.run([host_python, '-m', 'venv', tmpdir], check=True)
+ utils.print_subtitle("Building")
- venv_python = os.path.join(tmpdir, 'bin', 'python')
- subprocess.run([venv_python, '-m', 'pip',
- 'install', '-U', 'pip'], check=True)
+ with open(filename, 'r', encoding='utf-8') as f:
+ comments = read_comments(f)
- subprocess.run([venv_python, '-m', 'pip',
- 'install', '-r', filename], check=True)
+ with tempfile.TemporaryDirectory() as tmpdir:
+ venv_python = init_venv(host_python=host_python,
+ venv_dir=tmpdir,
+ requirements=filename,
+ pre=comments['pre'])
proc = subprocess.run([venv_python, '-m', 'pip', 'freeze'],
check=True, stdout=subprocess.PIPE)
reqs = proc.stdout.decode('utf-8')
- with open(filename, 'r', encoding='utf-8') as f:
- comments = read_comments(f)
-
with open(outfile, 'w', encoding='utf-8') as f:
f.write("# This file is automatically generated by "
"scripts/dev/recompile_requirements.py\n\n")
@@ -163,6 +185,11 @@ def main():
for line in comments['add']:
f.write(line + '\n')
+ # Test resulting file
+ utils.print_subtitle("Testing")
+ with tempfile.TemporaryDirectory() as tmpdir:
+ init_venv(host_python, tmpdir, outfile)
+
if __name__ == '__main__':
main()
diff --git a/scripts/dev/src2asciidoc.py b/scripts/dev/src2asciidoc.py
index b82ede3e1..70df0ebe0 100755
--- a/scripts/dev/src2asciidoc.py
+++ b/scripts/dev/src2asciidoc.py
@@ -59,6 +59,11 @@ class UsageFormatter(argparse.HelpFormatter):
argparse.HelpFormatter while copying 99% of the code :-/
"""
+ def __init__(self, prog, indent_increment=2, max_help_position=24,
+ width=200):
+ """Override __init__ to set a fixed width as default."""
+ super().__init__(prog, indent_increment, max_help_position, width)
+
def _format_usage(self, usage, actions, groups, _prefix):
"""Override _format_usage to not add the 'usage:' prefix."""
return super()._format_usage(usage, actions, groups, '')
@@ -162,7 +167,7 @@ def _get_configtypes():
inspect.isclass(e) and
# pylint: disable=protected-access
e not in [configtypes.BaseType, configtypes.MappingType,
- configtypes._Numeric] and
+ configtypes._Numeric, configtypes.FontBase] and
# pylint: enable=protected-access
issubclass(e, configtypes.BaseType))
yield from inspect.getmembers(configtypes, predicate)
diff --git a/scripts/dev/update_version.py b/scripts/dev/update_version.py
index f6cc2c27b..13bd3d776 100644
--- a/scripts/dev/update_version.py
+++ b/scripts/dev/update_version.py
@@ -52,11 +52,15 @@ if __name__ == "__main__":
parser.add_argument('bump', action="store",
choices=["major", "minor", "patch"],
help="Update release version")
+ parser.add_argument('--commands', action="store_true",
+ help="Only show commands to run post-release.")
args = parser.parse_args()
utils.change_cwd()
- bump_version(args.bump)
- show_commit()
+
+ if not args.commands:
+ bump_version(args.bump)
+ show_commit()
import qutebrowser
version = qutebrowser.__version__
diff --git a/scripts/dictcli.py b/scripts/dictcli.py
index 3676506e1..ebe4e285c 100755
--- a/scripts/dictcli.py
+++ b/scripts/dictcli.py
@@ -38,6 +38,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
from qutebrowser.browser.webengine import spell
from qutebrowser.config import configdata
from qutebrowser.utils import standarddir, utils
+from scripts import utils as scriptutils
API_URL = 'https://chromium.googlesource.com/chromium/deps/hunspell_dictionaries.git/+/master/'
@@ -219,7 +220,13 @@ def install(languages):
print('Installing {}: {}'.format(lang.code, lang.name))
install_lang(lang)
except PermissionError as e:
- sys.exit(str(e))
+ msg = ("\n{}\n\nWith Qt < 5.10, you will need to run this script "
+ "as root, as dictionaries need to be installed "
+ "system-wide. If your qutebrowser uses a newer Qt version "
+ "via a virtualenv, make sure you start this script with "
+ "the virtualenv's Python.".format(e))
+ scriptutils.print_error(msg)
+ sys.exit(1)
def update(languages):
diff --git a/scripts/keytester.py b/scripts/keytester.py
index b47e28d54..027dcbc59 100644
--- a/scripts/keytester.py
+++ b/scripts/keytester.py
@@ -23,34 +23,11 @@
Use python3 -m scripts.keytester to launch it.
"""
-from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QHBoxLayout
-
-from qutebrowser.keyinput import keyutils
-
-
-class KeyWidget(QWidget):
-
- """Widget displaying key presses."""
-
- def __init__(self, parent=None):
- super().__init__(parent)
- self._layout = QHBoxLayout(self)
- self._label = QLabel(text="Waiting for keypress...")
- self._layout.addWidget(self._label)
-
- def keyPressEvent(self, e):
- """Show pressed keys."""
- lines = [
- str(keyutils.KeyInfo.from_event(e)),
- '',
- 'key: 0x{:x}'.format(int(e.key())),
- 'modifiers: 0x{:x}'.format(int(e.modifiers())),
- 'text: {!r}'.format(e.text()),
- ]
- self._label.setText('\n'.join(lines))
+from PyQt5.QtWidgets import QApplication
+from qutebrowser.misc import miscwidgets
app = QApplication([])
-w = KeyWidget()
+w = miscwidgets.KeyTesterWidget()
w.show()
app.exec_()
diff --git a/scripts/mkvenv.py b/scripts/mkvenv.py
index 15f525f37..5eeb90640 100644
--- a/scripts/mkvenv.py
+++ b/scripts/mkvenv.py
@@ -52,9 +52,12 @@ def parse_args() -> argparse.Namespace:
default='auto',
help="PyQt version to install.")
parser.add_argument('--pyqt-type',
- choices=['binary', 'source', 'link'],
+ choices=['binary', 'source', 'link', 'wheels', 'skip'],
default='binary',
help="How to install PyQt/Qt.")
+ parser.add_argument('--pyqt-wheels-dir',
+ default='wheels',
+ help="Directory to get PyQt wheels from.")
parser.add_argument('--virtualenv',
action='store_true',
help="Use virtualenv instead of venv.")
@@ -65,6 +68,9 @@ def parse_args() -> argparse.Namespace:
parser.add_argument('--dev',
action='store_true',
help="Also install dev/test dependencies.")
+ parser.add_argument('--skip-docs',
+ action='store_true',
+ help="Skip doc generation.")
parser.add_argument('--tox-error',
action='store_true',
help=argparse.SUPPRESS)
@@ -95,7 +101,7 @@ def run_venv(venv_dir: pathlib.Path, executable, *args: str) -> None:
subprocess.run([str(venv_dir / subdir / executable)] +
[str(arg) for arg in args], check=True)
except subprocess.CalledProcessError as e:
- utils.print_col("Subprocess failed, exiting", 'red')
+ utils.print_error("Subprocess failed, exiting")
sys.exit(e.returncode)
@@ -103,25 +109,7 @@ def pip_install(venv_dir: pathlib.Path, *args: str) -> None:
"""Run a pip install command inside the virtualenv."""
arg_str = ' '.join(str(arg) for arg in args)
utils.print_col('venv$ pip install {}'.format(arg_str), 'blue')
- run_venv(venv_dir, 'python3', '-m', 'pip', 'install', *args)
-
-
-def show_tox_error(pyqt_type: str) -> None:
- """DIsplay an error when invoked from tox."""
- if pyqt_type == 'link':
- env = 'mkvenv'
- args = ' --pyqt-type link'
- elif pyqt_type == 'binary':
- env = 'mkvenv-pypi'
- args = ''
- else:
- raise AssertionError
-
- print()
- utils.print_col('tox -e {} is deprecated. '
- 'Please use "python3 scripts/mkvenv.py{}" instead.'
- .format(env, args), 'red')
- print()
+ run_venv(venv_dir, 'python', '-m', 'pip', 'install', *args)
def delete_old_venv(venv_dir: pathlib.Path) -> None:
@@ -137,9 +125,8 @@ def delete_old_venv(venv_dir: pathlib.Path) -> None:
]
if not any(m.exists() for m in markers):
- utils.print_col('{} does not look like a virtualenv, '
- 'cowardly refusing to remove it.'.format(venv_dir),
- 'red')
+ utils.print_error('{} does not look like a virtualenv, '
+ 'cowardly refusing to remove it.'.format(venv_dir))
sys.exit(1)
utils.print_col('$ rm -r {}'.format(venv_dir), 'blue')
@@ -154,7 +141,7 @@ def create_venv(venv_dir: pathlib.Path, use_virtualenv: bool = False) -> None:
subprocess.run([sys.executable, '-m', 'virtualenv', venv_dir],
check=True)
except subprocess.CalledProcessError as e:
- utils.print_col("virtualenv failed, exiting", 'red')
+ utils.print_error("virtualenv failed, exiting")
sys.exit(e.returncode)
else:
utils.print_col('$ python3 -m venv {}'.format(venv_dir), 'blue')
@@ -207,6 +194,14 @@ def install_pyqt_link(venv_dir: pathlib.Path) -> None:
link_pyqt.link_pyqt(sys.executable, lib_path)
+def install_pyqt_wheels(venv_dir: pathlib.Path,
+ wheels_dir: pathlib.Path) -> None:
+ """Install PyQt from the wheels/ directory."""
+ utils.print_title("Installing PyQt wheels")
+ wheels = [str(wheel) for wheel in wheels_dir.glob('*.whl')]
+ pip_install(venv_dir, *wheels)
+
+
def install_requirements(venv_dir: pathlib.Path) -> None:
"""Install qutebrowser's requirement.txt."""
utils.print_title("Installing other qutebrowser dependencies")
@@ -240,21 +235,24 @@ def regenerate_docs(venv_dir: pathlib.Path,
utils.print_col('venv$ python3 scripts/asciidoc2html.py {}'
.format(' '.join(a2h_args)), 'blue')
- run_venv(venv_dir, 'python3', str(script_path), *a2h_args)
+ run_venv(venv_dir, 'python', str(script_path), *a2h_args)
def main() -> None:
"""Install qutebrowser in a virtualenv.."""
args = parse_args()
venv_dir = pathlib.Path(args.venv_dir)
+ wheels_dir = pathlib.Path(args.pyqt_wheels_dir)
utils.change_cwd()
- if args.tox_error:
- show_tox_error(args.pyqt_type)
+ if (args.pyqt_version != 'auto' and
+ args.pyqt_type not in ['binary', 'source']):
+ utils.print_error('The --pyqt-version option is only available when '
+ 'installing PyQt from binary or source')
sys.exit(1)
- elif args.pyqt_type == 'link' and args.pyqt_version != 'auto':
- utils.print_col('The --pyqt-version option is not available when '
- 'linking a system-wide install.', 'red')
+ elif args.pyqt_wheels_dir != 'wheels' and args.pyqt_type != 'wheels':
+ utils.print_error('The --pyqt-wheels-dir option is only available '
+ 'when installing PyQt from wheels')
sys.exit(1)
if not args.keep:
@@ -270,6 +268,10 @@ def main() -> None:
install_pyqt_source(venv_dir, args.pyqt_version)
elif args.pyqt_type == 'link':
install_pyqt_link(venv_dir)
+ elif args.pyqt_type == 'wheels':
+ install_pyqt_wheels(venv_dir, wheels_dir)
+ elif args.pyqt_type == 'skip':
+ pass
else:
raise AssertionError
@@ -278,7 +280,8 @@ def main() -> None:
if args.dev:
install_dev_requirements(venv_dir)
- regenerate_docs(venv_dir, args.asciidoc)
+ if not args.skip_docs:
+ regenerate_docs(venv_dir, args.asciidoc)
if __name__ == '__main__':
diff --git a/scripts/utils.py b/scripts/utils.py
index 0d405c8a6..bdf3f96fc 100644
--- a/scripts/utils.py
+++ b/scripts/utils.py
@@ -21,6 +21,7 @@
import os
import os.path
+import sys
# Import side-effects are an evil thing, but here it's okay so scripts using
@@ -58,14 +59,18 @@ def _esc(code):
return '\033[{}m'.format(code)
-def print_col(text, color):
+def print_col(text, color, file=sys.stdout):
"""Print a colorized text."""
if use_color:
fg = _esc(fg_colors[color.lower()])
reset = _esc(fg_colors['reset'])
- print(''.join([fg, text, reset]))
+ print(''.join([fg, text, reset]), file=file)
else:
- print(text)
+ print(text, file=file)
+
+
+def print_error(text):
+ print_col(text, 'red', file=sys.stderr)
def print_title(text):
diff --git a/setup.py b/setup.py
index 6b2ea0acd..7741a71b7 100755
--- a/setup.py
+++ b/setup.py
@@ -97,6 +97,7 @@ try:
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
+ 'Programming Language :: Python :: 3.8',
'Topic :: Internet',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Browsers',
diff --git a/tests/conftest.py b/tests/conftest.py
index 0990e2702..c6b6c2efc 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -110,7 +110,7 @@ def _apply_platform_markers(config, item):
"https://bugreports.qt.io/browse/QTBUG-60673"),
('qtwebkit6021_xfail',
pytest.mark.xfail,
- version.qWebKitVersion and # type: ignore
+ version.qWebKitVersion and # type: ignore[unreachable]
version.qWebKitVersion() == '602.1',
"Broken on WebKit 602.1")
]
@@ -255,7 +255,7 @@ def set_backend(monkeypatch, request):
monkeypatch.setattr(objects, 'backend', backend)
-@pytest.fixture(autouse=True)
+@pytest.fixture(autouse=True, scope='session')
def apply_libgl_workaround():
"""Make sure we load libGL early so QtWebEngine tests run properly."""
libgl = ctypes.util.find_library("GL")
diff --git a/tests/end2end/features/conftest.py b/tests/end2end/features/conftest.py
index f9df23ac9..6ac5f281d 100644
--- a/tests/end2end/features/conftest.py
+++ b/tests/end2end/features/conftest.py
@@ -29,6 +29,7 @@ import logging
import collections
import textwrap
import subprocess
+import shutil
import pytest
import pytest_bdd as bdd
@@ -49,7 +50,7 @@ def _get_echo_exe_path():
return os.path.join(testutils.abs_datapath(), 'userscripts',
'echo.bat')
else:
- return 'echo'
+ return shutil.which("echo")
@pytest.hookimpl(hookwrapper=True)
diff --git a/tests/end2end/features/search.feature b/tests/end2end/features/search.feature
index 2c0aa06a5..de815a5b7 100644
--- a/tests/end2end/features/search.feature
+++ b/tests/end2end/features/search.feature
@@ -213,6 +213,56 @@ Feature: Searching on a page
# TODO: wrapping message with scrolling
# TODO: wrapping message without scrolling
+ ## wrapping prevented
+
+ @qtwebkit_skip @qt>=5.14
+ Scenario: Preventing wrapping at the top of the page with QtWebEngine
+ When I set search.ignore_case to always
+ And I set search.wrap to false
+ And I run :search --reverse foo
+ And I wait for "search found foo with flags FindBackward" in the log
+ And I run :search-next
+ And I wait for "next_result found foo with flags FindBackward" in the log
+ And I run :search-next
+ And I wait for "Search hit TOP" in the log
+ Then "foo" should be found
+
+ @qtwebkit_skip @qt>=5.14
+ Scenario: Preventing wrapping at the bottom of the page with QtWebEngine
+ When I set search.ignore_case to always
+ And I set search.wrap to false
+ And I run :search foo
+ And I wait for "search found foo" in the log
+ And I run :search-next
+ And I wait for "next_result found foo" in the log
+ And I run :search-next
+ And I wait for "Search hit BOTTOM" in the log
+ Then "Foo" should be found
+
+ @qtwebengine_skip
+ Scenario: Preventing wrapping at the top of the page with QtWebKit
+ When I set search.ignore_case to always
+ And I set search.wrap to false
+ And I run :search --reverse foo
+ And I wait for "search found foo with flags FindBackward" in the log
+ And I run :search-next
+ And I wait for "next_result found foo with flags FindBackward" in the log
+ And I run :search-next
+ And I wait for "next_result didn't find foo with flags FindBackward" in the log
+ Then the warning "Text 'foo' not found on page!" should be shown
+
+ @qtwebengine_skip
+ Scenario: Preventing wrapping at the bottom of the page with QtWebKit
+ When I set search.ignore_case to always
+ And I set search.wrap to false
+ And I run :search foo
+ And I wait for "search found foo" in the log
+ And I run :search-next
+ And I wait for "next_result found foo" in the log
+ And I run :search-next
+ And I wait for "next_result didn't find foo" in the log
+ Then the warning "Text 'foo' not found on page!" should be shown
+
## follow searched links
@skip # Too flaky
Scenario: Follow a searched link
diff --git a/tests/end2end/features/spawn.feature b/tests/end2end/features/spawn.feature
index 5fabb044d..623bf4959 100644
--- a/tests/end2end/features/spawn.feature
+++ b/tests/end2end/features/spawn.feature
@@ -38,6 +38,14 @@ Feature: :spawn
And I run :spawn (echo-exe) {url:pretty}
Then "Executing * with args ['http://localhost:(port)/data/title with spaces.html'], userscript=False" should be logged
+ Scenario: Running :spawn with -m
+ When I run :spawn -m (echo-exe) Message 1
+ Then the message "Message 1" should be shown
+
+ Scenario: Running :spawn with -u -m
+ When I run :spawn -u -m (echo-exe) Message 2
+ Then the message "Message 2" should be shown
+
@posix
Scenario: Running :spawn with userscript
When I open data/hello.txt
diff --git a/tests/end2end/features/test_editor_bdd.py b/tests/end2end/features/test_editor_bdd.py
index edc4a9927..36719324a 100644
--- a/tests/end2end/features/test_editor_bdd.py
+++ b/tests/end2end/features/test_editor_bdd.py
@@ -98,6 +98,9 @@ class EditorPidWatcher(QObject):
else:
self._watcher.addPath(str(self._pidfile))
+ def manual_check(self):
+ return self._pidfile.check()
+
@pytest.fixture
def editor_pid_watcher(tmpdir):
@@ -143,9 +146,12 @@ def set_up_editor_wait(quteproc, tmpdir, text, editor_pid_watcher):
@bdd.when("I wait until the editor has started")
def wait_editor(qtbot, editor_pid_watcher):
if not editor_pid_watcher.has_pidfile:
- with qtbot.wait_signal(editor_pid_watcher.appeared, timeout=5000):
+ with qtbot.wait_signal(editor_pid_watcher.appeared, raising=False):
pass
+ if not editor_pid_watcher.manual_check():
+ pytest.fail("Editor pidfile failed to appear!")
+
@bdd.when(bdd.parsers.parse('I kill the waiting editor'))
def kill_editor_wait(tmpdir):
diff --git a/tests/end2end/features/test_open_bdd.py b/tests/end2end/features/test_open_bdd.py
index b1c9714bb..40d11e9a7 100644
--- a/tests/end2end/features/test_open_bdd.py
+++ b/tests/end2end/features/test_open_bdd.py
@@ -19,16 +19,27 @@
import logging
+import pytest
import pytest_bdd as bdd
bdd.scenarios('open.feature')
-def test_open_s(quteproc, ssl_server):
+@pytest.mark.parametrize('scheme', ['http://', ''])
+def test_open_s(request, quteproc, ssl_server, scheme):
"""Test :open with -s."""
quteproc.set_setting('content.ssl_strict', 'false')
- quteproc.send_cmd(':open -s http://localhost:{}/'.format(ssl_server.port))
- quteproc.mark_expected(category='message',
- loglevel=logging.ERROR,
- message="Certificate error: *")
+ quteproc.send_cmd(':open -s {}localhost:{}/'
+ .format(scheme, ssl_server.port))
+ if scheme == 'http://' or not request.config.webengine:
+ # Error is only logged on the first error with QtWebEngine
+ quteproc.mark_expected(category='message',
+ loglevel=logging.ERROR,
+ message="Certificate error: *")
quteproc.wait_for_load_finished('/', port=ssl_server.port, https=True,
load_status='warn')
+
+
+def test_open_s_non_http(quteproc, ssl_server):
+ """Test :open with -s and a qute:// page."""
+ quteproc.send_cmd(':open -s qute://version')
+ quteproc.wait_for_load_finished('qute://version')
diff --git a/tests/end2end/features/test_prompts_bdd.py b/tests/end2end/features/test_prompts_bdd.py
index e7602c5b4..98f2febbb 100644
--- a/tests/end2end/features/test_prompts_bdd.py
+++ b/tests/end2end/features/test_prompts_bdd.py
@@ -17,6 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
+import logging
+
import pytest_bdd as bdd
bdd.scenarios('prompts.feature')
@@ -71,18 +73,17 @@ def ssl_error_page(request, quteproc):
assert "Unable to load page" in content
-class AbstractCertificateErrorWrapper:
-
- """A wrapper over an SSL/certificate error."""
-
- def __init__(self, error):
- self._error = error
-
- def __str__(self):
- raise NotImplementedError
-
- def __repr__(self):
- raise NotImplementedError
-
- def is_overridable(self):
- raise NotImplementedError
+def test_certificate_error_load_status(request, quteproc, ssl_server):
+ """If we load the same page twice, we should get a 'warn' status twice."""
+ quteproc.set_setting('content.ssl_strict', 'false')
+
+ for i in range(2):
+ quteproc.open_path('/', port=ssl_server.port, https=True, wait=False,
+ new_tab=True)
+ if i == 0 or not request.config.webengine:
+ # Error is only logged on the first error with QtWebEngine
+ quteproc.mark_expected(category='message',
+ loglevel=logging.ERROR,
+ message="Certificate error: *")
+ quteproc.wait_for_load_finished('/', port=ssl_server.port, https=True,
+ load_status='warn')
diff --git a/tests/end2end/features/yankpaste.feature b/tests/end2end/features/yankpaste.feature
index 46ef92a9c..a3264afa9 100644
--- a/tests/end2end/features/yankpaste.feature
+++ b/tests/end2end/features/yankpaste.feature
@@ -41,14 +41,6 @@ Feature: Yanking and pasting.
Then the message "Yanked title to clipboard: Test title" should be shown
And the clipboard should contain "Test title"
- Scenario: Yanking markdown URL to clipboard
- When I open data/title.html
- And I wait for regex "Changing title for idx \d to 'Test title'" in the log
- And I run :yank markdown
- Then the warning ":yank markdown is deprecated, *" should be shown
- And the message "Yanked markdown URL to clipboard: *" should be shown
- And the clipboard should contain "[Test title](http://localhost:(port)/data/title.html)"
-
Scenario: Yanking inline to clipboard
When I open data/title.html
And I run :yank inline '[[{url}][qutebrowser</3org]]'
@@ -194,10 +186,10 @@ Feature: Yanking and pasting.
http://qutebrowser.org
should not open
And I run :open -t {clipboard}
- And I wait until data/hello.txt?q=this%20url%3A%0Ahttp%3A%2F%2Fqutebrowser.org%0Ashould%20not%20open is loaded
+ And I wait until data/hello.txt?q=this%20url%3A%0Ahttp%3A//qutebrowser.org%0Ashould%20not%20open is loaded
Then the following tabs should be open:
- about:blank
- - data/hello.txt?q=this%20url%3A%0Ahttp%3A%2F%2Fqutebrowser.org%0Ashould%20not%20open (active)
+ - data/hello.txt?q=this%20url%3A%0Ahttp%3A//qutebrowser.org%0Ashould%20not%20open (active)
Scenario: Pasting multiline whose first line looks like a URI
When I set url.auto_search to naive
@@ -315,6 +307,7 @@ Feature: Yanking and pasting.
And I run :insert-text This text should be undone
And I wait for the javascript message "textarea contents: This text should be undone"
And I press the key "<Ctrl+z>"
+ And I wait for the javascript message "textarea contents: "
# Paste final text
And I run :insert-text This text should stay
# Compare
diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py
index 6222f3a6a..5f8263334 100644
--- a/tests/end2end/fixtures/quteprocess.py
+++ b/tests/end2end/fixtures/quteprocess.py
@@ -279,6 +279,12 @@ def is_ignored_chromium_message(line):
# https://bugreports.qt.io/browse/QTBUG-78319
'temp file failure: * : could not create temporary file: No such file '
'or directory (2)',
+
+ # Travis
+ # test_ssl_error_with_contentssl_strict__true
+ # [5306:5324:0417/151739.362362:ERROR:address_tracker_linux.cc(171)]
+ # Could not bind NETLINK socket: Address already in use (98)
+ 'Could not bind NETLINK socket: Address already in use (98)',
]
return any(testutils.pattern_match(pattern=pattern, value=message)
for pattern in ignored_messages)
diff --git a/tests/end2end/fixtures/testprocess.py b/tests/end2end/fixtures/testprocess.py
index 3c19b86ef..08f9754db 100644
--- a/tests/end2end/fixtures/testprocess.py
+++ b/tests/end2end/fixtures/testprocess.py
@@ -74,7 +74,10 @@ def _render_log(data, *, verbose, threshold=100):
data = [str(d) for d in data]
is_exception = any('Traceback (most recent call last):' in line or
'Uncaught exception' in line for line in data)
- if len(data) > threshold and not verbose and not is_exception:
+ if (len(data) > threshold and
+ not verbose and
+ not is_exception and
+ not utils.ON_CI):
msg = '[{} lines suppressed, use -v to show]'.format(
len(data) - threshold)
data = [msg] + data[-threshold:]
diff --git a/tests/end2end/fixtures/webserver.py b/tests/end2end/fixtures/webserver.py
index 54ea441de..839355664 100644
--- a/tests/end2end/fixtures/webserver.py
+++ b/tests/end2end/fixtures/webserver.py
@@ -63,7 +63,8 @@ class Request(testprocess.Line):
def _check_status(self):
"""Check if the http status is what we expected."""
path_to_statuses = {
- '/favicon.ico': [HTTPStatus.NOT_FOUND],
+ '/favicon.ico': [HTTPStatus.OK, HTTPStatus.PARTIAL_CONTENT],
+
'/does-not-exist': [HTTPStatus.NOT_FOUND],
'/does-not-exist-2': [HTTPStatus.NOT_FOUND],
'/404': [HTTPStatus.NOT_FOUND],
diff --git a/tests/end2end/fixtures/webserver_sub.py b/tests/end2end/fixtures/webserver_sub.py
index e34d4c295..9902ab125 100644
--- a/tests/end2end/fixtures/webserver_sub.py
+++ b/tests/end2end/fixtures/webserver_sub.py
@@ -272,6 +272,15 @@ def view_user_agent():
return flask.jsonify({'user-agent': flask.request.headers['user-agent']})
+@app.route('/favicon.ico')
+def favicon():
+ basedir = os.path.join(os.path.realpath(os.path.dirname(__file__)),
+ '..', '..', '..')
+ return flask.send_from_directory(os.path.join(basedir, 'icons'),
+ 'qutebrowser.ico',
+ mimetype='image/vnd.microsoft.icon')
+
+
@app.after_request
def log_request(response):
"""Log a webserver request."""
diff --git a/tests/end2end/fixtures/webserver_sub_ssl.py b/tests/end2end/fixtures/webserver_sub_ssl.py
index 7cd6dc92c..d3869201f 100644
--- a/tests/end2end/fixtures/webserver_sub_ssl.py
+++ b/tests/end2end/fixtures/webserver_sub_ssl.py
@@ -40,6 +40,11 @@ def hello_world():
return "Hello World via SSL!"
+@app.route('/favicon.ico')
+def favicon():
+ return webserver_sub.favicon()
+
+
@app.after_request
def log_request(response):
return webserver_sub.log_request(response)
diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py
index 3bb2ad3e5..60a4f02ba 100644
--- a/tests/helpers/fixtures.py
+++ b/tests/helpers/fixtures.py
@@ -45,11 +45,12 @@ import helpers.stubs as stubsmod
from qutebrowser.config import (config, configdata, configtypes, configexc,
configfiles, configcache, stylesheet)
from qutebrowser.api import config as configapi
-from qutebrowser.utils import objreg, standarddir, utils, usertypes
+from qutebrowser.utils import objreg, standarddir, utils, usertypes, qtutils
from qutebrowser.browser import greasemonkey, history, qutescheme
from qutebrowser.browser.webkit import cookies, cache
from qutebrowser.misc import savemanager, sql, objects, sessions
from qutebrowser.keyinput import modeman
+from qutebrowser.qt import sip
_qute_scheme_handler = None
@@ -64,14 +65,17 @@ class WidgetContainer(QWidget):
self._qtbot = qtbot
self.vbox = QVBoxLayout(self)
qtbot.add_widget(self)
+ self._widget = None
def set_widget(self, widget):
self.vbox.addWidget(widget)
widget.container = self
+ self._widget = widget
def expose(self):
with self._qtbot.waitExposed(self):
self.show()
+ self._widget.setFocus()
@pytest.fixture
@@ -204,19 +208,23 @@ def web_tab_setup(qtbot, tab_registry, session_manager_stub,
@pytest.fixture
def webkit_tab(web_tab_setup, qtbot, cookiejar_and_cache, mode_manager,
- widget_container, webpage):
+ widget_container, download_stub, webpage):
webkittab = pytest.importorskip('qutebrowser.browser.webkit.webkittab')
tab = webkittab.WebKitTab(win_id=0, mode_manager=mode_manager,
private=False)
widget_container.set_widget(tab)
- return tab
+ yield tab
+
+ # Make sure the tab shuts itself down properly
+ tab.private_api.shutdown()
@pytest.fixture
def webengine_tab(web_tab_setup, qtbot, redirect_webengine_data,
- tabbed_browser_stubs, mode_manager, widget_container):
+ tabbed_browser_stubs, mode_manager, widget_container,
+ monkeypatch):
tabwidget = tabbed_browser_stubs[0].widget
tabwidget.current_index = 0
tabwidget.index_of = 0
@@ -227,18 +235,34 @@ def webengine_tab(web_tab_setup, qtbot, redirect_webengine_data,
tab = webenginetab.WebEngineTab(win_id=0, mode_manager=mode_manager,
private=False)
widget_container.set_widget(tab)
+
yield tab
+
# If a page is still loading here, _on_load_finished could get called
# during teardown when session_manager_stub is already deleted.
tab.stop()
+ # Make sure the tab shuts itself down properly
+ tab.private_api.shutdown()
+
+ # If we wait for the GC to clean things up, there's a segfault inside
+ # QtWebEngine sometimes (e.g. if we only run
+ # tests/unit/browser/test_caret.py).
+ # However, with Qt < 5.12, doing this here will lead to an immediate
+ # segfault...
+ monkeypatch.undo() # version_check could be patched
+ if qtutils.version_check('5.12'):
+ sip.delete(tab._widget)
+
@pytest.fixture(params=['webkit', 'webengine'])
def web_tab(request):
"""A WebKitTab/WebEngineTab."""
if request.param == 'webkit':
+ pytest.importorskip('qutebrowser.browser.webkit.webkittab')
return request.getfixturevalue('webkit_tab')
elif request.param == 'webengine':
+ pytest.importorskip('qutebrowser.browser.webengine.webenginetab')
return request.getfixturevalue('webengine_tab')
else:
raise utils.Unreachable
@@ -313,7 +337,7 @@ def config_stub(stubs, monkeypatch, configdata_init, yaml_config_stub, qapp):
monkeypatch.setattr(config, 'cache', cache)
try:
- configtypes.Font.set_defaults(None, '10pt')
+ configtypes.FontBase.set_defaults(None, '10pt')
except configexc.NoOptionError:
# Completion tests patch configdata so fonts.default_family is
# unavailable.
diff --git a/tests/helpers/stubs.py b/tests/helpers/stubs.py
index ff6690da5..23fe7ac1d 100644
--- a/tests/helpers/stubs.py
+++ b/tests/helpers/stubs.py
@@ -115,8 +115,8 @@ class FakeQApplication:
UNSET = object()
- def __init__(self, style=None, all_widgets=None, active_window=None,
- instance=UNSET, arguments=None):
+ def __init__(self, *, style=None, all_widgets=None, active_window=None,
+ instance=UNSET, arguments=None, platform_name=None):
if instance is self.UNSET:
self.instance = mock.Mock(return_value=self)
@@ -129,6 +129,7 @@ class FakeQApplication:
self.allWidgets = lambda: all_widgets
self.activeWindow = lambda: active_window
self.arguments = lambda: arguments
+ self.platformName = lambda: platform_name
class FakeNetworkReply:
@@ -256,7 +257,7 @@ class FakeWebTab(browsertab.AbstractTab):
scroll_pos_perc=(0, 0),
load_status=usertypes.LoadStatus.success,
progress=0, can_go_back=None, can_go_forward=None):
- super().__init__(win_id=0, private=False)
+ super().__init__(win_id=0, mode_manager=None, private=False)
self._load_status = load_status
self._title = title
self._url = url
@@ -614,6 +615,10 @@ class FakeDownloadManager:
self.downloads.append(download_item)
return download_item
+ def has_downloads_with_nam(self, _nam):
+ """Needed during WebView.shutdown()."""
+ return False
+
class FakeHistoryProgress:
@@ -651,3 +656,18 @@ class FakeHintManager:
def handle_partial_key(self, keystr):
self.keystr = keystr
+
+
+class FakeWebEngineProfile:
+
+ def __init__(self, cookie_store):
+ self.cookieStore = lambda: cookie_store
+
+
+class FakeCookieStore:
+
+ def __init__(self, has_cookie_filter):
+ self.cookie_filter = None
+ if has_cookie_filter:
+ self.setCookieFilter = (
+ lambda func: setattr(self, 'cookie_filter', func)) # noqa
diff --git a/tests/unit/browser/test_caret.py b/tests/unit/browser/test_caret.py
index 9b817c4ac..7d1325612 100644
--- a/tests/unit/browser/test_caret.py
+++ b/tests/unit/browser/test_caret.py
@@ -24,15 +24,19 @@ import textwrap
import pytest
from PyQt5.QtCore import QUrl
-from qutebrowser.utils import utils, qtutils, usertypes
+from qutebrowser.utils import usertypes
+from qutebrowser.browser import browsertab
@pytest.fixture
def caret(web_tab, qtbot, mode_manager):
- with qtbot.wait_signal(web_tab.load_finished):
+ web_tab.container.expose()
+
+ with qtbot.wait_signal(web_tab.load_finished, timeout=10000):
web_tab.load_url(QUrl('qute://testdata/data/caret.html'))
- mode_manager.enter(usertypes.KeyMode.caret)
+ with qtbot.wait_signal(web_tab.caret.selection_toggled):
+ mode_manager.enter(usertypes.KeyMode.caret)
return web_tab.caret
@@ -61,15 +65,21 @@ class Selection:
selection = selection.strip()
assert selection == expected
return
+ elif not selection and not expected:
+ return
self._qtbot.wait(50)
+ assert False, 'Failed to get selection!'
+
def check_multiline(self, expected, *, strip=False):
self.check(textwrap.dedent(expected).strip(), strip=strip)
- def toggle(self):
- with self._qtbot.wait_signal(self._caret.selection_toggled):
- self._caret.toggle_selection()
+ def toggle(self, *, line=False):
+ """Toggle the selection and return the new selection state."""
+ with self._qtbot.wait_signal(self._caret.selection_toggled) as blocker:
+ self._caret.toggle_selection(line=line)
+ return blocker.args[0]
@pytest.fixture
@@ -77,6 +87,18 @@ def selection(qtbot, caret):
return Selection(qtbot, caret)
+def test_toggle(caret, selection, qtbot):
+ """Make sure calling toggleSelection produces the correct callback values.
+
+ This also makes sure that the SelectionState enum in JS lines up with the
+ Python browsertab.SelectionState enum.
+ """
+ assert selection.toggle() == browsertab.SelectionState.normal
+ assert selection.toggle(line=True) == browsertab.SelectionState.line
+ assert selection.toggle() == browsertab.SelectionState.normal
+ assert selection.toggle() == browsertab.SelectionState.none
+
+
class TestDocument:
def test_selecting_entire_document(self, caret, selection):
@@ -287,17 +309,6 @@ def test_drop_selection(caret, selection):
class TestSearch:
- @pytest.fixture(autouse=True)
- def expose(self, web_tab):
- """Expose the web view if needed.
-
- With QtWebEngine 5.13 on macOS/Windows, searching fails (callback
- called with False) when the view isn't exposed.
- """
- if qtutils.version_check('5.13') and not utils.is_linux:
- web_tab.container.expose()
- web_tab.show()
-
# https://bugreports.qt.io/browse/QTBUG-60673
@pytest.mark.qtbug60673
@@ -340,15 +351,6 @@ class TestFollowSelected:
def toggle_js(self, request, config_stub):
config_stub.val.content.javascript.enabled = request.param
- @pytest.fixture(autouse=True)
- def expose(self, web_tab):
- """Expose the web view if needed.
-
- On QtWebKit, or Qt < 5.11 and > 5.12 on QtWebEngine, we need to
- show the tab for selections to work properly.
- """
- web_tab.container.expose()
-
def test_follow_selected_without_a_selection(self, qtbot, caret, selection, web_tab,
mode_manager):
caret.move_to_next_word() # Move cursor away from the link
@@ -405,3 +407,93 @@ class TestReverse:
caret.reverse_selection()
caret.move_to_start_of_line()
selection.check("one two three")
+
+
+class TestLineSelection:
+
+ def test_toggle(self, caret, selection):
+ selection.toggle(line=True)
+ selection.check("one two three")
+
+ def test_toggle_untoggle(self, caret, selection):
+ selection.toggle()
+ selection.check("")
+ selection.toggle(line=True)
+ selection.check("one two three")
+ selection.toggle()
+ selection.check("one two three")
+
+ def test_from_center(self, caret, selection):
+ caret.move_to_next_char(4)
+ selection.toggle(line=True)
+ selection.check("one two three")
+
+ def test_more_lines(self, caret, selection):
+ selection.toggle(line=True)
+ caret.move_to_next_line(2)
+ selection.check_multiline("""
+ one two three
+ eins zwei drei
+
+ four five six
+ """, strip=True)
+
+ def test_not_selecting_char(self, caret, selection):
+ selection.toggle(line=True)
+ caret.move_to_next_char()
+ selection.check("one two three")
+ caret.move_to_prev_char()
+ selection.check("one two three")
+
+ def test_selecting_prev_next_word(self, caret, selection):
+ selection.toggle(line=True)
+ caret.move_to_next_word()
+ selection.check("one two three")
+ caret.move_to_prev_word()
+ selection.check("one two three")
+
+ def test_selecting_end_word(self, caret, selection):
+ selection.toggle(line=True)
+ caret.move_to_end_of_word()
+ selection.check("one two three")
+
+ def test_selecting_prev_next_line(self, caret, selection):
+ selection.toggle(line=True)
+ caret.move_to_next_line()
+ selection.check_multiline("""
+ one two three
+ eins zwei drei
+ """, strip=True)
+ caret.move_to_prev_line()
+ selection.check("one two three")
+
+ def test_not_selecting_start_end_line(self, caret, selection):
+ selection.toggle(line=True)
+ caret.move_to_end_of_line()
+ selection.check("one two three")
+ caret.move_to_start_of_line()
+ selection.check("one two three")
+
+ def test_selecting_block(self, caret, selection):
+ selection.toggle(line=True)
+ caret.move_to_end_of_next_block()
+ selection.check_multiline("""
+ one two three
+ eins zwei drei
+ """, strip=True)
+
+ @pytest.mark.not_mac(
+ reason='https://github.com/qutebrowser/qutebrowser/issues/5459')
+ def test_selecting_start_end_document(self, caret, selection):
+ selection.toggle(line=True)
+ caret.move_to_end_of_document()
+ selection.check_multiline("""
+ one two three
+ eins zwei drei
+
+ four five six
+ vier fünf sechs
+ """, strip=True)
+
+ caret.move_to_start_of_document()
+ selection.check("one two three")
diff --git a/tests/unit/browser/test_qutescheme.py b/tests/unit/browser/test_qutescheme.py
index 8f2e06148..d4a87c4f9 100644
--- a/tests/unit/browser/test_qutescheme.py
+++ b/tests/unit/browser/test_qutescheme.py
@@ -136,7 +136,7 @@ class TestHistoryHandler:
assert items
def test_qute_history_benchmark(self, web_history, benchmark, now):
- r = range(100000)
+ r = range(20000)
entries = {
'atime': [int(now - t) for t in r],
'url': ['www.x.com/{}'.format(t) for t in r],
diff --git a/tests/unit/browser/test_shared.py b/tests/unit/browser/test_shared.py
index 6e03ca6e9..8bd7a979c 100644
--- a/tests/unit/browser/test_shared.py
+++ b/tests/unit/browser/test_shared.py
@@ -19,8 +19,6 @@
import pytest
-from PyQt5.QtCore import QUrl
-
from qutebrowser.browser import shared
@@ -46,4 +44,4 @@ def test_custom_headers(config_stub, dnt, accept_language, custom_headers,
headers.custom = custom_headers
expected_items = sorted(expected.items())
- assert shared.custom_headers(QUrl()) == expected_items
+ assert shared.custom_headers(url=None) == expected_items
diff --git a/tests/unit/browser/webengine/test_webengine_cookies.py b/tests/unit/browser/webengine/test_webengine_cookies.py
new file mode 100644
index 000000000..0933fa1c6
--- /dev/null
+++ b/tests/unit/browser/webengine/test_webengine_cookies.py
@@ -0,0 +1,128 @@
+# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
+
+# Copyright 2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
+#
+# This file is part of qutebrowser.
+#
+# qutebrowser is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# qutebrowser is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
+
+import pytest
+from PyQt5.QtCore import QUrl
+pytest.importorskip('PyQt5.QtWebEngineCore')
+from PyQt5.QtWebEngineCore import QWebEngineCookieStore
+from PyQt5.QtWebEngineWidgets import QWebEngineProfile
+
+from qutebrowser.browser.webengine import cookies
+from qutebrowser.utils import urlmatch
+
+
+@pytest.fixture
+def filter_request():
+ try:
+ request = QWebEngineCookieStore.FilterRequest()
+ request.firstPartyUrl = QUrl('https://example.com')
+ return request
+ except AttributeError:
+ pytest.skip("FilterRequest not available")
+
+
+@pytest.fixture(autouse=True)
+def enable_cookie_logging(monkeypatch):
+ monkeypatch.setattr(cookies.objects, 'debug_flags', ['log-cookies'])
+
+
+@pytest.mark.parametrize('setting, third_party, accepted', [
+ ('all', False, True),
+ ('never', False, False),
+ ('no-3rdparty', False, True),
+ ('no-3rdparty', True, False),
+])
+def test_accept_cookie(config_stub, filter_request, setting, third_party,
+ accepted):
+ """Test that _accept_cookie respects content.cookies.accept."""
+ config_stub.val.content.cookies.accept = setting
+ filter_request.thirdParty = third_party
+ assert cookies._accept_cookie(filter_request) == accepted
+
+
+@pytest.mark.parametrize('setting, pattern_setting, third_party, accepted', [
+ ('never', 'all', False, True),
+ ('all', 'never', False, False),
+ ('no-3rdparty', 'all', True, True),
+ ('all', 'no-3rdparty', True, False),
+])
+def test_accept_cookie_with_pattern(config_stub, filter_request, setting,
+ pattern_setting, third_party, accepted):
+ """Test that _accept_cookie matches firstPartyUrl with the UrlPattern."""
+ filter_request.thirdParty = third_party
+ config_stub.set_str('content.cookies.accept', setting)
+ config_stub.set_str('content.cookies.accept', pattern_setting,
+ pattern=urlmatch.UrlPattern('https://*.example.com'))
+ assert cookies._accept_cookie(filter_request) == accepted
+
+
+@pytest.mark.parametrize('global_value', ['never', 'all'])
+def test_invalid_url(config_stub, filter_request, global_value):
+ """Make sure we fall back to the global value with invalid URLs.
+
+ This can happen when there's a cookie request from an iframe, e.g. here:
+ https://developers.google.com/youtube/youtube_player_demo
+ """
+ config_stub.val.content.cookies.accept = global_value
+ filter_request.firstPartyUrl = QUrl()
+ accepted = global_value == 'all'
+ assert cookies._accept_cookie(filter_request) == accepted
+
+
+def test_third_party_workaround(monkeypatch, config_stub, filter_request):
+ monkeypatch.setattr(cookies.qtutils, 'version_check',
+ lambda ver, compiled: False)
+ config_stub.val.content.cookies.accept = 'no-3rdparty'
+ filter_request.thirdParty = True
+ filter_request.firstPartyUrl = QUrl()
+ assert cookies._accept_cookie(filter_request)
+
+
+@pytest.mark.parametrize('enabled', [True, False])
+def test_logging(monkeypatch, config_stub, filter_request, caplog, enabled):
+ monkeypatch.setattr(cookies.objects, 'debug_flags',
+ ['log-cookies'] if enabled else [])
+ config_stub.val.content.cookies.accept = 'all'
+ caplog.clear()
+
+ cookies._accept_cookie(filter_request)
+
+ if enabled:
+ expected = ("Cookie from origin <unknown> on https://example.com "
+ "(third party: False) -> applying setting all")
+ assert caplog.messages == [expected]
+ else:
+ assert not caplog.messages
+
+
+class TestInstall:
+
+ def test_real_profile(self):
+ profile = QWebEngineProfile()
+ cookies.install_filter(profile)
+
+ @pytest.mark.parametrize('has_cookie_filter', [True, False])
+ def test_fake_profile(self, stubs, has_cookie_filter):
+ store = stubs.FakeCookieStore(has_cookie_filter=has_cookie_filter)
+ profile = stubs.FakeWebEngineProfile(cookie_store=store)
+
+ cookies.install_filter(profile)
+
+ if has_cookie_filter:
+ assert store.cookie_filter is cookies._accept_cookie
diff --git a/tests/unit/browser/webkit/test_cookies.py b/tests/unit/browser/webkit/test_cookies.py
index a43091f19..fb46a82fb 100644
--- a/tests/unit/browser/webkit/test_cookies.py
+++ b/tests/unit/browser/webkit/test_cookies.py
@@ -23,7 +23,7 @@ from PyQt5.QtCore import QUrl
import pytest
from qutebrowser.browser.webkit import cookies
-from qutebrowser.utils import usertypes
+from qutebrowser.utils import usertypes, urlmatch
from qutebrowser.misc import lineparser, objects
pytestmark = pytest.mark.usefixtures('data_tmpdir')
@@ -62,36 +62,71 @@ class LineparserSaveStub(lineparser.BaseLineParser):
return self.data[key]
-def test_set_cookies_accept(config_stub, qtbot, monkeypatch):
- """Test setCookiesFromUrl with cookies enabled."""
- monkeypatch.setattr(objects, 'backend', usertypes.Backend.QtWebKit)
- config_stub.val.content.cookies.accept = 'all'
+class TestSetCookies:
- ram_jar = cookies.RAMCookieJar()
- cookie = QNetworkCookie(b'foo', b'bar')
- url = QUrl('http://example.com/')
- with qtbot.waitSignal(ram_jar.changed):
- assert ram_jar.setCookiesFromUrl([cookie], url)
+ @pytest.fixture
+ def cookie(self):
+ return QNetworkCookie(b'foo', b'bar')
- # assert the cookies are added correctly
- all_cookies = ram_jar.cookiesForUrl(url)
- assert len(all_cookies) == 1
- saved_cookie = all_cookies[0]
- expected = cookie.name(), cookie.value()
- assert saved_cookie.name(), saved_cookie.value() == expected
+ @pytest.fixture
+ def ram_jar(self):
+ return cookies.RAMCookieJar()
+ @pytest.fixture
+ def url(self):
+ return QUrl('http://example.com/')
-def test_set_cookies_never_accept(qtbot, config_stub, monkeypatch):
- """Test setCookiesFromUrl when cookies are not accepted."""
- monkeypatch.setattr(objects, 'backend', usertypes.Backend.QtWebKit)
- config_stub.val.content.cookies.accept = 'never'
+ @pytest.fixture(autouse=True)
+ def set_webkit_backend(self, monkeypatch):
+ monkeypatch.setattr(objects, 'backend', usertypes.Backend.QtWebKit)
- ram_jar = cookies.RAMCookieJar()
- url = QUrl('http://example.com/')
+ def test_accept(self, config_stub, qtbot, monkeypatch,
+ cookie, ram_jar, url):
+ """Test setCookiesFromUrl with cookies enabled."""
+ config_stub.val.content.cookies.accept = 'all'
- with qtbot.assertNotEmitted(ram_jar.changed):
- assert not ram_jar.setCookiesFromUrl('test', url)
- assert not ram_jar.cookiesForUrl(url)
+ with qtbot.waitSignal(ram_jar.changed):
+ assert ram_jar.setCookiesFromUrl([cookie], url)
+
+ # assert the cookies are added correctly
+ all_cookies = ram_jar.cookiesForUrl(url)
+ assert len(all_cookies) == 1
+ saved_cookie = all_cookies[0]
+ expected = cookie.name(), cookie.value()
+ assert saved_cookie.name(), saved_cookie.value() == expected
+
+ def test_never_accept(self, qtbot, config_stub, monkeypatch,
+ cookie, ram_jar, url):
+ """Test setCookiesFromUrl when cookies are not accepted."""
+ config_stub.val.content.cookies.accept = 'never'
+
+ with qtbot.assertNotEmitted(ram_jar.changed):
+ assert not ram_jar.setCookiesFromUrl([cookie], url)
+ assert not ram_jar.cookiesForUrl(url)
+
+ def test_per_url(self, config_stub, qtbot, monkeypatch,
+ cookie, ram_jar, url):
+ config_stub.val.content.cookies.accept = 'all'
+ config_stub.set_str('content.cookies.accept', 'never',
+ pattern=urlmatch.UrlPattern('http://example.com'))
+
+ org_url = QUrl('http://example.org/')
+
+ with qtbot.waitSignal(ram_jar.changed):
+ assert ram_jar.setCookiesFromUrl([cookie], org_url)
+ assert ram_jar.cookiesForUrl(org_url)
+
+ with qtbot.assertNotEmitted(ram_jar.changed):
+ assert not ram_jar.setCookiesFromUrl([cookie], url)
+ assert not ram_jar.cookiesForUrl(url)
+
+ def test_logging(self, monkeypatch, caplog, config_stub,
+ cookie, ram_jar, url):
+ monkeypatch.setattr(objects, 'debug_flags', ['log-cookies'])
+ ram_jar.setCookiesFromUrl([cookie], url)
+
+ expected = "Cookie on http://example.com/ -> applying setting all"
+ assert caplog.messages == [expected]
def test_cookie_jar_init(config_stub, fake_save_manager):
@@ -159,3 +194,11 @@ def test_cookies_changed(config_stub, fake_save_manager, monkeypatch, qtbot,
assert not jar._lineparser.saved
else:
assert jar._lineparser.data
+
+
+def test_init(qapp, config_stub, fake_save_manager):
+ assert cookies.cookie_jar is None
+ assert cookies.ram_cookie_jar is None
+ cookies.init(qapp)
+ assert isinstance(cookies.cookie_jar, cookies.CookieJar)
+ assert isinstance(cookies.ram_cookie_jar, cookies.RAMCookieJar)
diff --git a/tests/unit/completion/test_models.py b/tests/unit/completion/test_models.py
index f2f3bb47b..1a2a2f0a8 100644
--- a/tests/unit/completion/test_models.py
+++ b/tests/unit/completion/test_models.py
@@ -832,6 +832,41 @@ def test_other_buffer_completion_id0(qtmodeltester, fake_web_tab,
})
+def test_tab_focus_completion(qtmodeltester, fake_web_tab, win_registry,
+ tabbed_browser_stubs, info):
+ tabbed_browser_stubs[0].widget.tabs = [
+ fake_web_tab(QUrl('https://github.com'), 'GitHub', 0),
+ fake_web_tab(QUrl('https://wikipedia.org'), 'Wikipedia', 1),
+ fake_web_tab(QUrl('https://duckduckgo.com'), 'DuckDuckGo', 2),
+ ]
+ tabbed_browser_stubs[1].widget.tabs = [
+ fake_web_tab(QUrl('https://wiki.archlinux.org'), 'ArchWiki', 0),
+ ]
+ info.win_id = 1
+ model = miscmodels.tab_focus(info=info)
+ model.set_pattern('')
+ qtmodeltester.check(model)
+
+ _check_completions(model, {
+ 'Tabs': [
+ ('1', 'https://wiki.archlinux.org', 'ArchWiki'),
+ ],
+ 'Special': [
+ ("last",
+ "Focus the last-focused tab",
+ None),
+
+ ("stack-next",
+ "Go forward through a stack of focused tabs",
+ None),
+
+ ("stack-prev",
+ "Go backward through a stack of focused tabs",
+ None),
+ ]
+ })
+
+
def test_window_completion(qtmodeltester, fake_web_tab, tabbed_browser_stubs,
info):
tabbed_browser_stubs[0].widget.tabs = [
diff --git a/tests/unit/config/test_configcommands.py b/tests/unit/config/test_configcommands.py
index f1479bda1..b793a49ce 100644
--- a/tests/unit/config/test_configcommands.py
+++ b/tests/unit/config/test_configcommands.py
@@ -212,6 +212,16 @@ class TestSet:
commands.set(win_id=0, option='foo?')
+@pytest.mark.parametrize('old', [True, False])
+def test_diff(commands, tabbed_browser_stubs, old):
+ """Run ':config-diff'.
+
+ Should open qute://configdiff."""
+ commands.config_diff(win_id=0, old=old)
+ url = QUrl('qute://configdiff/old') if old else QUrl('qute://configdiff')
+ assert tabbed_browser_stubs[0].loaded_url == url
+
+
class TestCycle:
"""Test :config-cycle."""
diff --git a/tests/unit/config/test_configdata.py b/tests/unit/config/test_configdata.py
index 3dd6a588f..4ea5ffe6d 100644
--- a/tests/unit/config/test_configdata.py
+++ b/tests/unit/config/test_configdata.py
@@ -47,10 +47,20 @@ def test_data(config_stub):
# https://github.com/qutebrowser/qutebrowser/issues/3104
# For lists/dicts, don't use None as default
if isinstance(option.typ, (configtypes.Dict, configtypes.List)):
- assert option.default is not None
+ assert option.default is not None, option
# For ListOrValue, use a list as default
if isinstance(option.typ, configtypes.ListOrValue):
- assert isinstance(option.default, list)
+ assert isinstance(option.default, list), option
+
+ # Make sure floats also have floats for defaults/bounds
+ if isinstance(option.typ, configtypes.Float):
+ for value in [option.default,
+ option.typ.minval,
+ option.typ.maxval]:
+ assert value is None or isinstance(value, float), option
+
+ # No double spaces after dots
+ assert '. ' not in option.description, option
def test_init_benchmark(benchmark):
diff --git a/tests/unit/config/test_configfiles.py b/tests/unit/config/test_configfiles.py
index f7512e2a6..4c0b6305c 100644
--- a/tests/unit/config/test_configfiles.py
+++ b/tests/unit/config/test_configfiles.py
@@ -810,12 +810,10 @@ class TestConfigPy:
with pytest.raises(configexc.ConfigFileErrors) as excinfo:
confpy.read()
- expected = {'normal': {'<Ctrl+q>': None}}
- assert config.instance.get_obj('bindings.commands') == expected
+ assert not config.instance.get_obj('bindings.commands')
- msg = ("While unbinding '<Ctrl+q>': Unbinding commands with "
- "config.bind('<Ctrl+q>', None) is deprecated. Use "
- "config.unbind('<Ctrl+q>') instead.")
+ msg = ("While binding '<Ctrl+q>': Can't bind <Ctrl+q> to None "
+ "(maybe you want to use config.unbind('<Ctrl+q>') instead?)")
assert len(excinfo.value.errors) == 1
assert str(excinfo.value.errors[0]) == msg
@@ -889,7 +887,9 @@ class TestConfigPy:
assert tblines[0] == "Traceback (most recent call last):"
assert tblines[-1] == "SyntaxError: invalid syntax"
assert " +" in tblines
- assert " ^" in tblines
+ # Starting with the new PEG-based parser in Python 3.9, the caret
+ # points at the location *after* the +
+ assert " ^" in tblines or " ^" in tblines
def test_unhandled_exception(self, confpy):
confpy.write("1/0")
diff --git a/tests/unit/config/test_configinit.py b/tests/unit/config/test_configinit.py
index 694a95437..2e149fa70 100644
--- a/tests/unit/config/test_configinit.py
+++ b/tests/unit/config/test_configinit.py
@@ -28,7 +28,7 @@ import pytest
from qutebrowser import qutebrowser
from qutebrowser.config import (config, configexc, configfiles, configinit,
configdata, configtypes)
-from qutebrowser.utils import objreg, usertypes
+from qutebrowser.utils import objreg, usertypes, version
from helpers import utils
@@ -40,8 +40,8 @@ def init_patch(qapp, fake_save_manager, monkeypatch, config_tmpdir,
monkeypatch.setattr(config, 'key_instance', None)
monkeypatch.setattr(config, 'change_filters', [])
monkeypatch.setattr(configinit, '_init_errors', None)
- monkeypatch.setattr(configtypes.Font, 'default_family', None)
- monkeypatch.setattr(configtypes.Font, 'default_size', None)
+ monkeypatch.setattr(configtypes.FontBase, 'default_family', None)
+ monkeypatch.setattr(configtypes.FontBase, 'default_size', None)
yield
try:
objreg.delete('config-commands')
@@ -705,6 +705,126 @@ class TestQtArgs:
assert ('--force-dark-mode' in args) == added
+ @utils.qt514
+ def test_blink_settings(self, config_stub, monkeypatch, parser):
+ monkeypatch.setattr(configinit.objects, 'backend',
+ usertypes.Backend.QtWebEngine)
+ monkeypatch.setattr(configinit.qtutils, 'version_check',
+ lambda version, exact=False, compiled=True:
+ True)
+
+ config_stub.val.colors.webpage.darkmode.enabled = True
+
+ parsed = parser.parse_args([])
+ args = configinit.qt_args(parsed)
+
+ assert '--blink-settings=darkModeEnabled=true' in args
+
+
+class TestDarkMode:
+
+ pytestmark = utils.qt514
+
+ @pytest.fixture(autouse=True)
+ def patch_backend(self, monkeypatch):
+ monkeypatch.setattr(configinit.objects, 'backend',
+ usertypes.Backend.QtWebEngine)
+
+ @pytest.mark.parametrize('settings, new_qt, expected', [
+ # Disabled
+ ({}, True, []),
+ ({}, False, []),
+
+ # Enabled without customization
+ (
+ {'enabled': True},
+ True,
+ [('darkModeEnabled', 'true')]
+ ),
+ (
+ {'enabled': True},
+ False,
+ [('darkMode', '4')]
+ ),
+
+ # Algorithm
+ (
+ {'enabled': True, 'algorithm': 'brightness-rgb'},
+ True,
+ [('darkModeEnabled', 'true'),
+ ('darkModeInversionAlgorithm', '2')],
+ ),
+ (
+ {'enabled': True, 'algorithm': 'brightness-rgb'},
+ False,
+ [('darkMode', '2')],
+ ),
+
+ ])
+ def test_basics(self, config_stub, monkeypatch,
+ settings, new_qt, expected):
+ for k, v in settings.items():
+ config_stub.set_obj('colors.webpage.darkmode.' + k, v)
+ monkeypatch.setattr(configinit.qtutils, 'version_check',
+ lambda version, exact=False, compiled=True:
+ new_qt)
+
+ assert list(configinit._darkmode_settings()) == expected
+
+ @pytest.mark.parametrize('setting, value, exp_key, exp_val', [
+ ('contrast', -0.5,
+ 'darkModeContrast', '-0.5'),
+ ('policy.page', 'smart',
+ 'darkModePagePolicy', '1'),
+ ('policy.images', 'smart',
+ 'darkModeImagePolicy', '2'),
+ ('threshold.text', 100,
+ 'darkModeTextBrightnessThreshold', '100'),
+ ('threshold.background', 100,
+ 'darkModeBackgroundBrightnessThreshold', '100'),
+ ('grayscale.all', True,
+ 'darkModeGrayscale', 'true'),
+ ('grayscale.images', 0.5,
+ 'darkModeImageGrayscale', '0.5'),
+ ])
+ def test_customization(self, config_stub, monkeypatch,
+ setting, value, exp_key, exp_val):
+ config_stub.val.colors.webpage.darkmode.enabled = True
+ config_stub.set_obj('colors.webpage.darkmode.' + setting, value)
+ monkeypatch.setattr(configinit.qtutils, 'version_check',
+ lambda version, exact=False, compiled=True:
+ True)
+
+ expected = [('darkModeEnabled', 'true'), (exp_key, exp_val)]
+ assert list(configinit._darkmode_settings()) == expected
+
+ def test_new_chromium(self):
+ """Fail if we encounter an unknown Chromium version.
+
+ Dark mode in Chromium currently is undergoing various changes (as it's
+ relatively recent), and Qt 5.15 is supposed to update the underlying
+ Chromium at some point.
+
+ Make this test fail deliberately with newer Chromium versions, so that
+ we can test whether dark mode still works manually, and adjust if not.
+ """
+ assert version._chromium_version() in [
+ 'unavailable', # QtWebKit
+ '77.0.3865.129', # Qt 5.14
+ '80.0.3987.163', # Qt 5.15
+ ]
+
+ def test_options(self, configdata_init):
+ """Make sure all darkmode options have the right attributes set."""
+ for name, opt in configdata.DATA.items():
+ if not name.startswith('colors.webpage.darkmode.'):
+ continue
+
+ backends = {'QtWebEngine': 'Qt 5.14', 'QtWebKit': False}
+ assert not opt.supports_pattern, name
+ assert opt.restart, name
+ assert opt.raw_backends == backends, name
+
@pytest.mark.parametrize('arg, confval, used', [
# overridden by commandline arg
diff --git a/tests/unit/config/test_configtypes.py b/tests/unit/config/test_configtypes.py
index f949e1ca0..841892ef2 100644
--- a/tests/unit/config/test_configtypes.py
+++ b/tests/unit/config/test_configtypes.py
@@ -212,17 +212,25 @@ class TestAll:
"""
for _name, member in inspect.getmembers(configtypes, inspect.isclass):
if member in [configtypes.BaseType, configtypes.MappingType,
- configtypes._Numeric]:
+ configtypes._Numeric, configtypes.FontBase]:
pass
elif (member is configtypes.List or
member is configtypes.ListOrValue):
- yield functools.partial(member, valtype=configtypes.Int())
- yield functools.partial(member, valtype=configtypes.Url())
+ yield pytest.param(
+ functools.partial(member, valtype=configtypes.Int()),
+ id=member.__name__ + '-Int')
+ yield pytest.param(
+ functools.partial(member, valtype=configtypes.Url()),
+ id=member.__name__ + '-Url')
elif member is configtypes.Dict:
- yield functools.partial(member, keytype=configtypes.String(),
- valtype=configtypes.String())
+ yield pytest.param(
+ functools.partial(member, keytype=configtypes.String(),
+ valtype=configtypes.String()),
+ id=member.__name__)
elif member is configtypes.FormatString:
- yield functools.partial(member, fields=['a', 'b'])
+ yield pytest.param(
+ functools.partial(member, fields=['a', 'b']),
+ id=member.__name__)
elif issubclass(member, configtypes.BaseType):
yield member
@@ -262,8 +270,15 @@ class TestAll:
configtypes.PercOrInt, # ditto
]:
return
- if (isinstance(typ, configtypes.ListOrValue) and
- isinstance(typ.valtype, configtypes.Int)):
+ elif (isinstance(typ, functools.partial) and
+ isinstance(typ.func, (configtypes.ListOrValue,
+ configtypes.List))):
+ # ListOrValue: "- /" -> "/"
+ # List: "- /" -> ["/"]
+ return
+ elif (isinstance(typ, configtypes.ListOrValue) and
+ isinstance(typ.valtype, configtypes.Int)):
+ # "00" -> "0"
return
assert converted == s
@@ -1032,6 +1047,10 @@ class TestInt:
converted = typ.from_str(text)
assert typ.to_str(converted) == text
+ def test_bounds_handling_unset(self, klass):
+ typ = klass(minval=1, maxval=2)
+ assert typ.to_py(usertypes.UNSET) is usertypes.UNSET
+
class TestFloat:
@@ -1475,7 +1494,7 @@ class TestFont:
klass().to_py(val)
def test_defaults_replacement(self, klass, monkeypatch):
- configtypes.Font.set_defaults(['Terminus'], '23pt')
+ configtypes.FontBase.set_defaults(['Terminus'], '23pt')
if klass is configtypes.Font:
expected = '23pt Terminus'
elif klass is configtypes.QtFont:
@@ -2003,7 +2022,6 @@ class TestSearchEngineUrl:
@pytest.mark.parametrize('val', [
'foo', # no placeholder
- ':{}', # invalid URL
'foo{bar}baz{}', # {bar} format string variable
'{1}{}', # numbered format string variable
'{{}', # invalid format syntax
diff --git a/tests/unit/config/test_configutils.py b/tests/unit/config/test_configutils.py
index 8dfa75609..7e1a7c744 100644
--- a/tests/unit/config/test_configutils.py
+++ b/tests/unit/config/test_configutils.py
@@ -23,7 +23,7 @@ import pytest
from PyQt5.QtCore import QUrl
from qutebrowser.config import configutils, configdata, configtypes, configexc
-from qutebrowser.utils import urlmatch, usertypes
+from qutebrowser.utils import urlmatch, usertypes, qtutils
from tests.helpers import utils
@@ -145,6 +145,11 @@ def test_get_matching(values):
assert values.get_for_url(url, fallback=False) == 'example value'
+def test_get_invalid(values):
+ with pytest.raises(qtutils.QtValueError):
+ values.get_for_url(QUrl())
+
+
def test_get_unset(empty_values):
assert empty_values.get_for_url(fallback=False) is usertypes.UNSET
diff --git a/tests/unit/mainwindow/test_messageview.py b/tests/unit/mainwindow/test_messageview.py
index 68d3b2c56..8691bf07f 100644
--- a/tests/unit/mainwindow/test_messageview.py
+++ b/tests/unit/mainwindow/test_messageview.py
@@ -36,7 +36,7 @@ def view(qtbot, config_stub):
usertypes.MessageLevel.warning,
usertypes.MessageLevel.error])
def test_single_message(qtbot, view, level):
- with qtbot.waitExposed(view):
+ with qtbot.waitExposed(view, timeout=5000):
view.show_message(level, 'test')
assert view._messages[0].isVisible()
diff --git a/tests/unit/misc/test_editor.py b/tests/unit/misc/test_editor.py
index edd32b5a5..5fb4478a7 100644
--- a/tests/unit/misc/test_editor.py
+++ b/tests/unit/misc/test_editor.py
@@ -167,7 +167,7 @@ class TestFileHandling:
def test_backup(self, qtbot, message_mock):
editor = editormod.ExternalEditor(watch=True)
editor.edit('foo')
- with qtbot.wait_signal(editor.file_updated):
+ with qtbot.wait_signal(editor.file_updated, timeout=5000):
_update_file(editor._filename, 'bar')
editor.backup()
diff --git a/tests/unit/misc/test_ipc.py b/tests/unit/misc/test_ipc.py
index 0b52584b6..4b94162c6 100644
--- a/tests/unit/misc/test_ipc.py
+++ b/tests/unit/misc/test_ipc.py
@@ -83,7 +83,7 @@ def qlocalsocket(qapp):
@pytest.fixture(autouse=True)
def fake_runtime_dir(monkeypatch, short_tmpdir):
monkeypatch.setenv('XDG_RUNTIME_DIR', str(short_tmpdir))
- standarddir._init_dirs()
+ standarddir._init_runtime(args=None)
return short_tmpdir
diff --git a/tests/unit/misc/test_throttle.py b/tests/unit/misc/test_throttle.py
index 63babc122..0e2db3aee 100644
--- a/tests/unit/misc/test_throttle.py
+++ b/tests/unit/misc/test_throttle.py
@@ -29,7 +29,7 @@ from helpers import utils
from qutebrowser.misc import throttle
-DELAY = 300 if utils.ON_CI else 100
+DELAY = 500 if utils.ON_CI else 100
@pytest.fixture
diff --git a/tests/unit/utils/test_error.py b/tests/unit/utils/test_error.py
index 82ca3ec55..f8847d39a 100644
--- a/tests/unit/utils/test_error.py
+++ b/tests/unit/utils/test_error.py
@@ -73,10 +73,11 @@ def test_no_err_windows(caplog, exc, name, exc_text):
('foo', 'bar', 'foo: exception\n\nbar'),
('', 'bar', 'exception\n\nbar'),
], ids=repr)
-def test_err_windows(qtbot, qapp, pre_text, post_text, expected):
+def test_err_windows(qtbot, qapp, pre_text, post_text, expected, caplog):
def err_window_check():
w = qapp.activeModalWidget()
+ assert w is not None
try:
qtbot.add_widget(w)
if not utils.is_mac:
@@ -87,7 +88,9 @@ def test_err_windows(qtbot, qapp, pre_text, post_text, expected):
finally:
w.close()
- QTimer.singleShot(0, err_window_check)
- error.handle_fatal_exc(ValueError("exception"), 'title',
- pre_text=pre_text, post_text=post_text,
- no_err_windows=False)
+ QTimer.singleShot(10, err_window_check)
+
+ with caplog.at_level(logging.ERROR):
+ error.handle_fatal_exc(ValueError("exception"), 'title',
+ pre_text=pre_text, post_text=post_text,
+ no_err_windows=False)
diff --git a/tests/unit/utils/test_qtutils.py b/tests/unit/utils/test_qtutils.py
index 150a03f6e..81d198946 100644
--- a/tests/unit/utils/test_qtutils.py
+++ b/tests/unit/utils/test_qtutils.py
@@ -467,9 +467,9 @@ class TestSavefileOpen:
with pytest.raises(OSError) as excinfo:
with qtutils.savefile_open(str(filename)):
pass
- errors = ["Filename refers to a directory", # Qt >= 5.4
- "Commit failed!"] # older Qt versions
- assert str(excinfo.value) in errors
+
+ msg = "Filename refers to a directory: {!r}".format(str(filename))
+ assert str(excinfo.value) == msg
assert tmpdir.listdir() == [filename]
def test_failing_flush(self, tmpdir):
diff --git a/tests/unit/utils/test_standarddir.py b/tests/unit/utils/test_standarddir.py
index e4d8575fe..c2d2c6cd7 100644
--- a/tests/unit/utils/test_standarddir.py
+++ b/tests/unit/utils/test_standarddir.py
@@ -142,26 +142,29 @@ class TestWritableLocation:
class TestStandardDir:
- @pytest.mark.parametrize('func, varname', [
- (standarddir.data, 'XDG_DATA_HOME'),
- (standarddir.config, 'XDG_CONFIG_HOME'),
- (lambda: standarddir.config(auto=True), 'XDG_CONFIG_HOME'),
- (standarddir.cache, 'XDG_CACHE_HOME'),
- (standarddir.runtime, 'XDG_RUNTIME_DIR'),
+ @pytest.mark.parametrize('func, init_func, varname', [
+ (standarddir.data, standarddir._init_data, 'XDG_DATA_HOME'),
+ (standarddir.config, standarddir._init_config, 'XDG_CONFIG_HOME'),
+ (lambda: standarddir.config(auto=True),
+ standarddir._init_config, 'XDG_CONFIG_HOME'),
+ (standarddir.cache, standarddir._init_cache, 'XDG_CACHE_HOME'),
+ (standarddir.runtime, standarddir._init_runtime, 'XDG_RUNTIME_DIR'),
])
@pytest.mark.linux
- def test_linux_explicit(self, monkeypatch, tmpdir, func, varname):
+ def test_linux_explicit(self, monkeypatch, tmpdir,
+ func, init_func, varname):
"""Test dirs with XDG environment variables explicitly set.
Args:
func: The function to test.
+ init_func: The initialization function to call.
varname: The environment variable which should be set.
"""
monkeypatch.setenv(varname, str(tmpdir))
if varname == 'XDG_RUNTIME_DIR':
tmpdir.chmod(0o0700)
- standarddir._init_dirs()
+ init_func(args=None)
assert func() == str(tmpdir / APPNAME)
@pytest.mark.parametrize('func, subdirs', [
@@ -192,7 +195,7 @@ class TestStandardDir:
monkeypatch.setenv('XDG_RUNTIME_DIR', str(tmpdir / 'does-not-exist'))
monkeypatch.setenv('TMPDIR', str(tmpdir_env))
- standarddir._init_dirs()
+ standarddir._init_runtime(args=None)
assert standarddir.runtime() == str(tmpdir_env / APPNAME)
@pytest.mark.fake_os('windows')
@@ -370,10 +373,11 @@ class TestSystemData:
"""Test system data path."""
@pytest.mark.linux
- def test_system_datadir_exist_linux(self, monkeypatch):
+ def test_system_datadir_exist_linux(self, monkeypatch, tmpdir):
"""Test that /usr/share/qute_test is used if path exists."""
+ monkeypatch.setenv('XDG_DATA_HOME', str(tmpdir))
monkeypatch.setattr(os.path, 'exists', lambda path: True)
- standarddir._init_dirs()
+ standarddir._init_data(args=None)
assert standarddir.data(system=True) == "/usr/share/qute_test"
@pytest.mark.linux
@@ -382,7 +386,7 @@ class TestSystemData:
"""Test that system-wide path isn't used on linux if path not exist."""
fake_args.basedir = str(tmpdir)
monkeypatch.setattr(os.path, 'exists', lambda path: False)
- standarddir._init_dirs(fake_args)
+ standarddir._init_data(args=fake_args)
assert standarddir.data(system=True) == standarddir.data()
def test_system_datadir_unsupportedos(self, monkeypatch, tmpdir,
@@ -390,7 +394,7 @@ class TestSystemData:
"""Test that system-wide path is not used on non-Linux OS."""
fake_args.basedir = str(tmpdir)
monkeypatch.setattr('sys.platform', "potato")
- standarddir._init_dirs(fake_args)
+ standarddir._init_data(args=fake_args)
assert standarddir.data(system=True) == standarddir.data()
@@ -515,13 +519,15 @@ class TestMove:
@pytest.mark.parametrize('args_kind', ['basedir', 'normal', 'none'])
-def test_init(mocker, tmpdir, args_kind):
+def test_init(mocker, tmpdir, monkeypatch, args_kind):
"""Do some sanity checks for standarddir.init().
Things like _init_cachedir_tag() are tested in more detail in other tests.
"""
assert standarddir._locations == {}
+ monkeypatch.setenv('HOME', str(tmpdir))
+
m_windows = mocker.patch('qutebrowser.utils.standarddir._move_windows')
m_mac = mocker.patch('qutebrowser.utils.standarddir._move_macos')
if args_kind == 'normal':
@@ -562,11 +568,12 @@ def test_downloads_dir_not_created(monkeypatch, tmpdir):
assert not download_dir.exists()
-def test_no_qapplication(qapp, tmpdir):
+def test_no_qapplication(qapp, tmpdir, monkeypatch):
"""Make sure directories with/without QApplication are equal."""
sub_code = """
import sys
import json
+
sys.path = sys.argv[1:] # make sure we have the same python path
from PyQt5.QtWidgets import QApplication
@@ -583,11 +590,25 @@ def test_no_qapplication(qapp, tmpdir):
pyfile = tmpdir / 'sub.py'
pyfile.write_text(textwrap.dedent(sub_code), encoding='ascii')
- output = subprocess.run([sys.executable, str(pyfile)] + sys.path,
- universal_newlines=True,
- check=True, stdout=subprocess.PIPE).stdout
- sub_locations = json.loads(output)
+ for name in ['CONFIG', 'DATA', 'CACHE']:
+ monkeypatch.delenv('XDG_{}_HOME'.format(name), raising=False)
+
+ runtime_dir = tmpdir / 'runtime'
+ runtime_dir.ensure(dir=True)
+ runtime_dir.chmod(0o0700)
+ monkeypatch.setenv('XDG_RUNTIME_DIR', str(runtime_dir))
+
+ home_dir = tmpdir / 'home'
+ home_dir.ensure(dir=True)
+ monkeypatch.setenv('HOME', str(home_dir))
+
+ proc = subprocess.run([sys.executable, str(pyfile)] + sys.path,
+ universal_newlines=True,
+ check=True,
+ stdout=subprocess.PIPE)
+ sub_locations = json.loads(proc.stdout)
standarddir._init_dirs()
locations = {k.name: v for k, v in standarddir._locations.items()}
+
assert sub_locations == locations
diff --git a/tests/unit/utils/test_urlutils.py b/tests/unit/utils/test_urlutils.py
index 0c265917d..39a43479b 100644
--- a/tests/unit/utils/test_urlutils.py
+++ b/tests/unit/utils/test_urlutils.py
@@ -98,6 +98,8 @@ def init_config(config_stub):
'test': 'http://www.qutebrowser.org/?q={}',
'test-with-dash': 'http://www.example.org/?q={}',
'path-search': 'http://www.example.org/{}',
+ 'quoted-path': 'http://www.example.org/{quoted}',
+ 'unquoted': 'http://www.example.org/?{unquoted}',
'DEFAULT': 'http://www.example.com/?q={}',
}
@@ -286,8 +288,10 @@ def test_special_urls(url, special):
('blub testfoo', 'www.example.com', 'q=blub testfoo'),
('stripped ', 'www.example.com', 'q=stripped'),
('test-with-dash testfoo', 'www.example.org', 'q=testfoo'),
- ('test/with/slashes', 'www.example.com', 'q=test%2Fwith%2Fslashes'),
+ ('test/with/slashes', 'www.example.com', 'q=test/with/slashes'),
('test path-search', 'www.qutebrowser.org', 'q=path-search'),
+ ('slash/and&amp', 'www.example.com', 'q=slash/and%26amp'),
+ ('unquoted one=1&two=2', 'www.example.org', 'one=1&two=2'),
])
def test_get_search_url(config_stub, url, host, query, open_base_url):
"""Test _get_search_url().
@@ -303,6 +307,25 @@ def test_get_search_url(config_stub, url, host, query, open_base_url):
assert url.query() == query
+@pytest.mark.parametrize('open_base_url', [True, False])
+@pytest.mark.parametrize('url, host, path', [
+ ('path-search t/w/s', 'www.example.org', 't/w/s'),
+ ('quoted-path t/w/s', 'www.example.org', 't%2Fw%2Fs'),
+])
+def test_get_search_url_for_path_search(config_stub, url, host, path, open_base_url):
+ """Test _get_search_url_for_path_search().
+
+ Args:
+ url: The "URL" to enter.
+ host: The expected search machine host.
+ path: The expected path on that host that is requested.
+ """
+ config_stub.val.url.open_base_url = open_base_url
+ url = urlutils._get_search_url(url)
+ assert url.host() == host
+ assert url.path(options=QUrl.PrettyDecoded) == '/' + path
+
+
@pytest.mark.parametrize('url, host', [
('test', 'www.qutebrowser.org'),
('test-with-dash', 'www.example.org'),
diff --git a/tests/unit/utils/test_version.py b/tests/unit/utils/test_version.py
index 1b703e6b0..0a3c5e4aa 100644
--- a/tests/unit/utils/test_version.py
+++ b/tests/unit/utils/test_version.py
@@ -196,6 +196,15 @@ from qutebrowser.browser import pdfjs
version.DistributionInfo(
id='tux', parsed=version.Distribution.unknown,
version=None, pretty='Tux')),
+ # Invalid multi-line value
+ ("""
+ ID=tux
+ PRETTY_NAME="Multiline
+ Text"
+ """,
+ version.DistributionInfo(
+ id='tux', parsed=version.Distribution.unknown,
+ version=None, pretty='Multiline')),
])
def test_distribution(tmpdir, monkeypatch, os_release, expected):
os_release_file = tmpdir / 'os-release'
@@ -897,7 +906,7 @@ class VersionParams:
name = attr.ib()
git_commit = attr.ib(True)
frozen = attr.ib(False)
- style = attr.ib(True)
+ qapp = attr.ib(True)
with_webkit = attr.ib(True)
known_distribution = attr.ib(True)
ssl_support = attr.ib(True)
@@ -909,7 +918,7 @@ class VersionParams:
VersionParams('normal'),
VersionParams('no-git-commit', git_commit=False),
VersionParams('frozen', frozen=True),
- VersionParams('no-style', style=False),
+ VersionParams('no-qapp', qapp=False),
VersionParams('no-webkit', with_webkit=False),
VersionParams('unknown-dist', known_distribution=False),
VersionParams('no-ssl', ssl_support=False),
@@ -937,8 +946,9 @@ def test_version_output(params, stubs, monkeypatch, config_stub):
'platform.architecture': lambda: ('ARCHITECTURE', ''),
'_os_info': lambda: ['OS INFO 1', 'OS INFO 2'],
'_path_info': lambda: {'PATH DESC': 'PATH NAME'},
- 'QApplication': (stubs.FakeQApplication(style='STYLE')
- if params.style else
+ 'QApplication': (stubs.FakeQApplication(style='STYLE',
+ platform_name='PLATFORM')
+ if params.qapp else
stubs.FakeQApplication(instance=None)),
'QLibraryInfo.location': (lambda _loc: 'QT PATH'),
'sql.version': lambda: 'SQLITE VERSION',
@@ -948,7 +958,9 @@ def test_version_output(params, stubs, monkeypatch, config_stub):
substitutions = {
'git_commit': '\nGit commit: GIT COMMIT' if params.git_commit else '',
- 'style': '\nStyle: STYLE' if params.style else '',
+ 'style': '\nStyle: STYLE' if params.qapp else '',
+ 'platform_plugin': ('\nPlatform plugin: PLATFORM' if params.qapp
+ else ''),
'qt': 'QT VERSION',
'frozen': str(params.frozen),
'import_path': import_path,
@@ -1014,7 +1026,7 @@ def test_version_output(params, stubs, monkeypatch, config_stub):
pdf.js: PDFJS VERSION
sqlite: SQLITE VERSION
QtNetwork SSL: {ssl}
- {style}
+ {style}{platform_plugin}
Platform: PLATFORM, ARCHITECTURE{linuxdist}
Frozen: {frozen}
Imported from {import_path}
diff --git a/tox.ini b/tox.ini
index 17fde13b9..00b14bfb0 100644
--- a/tox.ini
+++ b/tox.ini
@@ -39,26 +39,6 @@ commands =
# other envs
-[testenv:mkvenv]
-basepython = {env:PYTHON:python3}
-commands = {envpython} scripts/mkvenv.py --tox-error --pyqt-type link
-usedevelop = true
-deps =
-
-# This is undocumented, but it's a common typo, so let's make it work
-[testenv:mkenv]
-basepython = {[testenv:mkvenv]basepython}
-commands = {[testenv:mkvenv]commands}
-usedevelop = {[testenv:mkvenv]usedevelop}
-deps = {[testenv:mkvenv]deps}
-
-# Virtualenv with PyQt5 from PyPI
-[testenv:mkvenv-pypi]
-basepython = {env:PYTHON:python3}
-commands = {envpython} scripts/mkvenv.py --tox-error
-usedevelop = true
-deps =
-
[testenv:misc]
ignore_errors = true
basepython = {env:PYTHON:python3}
@@ -187,6 +167,17 @@ deps =
commands =
{envbindir}/pyinstaller --noconfirm misc/qutebrowser.spec
+[testenv:pyinstaller32]
+# A copy of the pyinstaller environment above, to be used for 32-bit on Windows
+# to make sure the both installations are separated.
+# This doesn't actually do anything 32-bit specific, that part happens by
+# setting the PYTHON environment variable accordingly.
+basepython = {[testenv:pyinstaller]basepython}
+pip_version = {[testenv:pyinstaller]pip_version}
+passenv = {[testenv:pyinstaller]passenv}
+deps = {[testenv:pyinstaller]deps}
+commands = {[testenv:pyinstaller]commands}
+
[testenv:eslint]
# This is duplicated in travis_run.sh for Travis CI because we can't get tox in
# the JavaScript environment easily.
@@ -204,7 +195,6 @@ deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/misc/requirements/requirements-dev.txt
-r{toxinidir}/misc/requirements/requirements-tests.txt
- -r{toxinidir}/misc/requirements/requirements-pyqt.txt
-r{toxinidir}/misc/requirements/requirements-mypy.txt
commands =
{envpython} -m mypy qutebrowser tests {posargs}
diff --git a/www/header.asciidoc b/www/header.asciidoc
index 2f8ed6a1e..66f6f2bb3 100644
--- a/www/header.asciidoc
+++ b/www/header.asciidoc
@@ -28,9 +28,5 @@ time, your help is needed! See the
information. Depending on your sign-up date and how long you keep a certain
level, you can get qutebrowser t-shirts, stickers and more!
</p>
-<p>
-Thanks to the GitHub Sponsors Matching Fund, all donations done via GitHub
-Sponsors (up to a $5000 total) will be doubled until October 2020.
-</p>
</div>
+++