summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2020-06-18 13:48:19 +0200
committerFlorian Bruhin <me@the-compiler.org>2020-06-18 13:48:19 +0200
commit1c01420aec64061837b9b71a9c15d2d86acca9a6 (patch)
tree122bb25ef92919ae791148329d537f9cc8f130f0
parentc7ab818743f81a083a4749b0938b562506ab79ee (diff)
parentf0eed465ab608061212366c6ebc26a0c47803060 (diff)
downloadqutebrowser-1c01420aec64061837b9b71a9c15d2d86acca9a6.tar.gz
qutebrowser-1c01420aec64061837b9b71a9c15d2d86acca9a6.zip
Merge branch 'master' into docked-inspector
-rw-r--r--.appveyor.yml4
-rw-r--r--.bumpversion.cfg2
-rw-r--r--.github/ISSUE_TEMPLATE/3_Support_question.md16
-rw-r--r--.github/ISSUE_TEMPLATE/config.yml5
-rw-r--r--.github/workflows/codeql-analysis.yml33
-rw-r--r--.mypy.ini (renamed from mypy.ini)0
-rw-r--r--.travis.yml20
-rw-r--r--README.asciidoc12
-rw-r--r--doc/changelog.asciidoc109
-rw-r--r--doc/faq.asciidoc4
-rw-r--r--doc/help/commands.asciidoc47
-rw-r--r--doc/help/settings.asciidoc294
-rw-r--r--doc/qutebrowser.1.asciidoc2
-rw-r--r--doc/stacktrace.asciidoc21
-rw-r--r--misc/org.qutebrowser.qutebrowser.appdata.xml1
-rw-r--r--misc/requirements/requirements-codecov.txt4
-rw-r--r--misc/requirements/requirements-dev.txt11
-rw-r--r--misc/requirements/requirements-dev.txt-raw1
-rw-r--r--misc/requirements/requirements-flake8.txt6
-rw-r--r--misc/requirements/requirements-mypy.txt2
-rw-r--r--misc/requirements/requirements-pip.txt6
-rw-r--r--misc/requirements/requirements-pylint.txt6
-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.txt2
-rw-r--r--misc/requirements/requirements-pyqt-5.15.txt5
-rw-r--r--misc/requirements/requirements-pyqt-5.15.txt-raw4
-rw-r--r--misc/requirements/requirements-pyqt.txt6
-rw-r--r--misc/requirements/requirements-sphinx.txt8
-rw-r--r--misc/requirements/requirements-tests.txt24
-rw-r--r--misc/requirements/requirements-tests.txt-raw3
-rw-r--r--misc/requirements/requirements-tox.txt8
-rw-r--r--misc/requirements/requirements-vulture.txt2
-rwxr-xr-xmisc/userscripts/tor_identity29
-rw-r--r--qutebrowser/__init__.py2
-rw-r--r--qutebrowser/app.py17
-rw-r--r--qutebrowser/browser/browsertab.py27
-rw-r--r--qutebrowser/browser/commands.py35
-rw-r--r--qutebrowser/browser/eventfilter.py9
-rw-r--r--qutebrowser/browser/pdfjs.py25
-rw-r--r--qutebrowser/browser/qutescheme.py53
-rw-r--r--qutebrowser/browser/shared.py4
-rw-r--r--qutebrowser/browser/webengine/interceptor.py8
-rw-r--r--qutebrowser/browser/webengine/webenginequtescheme.py12
-rw-r--r--qutebrowser/browser/webengine/webenginesettings.py8
-rw-r--r--qutebrowser/browser/webengine/webenginetab.py92
-rw-r--r--qutebrowser/browser/webengine/webview.py22
-rw-r--r--qutebrowser/browser/webkit/network/networkmanager.py18
-rw-r--r--qutebrowser/browser/webkit/network/webkitqutescheme.py2
-rw-r--r--qutebrowser/browser/webkit/webkittab.py198
-rw-r--r--qutebrowser/commands/command.py4
-rw-r--r--qutebrowser/commands/userscripts.py3
-rw-r--r--qutebrowser/completion/completionwidget.py4
-rw-r--r--qutebrowser/components/adblock.py6
-rw-r--r--qutebrowser/components/caretcommands.py10
-rw-r--r--qutebrowser/config/configcommands.py2
-rw-r--r--qutebrowser/config/configdata.yml249
-rw-r--r--qutebrowser/config/configfiles.py33
-rw-r--r--qutebrowser/config/configinit.py89
-rw-r--r--qutebrowser/config/configtypes.py154
-rw-r--r--qutebrowser/html/warning-sessions.html3
-rw-r--r--qutebrowser/javascript/.eslintrc.yaml1
-rw-r--r--qutebrowser/javascript/caret.js86
-rw-r--r--qutebrowser/javascript/globalthis_quirk.user.js9
-rw-r--r--qutebrowser/keyinput/basekeyparser.py88
-rw-r--r--qutebrowser/keyinput/keyutils.py15
-rw-r--r--qutebrowser/keyinput/modeman.py83
-rw-r--r--qutebrowser/keyinput/modeparsers.py140
-rw-r--r--qutebrowser/mainwindow/mainwindow.py9
-rw-r--r--qutebrowser/mainwindow/statusbar/bar.py38
-rw-r--r--qutebrowser/mainwindow/statusbar/keystring.py7
-rw-r--r--qutebrowser/mainwindow/tabbedbrowser.py7
-rw-r--r--qutebrowser/mainwindow/tabwidget.py27
-rw-r--r--qutebrowser/misc/backendproblem.py144
-rw-r--r--qutebrowser/misc/consolewidget.py23
-rw-r--r--qutebrowser/misc/crashdialog.py22
-rw-r--r--qutebrowser/misc/crashsignal.py17
-rw-r--r--qutebrowser/misc/ipc.py12
-rw-r--r--qutebrowser/misc/keyhintwidget.py6
-rw-r--r--qutebrowser/misc/utilcmds.py32
-rw-r--r--qutebrowser/qutebrowser.py13
-rw-r--r--qutebrowser/utils/error.py1
-rw-r--r--qutebrowser/utils/log.py135
-rw-r--r--qutebrowser/utils/message.py2
-rw-r--r--qutebrowser/utils/qtutils.py21
-rw-r--r--qutebrowser/utils/usertypes.py4
-rw-r--r--qutebrowser/utils/utils.py15
-rw-r--r--qutebrowser/utils/version.py108
-rwxr-xr-xscripts/asciidoc2html.py141
-rw-r--r--scripts/dev/misc_checks.py2
-rwxr-xr-xscripts/dev/src2asciidoc.py5
-rw-r--r--scripts/setupcommon.py22
-rw-r--r--tests/conftest.py6
-rw-r--r--tests/end2end/features/caret.feature3
-rw-r--r--tests/end2end/features/conftest.py11
-rw-r--r--tests/end2end/features/hints.feature4
-rw-r--r--tests/end2end/features/private.feature2
-rw-r--r--tests/end2end/features/qutescheme.feature23
-rw-r--r--tests/end2end/features/sessions.feature1
-rw-r--r--tests/end2end/features/utilcmds.feature6
-rw-r--r--tests/end2end/fixtures/quteprocess.py17
-rw-r--r--tests/end2end/fixtures/testprocess.py5
-rw-r--r--tests/end2end/test_invocations.py3
-rw-r--r--tests/helpers/fixtures.py30
-rw-r--r--tests/helpers/stubs.py7
-rw-r--r--tests/helpers/utils.py12
-rw-r--r--tests/manual/mouse.html5
-rw-r--r--tests/unit/api/test_cmdutils.py21
-rw-r--r--tests/unit/browser/test_caret.py144
-rw-r--r--tests/unit/browser/test_pdfjs.py9
-rw-r--r--tests/unit/browser/test_urlmarks.py (renamed from tests/unit/browser/urlmarks.py)8
-rw-r--r--tests/unit/config/test_configcommands.py13
-rw-r--r--tests/unit/config/test_configdata.py14
-rw-r--r--tests/unit/config/test_configfiles.py35
-rw-r--r--tests/unit/config/test_configinit.py132
-rw-r--r--tests/unit/config/test_configtypes.py85
-rw-r--r--tests/unit/keyinput/conftest.py16
-rw-r--r--tests/unit/keyinput/test_basekeyparser.py327
-rw-r--r--tests/unit/keyinput/test_bindingtrie.py34
-rw-r--r--tests/unit/keyinput/test_keyutils.py28
-rw-r--r--tests/unit/keyinput/test_modeman.py6
-rw-r--r--tests/unit/keyinput/test_modeparsers.py87
-rw-r--r--tests/unit/mainwindow/test_tabbedbrowser.py32
-rw-r--r--tests/unit/misc/test_editor.py58
-rw-r--r--tests/unit/misc/test_ipc.py36
-rw-r--r--tests/unit/misc/test_keyhints.py19
-rw-r--r--tests/unit/misc/test_lineparser.py31
-rw-r--r--tests/unit/misc/test_sessions.py77
-rw-r--r--tests/unit/misc/test_utilcmds.py13
-rw-r--r--tests/unit/scripts/test_check_coverage.py13
-rw-r--r--tests/unit/scripts/test_dictcli.py37
-rw-r--r--tests/unit/scripts/test_importer.py18
-rw-r--r--tests/unit/scripts/test_run_vulture.py22
-rw-r--r--tests/unit/test_qutebrowser.py62
-rw-r--r--tests/unit/utils/test_error.py13
-rw-r--r--tests/unit/utils/test_log.py184
-rw-r--r--tests/unit/utils/test_qtutils.py6
-rw-r--r--tests/unit/utils/test_standarddir.py1
-rw-r--r--tests/unit/utils/test_urlutils.py3
-rw-r--r--tests/unit/utils/test_utils.py7
-rw-r--r--tests/unit/utils/test_version.py96
-rw-r--r--tox.ini7
142 files changed, 3332 insertions, 1522 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index 0ee670b37..47ad9964a 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -10,8 +10,8 @@ image:
environment:
PYTHONUNBUFFERED: 1
- PYTHON: C:\Python37-x64\python.exe
- TESTENV: py37-pyqt514
+ PYTHON: C:\Python38-x64\python.exe
+ TESTENV: py38-pyqt514
install:
- '%PYTHON% --version'
diff --git a/.bumpversion.cfg b/.bumpversion.cfg
index c5defd11a..c260a28da 100644
--- a/.bumpversion.cfg
+++ b/.bumpversion.cfg
@@ -1,5 +1,5 @@
[bumpversion]
-current_version = 1.11.1
+current_version = 1.12.0
commit = True
message = Release v{new_version}
tag = True
diff --git a/.github/ISSUE_TEMPLATE/3_Support_question.md b/.github/ISSUE_TEMPLATE/3_Support_question.md
deleted file mode 100644
index 9d67d716b..000000000
--- a/.github/ISSUE_TEMPLATE/3_Support_question.md
+++ /dev/null
@@ -1,16 +0,0 @@
----
-name: ❓ Support Question
-about: It's okay to ask questions via GitHub, but IRC/Reddit/Mailinglist might be better.
-
----
-
-<!--
-While it's fine to ask questions here, check the documentation for better
-ways to get help:
-
-https://github.com/qutebrowser/qutebrowser#getting-help
--->
-
-**Version info (see `:version`)**:
-
-**If applicable: Does the issue happen if you start with `--temp-basedir`?**:
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 000000000..f736a6fd6
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,5 @@
+blank_issues_enabled: false
+contact_links:
+ - name: ❓ Support Question
+ url: https://github.com/qutebrowser/qutebrowser/discussions
+ about: Use GitHub's new discussions feature for questions
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
new file mode 100644
index 000000000..5de8a8726
--- /dev/null
+++ b/.github/workflows/codeql-analysis.yml
@@ -0,0 +1,33 @@
+name: "Code scanning"
+
+on:
+ push:
+ pull_request:
+ schedule:
+ - cron: '0 3 * * 1'
+
+jobs:
+ CodeQL-Build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v2
+ with:
+ # We must fetch at least the immediate parents so that if this is
+ # a pull request then we can checkout the head.
+ fetch-depth: 2
+
+ # If this run was triggered by a pull request event, then checkout
+ # the head of the pull request instead of the merge commit.
+ - run: git checkout HEAD^2
+ if: ${{ github.event_name == 'pull_request' }}
+
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v1
+ with:
+ languages: javascript, python
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v1
diff --git a/mypy.ini b/.mypy.ini
index edab4b930..edab4b930 100644
--- a/mypy.ini
+++ b/.mypy.ini
diff --git a/.travis.yml b/.travis.yml
index 4ca28c375..28ad24af9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -45,7 +45,6 @@ matrix:
### PyQt 5.12 (Python 3.8)
- env: TESTENV=py38-pyqt512
- # http://code.qt.io/cgit/qt/qtbase.git/commit/?id=c3a963da1f9e7b1d37e63eedded61da4fbdaaf9a
addons:
apt:
packages:
@@ -53,20 +52,31 @@ matrix:
### PyQt 5.13 (Python 3.8)
- env: TESTENV=py38-pyqt513
- # http://code.qt.io/cgit/qt/qtbase.git/commit/?id=c3a963da1f9e7b1d37e63eedded61da4fbdaaf9a
addons:
apt:
packages:
- libxkbcommon-x11-0
- ### PyQt 5.14 (Python 3.8, with coverage)
- - env: TESTENV=py38-pyqt514-cov
- # http://code.qt.io/cgit/qt/qtbase.git/commit/?id=c3a963da1f9e7b1d37e63eedded61da4fbdaaf9a
+ ### PyQt 5.14 (Python 3.8)
+ - env: TESTENV=py38-pyqt514
addons:
apt:
packages:
- libxkbcommon-x11-0
+ ### PyQt 5.15 (Python 3.8, with coverage)
+ - env: TESTENV=py38-pyqt515-cov
+ addons:
+ apt:
+ packages:
+ - libxkbcommon-x11-0
+ - libxcb-icccm4
+ - libxcb-image0
+ - libxcb-keysyms1
+ - libxcb-randr0
+ - libxcb-render-util0
+ - libxcb-xinerama0
+
### macOS Mojave (10.14)
- os: osx
env: TESTENV=py37-pyqt514 OSX=mojave
diff --git a/README.asciidoc b/README.asciidoc
index 41d0e7f1b..1c943da40 100644
--- a/README.asciidoc
+++ b/README.asciidoc
@@ -81,6 +81,11 @@ get sent to the general qutebrowser@ list).
If you're a reddit user, there's a
https://www.reddit.com/r/qutebrowser/[/r/qutebrowser] subreddit there.
+Finally, qutebrowser is participating in the Beta for GitHub's new Discussions
+feature, so you can also use the
+https://github.com/qutebrowser/qutebrowser/discussions[discussions tab] on
+GitHub to get in touch.
+
Contributions / Bugs
--------------------
@@ -206,8 +211,8 @@ link:doc/backers.asciidoc[crowdfunding campaigns]!
Similar projects
----------------
-Many projects with a similar goal as qutebrowser exist.
-Most of them were inspirations for qutebrowser in some way, thanks for that!
+Various projects with a similar goal like qutebrowser exist.
+Many of them were inspirations for qutebrowser in some way, thanks for that!
Active
~~~~~~
@@ -215,8 +220,9 @@ 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://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://next.atlas.engineer/[next] (Lisp, Emacs-like but also offers Vim bindings, QtWebKit or GTK+/WebKit2 - 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)
+* https://vieb.dev/[Vieb] (JavaScript, Electron)
* Chrome/Chromium addons:
https://vimium.github.io/[Vimium],
* Firefox addons (based on WebExtensions):
diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc
index 001089247..9596a41ad 100644
--- a/doc/changelog.asciidoc
+++ b/doc/changelog.asciidoc
@@ -15,7 +15,90 @@ 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.12.0 (unreleased)
+v1.13.0 (unreleased)
+--------------------
+
+Removed
+~~~~~~~
+
+- The `:debug-log-level` command was removed as it's replaced by the new
+ `logging.level.console` setting.
+- The `qute://plainlog` special page got replaced by `qute://log?plain` - the
+ names of those pages is considered an implementation detail, and
+ `:messages --plain` should be used instead.
+
+Changed
+~~~~~~~
+
+- New handling of bindings in hint mode which fixes various bugs and allows for
+ single-letter keybindings in hint mode.
+- The `tor_identity` userscript now takes the password via a `-p` flag and has
+ a new `-c` flag to customize the Tor control port.
+- `:config-write-py` now adds a note about `config.py` files being targeted at
+ advanced users.
+- `:report` now takes two optional arguments for bug/contact information, so
+ that it can be used without the report window popping up.
+- New `t[Cc][Hh]` default bindings which work similarly to the `t[Ss][Hh]`
+ bindings for JavaScript but toggle cookie permissions.
+- The `:message` command now takes a `--logfilter` / `-f` argument, which is a
+ list of logging categories to show.
+- The `:debug-log-filter` command now understands the full logfilter syntax.
+- Changes to settings:
+ * `fonts.tabs` has been split into `fonts.tabs.{selected,unselected}` (see
+ below).
+ * `statusbar.hide` has been renamed to `statusbar.show` with the possible
+ values being `always` (`hide = False`), `never` (`hide = True`) or
+ `in-mode` (new, only show statusbar outside of normal mode.
+ * The `QtFont` config type formerly used for `fonts.tabs` and
+ `fonts.debug_console` is now removed and entirely replaced by `Font`. The
+ former distinction was mainly an implementation detail, and the accepted
+ values shouldn't have changed.
+ * `input.rocker_gestures` has been renamed to `input.mouse.rocker_gestures`.
+ * `content.dns_prefetch` is now enabled by default again, since the crashes
+ it caused are now fixed (Qt 5.15) or worked around.
+- The statusbar now shows partial keychains in all modes (e.g. while hinting)
+- Small performance improvements.
+
+Added
+~~~~~
+
+- New settings:
+ * `logging.level.ram` and `logging.level.console` to configure the default
+ logging levels via the config.
+ * `fonts.tabs.selected` and `fonts.tabs.unselected` to set the font of the
+ selected tab independently from unselected tabs (e.g. to make it bold).
+ * `input.mouse.back_forward_buttons` which can be set to `false` to disable
+ back/forward mouse buttons.
+
+Fixed
+~~~~~
+
+- Crash when `tabs.focus_stack_size` is set to -1.
+- Crash when a `pdf.js` file for PDF.js exists, but `viewer.html` does not.
+- Crash when `:completion-item-yank --sel` is used on a platform without
+ primary selection support (e.g. Windows/macOS).
+- Crash when there's a feature permission request from Qt with an invalid URL
+ (which seems to happen with Qt 5.15 sometimes).
+- Crash in rare cases where QtWebKit/QtWebEngine imports fail in unexpected
+ ways.
+- Crash when something removed qutebrowser's IPC socket file and it's been
+ running for 6 hours.
+- `:config-write-py` now works with paths starting with `~/...` again.
+- New site-specific quirk for a missing `globalThis` in Qt <= 5.12 on Reddit
+ and Spotify.
+- When `;` is added to `hints.chars`, using hint labels containing `;;` now
+ works properly.
+- Hint letters outside of ASCII should now work.
+- When `bindings.key_mappings` is used with hints, it now works properly with
+ letters outside of ASCII as well.
+- With Qt 5.15, the audible/muted indicators are not updated properly due to a
+ Qt bug. This release adds a workaround so that at least the muted indicator
+ is shown properly.
+- As a workaround for crashes with QtWebEngine versions between 5.12 and 5.14
+ (inclusive), changing the user agent (`content.headers.user_agent`) exposed
+ to JS now requires a restart. The corresponding HTTP header is not affected.
+
+v1.12.0 (2020-06-01)
--------------------
Removed
@@ -36,19 +119,26 @@ Added
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 `--debug-flag log-cookies` to log cookies to the debug log.
- 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
~~~~~~~
+- Windows and macOS releases now ship Qt 5.15, which is based on Chromium
+ 80.0.3987.163 with security fixes up to 81.0.4044.138.
- 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
~~~~~
@@ -59,6 +149,19 @@ Fixed
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.
+- A site specific quirk to allow typing accented characters on Google
+ Docs was active for docs.google.com, but not drive.google.com. It is
+ now applied for both subdomains.
+- With older graphics hardware (OpenGL < 4.3) with Qt 5.14 on Wayland, WebGL
+ causes segfaults. Now qutebrowser detects that combination and suggests to
+ disable WebGL or use XWayland.
v1.11.1 (2020-05-07)
--------------------
diff --git a/doc/faq.asciidoc b/doc/faq.asciidoc
index 3df5b8e40..651df9665 100644
--- a/doc/faq.asciidoc
+++ b/doc/faq.asciidoc
@@ -305,13 +305,13 @@ If you ever need to renew any of these certificates, you can take a look
at the currently imported certificates using:
+
----
-certutil -D "sql:${HOME}/.pki/nssdb" -L
+certutil -d "sql:${HOME}/.pki/nssdb" -L
----
+
Then remove the expired certificates using:
+
----
-certutil -D "sql:${HOME}/.pki/nssdb" -D -n "My Fancy Certificate Nickname"
+certutil -d "sql:${HOME}/.pki/nssdb" -D -n "My Fancy Certificate Nickname"
----
+
And then import the new and valid certificates using the procedure
diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc
index 7c8da37a8..8d70b19c8 100644
--- a/doc/help/commands.asciidoc
+++ b/doc/help/commands.asciidoc
@@ -286,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.
@@ -608,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.
@@ -811,7 +809,7 @@ Show a warning message in the statusbar.
[[messages]]
=== messages
-Syntax: +:messages [*--plain*] [*--tab*] [*--bg*] [*--window*] ['level']+
+Syntax: +:messages [*--plain*] [*--tab*] [*--bg*] [*--window*] [*--logfilter* 'logfilter'] ['level']+
Show a log of past messages.
@@ -824,6 +822,9 @@ Show a log of past messages.
* +*-t*+, +*--tab*+: Open in a new tab.
* +*-b*+, +*--bg*+: Open in a background tab.
* +*-w*+, +*--window*+: Open in a new window.
+* +*-f*+, +*--logfilter*+: A comma-separated filter string of logging categories. If the filter string starts with an exclamation mark, it
+ is negated.
+
[[navigate]]
=== navigate
@@ -866,8 +867,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.
@@ -1018,8 +1018,15 @@ Which count to pass the command.
[[report]]
=== report
+Syntax: +:report ['info'] ['contact']+
+
Report a bug in qutebrowser.
+==== positional arguments
+* +'info'+: Information about the bug report. If given, no report dialog shows up.
+
+* +'contact'+: Contact information for the report.
+
[[restart]]
=== restart
Restart qutebrowser while keeping existing tabs open.
@@ -1197,9 +1204,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.
@@ -1263,9 +1268,7 @@ 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 an external command.
@@ -1348,7 +1351,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.
@@ -1359,6 +1362,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).
@@ -1903,8 +1907,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.
@@ -1923,7 +1932,6 @@ These commands are mainly intended for debugging. They are hidden if qutebrowser
|<<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.
|<<debug-pyeval,debug-pyeval>>|Evaluate a python string and display the results as a web page.
|<<debug-set-fake-clipboard,debug-set-fake-clipboard>>|Put data into the fake clipboard and enable logging, used for tests.
|<<debug-trace,debug-trace>>|Trace executed code via hunter.
@@ -1998,15 +2006,6 @@ Change the log filter for console logging.
* +'filters'+: A comma separated list of logger names. Can also be "none" to clear any existing filters.
-[[debug-log-level]]
-=== debug-log-level
-Syntax: +:debug-log-level 'level'+
-
-Change the log level for console logging.
-
-==== positional arguments
-* +'level'+: The log level to set.
-
[[debug-pyeval]]
=== debug-pyeval
Syntax: +:debug-pyeval [*--file*] [*--quiet*] 's'+
diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc
index cf6ee2069..8fde54613 100644
--- a/doc/help/settings.asciidoc
+++ b/doc/help/settings.asciidoc
@@ -111,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.
@@ -205,7 +214,8 @@
|<<fonts.messages.warning,fonts.messages.warning>>|Font used for warning messages.
|<<fonts.prompts,fonts.prompts>>|Font used for prompts.
|<<fonts.statusbar,fonts.statusbar>>|Font used in the statusbar.
-|<<fonts.tabs,fonts.tabs>>|Font used in the tab bar.
+|<<fonts.tabs.selected,fonts.tabs.selected>>|Font used for selected tabs.
+|<<fonts.tabs.unselected,fonts.tabs.unselected>>|Font used for unselected tabs.
|<<fonts.web.family.cursive,fonts.web.family.cursive>>|Font family for cursive fonts.
|<<fonts.web.family.fantasy,fonts.web.family.fantasy>>|Font family for fantasy fonts.
|<<fonts.web.family.fixed,fonts.web.family.fixed>>|Font family for fixed fonts.
@@ -242,12 +252,15 @@
|<<input.insert_mode.leave_on_load,input.insert_mode.leave_on_load>>|Leave insert mode when starting a new page load.
|<<input.insert_mode.plugins,input.insert_mode.plugins>>|Switch to insert mode when clicking flash and other plugins.
|<<input.links_included_in_focus_chain,input.links_included_in_focus_chain>>|Include hyperlinks in the keyboard focus chain when tabbing.
+|<<input.mouse.back_forward_buttons,input.mouse.back_forward_buttons>>|Enable back and forward buttons on the mouse.
+|<<input.mouse.rocker_gestures,input.mouse.rocker_gestures>>|Enable Opera-like mouse rocker gestures.
|<<input.partial_timeout,input.partial_timeout>>|Timeout (in milliseconds) for partially typed key bindings.
-|<<input.rocker_gestures,input.rocker_gestures>>|Enable Opera-like mouse rocker gestures.
|<<input.spatial_navigation,input.spatial_navigation>>|Enable spatial navigation.
|<<keyhint.blacklist,keyhint.blacklist>>|Keychains that shouldn't be shown in the keyhint dialog.
|<<keyhint.delay,keyhint.delay>>|Time (in milliseconds) from pressing a key to seeing the keyhint dialog.
|<<keyhint.radius,keyhint.radius>>|Rounding radius (in pixels) for the edges of the keyhint dialog.
+|<<logging.level.console,logging.level.console>>|Level for console (stdout/stderr) logs. Ignored if the `--loglevel` or `--debug` CLI flags are used.
+|<<logging.level.ram,logging.level.ram>>|Level for in-memory logs.
|<<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.
@@ -268,9 +281,9 @@
|<<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.
-|<<statusbar.hide,statusbar.hide>>|Hide the statusbar unless a message is shown.
|<<statusbar.padding,statusbar.padding>>|Padding (in pixels) for the statusbar.
|<<statusbar.position,statusbar.position>>|Position of the status bar.
+|<<statusbar.show,statusbar.show>>|When to show the statusbar.
|<<statusbar.widgets,statusbar.widgets>>|List of widgets displayed in the statusbar.
|<<tabs.background,tabs.background>>|Open new tabs (middleclick/ctrl+click) in the background.
|<<tabs.close_mouse_button,tabs.close_mouse_button>>|Mouse button with which to close tabs.
@@ -446,6 +459,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]+
@@ -590,6 +604,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]+
@@ -637,6 +652,9 @@ Default:
* +pass:[sk]+: +pass:[set-cmd-text -s :bind]+
* +pass:[sl]+: +pass:[set-cmd-text -s :set -t]+
* +pass:[ss]+: +pass:[set-cmd-text -s :set]+
+* +pass:[tCH]+: +pass:[config-cycle -p -u *://*.{url:host}/* content.cookies.accept all no-3rdparty never ;; reload]+
+* +pass:[tCh]+: +pass:[config-cycle -p -u *://{url:host}/* content.cookies.accept all no-3rdparty never ;; reload]+
+* +pass:[tCu]+: +pass:[config-cycle -p -u {url} content.cookies.accept all no-3rdparty never ;; reload]+
* +pass:[tIH]+: +pass:[config-cycle -p -u *://*.{url:host}/* content.images ;; reload]+
* +pass:[tIh]+: +pass:[config-cycle -p -u *://{url:host}/* content.images ;; reload]+
* +pass:[tIu]+: +pass:[config-cycle -p -u {url} content.images ;; reload]+
@@ -646,6 +664,9 @@ Default:
* +pass:[tSH]+: +pass:[config-cycle -p -u *://*.{url:host}/* content.javascript.enabled ;; reload]+
* +pass:[tSh]+: +pass:[config-cycle -p -u *://{url:host}/* content.javascript.enabled ;; reload]+
* +pass:[tSu]+: +pass:[config-cycle -p -u {url} content.javascript.enabled ;; reload]+
+* +pass:[tcH]+: +pass:[config-cycle -p -t -u *://*.{url:host}/* content.cookies.accept all no-3rdparty never ;; reload]+
+* +pass:[tch]+: +pass:[config-cycle -p -t -u *://{url:host}/* content.cookies.accept all no-3rdparty never ;; reload]+
+* +pass:[tcu]+: +pass:[config-cycle -p -t -u {url} content.cookies.accept all no-3rdparty never ;; reload]+
* +pass:[th]+: +pass:[back -t]+
* +pass:[tiH]+: +pass:[config-cycle -p -t -u *://*.{url:host}/* content.images ;; reload]+
* +pass:[tih]+: +pass:[config-cycle -p -t -u *://{url:host}/* content.images ;; reload]+
@@ -739,6 +760,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;]+
@@ -1531,6 +1553,161 @@ 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.
+WARNING: On Qt 5.15.0, this setting can cause frequent renderer process crashes due to a https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/304211[bug in Qt].
+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.
@@ -1760,6 +1937,7 @@ 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.
@@ -1820,7 +1998,7 @@ This setting supports URL patterns.
Type: <<types,Bool>>
-Default: +pass:[false]+
+Default: +pass:[true]+
On QtWebEngine, this setting requires Qt 5.12 or newer.
@@ -1937,7 +2115,9 @@ The following placeholders are defined:
The default value is equal to the unchanged user agent of
QtWebKit/QtWebEngine.
-Note that the value read from JavaScript is always the global value.
+Note that the value read from JavaScript is always the global value. With
+QtWebEngine between 5.12 and 5.14 (inclusive), changing the value exposed
+to JavaScript requires a restart.
This setting supports URL patterns.
@@ -2530,7 +2710,7 @@ Default: empty
=== fonts.debug_console
Font used for the debugging console.
-Type: <<types,QtFont>>
+Type: <<types,Font>>
Default: +pass:[default_size default_family]+
@@ -2618,11 +2798,19 @@ Type: <<types,Font>>
Default: +pass:[default_size default_family]+
-[[fonts.tabs]]
-=== fonts.tabs
-Font used in the tab bar.
+[[fonts.tabs.selected]]
+=== fonts.tabs.selected
+Font used for selected tabs.
-Type: <<types,QtFont>>
+Type: <<types,Font>>
+
+Default: +pass:[default_size default_family]+
+
+[[fonts.tabs.unselected]]
+=== fonts.tabs.unselected
+Font used for unselected tabs.
+
+Type: <<types,Font>>
Default: +pass:[default_size default_family]+
@@ -3027,17 +3215,16 @@ Type: <<types,Bool>>
Default: +pass:[true]+
-[[input.partial_timeout]]
-=== input.partial_timeout
-Timeout (in milliseconds) for partially typed key bindings.
-If the current input forms only partial matches, the keystring will be cleared after this time.
+[[input.mouse.back_forward_buttons]]
+=== input.mouse.back_forward_buttons
+Enable back and forward buttons on the mouse.
-Type: <<types,Int>>
+Type: <<types,Bool>>
-Default: +pass:[5000]+
+Default: +pass:[true]+
-[[input.rocker_gestures]]
-=== input.rocker_gestures
+[[input.mouse.rocker_gestures]]
+=== input.mouse.rocker_gestures
Enable Opera-like mouse rocker gestures.
This disables the context menu.
@@ -3045,6 +3232,15 @@ Type: <<types,Bool>>
Default: +pass:[false]+
+[[input.partial_timeout]]
+=== input.partial_timeout
+Timeout (in milliseconds) for partially typed key bindings.
+If the current input forms only partial matches, the keystring will be cleared after this time.
+
+Type: <<types,Int>>
+
+Default: +pass:[5000]+
+
[[input.spatial_navigation]]
=== input.spatial_navigation
Enable spatial navigation.
@@ -3081,6 +3277,40 @@ Type: <<types,Int>>
Default: +pass:[6]+
+[[logging.level.console]]
+=== logging.level.console
+Level for console (stdout/stderr) logs. Ignored if the `--loglevel` or `--debug` CLI flags are used.
+
+Type: <<types,LogLevel>>
+
+Valid values:
+
+ * +vdebug+
+ * +debug+
+ * +info+
+ * +warning+
+ * +error+
+ * +critical+
+
+Default: +pass:[info]+
+
+[[logging.level.ram]]
+=== logging.level.ram
+Level for in-memory logs.
+
+Type: <<types,LogLevel>>
+
+Valid values:
+
+ * +vdebug+
+ * +debug+
+ * +info+
+ * +warning+
+ * +error+
+ * +critical+
+
+Default: +pass:[debug]+
+
[[messages.timeout]]
=== messages.timeout
Duration (in milliseconds) to show messages in the statusbar for.
@@ -3373,14 +3603,6 @@ On QtWebEngine, this setting requires Qt 5.8 or newer.
On QtWebKit, this setting is unavailable.
-[[statusbar.hide]]
-=== statusbar.hide
-Hide the statusbar unless a message is shown.
-
-Type: <<types,Bool>>
-
-Default: +pass:[false]+
-
[[statusbar.padding]]
=== statusbar.padding
Padding (in pixels) for the statusbar.
@@ -3407,6 +3629,20 @@ Valid values:
Default: +pass:[bottom]+
+[[statusbar.show]]
+=== statusbar.show
+When to show the statusbar.
+
+Type: <<types,String>>
+
+Valid values:
+
+ * +always+: Always show the statusbar.
+ * +never+: Always hide the statusbar.
+ * +in-mode+: Show the statusbar when in modes other than normal mode.
+
+Default: +pass:[always]+
+
[[statusbar.widgets]]
=== statusbar.widgets
List of widgets displayed in the statusbar.
@@ -3862,7 +4098,7 @@ characters in the search terms are replaced by safe characters (called
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`.
Type: <<types,Dict>>
@@ -4003,6 +4239,7 @@ Lists with duplicate flags are invalid. Each item is checked against the valid v
When setting from a string, pass a json-like list, e.g. `["one", "two"]`.
|ListOrValue|A list of values, or a single value.
+|LogLevel|A logging level.
|NewTabPosition|How new tabs are positioned.
|Padding|Setting for paddings around elements.
|Perc|A percentage.
@@ -4015,9 +4252,6 @@ A value can be in one of the following formats: * `#RGB`/`#RRGGBB`/`#RRRGGGBBB`/
|QtColor|A color value.
A value can be in one of the following formats: * `#RGB`/`#RRGGBB`/`#RRRGGGBBB`/`#RRRRGGGGBBBB` * An SVG color name as specified in http://www.w3.org/TR/SVG/types.html#ColorKeywords[the W3C specification]. * transparent (no color) * `rgb(r, g, b)` / `rgba(r, g, b, a)` (values 0-255 or percentages) * `hsv(h, s, v)` / `hsva(h, s, v, a)` (values 0-255, hue 0-359)
-|QtFont|A font family, with optional style/weight/size.
-
-* Style: `normal`/`italic`/`oblique` * Weight: `normal`, `bold`, `100`..`900` * Size: _number_ `px`/`pt`
|Regex|A regular expression.
When setting from `config.py`, both a string or a `re.compile(...)` object are valid.
diff --git a/doc/qutebrowser.1.asciidoc b/doc/qutebrowser.1.asciidoc
index 52ed64d3e..8dae3eaef 100644
--- a/doc/qutebrowser.1.asciidoc
+++ b/doc/qutebrowser.1.asciidoc
@@ -67,7 +67,7 @@ show it.
=== debug arguments
*-l* '{critical,error,warning,info,debug,vdebug}', *--loglevel* '{critical,error,warning,info,debug,vdebug}'::
- Set loglevel
+ Override the configured console loglevel
*--logfilter* 'LOGFILTER'::
Comma-separated list of things to be logged to the debug log on stdout.
diff --git a/doc/stacktrace.asciidoc b/doc/stacktrace.asciidoc
index f38c54940..4dc327e0e 100644
--- a/doc/stacktrace.asciidoc
+++ b/doc/stacktrace.asciidoc
@@ -34,6 +34,27 @@ is available in the repositories:
# apt-get install python3-pyqt5-dbg python3-pyqt5.qtwebkit-dbg python3-dbg libqt5webkit5-dbg
----
+Fedora
+^^^^^^
+
+For Fedora you first need to install the dnf/yum-utils:
+
+----
+# dnf install dnf-utils
+----
+
+Or:
+
+----
+# yum install yum-utils
+----
+
+Then install the needed debuginfo packages:
+
+----
+# debuginfo-install python3 qt5-qtwebengine python3-qt5-webengine python3-qt5-base python-qt5 python3-qt5 python3-qt5-webkit
+----
+
Archlinux
^^^^^^^^^
diff --git a/misc/org.qutebrowser.qutebrowser.appdata.xml b/misc/org.qutebrowser.qutebrowser.appdata.xml
index ca58f4bd5..f02fcb00d 100644
--- a/misc/org.qutebrowser.qutebrowser.appdata.xml
+++ b/misc/org.qutebrowser.qutebrowser.appdata.xml
@@ -44,6 +44,7 @@
</content_rating>
<releases>
<!-- Add new releases here -->
+<release version="1.12.0" date="2020-06-01"/>
<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"/>
diff --git a/misc/requirements/requirements-codecov.txt b/misc/requirements/requirements-codecov.txt
index 54d5bdfb4..7e869803a 100644
--- a/misc/requirements/requirements-codecov.txt
+++ b/misc/requirements/requirements-codecov.txt
@@ -1,8 +1,8 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
-certifi==2020.4.5.1
+certifi==2020.4.5.2
chardet==3.0.4
-codecov==2.1.0
+codecov==2.1.4
coverage==5.1
idna==2.9
requests==2.23.0
diff --git a/misc/requirements/requirements-dev.txt b/misc/requirements/requirements-dev.txt
index 1c790abc4..cf4d246f4 100644
--- a/misc/requirements/requirements-dev.txt
+++ b/misc/requirements/requirements-dev.txt
@@ -1,7 +1,7 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
bump2version==1.0.0
-certifi==2020.4.5.1
+certifi==2020.4.5.2
cffi==1.14.0
chardet==3.0.4
colorama==0.4.3
@@ -11,17 +11,16 @@ github3.py==1.3.0
hunter==3.1.3
idna==2.9
jwcrypto==0.7
-lxml==4.5.0
manhole==1.6.0
-packaging==20.3
+packaging==20.4
pycparser==2.20
Pympler==0.8
pyparsing==2.4.7
-PyQt-builder==1.3.2
+PyQt-builder==1.4.0
python-dateutil==2.8.1
requests==2.23.0
-sip==5.2.0
-six==1.14.0
+sip==5.3.0
+six==1.15.0
toml==0.10.1
uritemplate==3.0.1
urllib3==1.25.9
diff --git a/misc/requirements/requirements-dev.txt-raw b/misc/requirements/requirements-dev.txt-raw
index f75a837af..71e19f502 100644
--- a/misc/requirements/requirements-dev.txt-raw
+++ b/misc/requirements/requirements-dev.txt-raw
@@ -4,5 +4,4 @@ pympler
github3.py
bump2version
requests
-lxml
pyqt-builder
diff --git a/misc/requirements/requirements-flake8.txt b/misc/requirements/requirements-flake8.txt
index e4b59b368..0cd0df369 100644
--- a/misc/requirements/requirements-flake8.txt
+++ b/misc/requirements/requirements-flake8.txt
@@ -1,10 +1,10 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
attrs==19.3.0
-flake8==3.8.1
+flake8==3.8.2
flake8-bugbear==20.1.4
flake8-builtins==1.5.3
-flake8-comprehensions==3.2.2
+flake8-comprehensions==3.2.3
flake8-copyright==0.2.2
flake8-debugger==3.2.1
flake8-deprecated==1.3
@@ -20,5 +20,5 @@ pep8-naming==0.10.0
pycodestyle==2.6.0
pydocstyle==5.0.2
pyflakes==2.2.0
-six==1.14.0
+six==1.15.0
snowballstemmer==2.0.0
diff --git a/misc/requirements/requirements-mypy.txt b/misc/requirements/requirements-mypy.txt
index 3900a8c20..7759f96b8 100644
--- a/misc/requirements/requirements-mypy.txt
+++ b/misc/requirements/requirements-mypy.txt
@@ -1,6 +1,6 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
-mypy==0.770
+mypy==0.780
mypy-extensions==0.4.3
-e git+https://github.com/stlehmann/PyQt5-stubs.git@master#egg=PyQt5_stubs
typed-ast==1.4.1
diff --git a/misc/requirements/requirements-pip.txt b/misc/requirements/requirements-pip.txt
index 92b8cf057..db2eb7a02 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.4
-packaging==20.3
+packaging==20.4
pyparsing==2.4.7
-setuptools==46.4.0
-six==1.14.0
+setuptools==47.1.1
+six==1.15.0
wheel==0.34.2
diff --git a/misc/requirements/requirements-pylint.txt b/misc/requirements/requirements-pylint.txt
index 1f5552a97..cb4892f9c 100644
--- a/misc/requirements/requirements-pylint.txt
+++ b/misc/requirements/requirements-pylint.txt
@@ -1,7 +1,7 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
astroid==2.3.3 # rq.filter: < 2.4
-certifi==2020.4.5.1
+certifi==2020.4.5.2
cffi==1.14.0
chardet==3.0.4
cryptography==2.9.2
@@ -9,14 +9,14 @@ github3.py==1.3.0
idna==2.9
isort==4.3.21
jwcrypto==0.7
-lazy-object-proxy==1.4.3
+lazy-object-proxy==1.5.0
mccabe==0.6.1
pycparser==2.20
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.9
diff --git a/misc/requirements/requirements-pyqt-5.12.txt b/misc/requirements/requirements-pyqt-5.12.txt
index b1be83265..9b458cd98 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.2
+PyQt5-sip==12.8.0
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 dc2f0359a..7c07eac3d 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.2
+PyQt5-sip==12.8.0
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 7640a8adb..c82acedb0 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.2 # rq.filter: < 5.15
-PyQt5-sip==12.7.2
+PyQt5-sip==12.8.0
PyQtWebEngine==5.14.0 # rq.filter: < 5.15
diff --git a/misc/requirements/requirements-pyqt-5.15.txt b/misc/requirements/requirements-pyqt-5.15.txt
new file mode 100644
index 000000000..c21b7b742
--- /dev/null
+++ b/misc/requirements/requirements-pyqt-5.15.txt
@@ -0,0 +1,5 @@
+# This file is automatically generated by scripts/dev/recompile_requirements.py
+
+PyQt5==5.15.0 # rq.filter: < 6
+PyQt5-sip==12.8.0
+PyQtWebEngine==5.15.0 # rq.filter: < 6
diff --git a/misc/requirements/requirements-pyqt-5.15.txt-raw b/misc/requirements/requirements-pyqt-5.15.txt-raw
new file mode 100644
index 000000000..c9eeb9fb7
--- /dev/null
+++ b/misc/requirements/requirements-pyqt-5.15.txt-raw
@@ -0,0 +1,4 @@
+#@ filter: PyQt5 < 6
+#@ filter: PyQtWebEngine < 6
+PyQt5 >= 5.15, < 6
+PyQtWebEngine >= 5.15, < 6
diff --git a/misc/requirements/requirements-pyqt.txt b/misc/requirements/requirements-pyqt.txt
index 90febc2e7..74d86e8d5 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.2
-PyQt5-sip==12.7.2
-PyQtWebEngine==5.14.0
+PyQt5==5.15.0
+PyQt5-sip==12.8.0
+PyQtWebEngine==5.15.0
diff --git a/misc/requirements/requirements-sphinx.txt b/misc/requirements/requirements-sphinx.txt
index 1556e1d93..5851b8b72 100644
--- a/misc/requirements/requirements-sphinx.txt
+++ b/misc/requirements/requirements-sphinx.txt
@@ -2,21 +2,21 @@
alabaster==0.7.12
Babel==2.8.0
-certifi==2020.4.5.1
+certifi==2020.4.5.2
chardet==3.0.4
docutils==0.16
idna==2.9
imagesize==1.2.0
Jinja2==2.11.2
MarkupSafe==1.1.1
-packaging==20.3
+packaging==20.4
Pygments==2.6.1
pyparsing==2.4.7
pytz==2020.1
requests==2.23.0
-six==1.14.0
+six==1.15.0
snowballstemmer==2.0.0
-Sphinx==3.0.3
+Sphinx==3.1.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==1.0.3
diff --git a/misc/requirements/requirements-tests.txt b/misc/requirements/requirements-tests.txt
index 8e94f36d6..ed4596a82 100644
--- a/misc/requirements/requirements-tests.txt
+++ b/misc/requirements/requirements-tests.txt
@@ -10,15 +10,15 @@ EasyProcess==0.3
Flask==1.1.2
glob2==0.7
hunter==3.1.3
-hypothesis==5.14.0
+hypothesis==5.16.0
itsdangerous==1.1.0
jaraco.functools==3.0.1 ; python_version>="3.6"
# Jinja2==2.11.2
-Mako==1.1.2
+Mako==1.1.3
manhole==1.6.0
# MarkupSafe==1.1.1
more-itertools==8.3.0
-packaging==20.3
+packaging==20.4
parse==1.15.0
parse-type==0.5.2
pluggy==0.13.1
@@ -26,22 +26,22 @@ py==1.8.1
py-cpuinfo==5.0.0
Pygments==2.6.1
pyparsing==2.4.7
-pytest==5.4.2
-pytest-bdd==3.3.0
+pytest==5.4.3
+pytest-bdd==3.4.0
pytest-benchmark==3.2.3
-pytest-cov==2.8.1
+pytest-cov==2.9.0
pytest-instafail==0.4.1.post0
-pytest-mock==3.1.0
+pytest-mock==3.1.1
pytest-qt==3.3.0
pytest-repeat==0.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
-sortedcontainers==2.1.0
+PyVirtualDisplay==0.2.5 # rq.filter: < 1.0
+six==1.15.0
+sortedcontainers==2.2.2
soupsieve==2.0.1
-vulture==1.4
-wcwidth==0.1.9
+vulture==1.5
+wcwidth==0.2.4
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 4d6932c82..d5a20dea3 100644
--- a/misc/requirements/requirements-tests.txt-raw
+++ b/misc/requirements/requirements-tests.txt-raw
@@ -12,6 +12,8 @@ pytest-mock
pytest-qt
pytest-rerunfailures
pytest-xvfb
+# https://github.com/The-Compiler/pytest-xvfb/issues/22
+PyVirtualDisplay < 1.0
## optional:
# To test :debug-trace, gets skipped if hunter is not installed
@@ -28,3 +30,4 @@ pytest-repeat
#@ markers: jaraco.functools python_version>="3.6"
#@ add: jaraco.functools==2.0; python_version<"3.6" # rq.filter: <= 2.0
#@ ignore: Jinja2, MarkupSafe, colorama
+#@ filter: PyVirtualDisplay < 1.0
diff --git a/misc/requirements/requirements-tox.txt b/misc/requirements/requirements-tox.txt
index 33bcd072b..dd288088d 100644
--- a/misc/requirements/requirements-tox.txt
+++ b/misc/requirements/requirements-tox.txt
@@ -3,13 +3,13 @@
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.7
-six==1.14.0
+six==1.15.0
toml==0.10.1
-tox==3.15.0
+tox==3.15.2
tox-pip-version==0.0.7
tox-venv==0.4.0
-virtualenv==20.0.20
+virtualenv==20.0.21
diff --git a/misc/requirements/requirements-vulture.txt b/misc/requirements/requirements-vulture.txt
index c5c343f9e..32d36560b 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.4
+vulture==1.5
diff --git a/misc/userscripts/tor_identity b/misc/userscripts/tor_identity
index 93b6d4136..1631a0b94 100755
--- a/misc/userscripts/tor_identity
+++ b/misc/userscripts/tor_identity
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
-# Copyright 2018 jnphilipp <mail@jnphilipp.org>
+# Copyright 2018-2020 J. Nathanael Philipp (jnphilipp) <nathanael@philipp.land>
#
# This file is part of qutebrowser.
#
@@ -30,6 +30,8 @@
import os
import sys
+from argparse import ArgumentParser
+
try:
from stem import Signal
from stem.control import Controller
@@ -41,12 +43,19 @@ except ImportError:
print('Failed to import stem.')
-password = sys.argv[1]
-with Controller.from_port(port=9051) as controller:
- controller.authenticate(password)
- controller.signal(Signal.NEWNYM)
- if os.getenv('QUTE_FIFO'):
- with open(os.environ['QUTE_FIFO'], 'w') as f:
- f.write('message-info "Tor identity changed."')
- else:
- print('Tor identity changed.')
+if __name__ == '__main__':
+ parser = ArgumentParser(prog='tor_identity')
+ parser.add_argument('-c', '--control-port', default=9051,
+ help='Tor control port (default 9051).')
+ parser.add_argument('-p', '--password', type=str, default=None,
+ help='Tor control port password.')
+ args = parser.parse_args()
+
+ with Controller.from_port(port=args.control_port) as controller:
+ controller.authenticate(args.password)
+ controller.signal(Signal.NEWNYM)
+ if os.getenv('QUTE_FIFO'):
+ with open(os.environ['QUTE_FIFO'], 'w') as f:
+ f.write('message-info "Tor identity changed."')
+ else:
+ print('Tor identity changed.')
diff --git a/qutebrowser/__init__.py b/qutebrowser/__init__.py
index 6d684d6e3..147606f42 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.11.1"
+__version__ = "1.12.0"
__version_info__ = tuple(int(part) for part in __version__.split('.'))
__description__ = "A keyboard-driven, vim-like browser based on PyQt5."
diff --git a/qutebrowser/app.py b/qutebrowser/app.py
index 6d01e0ddd..c90de481e 100644
--- a/qutebrowser/app.py
+++ b/qutebrowser/app.py
@@ -96,7 +96,7 @@ def run(args):
q_app.setApplicationVersion(qutebrowser.__version__)
if args.version:
- print(version.version())
+ print(version.version_info())
sys.exit(usertypes.Exit.ok)
quitter.init(args)
@@ -373,12 +373,23 @@ def open_desktopservices_url(url):
tabbed_browser.tabopen(url)
+# This is effectively a @config.change_filter
+# Howerver, logging is initialized too early to use that annotation
+def _on_config_changed(name: str) -> None:
+ if name.startswith('logging.'):
+ log.init_from_config(config.val)
+
+
def _init_modules(*, args):
"""Initialize all 'modules' which need to be initialized.
Args:
args: The argparse namespace.
"""
+ log.init.debug("Initializing logging from config...")
+ log.init_from_config(config.val)
+ config.instance.changed.connect(_on_config_changed)
+
log.init.debug("Initializing save manager...")
save_manager = savemanager.SaveManager(q_app)
objreg.register('save-manager', save_manager)
@@ -474,7 +485,9 @@ class Application(QApplication):
self._last_focus_object = None
qt_args = configinit.qt_args(args)
- log.init.debug("Qt arguments: {}, based on {}".format(qt_args, args))
+ log.init.debug("Commandline args: {}".format(sys.argv[1:]))
+ log.init.debug("Parsed: {}".format(args))
+ log.init.debug("Qt arguments: {}".format(qt_args[1:]))
super().__init__(qt_args)
objects.args = args
diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py
index f67a5b383..0ca0236cf 100644
--- a/qutebrowser/browser/browsertab.py
+++ b/qutebrowser/browser/browsertab.py
@@ -429,13 +429,24 @@ 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()
@@ -444,7 +455,6 @@ class AbstractCaret(QObject):
parent: QWidget = None) -> None:
super().__init__(parent)
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)
@@ -501,7 +511,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:
@@ -827,6 +837,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):
diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py
index 0d9cbb5c0..70c9ad7a6 100644
--- a/qutebrowser/browser/commands.py
+++ b/qutebrowser/browser/commands.py
@@ -453,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.
@@ -462,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 "
@@ -479,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(
@@ -488,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(),
@@ -1404,24 +1409,40 @@ class CommandDispatcher:
self._open(url, tab, bg, window)
@cmdutils.register(instance='command-dispatcher', scope='window')
- def messages(self, level='info', plain=False, tab=False, bg=False,
- window=False):
+ @cmdutils.argument('logfilter', flag='f')
+ def messages(self, level='info', *, plain=False, tab=False, bg=False,
+ window=False, logfilter=None):
"""Show a log of past messages.
Args:
level: Include messages with `level` or higher severity.
Valid values: vdebug, debug, info, warning, error, critical.
plain: Whether to show plaintext (as opposed to html).
+ logfilter: A comma-separated filter string of logging categories.
+ If the filter string starts with an exclamation mark, it
+ is negated.
tab: Open in a new tab.
bg: Open in a background tab.
window: Open in a new window.
"""
if level.upper() not in log.LOG_LEVELS:
raise cmdutils.CommandError("Invalid log level {}!".format(level))
+
+ query = QUrlQuery()
+ query.addQueryItem('level', level)
if plain:
- url = QUrl('qute://plainlog?level={}'.format(level))
- else:
- url = QUrl('qute://log?level={}'.format(level))
+ query.addQueryItem('plain', typing.cast(str, None))
+
+ if logfilter:
+ try:
+ log.LogFilter.parse(logfilter)
+ except log.InvalidLogFilterError as e:
+ raise cmdutils.CommandError(e)
+ query.addQueryItem('logfilter', logfilter)
+
+ url = QUrl('qute://log')
+ url.setQuery(query)
+
self._open(url, tab, bg, window)
def _open_editor_cb(self, elem):
diff --git a/qutebrowser/browser/eventfilter.py b/qutebrowser/browser/eventfilter.py
index 3702a469c..d91502092 100644
--- a/qutebrowser/browser/eventfilter.py
+++ b/qutebrowser/browser/eventfilter.py
@@ -131,7 +131,7 @@ class TabEventFilter(QObject):
Return:
True if the event should be filtered, False otherwise.
"""
- is_rocker_gesture = (config.val.input.rocker_gestures and
+ is_rocker_gesture = (config.val.input.mouse.rocker_gestures and
e.buttons() == Qt.LeftButton | Qt.RightButton)
if e.button() in [Qt.XButton1, Qt.XButton2] or is_rocker_gesture:
@@ -219,7 +219,7 @@ class TabEventFilter(QObject):
Return:
True if the event should be filtered, False otherwise.
"""
- return config.val.input.rocker_gestures
+ return config.val.input.mouse.rocker_gestures
def _handle_key_release(self, e):
"""Ignore repeated key release events going to the website.
@@ -291,6 +291,11 @@ class TabEventFilter(QObject):
Return:
True if the event should be filtered, False otherwise.
"""
+ if (not config.val.input.mouse.back_forward_buttons and
+ e.button() in [Qt.XButton1, Qt.XButton2]):
+ # Back and forward on mice are disabled
+ return
+
if e.button() in [Qt.XButton1, Qt.LeftButton]:
# Back button on mice which have it, or rocker gesture
if self._tab.history.can_go_back():
diff --git a/qutebrowser/browser/pdfjs.py b/qutebrowser/browser/pdfjs.py
index cca21abcb..0c6d02501 100644
--- a/qutebrowser/browser/pdfjs.py
+++ b/qutebrowser/browser/pdfjs.py
@@ -30,6 +30,19 @@ from qutebrowser.misc import objects
from qutebrowser.config import config
+_SYSTEM_PATHS = [
+ # Debian pdf.js-common
+ # Arch Linux pdfjs (AUR)
+ '/usr/share/pdf.js/',
+ # Flatpak (Flathub)
+ '/app/share/pdf.js/',
+ # Arch Linux pdf.js (AUR)
+ '/usr/share/javascript/pdf.js/',
+ # Debian libjs-pdf
+ '/usr/share/javascript/pdf/',
+]
+
+
class PDFJSNotFound(Exception):
"""Raised when no pdf.js installation is found.
@@ -130,16 +143,7 @@ def get_pdfjs_res_and_path(path):
content = None
file_path = None
- system_paths = [
- # Debian pdf.js-common
- # Arch Linux pdfjs (AUR)
- '/usr/share/pdf.js/',
- # Flatpak (Flathub)
- '/app/share/pdf.js/',
- # Arch Linux pdf.js (AUR)
- '/usr/share/javascript/pdf.js/',
- # Debian libjs-pdf
- '/usr/share/javascript/pdf/',
+ system_paths = _SYSTEM_PATHS + [
# fallback
os.path.join(standarddir.data(), 'pdfjs'),
# hardcoded fallback for --temp-basedir
@@ -224,6 +228,7 @@ def is_available():
"""Return true if a pdfjs installation is available."""
try:
get_pdfjs_res('build/pdf.js')
+ get_pdfjs_res('web/viewer.html')
except PDFJSNotFound:
return False
else:
diff --git a/qutebrowser/browser/qutescheme.py b/qutebrowser/browser/qutescheme.py
index 53004e66a..b661f533d 100644
--- a/qutebrowser/browser/qutescheme.py
+++ b/qutebrowser/browser/qutescheme.py
@@ -302,47 +302,50 @@ def qute_spawn_output(_url: QUrl) -> _HandlerRet:
def qute_version(_url):
"""Handler for qute://version."""
src = jinja.render('version.html', title='Version info',
- version=version.version(),
+ version=version.version_info(),
copyright=qutebrowser.__copyright__)
return 'text/html', src
-@add_handler('plainlog')
-def qute_plainlog(url: QUrl) -> _HandlerRet:
- """Handler for qute://plainlog.
-
- An optional query parameter specifies the minimum log level to print.
- For example, qute://log?level=warning prints warnings and errors.
- Level can be one of: vdebug, debug, info, warning, error, critical.
- """
- if log.ram_handler is None:
- text = "Log output was disabled."
- else:
- level = QUrlQuery(url).queryItemValue('level')
- if not level:
- level = 'vdebug'
- text = log.ram_handler.dump_log(html=False, level=level)
- src = jinja.render('pre.html', title='log', content=text)
- return 'text/html', src
-
-
@add_handler('log')
def qute_log(url: QUrl) -> _HandlerRet:
"""Handler for qute://log.
- An optional query parameter specifies the minimum log level to print.
+ There are three query parameters:
+
+ - level: The minimum log level to print.
For example, qute://log?level=warning prints warnings and errors.
Level can be one of: vdebug, debug, info, warning, error, critical.
+
+ - plain: If given (and not 'false'), plaintext is shown.
+
+ - logfilter: A filter string like the --logfilter commandline argument
+ accepts.
"""
+ query = QUrlQuery(url)
+ plain = (query.hasQueryItem('plain') and
+ query.queryItemValue('plain').lower() != 'false')
+
if log.ram_handler is None:
- html_log = None
+ content = "Log output was disabled." if plain else None
else:
- level = QUrlQuery(url).queryItemValue('level')
+ level = query.queryItemValue('level')
if not level:
level = 'vdebug'
- html_log = log.ram_handler.dump_log(html=True, level=level)
- src = jinja.render('log.html', title='log', content=html_log)
+ filter_str = query.queryItemValue('logfilter')
+
+ try:
+ logfilter = (log.LogFilter.parse(filter_str, only_debug=False)
+ if filter_str else None)
+ except log.InvalidLogFilterError as e:
+ raise UrlInvalidError(e)
+
+ content = log.ram_handler.dump_log(html=not plain,
+ level=level, logfilter=logfilter)
+
+ template = 'pre.html' if plain else 'log.html'
+ src = jinja.render(template, title='log', content=content)
return 'text/html', src
diff --git a/qutebrowser/browser/shared.py b/qutebrowser/browser/shared.py
index 4fbede419..a689e287a 100644
--- a/qutebrowser/browser/shared.py
+++ b/qutebrowser/browser/shared.py
@@ -160,7 +160,7 @@ def ignore_certificate_errors(url, errors, abort_on):
True if the error should be ignored, False otherwise.
"""
ssl_strict = config.instance.get('content.ssl_strict', url=url)
- log.webview.debug("Certificate errors {!r}, strict {}".format(
+ log.network.debug("Certificate errors {!r}, strict {}".format(
errors, ssl_strict))
for error in errors:
@@ -186,7 +186,7 @@ def ignore_certificate_errors(url, errors, abort_on):
ignore = False
return ignore
elif ssl_strict is False:
- log.webview.debug("ssl_strict is False, only warning about errors")
+ log.network.debug("ssl_strict is False, only warning about errors")
for err in errors:
# FIXME we might want to use warn here (non-fatal error)
# https://github.com/qutebrowser/qutebrowser/issues/114
diff --git a/qutebrowser/browser/webengine/interceptor.py b/qutebrowser/browser/webengine/interceptor.py
index 7d455d4c3..d4dcb522f 100644
--- a/qutebrowser/browser/webengine/interceptor.py
+++ b/qutebrowser/browser/webengine/interceptor.py
@@ -154,7 +154,7 @@ class RequestInterceptor(QWebEngineUrlRequestInterceptor):
info.resourceType())
navigation_type_str = debug.qenum_key(QWebEngineUrlRequestInfo,
info.navigationType())
- log.webview.debug("{} {}, first-party {}, resource {}, "
+ log.network.debug("{} {}, first-party {}, resource {}, "
"navigation {}".format(
bytes(info.requestMethod()).decode('ascii'),
info.requestUrl().toDisplayString(),
@@ -164,7 +164,7 @@ class RequestInterceptor(QWebEngineUrlRequestInterceptor):
url = info.requestUrl()
first_party = info.firstPartyUrl()
if not url.isValid():
- log.webview.debug("Ignoring invalid intercepted URL: {}".format(
+ log.network.debug("Ignoring invalid intercepted URL: {}".format(
url.errorString()))
return
@@ -173,7 +173,7 @@ class RequestInterceptor(QWebEngineUrlRequestInterceptor):
try:
resource_type = self._resource_types[info.resourceType()]
except KeyError:
- log.webview.warning(
+ log.network.warning(
"Resource type {} not found in RequestInterceptor dict."
.format(debug.qenum_key(QWebEngineUrlRequestInfo,
info.resourceType())))
@@ -184,7 +184,7 @@ class RequestInterceptor(QWebEngineUrlRequestInterceptor):
if (first_party != QUrl('qute://settings/') or
info.resourceType() !=
QWebEngineUrlRequestInfo.ResourceTypeXhr):
- log.webview.warning("Blocking malicious request from {} to {}"
+ log.network.warning("Blocking malicious request from {} to {}"
.format(first_party.toDisplayString(),
url.toDisplayString()))
info.block(True)
diff --git a/qutebrowser/browser/webengine/webenginequtescheme.py b/qutebrowser/browser/webengine/webenginequtescheme.py
index 2c69b521f..879f8aeca 100644
--- a/qutebrowser/browser/webengine/webenginequtescheme.py
+++ b/qutebrowser/browser/webengine/webenginequtescheme.py
@@ -86,9 +86,9 @@ class QuteSchemeHandler(QWebEngineUrlSchemeHandler):
return True
if initiator.isValid() and initiator.scheme() != 'qute':
- log.misc.warning("Blocking malicious request from {} to {}".format(
- initiator.toDisplayString(),
- request_url.toDisplayString()))
+ log.network.warning("Blocking malicious request from {} to {}"
+ .format(initiator.toDisplayString(),
+ request_url.toDisplayString()))
job.fail(QWebEngineUrlRequestJob.RequestDenied)
return False
@@ -119,7 +119,7 @@ class QuteSchemeHandler(QWebEngineUrlSchemeHandler):
assert url.scheme() == 'qute'
- log.misc.debug("Got request for {}".format(url.toDisplayString()))
+ log.network.debug("Got request for {}".format(url.toDisplayString()))
try:
mimetype, data = qutescheme.data_for_url(url)
except qutescheme.Error as e:
@@ -136,14 +136,14 @@ class QuteSchemeHandler(QWebEngineUrlSchemeHandler):
QWebEngineUrlRequestJob.RequestFailed,
}
exctype = type(e)
- log.misc.error("{} while handling qute://* URL".format(
+ log.network.error("{} while handling qute://* URL".format(
exctype.__name__))
job.fail(errors[exctype])
except qutescheme.Redirect as e:
qtutils.ensure_valid(e.url)
job.redirect(e.url)
else:
- log.misc.debug("Returning {} data".format(mimetype))
+ log.network.debug("Returning {} data".format(mimetype))
# We can't just use the QBuffer constructor taking a QByteArray,
# because that somehow segfaults...
diff --git a/qutebrowser/browser/webengine/webenginesettings.py b/qutebrowser/browser/webengine/webenginesettings.py
index d5d654dbf..b7e67e379 100644
--- a/qutebrowser/browser/webengine/webenginesettings.py
+++ b/qutebrowser/browser/webengine/webenginesettings.py
@@ -326,8 +326,13 @@ def _update_settings(option):
"""Update global settings when qwebsettings changed."""
global_settings.update_setting(option)
+ # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-75884
+ # (note this isn't actually fixed properly before Qt 5.15)
+ header_bug_fixed = (not qtutils.version_check('5.12', compiled=False) or
+ qtutils.version_check('5.15', compiled=False))
+
if option in ['content.headers.user_agent',
- 'content.headers.accept_language']:
+ 'content.headers.accept_language'] and header_bug_fixed:
default_profile.setter.set_http_headers()
if private_profile:
private_profile.setter.set_http_headers()
@@ -403,6 +408,7 @@ def _init_site_specific_quirks():
'https://accounts.google.com/*': firefox_ua,
'https://*.slack.com/*': new_chrome_ua,
'https://docs.google.com/*': firefox_ua,
+ 'https://drive.google.com/*': firefox_ua,
}
if not qtutils.version_check('5.9'):
diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py
index ee9b39de7..c161afd0c 100644
--- a/qutebrowser/browser/webengine/webenginetab.py
+++ b/qutebrowser/browser/webengine/webenginetab.py
@@ -183,9 +183,23 @@ class _WebEngineSearchWrapHandler:
Args:
page: The QtWebEnginePage to connect to this handler.
"""
- if qtutils.version_check("5.14"):
- page.findTextFinished.connect(self._store_match_data)
- self._nowrap_available = True
+ 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.
@@ -381,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):
@@ -436,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')
@@ -512,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):
@@ -660,7 +685,11 @@ class WebEngineHistoryPrivate(browsertab.AbstractHistoryPrivate):
if qtutils.version_check('5.15', compiled=False):
# WORKAROUND for https://github.com/qutebrowser/qutebrowser/issues/5359
if items:
- self._tab.load_url(items[-1].url)
+ 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:
@@ -817,10 +846,15 @@ class WebEngineAudio(browsertab.AbstractAudio):
config.instance.changed.connect(self._on_config_changed)
def set_muted(self, muted: bool, override: bool = False) -> None:
+ was_muted = self.is_muted()
self._overridden = override
assert self._widget is not None
page = self._widget.page()
page.setAudioMuted(muted)
+ if was_muted != muted and qtutils.version_check('5.15'):
+ # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-85118
+ # so that the tab title at least updates the muted indicator
+ self.muted_changed.emit(muted)
def is_muted(self):
page = self._widget.page()
@@ -940,9 +974,18 @@ class _WebEnginePermissions(QObject):
page.setFeaturePermission, url, feature,
QWebEnginePage.PermissionDeniedByUser)
+ permission_str = debug.qenum_key(QWebEnginePage, feature)
+
+ if not url.isValid():
+ # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-85116
+ log.webview.warning("Ignoring feature permission {} for invalid "
+ "URL {}".format(permission_str, url))
+ deny_permission()
+ return
+
if feature not in self._options:
log.webview.error("Unhandled feature permission {}".format(
- debug.qenum_key(QWebEnginePage, feature)))
+ permission_str))
deny_permission()
return
@@ -1208,19 +1251,31 @@ class _WebEngineScripts(QObject):
"""Add site-specific quirk scripts.
NOTE: This isn't implemented for Qt 5.7 because of different UserScript
- semantics there. We only have a quirk for WhatsApp Web right now. It
- looks like that quirk isn't needed for Qt < 5.13.
+ semantics there. The WhatsApp Web quirk isn't needed for Qt < 5.13.
+ The globalthis_quirk would be, but let's not keep such old QtWebEngine
+ versions on life support.
"""
if not config.val.content.site_specific_quirks:
return
page_scripts = self._widget.page().scripts()
-
- for filename in ['whatsapp_web_quirk']:
+ quirks = [
+ (
+ 'whatsapp_web_quirk',
+ QWebEngineScript.DocumentReady,
+ QWebEngineScript.ApplicationWorld,
+ ),
+ ]
+ if not qtutils.version_check('5.13'):
+ quirks.append(('globalthis_quirk',
+ QWebEngineScript.DocumentCreation,
+ QWebEngineScript.MainWorld))
+
+ for filename, injection_point, world in quirks:
script = QWebEngineScript()
script.setName(filename)
- script.setWorldId(QWebEngineScript.ApplicationWorld)
- script.setInjectionPoint(QWebEngineScript.DocumentReady)
+ script.setWorldId(world)
+ script.setInjectionPoint(injection_point)
src = utils.read_file("javascript/{}.user.js".format(filename))
script.setSourceCode(src)
page_scripts.insert(script)
@@ -1247,6 +1302,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):
@@ -1579,16 +1637,16 @@ class WebEngineTab(browsertab.AbstractTab):
url = error.url()
self._insecure_hosts.add(url.host())
- log.webview.debug("Certificate error: {}".format(error))
+ log.network.debug("Certificate error: {}".format(error))
if error.is_overridable():
error.ignore = shared.ignore_certificate_errors(
url, [error], abort_on=[self.abort_questions])
else:
- log.webview.error("Non-overridable certificate error: "
+ log.network.error("Non-overridable certificate error: "
"{}".format(error))
- log.webview.debug("ignore {}, URL {}, requested {}".format(
+ log.network.debug("ignore {}, URL {}, requested {}".format(
error.ignore, url, self.url(requested=True)))
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-56207
diff --git a/qutebrowser/browser/webengine/webview.py b/qutebrowser/browser/webengine/webview.py
index 2b197323b..9f2984f8d 100644
--- a/qutebrowser/browser/webengine/webview.py
+++ b/qutebrowser/browser/webengine/webview.py
@@ -19,6 +19,8 @@
"""The main browser widget for QtWebEngine."""
+import typing
+
from PyQt5.QtCore import pyqtSignal, QUrl, PYQT_VERSION
from PyQt5.QtGui import QPalette
from PyQt5.QtWidgets import QWidget
@@ -66,20 +68,26 @@ class WebEngineView(QWebEngineView):
However, it sometimes isn't, so we use this as a WORKAROUND for
https://bugreports.qt.io/browse/QTBUG-68727
- This got introduced in Qt 5.11.0 and fixed in 5.12.0.
+ The above bug got introduced in Qt 5.11.0 and fixed in 5.12.0.
"""
- if 'lost-focusproxy' not in objects.debug_flags:
- proxy = self.focusProxy()
- if proxy is not None:
- return proxy
+ proxy = self.focusProxy() # type: typing.Optional[QWidget]
+
+ if 'lost-focusproxy' in objects.debug_flags:
+ proxy = None
+
+ if (proxy is not None or
+ not qtutils.version_check('5.11', compiled=False) or
+ qtutils.version_check('5.12', compiled=False)):
+ return proxy
# We don't want e.g. a QMenu.
rwhv_class = 'QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget'
children = [c for c in self.findChildren(QWidget)
if c.isVisible() and c.inherits(rwhv_class)]
- log.webview.debug("Found possibly lost focusProxy: {}"
- .format(children))
+ if children:
+ log.webview.debug("Found possibly lost focusProxy: {}"
+ .format(children))
return children[-1] if children else None
diff --git a/qutebrowser/browser/webkit/network/networkmanager.py b/qutebrowser/browser/webkit/network/networkmanager.py
index 039ed0dba..0f5063cfb 100644
--- a/qutebrowser/browser/webkit/network/networkmanager.py
+++ b/qutebrowser/browser/webkit/network/networkmanager.py
@@ -105,8 +105,9 @@ def _is_secure_cipher(cipher):
def init():
"""Disable insecure SSL ciphers on old Qt versions."""
default_ciphers = QSslSocket.defaultCiphers()
- log.init.debug("Default Qt ciphers: {}".format(
- ', '.join(c.name() for c in default_ciphers)))
+ log.init.vdebug( # type: ignore[attr-defined]
+ "Default Qt ciphers: {}".format(
+ ', '.join(c.name() for c in default_ciphers)))
good_ciphers = []
bad_ciphers = []
@@ -116,9 +117,10 @@ def init():
else:
bad_ciphers.append(cipher)
- log.init.debug("Disabling bad ciphers: {}".format(
- ', '.join(c.name() for c in bad_ciphers)))
- QSslSocket.setDefaultCiphers(good_ciphers)
+ if bad_ciphers:
+ log.init.debug("Disabling bad ciphers: {}".format(
+ ', '.join(c.name() for c in bad_ciphers)))
+ QSslSocket.setDefaultCiphers(good_ciphers)
_SavedErrorsType = typing.MutableMapping[urlutils.HostTupleType,
@@ -236,7 +238,7 @@ class NetworkManager(QNetworkAccessManager):
errors: A list of errors.
"""
errors = [certificateerror.CertificateErrorWrapper(e) for e in errors]
- log.webview.debug("Certificate errors: {!r}".format(
+ log.network.debug("Certificate errors: {!r}".format(
' / '.join(str(err) for err in errors)))
try:
host_tpl = urlutils.host_tuple(
@@ -252,7 +254,7 @@ class NetworkManager(QNetworkAccessManager):
is_rejected = set(errors).issubset(
self._rejected_ssl_errors[host_tpl])
- log.webview.debug("Already accepted: {} / "
+ log.network.debug("Already accepted: {} / "
"rejected {}".format(is_accepted, is_rejected))
if is_rejected:
@@ -425,7 +427,7 @@ class NetworkManager(QNetworkAccessManager):
if 'log-requests' in objects.debug_flags:
operation = debug.qenum_key(QNetworkAccessManager, op)
operation = operation.replace('Operation', '').upper()
- log.webview.debug("{} {}, first-party {}".format(
+ log.network.debug("{} {}, first-party {}".format(
operation,
req.url().toDisplayString(),
current_url.toDisplayString()))
diff --git a/qutebrowser/browser/webkit/network/webkitqutescheme.py b/qutebrowser/browser/webkit/network/webkitqutescheme.py
index 782bcc94a..0dce98765 100644
--- a/qutebrowser/browser/webkit/network/webkitqutescheme.py
+++ b/qutebrowser/browser/webkit/network/webkitqutescheme.py
@@ -48,7 +48,7 @@ def handler(request, operation, current_url):
if ((url.scheme(), url.host(), url.path()) ==
('qute', 'settings', '/set')):
if current_url != QUrl('qute://settings/'):
- log.webview.warning("Blocking malicious request from {} to {}"
+ log.network.warning("Blocking malicious request from {} to {}"
.format(current_url.toDisplayString(),
url.toDisplayString()))
return networkreply.ErrorNetworkReply(
diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py
index 213c7f277..1e9276265 100644
--- a/qutebrowser/browser/webkit/webkittab.py
+++ b/qutebrowser/browser/webkit/webkittab.py
@@ -25,9 +25,9 @@ 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.QtWidgets import QWidget
from PyQt5.QtPrintSupport import QPrinter
from qutebrowser.browser import browsertab, shared
@@ -184,14 +184,18 @@ class WebKitCaret(browsertab.AbstractCaret):
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)
@@ -206,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'))
@@ -214,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)
@@ -375,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):
@@ -710,6 +778,11 @@ 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):
@@ -771,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)
diff --git a/qutebrowser/commands/command.py b/qutebrowser/commands/command.py
index 4eefe481c..2672fcd68 100644
--- a/qutebrowser/commands/command.py
+++ b/qutebrowser/commands/command.py
@@ -334,8 +334,8 @@ class Command:
Args:
param: The inspect.Parameter to look at.
"""
- arginfo = self.get_arg_info(param)
- if arginfo.value:
+ arg_info = self.get_arg_info(param)
+ if arg_info.value:
# Filled values are passed 1:1
return None
elif param.kind in [inspect.Parameter.VAR_POSITIONAL,
diff --git a/qutebrowser/commands/userscripts.py b/qutebrowser/commands/userscripts.py
index b9ef41f01..485161600 100644
--- a/qutebrowser/commands/userscripts.py
+++ b/qutebrowser/commands/userscripts.py
@@ -259,9 +259,10 @@ class _POSIXUserscriptRunner(_BaseUserscriptRunner):
self._filepath = tempfile.mktemp(prefix='qutebrowser-userscript-',
dir=standarddir.runtime())
# pylint: disable=no-member,useless-suppression
- os.mkfifo(self._filepath)
+ os.mkfifo(self._filepath, mode=0o600)
# pylint: enable=no-member,useless-suppression
except OSError as e:
+ self._filepath = None # Make sure it's not used
message.error("Error while creating FIFO: {}".format(e))
return
diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py
index b9be0bd9d..26fbcdf4f 100644
--- a/qutebrowser/completion/completionwidget.py
+++ b/qutebrowser/completion/completionwidget.py
@@ -424,4 +424,8 @@ class CompletionView(QTreeView):
if not index.isValid():
raise cmdutils.CommandError("No item selected!")
text = self.model().data(index)
+
+ if not utils.supports_selection():
+ sel = False
+
utils.set_clipboard(text, selection=sel)
diff --git a/qutebrowser/components/adblock.py b/qutebrowser/components/adblock.py
index 2ceea2cf7..b34711fdd 100644
--- a/qutebrowser/components/adblock.py
+++ b/qutebrowser/components/adblock.py
@@ -33,7 +33,7 @@ from qutebrowser.api import (cmdutils, hook, config, message, downloads,
interceptor, apitypes, qtutils)
-logger = logging.getLogger('misc')
+logger = logging.getLogger('network')
_host_blocker = typing.cast('HostBlocker', None)
@@ -128,8 +128,8 @@ class HostBlocker:
"""Block the given request if necessary."""
if self._is_blocked(request_url=info.request_url,
first_party_url=info.first_party_url):
- logger.info("Request to {} blocked by host blocker."
- .format(info.request_url.host()))
+ logger.debug("Request to {} blocked by host blocker."
+ .format(info.request_url.host()))
info.block()
def _read_hosts_line(self, raw_line: bytes) -> typing.Set[str]:
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/config/configcommands.py b/qutebrowser/config/configcommands.py
index 25b49055c..20702be10 100644
--- a/qutebrowser/config/configcommands.py
+++ b/qutebrowser/config/configcommands.py
@@ -460,9 +460,9 @@ class ConfigCommands:
if filename is None:
filename = standarddir.config_py()
else:
+ filename = os.path.expanduser(filename)
if not os.path.isabs(filename):
filename = os.path.join(standarddir.config(), filename)
- filename = os.path.expanduser(filename)
if os.path.exists(filename) and not force:
raise cmdutils.CommandError("{} already exists - use --force to "
diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml
index b231fccb4..b3ffa9c5a 100644
--- a/qutebrowser/config/configdata.yml
+++ b/qutebrowser/config/configdata.yml
@@ -365,6 +365,10 @@ content.cookies.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`.
@@ -440,7 +444,7 @@ content.developer_extras:
deleted: true
content.dns_prefetch:
- default: false
+ default: true
type: Bool
backend:
QtWebKit: true
@@ -558,10 +562,10 @@ 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/80.0.3987.163 Safari/537.36"
+ 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/80.0.3987.149 Safari/537.36 "
+ Gecko) Chrome/81.0.4044.138 Safari/537.36"
- Chrome 80 Linux
supports_pattern: true
desc: |
@@ -581,7 +585,9 @@ content.headers.user_agent:
The default value is equal to the unchanged user agent of
QtWebKit/QtWebEngine.
- Note that the value read from JavaScript is always the global value.
+ Note that the value read from JavaScript is always the global value. With
+ QtWebEngine between 5.12 and 5.14 (inclusive), changing the value exposed
+ to JavaScript requires a restart.
content.host_blocking.enabled:
default: true
@@ -1375,6 +1381,19 @@ input.links_included_in_focus_chain:
supports_pattern: true
desc: Include hyperlinks in the keyboard focus chain when tabbing.
+input.mouse.back_forward_buttons:
+ default: true
+ type: Bool
+ desc: Enable back and forward buttons on the mouse.
+
+input.mouse.rocker_gestures:
+ default: false
+ type: Bool
+ desc: >-
+ Enable Opera-like mouse rocker gestures.
+
+ This disables the context menu.
+
input.partial_timeout:
default: 5000
type:
@@ -1388,12 +1407,7 @@ input.partial_timeout:
cleared after this time.
input.rocker_gestures:
- default: false
- type: Bool
- desc: >-
- Enable Opera-like mouse rocker gestures.
-
- This disables the context menu.
+ renamed: input.mouse.rocker_gestures
input.spatial_navigation:
default: false
@@ -1555,10 +1569,15 @@ spellcheck.languages:
## statusbar
-statusbar.hide:
- type: Bool
- default: false
- desc: Hide the statusbar unless a message is shown.
+statusbar.show:
+ default: always
+ type:
+ name: String
+ valid_values:
+ - always: Always show the statusbar.
+ - never: Always hide the statusbar.
+ - in-mode: Show the statusbar when in modes other than normal mode.
+ desc: When to show the statusbar.
statusbar.padding:
type: Padding
@@ -1971,7 +1990,7 @@ url.searchengines:
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:
@@ -2608,6 +2627,169 @@ colors.webpage.prefers_color_scheme_dark:
QtWebEngine: Qt 5.14
QtWebKit: false
+## dark mode
+
+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.
+
+ WARNING: On Qt 5.15.0, this setting can cause frequent renderer process
+ crashes due to a
+ https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/304211[bug in Qt].
+ 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
@@ -2662,7 +2844,7 @@ fonts.contextmenu:
fonts.debug_console:
default: default_size default_family
- type: QtFont
+ type: Font
desc: Font used for the debugging console.
fonts.downloads:
@@ -2705,10 +2887,15 @@ fonts.statusbar:
type: Font
desc: Font used in the statusbar.
-fonts.tabs:
+fonts.tabs.selected:
default: default_size default_family
- type: QtFont
- desc: Font used in the tab bar.
+ type: Font
+ desc: Font used for selected tabs.
+
+fonts.tabs.unselected:
+ default: default_size default_family
+ type: Font
+ desc: Font used for unselected tabs.
fonts.web.family.standard:
default: ''
@@ -2799,6 +2986,7 @@ bindings.key_mappings:
<Ctrl-6>: <Ctrl-^>
<Ctrl-M>: <Return>
<Ctrl-J>: <Return>
+ <Ctrl-I>: <Tab>
<Shift-Return>: <Return>
<Enter>: <Return>
<Shift-Enter>: <Return>
@@ -2896,6 +3084,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
@@ -2999,6 +3188,12 @@ bindings.default:
tIH: config-cycle -p -u *://*.{url:host}/* content.images ;; reload
tiu: config-cycle -p -t -u {url} content.images ;; reload
tIu: config-cycle -p -u {url} content.images ;; reload
+ tch: config-cycle -p -t -u *://{url:host}/* content.cookies.accept all no-3rdparty never ;; reload
+ tCh: config-cycle -p -u *://{url:host}/* content.cookies.accept all no-3rdparty never ;; reload
+ tcH: config-cycle -p -t -u *://*.{url:host}/* content.cookies.accept all no-3rdparty never ;; reload
+ tCH: config-cycle -p -u *://*.{url:host}/* content.cookies.accept all no-3rdparty never ;; reload
+ tcu: config-cycle -p -t -u {url} content.cookies.accept all no-3rdparty never ;; reload
+ tCu: config-cycle -p -u {url} content.cookies.accept all no-3rdparty never ;; reload
insert:
<Ctrl-E>: open-editor
<Shift-Ins>: insert-text -- {primary}
@@ -3077,6 +3272,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
@@ -3214,3 +3410,18 @@ bindings.commands:
* register: Entered when qutebrowser is waiting for a register name/key for
commands like `:set-mark`.
+
+## logging
+
+logging.level.ram:
+ default: debug
+ type: LogLevel
+ desc:
+ Level for in-memory logs.
+
+logging.level.console:
+ default: info
+ type: LogLevel
+ desc: >-
+ Level for console (stdout/stderr) logs.
+ Ignored if the `--loglevel` or `--debug` CLI flags are used.
diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py
index 7d567ebd3..01f58e5d1 100644
--- a/qutebrowser/config/configfiles.py
+++ b/qutebrowser/config/configfiles.py
@@ -332,6 +332,11 @@ class YamlMigrations(QObject):
new_name='tabs.mode_on_change',
true_value='persist',
false_value='normal')
+ self._migrate_renamed_bool(
+ old_name='statusbar.hide',
+ new_name='statusbar.show',
+ true_value='never',
+ false_value='always')
for setting in ['tabs.title.format',
'tabs.title.format_pinned',
@@ -340,6 +345,10 @@ class YamlMigrations(QObject):
r'(?<!{)\{title\}(?!})',
r'{current_title}')
+ self._migrate_to_multiple('fonts.tabs',
+ ('fonts.tabs.selected',
+ 'fonts.tabs.unselected'))
+
# content.headers.user_agent can't be empty to get the default anymore.
setting = 'content.headers.user_agent'
self._migrate_none(setting, configdata.DATA[setting].default)
@@ -446,6 +455,19 @@ class YamlMigrations(QObject):
self._settings[name][scope] = value
self.changed.emit()
+ def _migrate_to_multiple(self, old_name: str,
+ new_names: typing.Iterable[str]) -> None:
+ if old_name not in self._settings:
+ return
+
+ for new_name in new_names:
+ self._settings[new_name] = {}
+ for scope, val in self._settings[old_name].items():
+ self._settings[new_name][scope] = val
+
+ del self._settings[old_name]
+ self.changed.emit()
+
def _migrate_string_value(self, name: str,
source: str,
target: str) -> None:
@@ -603,6 +625,17 @@ class ConfigPyWriter:
def _gen_header(self) -> typing.Iterator[str]:
"""Generate the initial header of the config."""
yield self._line("# Autogenerated config.py")
+ yield self._line("#")
+
+ note = ("NOTE: config.py is intended for advanced users who are "
+ "comfortable with manually migrating the config file on "
+ "qutebrowser upgrades. If you prefer, you can also configure "
+ "qutebrowser using the :set/:bind/:config-* commands without "
+ "having to write a config.py file.")
+ for line in textwrap.wrap(note):
+ yield self._line("# {}".format(line))
+
+ yield self._line("#")
yield self._line("# Documentation:")
yield self._line("# qute://help/configuring.html")
yield self._line("# qute://help/settings.html")
diff --git a/qutebrowser/config/configinit.py b/qutebrowser/config/configinit.py
index b15225210..3c80cfe1b 100644
--- a/qutebrowser/config/configinit.py
+++ b/qutebrowser/config/configinit.py
@@ -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 6eec13293..e798498fc 100644
--- a/qutebrowser/config/configtypes.py
+++ b/qutebrowser/config/configtypes.py
@@ -56,14 +56,14 @@ import typing
import attr
import yaml
from PyQt5.QtCore import QUrl, Qt
-from PyQt5.QtGui import QColor, QFont, QFontDatabase
+from PyQt5.QtGui import QColor, QFontDatabase
from PyQt5.QtWidgets import QTabWidget, QTabBar, QApplication
from PyQt5.QtNetwork import QNetworkProxy
from qutebrowser.misc import objects, debugcachestats
from qutebrowser.config import configexc, configutils
from qutebrowser.utils import (standarddir, utils, qtutils, urlutils, urlmatch,
- usertypes)
+ usertypes, log)
from qutebrowser.keyinput import keyutils
from qutebrowser.browser.network import pac
@@ -82,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:
@@ -797,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))
@@ -837,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
@@ -861,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
@@ -874,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
@@ -1070,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
@@ -1151,7 +1157,7 @@ class QssColor(BaseType):
class FontBase(BaseType):
- """Base class for Font/QtFont/FontFamily."""
+ """Base class for Font/FontFamily."""
# Gets set when the config is initialized.
default_family = None # type: str
@@ -1286,97 +1292,6 @@ class FontFamily(FontBase):
return value
-class QtFont(FontBase):
-
- """A Font which gets converted to a QFont."""
-
- __doc__ = Font.__doc__ # for src2asciidoc.py
-
- def _parse_families(self, family_str: str) -> configutils.FontFamilies:
- if family_str == 'default_family' and self.default_family is not None:
- family_str = self.default_family
-
- return configutils.FontFamilies.from_str(family_str)
-
- def _set_style(self, font: QFont, match: typing.Match) -> None:
- style = match.group('style')
- style_map = {
- 'normal': QFont.StyleNormal,
- 'italic': QFont.StyleItalic,
- 'oblique': QFont.StyleOblique,
- }
- if style:
- font.setStyle(style_map[style])
- else:
- font.setStyle(QFont.StyleNormal)
-
- def _set_weight(self, font: QFont, match: typing.Match) -> None:
- weight = match.group('weight')
- namedweight = match.group('namedweight')
- weight_map = {
- 'normal': QFont.Normal,
- 'bold': QFont.Bold,
- }
- if namedweight:
- font.setWeight(weight_map[namedweight])
- elif weight:
- # based on qcssparser.cpp:setFontWeightFromValue
- font.setWeight(min(int(weight) // 8, 99))
- else:
- font.setWeight(QFont.Normal)
-
- def _set_size(self, font: QFont, match: typing.Match) -> None:
- size = match.group('size')
- if size:
- if size == 'default_size':
- size = self.default_size
-
- if size is None:
- # initial validation before default_size is set up.
- pass
- elif size.lower().endswith('pt'):
- font.setPointSizeF(float(size[:-2]))
- elif size.lower().endswith('px'):
- font.setPixelSize(int(size[:-2]))
- else:
- # This should never happen as the regex only lets pt/px
- # through.
- raise ValueError("Unexpected size unit in {!r}!".format(
- size)) # pragma: no cover
-
- def _set_families(self, font: QFont, match: typing.Match) -> None:
- family_str = match.group('family')
- families = self._parse_families(family_str)
- if hasattr(font, 'setFamilies'):
- # Added in Qt 5.13
- 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]:
- self._basic_py_validation(value, str)
- if isinstance(value, usertypes.Unset):
- return value
- elif not value:
- return None
-
- match = self.font_regex.fullmatch(value)
- if not match: # pragma: no cover
- # This should never happen, as the regex always matches everything
- # as family.
- raise configexc.ValidationError(value, "must be a valid font")
-
- font = QFont()
- self._set_style(font, match)
- self._set_weight(font, match)
- self._set_size(font, match)
- self._set_families(font, match)
-
- return font
-
-
class Regex(BaseType):
"""A regular expression.
@@ -1434,7 +1349,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):
@@ -1525,7 +1440,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):
@@ -1724,8 +1639,7 @@ class Proxy(BaseType):
def to_py(
self,
value: _StrUnset
- ) -> typing.Union[usertypes.Unset, None,
- QNetworkProxy, _SystemProxy, pac.PACFetcher]:
+ ) -> typing.Union[_UnsetNone, QNetworkProxy, _SystemProxy, pac.PACFetcher]:
self._basic_py_validation(value, str)
if isinstance(value, usertypes.Unset):
return value
@@ -1795,10 +1709,7 @@ class FuzzyUrl(BaseType):
"""A URL which gets interpreted as search if needed."""
- def to_py(
- self,
- value: _StrUnset
- ) -> typing.Union[None, QUrl, usertypes.Unset]:
+ def to_py(self, value: _StrUnset) -> typing.Union[QUrl, _UnsetNone]:
self._basic_py_validation(value, str)
if isinstance(value, usertypes.Unset):
return value
@@ -1836,7 +1747,7 @@ class Padding(Dict):
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):
@@ -1908,10 +1819,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
@@ -2014,6 +1922,16 @@ class NewTabPosition(String):
('last', "At the end."))
+class LogLevel(String):
+
+ """A logging level."""
+
+ def __init__(self, none_ok: bool = False) -> None:
+ super().__init__(none_ok=none_ok)
+ self.valid_values = ValidValues(*[level.lower()
+ for level in log.LOG_LEVELS])
+
+
class Key(BaseType):
"""A name of a key."""
@@ -2025,7 +1943,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
@@ -2049,7 +1967,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/html/warning-sessions.html b/qutebrowser/html/warning-sessions.html
index f93971c6a..0c6622df6 100644
--- a/qutebrowser/html/warning-sessions.html
+++ b/qutebrowser/html/warning-sessions.html
@@ -9,12 +9,13 @@ qute://warning/sessions</span> to show it again at a later time.</span>
<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>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 is expected to be released with qutebrowser v1.13.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>
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/globalthis_quirk.user.js b/qutebrowser/javascript/globalthis_quirk.user.js
new file mode 100644
index 000000000..03e74de3c
--- /dev/null
+++ b/qutebrowser/javascript/globalthis_quirk.user.js
@@ -0,0 +1,9 @@
+// ==UserScript==
+// @include https://www.reddit.com/*
+// @include https://open.spotify.com/*
+// ==/UserScript==
+
+// Polyfill for a failing globalThis with older Qt versions.
+
+"use strict";
+window.globalThis = window;
diff --git a/qutebrowser/keyinput/basekeyparser.py b/qutebrowser/keyinput/basekeyparser.py
index 3c4adee49..dea85aede 100644
--- a/qutebrowser/keyinput/basekeyparser.py
+++ b/qutebrowser/keyinput/basekeyparser.py
@@ -96,6 +96,24 @@ class BindingTrie:
return utils.get_repr(self, children=self.children,
command=self.command)
+ def __str__(self) -> str:
+ return '\n'.join(self.string_lines(blank=True))
+
+ def string_lines(self, indent: int = 0,
+ blank: bool = False) -> typing.Sequence[str]:
+ """Get a list of strings for a pretty-printed version of this trie."""
+ lines = []
+ if self.command is not None:
+ lines.append('{}=> {}'.format(' ' * indent, self.command))
+
+ for key, child in sorted(self.children.items()):
+ lines.append('{}{}:'.format(' ' * indent, key))
+ lines.extend(child.string_lines(indent=indent+1))
+ if blank:
+ lines.append('')
+
+ return lines
+
def update(self, mapping: typing.Mapping) -> None:
"""Add data from the given mapping to the trie."""
for key in mapping:
@@ -140,23 +158,16 @@ class BaseKeyParser(QObject):
Not intended to be instantiated directly. Subclasses have to override
execute() to do whatever they want to.
- Class Attributes:
- Match: types of a match between a binding and the keystring.
- partial: No keychain matched yet, but it's still possible in the
- future.
- definitive: Keychain matches exactly.
- none: No more matches possible.
-
- do_log: Whether to log keypresses or not.
- passthrough: Whether unbound keys should be passed through with this
- handler.
- supports_count: Whether count is supported.
-
Attributes:
+ mode_name: The name of the mode in the config.
bindings: Bound key bindings
+ _mode: The usertypes.KeyMode associated with this keyparser.
_win_id: The window ID this keyparser is associated with.
_sequence: The currently entered key sequence
- _modename: The name of the input mode associated with this keyparser.
+ _do_log: Whether to log keypresses or not.
+ passthrough: Whether unbound keys should be passed through with this
+ handler.
+ _supports_count: Whether count is supported.
Signals:
keystring_updated: Emitted when the keystring is updated.
@@ -169,21 +180,31 @@ class BaseKeyParser(QObject):
keystring_updated = pyqtSignal(str)
request_leave = pyqtSignal(usertypes.KeyMode, str, bool)
- do_log = True
- passthrough = False
- supports_count = True
- def __init__(self, win_id: int, parent: QObject = None) -> None:
+ def __init__(self, *, mode: usertypes.KeyMode,
+ win_id: int,
+ parent: QObject = None,
+ do_log: bool = True,
+ passthrough: bool = False,
+ supports_count: bool = True) -> None:
super().__init__(parent)
self._win_id = win_id
- self._modename = None
self._sequence = keyutils.KeySequence()
self._count = ''
+ self._mode = mode
+ self._do_log = do_log
+ self.passthrough = passthrough
+ self._supports_count = supports_count
self.bindings = BindingTrie()
+ self._read_config()
config.instance.changed.connect(self._on_config_changed)
def __repr__(self) -> str:
- return utils.get_repr(self)
+ return utils.get_repr(self, mode=self._mode,
+ win_id=self._win_id,
+ do_log=self._do_log,
+ passthrough=self.passthrough,
+ supports_count=self._supports_count)
def _debug_log(self, message: str) -> None:
"""Log a message to the debug log if logging is active.
@@ -191,8 +212,10 @@ class BaseKeyParser(QObject):
Args:
message: The message to log.
"""
- if self.do_log:
- log.keyboard.debug(message)
+ if self._do_log:
+ prefix = '{} for mode {}: '.format(self.__class__.__name__,
+ self._mode.name)
+ log.keyboard.debug(prefix + message)
def _match_key(self, sequence: keyutils.KeySequence) -> MatchResult:
"""Try to match a given keystring with any bound keychain.
@@ -234,7 +257,7 @@ class BaseKeyParser(QObject):
dry_run: bool) -> bool:
"""Try to match a key as count."""
txt = str(sequence[-1]) # To account for sequences changed above.
- if (txt in string.digits and self.supports_count and
+ if (txt in string.digits and self._supports_count and
not (not self._count and txt == '0')):
self._debug_log("Trying match as count")
assert len(txt) == 1, txt
@@ -319,25 +342,12 @@ class BaseKeyParser(QObject):
def _on_config_changed(self) -> None:
self._read_config()
- def _read_config(self, modename: str = None) -> None:
- """Read the configuration.
-
- Config format: key = command, e.g.:
- <Ctrl+Q> = quit
-
- Args:
- modename: Name of the mode to use.
- """
- if modename is None:
- if self._modename is None:
- raise ValueError("read_config called with no mode given, but "
- "None defined so far!")
- modename = self._modename
- else:
- self._modename = modename
+ def _read_config(self) -> None:
+ """Read the configuration."""
self.bindings = BindingTrie()
+ config_bindings = config.key_instance.get_bindings_for(self._mode.name)
- for key, cmd in config.key_instance.get_bindings_for(modename).items():
+ for key, cmd in config_bindings.items():
assert cmd
self.bindings[key] = cmd
diff --git a/qutebrowser/keyinput/keyutils.py b/qutebrowser/keyinput/keyutils.py
index 142bedd2f..b95f4a55d 100644
--- a/qutebrowser/keyinput/keyutils.py
+++ b/qutebrowser/keyinput/keyutils.py
@@ -180,21 +180,6 @@ 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: _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
- a key chain in hint mode.
- """
- _assert_plain_key(key)
- _assert_plain_modifier(modifiers)
- if is_modifier_key(key):
- return False
- return not (_is_printable(key) and
- modifiers in [Qt.ShiftModifier, Qt.NoModifier,
- Qt.KeypadModifier])
-
-
def is_special(key: Qt.Key, modifiers: _ModifierType) -> bool:
"""Check whether this key requires special key syntax."""
_assert_plain_key(key)
diff --git a/qutebrowser/keyinput/modeman.py b/qutebrowser/keyinput/modeman.py
index 880b1ec93..74ab8a27c 100644
--- a/qutebrowser/keyinput/modeman.py
+++ b/qutebrowser/keyinput/modeman.py
@@ -68,6 +68,14 @@ class NotInModeError(Exception):
"""Exception raised when we want to leave a mode we're not in."""
+class UnavailableError(Exception):
+
+ """Exception raised when trying to access modeman before initialization.
+
+ Thrown by instance() if modeman has not been initialized yet.
+ """
+
+
def init(win_id: int, parent: QObject) -> 'ModeManager':
"""Initialize the mode manager and the keyparsers for the given win_id."""
modeman = ModeManager(win_id, parent)
@@ -94,70 +102,86 @@ def init(win_id: int, parent: QObject) -> 'ModeManager':
parent=modeman),
usertypes.KeyMode.insert:
- modeparsers.PassthroughKeyParser(
- win_id=win_id,
+ modeparsers.CommandKeyParser(
mode=usertypes.KeyMode.insert,
+ win_id=win_id,
commandrunner=commandrunner,
- parent=modeman),
+ parent=modeman,
+ passthrough=True,
+ do_log=False,
+ supports_count=False),
usertypes.KeyMode.passthrough:
- modeparsers.PassthroughKeyParser(
- win_id=win_id,
+ modeparsers.CommandKeyParser(
mode=usertypes.KeyMode.passthrough,
+ win_id=win_id,
commandrunner=commandrunner,
- parent=modeman),
+ parent=modeman,
+ passthrough=True,
+ do_log=False,
+ supports_count=False),
usertypes.KeyMode.command:
- modeparsers.PassthroughKeyParser(
- win_id=win_id,
+ modeparsers.CommandKeyParser(
mode=usertypes.KeyMode.command,
+ win_id=win_id,
commandrunner=commandrunner,
- parent=modeman),
+ parent=modeman,
+ passthrough=True,
+ do_log=False,
+ supports_count=False),
usertypes.KeyMode.prompt:
- modeparsers.PassthroughKeyParser(
- win_id=win_id,
+ modeparsers.CommandKeyParser(
mode=usertypes.KeyMode.prompt,
+ win_id=win_id,
commandrunner=commandrunner,
- parent=modeman),
+ parent=modeman,
+ passthrough=True,
+ do_log=False,
+ supports_count=False),
usertypes.KeyMode.yesno:
- modeparsers.PromptKeyParser(
+ modeparsers.CommandKeyParser(
+ mode=usertypes.KeyMode.yesno,
win_id=win_id,
commandrunner=commandrunner,
- parent=modeman),
+ parent=modeman,
+ supports_count=False),
usertypes.KeyMode.caret:
- modeparsers.CaretKeyParser(
+ modeparsers.CommandKeyParser(
+ mode=usertypes.KeyMode.caret,
win_id=win_id,
commandrunner=commandrunner,
- parent=modeman),
+ parent=modeman,
+ passthrough=True),
usertypes.KeyMode.set_mark:
modeparsers.RegisterKeyParser(
- win_id=win_id,
mode=usertypes.KeyMode.set_mark,
+ win_id=win_id,
commandrunner=commandrunner,
parent=modeman),
usertypes.KeyMode.jump_mark:
modeparsers.RegisterKeyParser(
- win_id=win_id,
mode=usertypes.KeyMode.jump_mark,
+ win_id=win_id,
commandrunner=commandrunner,
parent=modeman),
usertypes.KeyMode.record_macro:
modeparsers.RegisterKeyParser(
- win_id=win_id,
mode=usertypes.KeyMode.record_macro,
+ win_id=win_id,
commandrunner=commandrunner,
parent=modeman),
usertypes.KeyMode.run_macro:
modeparsers.RegisterKeyParser(
- win_id=win_id,
mode=usertypes.KeyMode.run_macro,
+ win_id=win_id,
commandrunner=commandrunner,
parent=modeman),
} # type: ParserDictType
@@ -169,8 +193,16 @@ def init(win_id: int, parent: QObject) -> 'ModeManager':
def instance(win_id: Union[int, str]) -> 'ModeManager':
- """Get a modemanager object."""
- return objreg.get('mode-manager', scope='window', window=win_id)
+ """Get a modemanager object.
+
+ Raises UnavailableError if there is no instance available yet.
+ """
+ mode_manager = objreg.get('mode-manager', scope='window', window=win_id,
+ default=None)
+ if mode_manager is not None:
+ return mode_manager
+ else:
+ raise UnavailableError("ModeManager is not initialized yet.")
def enter(win_id: int,
@@ -211,10 +243,15 @@ class ModeManager(QObject):
arg1: The mode which has been left.
arg2: The new current mode.
arg3: The window ID of this mode manager.
+ keystring_updated: Emitted when the keystring was updated in any mode.
+ arg 1: The mode in which the keystring has been
+ updated.
+ arg 2: The new key string.
"""
entered = pyqtSignal(usertypes.KeyMode, int)
left = pyqtSignal(usertypes.KeyMode, usertypes.KeyMode, int)
+ keystring_updated = pyqtSignal(usertypes.KeyMode, str)
def __init__(self, win_id: int, parent: QObject = None) -> None:
super().__init__(parent)
@@ -300,6 +337,8 @@ class ModeManager(QObject):
assert parser is not None
self.parsers[mode] = parser
parser.request_leave.connect(self.leave)
+ parser.keystring_updated.connect(
+ functools.partial(self.keystring_updated.emit, mode))
def enter(self, mode: usertypes.KeyMode,
reason: str = None,
diff --git a/qutebrowser/keyinput/modeparsers.py b/qutebrowser/keyinput/modeparsers.py
index acac59ad5..a55639898 100644
--- a/qutebrowser/keyinput/modeparsers.py
+++ b/qutebrowser/keyinput/modeparsers.py
@@ -51,10 +51,16 @@ class CommandKeyParser(basekeyparser.BaseKeyParser):
_commandrunner: CommandRunner instance.
"""
- def __init__(self, win_id: int,
+ def __init__(self, *, mode: usertypes.KeyMode,
+ win_id: int,
commandrunner: 'runners.CommandRunner',
- parent: QObject = None) -> None:
- super().__init__(win_id, parent)
+ parent: QObject = None,
+ do_log: bool = True,
+ passthrough: bool = False,
+ supports_count: bool = True) -> None:
+ super().__init__(mode=mode, win_id=win_id, parent=parent,
+ do_log=do_log, passthrough=passthrough,
+ supports_count=supports_count)
self._commandrunner = commandrunner
def execute(self, cmdstr: str, count: int = None) -> None:
@@ -72,11 +78,11 @@ class NormalKeyParser(CommandKeyParser):
_partial_timer: Timer to clear partial keypresses.
"""
- def __init__(self, win_id: int,
+ def __init__(self, *, win_id: int,
commandrunner: 'runners.CommandRunner',
parent: QObject = None) -> None:
- super().__init__(win_id, commandrunner, parent)
- self._read_config('normal')
+ super().__init__(mode=usertypes.KeyMode.normal, win_id=win_id,
+ commandrunner=commandrunner, parent=parent)
self._partial_timer = usertypes.Timer(self, 'partial-match')
self._partial_timer.setSingleShot(True)
self._partial_timer.timeout.connect(self._clear_partial_match)
@@ -130,56 +136,7 @@ class NormalKeyParser(CommandKeyParser):
self._inhibited = False
-class PassthroughKeyParser(CommandKeyParser):
-
- """KeyChainParser which passes through normal keys.
-
- Used for insert/passthrough modes.
-
- Attributes:
- _mode: The mode this keyparser is for.
- """
-
- do_log = False
- passthrough = True
- supports_count = False
-
- def __init__(self, win_id: int,
- mode: usertypes.KeyMode,
- commandrunner: 'runners.CommandRunner',
- parent: QObject = None) -> None:
- """Constructor.
-
- Args:
- mode: The mode this keyparser is for.
- parent: Qt parent.
- warn: Whether to warn if an ignored key was bound.
- """
- super().__init__(win_id, commandrunner, parent)
- self._read_config(mode.name)
- self._mode = mode
-
- def __repr__(self) -> str:
- return utils.get_repr(self, mode=self._mode)
-
-
-class PromptKeyParser(CommandKeyParser):
-
- """KeyParser for yes/no prompts."""
-
- supports_count = False
-
- def __init__(self, win_id: int,
- commandrunner: 'runners.CommandRunner',
- parent: QObject = None) -> None:
- super().__init__(win_id, commandrunner, parent)
- self._read_config('yesno')
-
- def __repr__(self) -> str:
- return utils.get_repr(self)
-
-
-class HintKeyParser(CommandKeyParser):
+class HintKeyParser(basekeyparser.BaseKeyParser):
"""KeyChainParser for hints.
@@ -189,17 +146,20 @@ class HintKeyParser(CommandKeyParser):
_last_press: The nature of the last keypress, a LastPress member.
"""
- supports_count = False
-
- def __init__(self, win_id: int,
+ def __init__(self, *, win_id: int,
commandrunner: 'runners.CommandRunner',
hintmanager: hints.HintManager,
parent: QObject = None) -> None:
- super().__init__(win_id, commandrunner, parent)
+ super().__init__(mode=usertypes.KeyMode.hint, win_id=win_id,
+ parent=parent, supports_count=False)
+ self._command_parser = CommandKeyParser(mode=usertypes.KeyMode.hint,
+ win_id=win_id,
+ commandrunner=commandrunner,
+ parent=self,
+ supports_count=False)
self._hintmanager = hintmanager
self._filtertext = ''
self._last_press = LastPress.none
- self._read_config('hint')
self.keystring_updated.connect(self._hintmanager.handle_partial_key)
def _handle_filter_key(self, e: QKeyEvent) -> QKeySequence.SequenceMatch:
@@ -242,11 +202,14 @@ class HintKeyParser(CommandKeyParser):
if dry_run:
return super().handle(e, dry_run=True)
- if keyutils.is_special_hint_mode(Qt.Key(e.key()), e.modifiers()):
- log.keyboard.debug("Got special key, clearing keychain")
+ assert not dry_run
+
+ if (self._command_parser.handle(e, dry_run=True) !=
+ QKeySequence.NoMatch):
+ log.keyboard.debug("Handling key via command parser")
self.clear_keystring()
+ return self._command_parser.handle(e)
- assert not dry_run
match = super().handle(e)
if match == QKeySequence.PartialMatch:
@@ -271,23 +234,14 @@ class HintKeyParser(CommandKeyParser):
`self._filtertext`.
"""
self._read_config()
- self.bindings.update({keyutils.KeySequence.parse(s):
- 'follow-hint -s ' + s for s in strings})
+ self.bindings.update({keyutils.KeySequence.parse(s): s
+ for s in strings})
if not preserve_filter:
self._filtertext = ''
-
-class CaretKeyParser(CommandKeyParser):
-
- """KeyParser for caret mode."""
-
- passthrough = True
-
- def __init__(self, win_id: int,
- commandrunner: 'runners.CommandRunner',
- parent: QObject = None) -> None:
- super().__init__(win_id, commandrunner, parent)
- self._read_config('caret')
+ def execute(self, cmdstr: str, count: int = None) -> None:
+ assert count is None
+ self._hintmanager.handle_partial_key(cmdstr)
class RegisterKeyParser(CommandKeyParser):
@@ -295,19 +249,18 @@ class RegisterKeyParser(CommandKeyParser):
"""KeyParser for modes that record a register key.
Attributes:
- _mode: One of KeyMode.set_mark, KeyMode.jump_mark, KeyMode.record_macro
- and KeyMode.run_macro.
+ _register_mode: One of KeyMode.set_mark, KeyMode.jump_mark,
+ KeyMode.record_macro and KeyMode.run_macro.
"""
- supports_count = False
-
- def __init__(self, win_id: int,
+ def __init__(self, *, win_id: int,
mode: usertypes.KeyMode,
commandrunner: 'runners.CommandRunner',
parent: QObject = None) -> None:
- super().__init__(win_id, commandrunner, parent)
- self._mode = mode
- self._read_config('register')
+ super().__init__(mode=usertypes.KeyMode.register, win_id=win_id,
+ commandrunner=commandrunner, parent=parent,
+ supports_count=False)
+ self._register_mode = mode
def handle(self, e: QKeyEvent, *,
dry_run: bool = False) -> QKeySequence.SequenceMatch:
@@ -326,19 +279,20 @@ class RegisterKeyParser(CommandKeyParser):
window=self._win_id)
try:
- if self._mode == usertypes.KeyMode.set_mark:
+ if self._register_mode == usertypes.KeyMode.set_mark:
tabbed_browser.set_mark(key)
- elif self._mode == usertypes.KeyMode.jump_mark:
+ elif self._register_mode == usertypes.KeyMode.jump_mark:
tabbed_browser.jump_mark(key)
- elif self._mode == usertypes.KeyMode.record_macro:
+ elif self._register_mode == usertypes.KeyMode.record_macro:
macros.macro_recorder.record_macro(key)
- elif self._mode == usertypes.KeyMode.run_macro:
+ elif self._register_mode == usertypes.KeyMode.run_macro:
macros.macro_recorder.run_macro(self._win_id, key)
else:
- raise ValueError(
- "{} is not a valid register mode".format(self._mode))
+ raise ValueError("{} is not a valid register mode".format(
+ self._register_mode))
except cmdexc.Error as err:
message.error(str(err), stack=traceback.format_exc())
- self.request_leave.emit(self._mode, "valid register key", True)
+ self.request_leave.emit(
+ self._register_mode, "valid register key", True)
return QKeySequence.ExactMatch
diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py
index 41f97868c..cf77866f2 100644
--- a/qutebrowser/mainwindow/mainwindow.py
+++ b/qutebrowser/mainwindow/mainwindow.py
@@ -505,9 +505,8 @@ class MainWindow(QWidget):
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)
+ mode_manager.keystring_updated.connect(
+ self.status.keystring.on_keystring_updated)
self.status.cmd.got_cmd[str].connect( # type: ignore[index]
self._commandrunner.run_safely)
self.status.cmd.got_cmd[str, int].connect( # type: ignore[index]
@@ -518,9 +517,7 @@ class MainWindow(QWidget):
self._command_dispatcher.search)
# key hint popup
- for mode, parser in mode_manager.parsers.items():
- parser.keystring_updated.connect(functools.partial(
- self._keyhint.update_keyhint, mode.name))
+ mode_manager.keystring_updated.connect(self._keyhint.update_keyhint)
# messages
message.global_bridge.show_message.connect(
diff --git a/qutebrowser/mainwindow/statusbar/bar.py b/qutebrowser/mainwindow/statusbar/bar.py
index 119b16584..f83c77db9 100644
--- a/qutebrowser/mainwindow/statusbar/bar.py
+++ b/qutebrowser/mainwindow/statusbar/bar.py
@@ -203,7 +203,7 @@ class StatusBar(QWidget):
@pyqtSlot(str)
def _on_config_changed(self, option):
- if option == 'statusbar.hide':
+ if option == 'statusbar.show':
self.maybe_hide()
elif option == 'statusbar.padding':
self._set_hbox_padding()
@@ -254,12 +254,26 @@ class StatusBar(QWidget):
@pyqtSlot()
def maybe_hide(self):
"""Hide the statusbar if it's configured to do so."""
+ strategy = config.val.statusbar.show
tab = self._current_tab()
- hide = config.val.statusbar.hide
- if hide or (tab is not None and tab.data.fullscreen):
+ if tab is not None and tab.data.fullscreen:
self.hide()
- else:
+ elif strategy == 'never':
+ self.hide()
+ elif strategy == 'in-mode':
+ try:
+ mode_manager = modeman.instance(self._win_id)
+ except modeman.UnavailableError:
+ self.hide()
+ else:
+ if mode_manager.mode == usertypes.KeyMode.normal:
+ self.hide()
+ else:
+ self.show()
+ elif strategy == 'always':
self.show()
+ else:
+ raise utils.Unreachable
def _set_hbox_padding(self):
padding = config.val.statusbar.padding
@@ -336,6 +350,8 @@ class StatusBar(QWidget):
def on_mode_entered(self, mode):
"""Mark certain modes in the commandline."""
mode_manager = modeman.instance(self._win_id)
+ if config.val.statusbar.show == 'in-mode':
+ self.show()
if mode_manager.parsers[mode].passthrough:
self._set_mode_text(mode.name)
if mode in [usertypes.KeyMode.insert,
@@ -350,6 +366,8 @@ class StatusBar(QWidget):
def on_mode_left(self, old_mode, new_mode):
"""Clear marked mode."""
mode_manager = modeman.instance(self._win_id)
+ if config.val.statusbar.show == 'in-mode':
+ self.hide()
if mode_manager.parsers[old_mode].passthrough:
if mode_manager.parsers[new_mode].passthrough:
self._set_mode_text(new_mode.name)
@@ -373,13 +391,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/keystring.py b/qutebrowser/mainwindow/statusbar/keystring.py
index a3b64892f..a64c8e0e2 100644
--- a/qutebrowser/mainwindow/statusbar/keystring.py
+++ b/qutebrowser/mainwindow/statusbar/keystring.py
@@ -19,9 +19,16 @@
"""Keychain string displayed in the statusbar."""
+from PyQt5.QtCore import pyqtSlot
+
from qutebrowser.mainwindow.statusbar import textbase
+from qutebrowser.utils import usertypes
class KeyString(textbase.TextBase):
"""Keychain string displayed in the statusbar."""
+
+ @pyqtSlot(usertypes.KeyMode, str)
+ def on_keystring_updated(self, _mode, keystr):
+ self.setText(keystr)
diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py
index c1179abbf..f9112c6ab 100644
--- a/qutebrowser/mainwindow/tabbedbrowser.py
+++ b/qutebrowser/mainwindow/tabbedbrowser.py
@@ -64,8 +64,11 @@ class TabDeque:
"""
def __init__(self) -> None:
+ size = config.val.tabs.focus_stack_size
+ if size < 0:
+ size = None
self._stack = collections.deque(
- maxlen=config.val.tabs.focus_stack_size
+ maxlen=size
) # type: typing.Deque[weakref.ReferenceType[QWidget]]
# Items that have been removed from the primary stack.
self._stack_deleted = [
@@ -189,7 +192,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)
diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py
index 558713fdf..60006fa14 100644
--- a/qutebrowser/mainwindow/tabwidget.py
+++ b/qutebrowser/mainwindow/tabwidget.py
@@ -385,8 +385,13 @@ class TabBar(QTabBar):
STYLESHEET = """
TabBar {
+ font: {{ conf.fonts.tabs.unselected }};
background-color: {{ conf.colors.tabs.bar.bg }};
}
+
+ TabBar::tab:selected {
+ font: {{ conf.fonts.tabs.selected }};
+ }
"""
new_tab_requested = pyqtSignal()
@@ -395,8 +400,6 @@ class TabBar(QTabBar):
super().__init__(parent)
self._win_id = win_id
self.setStyle(TabBarStyle())
- self._set_font()
- config.instance.changed.connect(self._on_config_changed)
self.vertical = False
self._auto_hide_timer = QTimer()
self._auto_hide_timer.setSingleShot(True)
@@ -405,6 +408,9 @@ class TabBar(QTabBar):
self.setAutoFillBackground(True)
self.drag_in_progress = False
stylesheet.set_register(self)
+ self.ensurePolished()
+ config.instance.changed.connect(self._on_config_changed)
+ self._set_icon_size()
QTimer.singleShot(0, self.maybe_hide)
def __repr__(self):
@@ -416,8 +422,9 @@ class TabBar(QTabBar):
@pyqtSlot(str)
def _on_config_changed(self, option: str) -> None:
- if option == 'fonts.tabs':
- self._set_font()
+ if option.startswith('fonts.tabs.'):
+ self.ensurePolished()
+ self._set_icon_size()
elif option == 'tabs.favicons.scale':
self._set_icon_size()
elif option == 'tabs.show_switching_delay':
@@ -433,7 +440,9 @@ class TabBar(QTabBar):
"tabs.padding",
"tabs.indicator.width",
"tabs.min_width",
- "tabs.pinned.shrink"]:
+ "tabs.pinned.shrink",
+ "fonts.tabs.selected",
+ "fonts.tabs.unselected"]:
self._minimum_tab_size_hint_helper.cache_clear()
self._minimum_tab_height.cache_clear()
@@ -506,14 +515,6 @@ class TabBar(QTabBar):
# code sets layoutDirty so it actually relayouts the tabs.
self.setIconSize(self.iconSize())
- def _set_font(self):
- """Set the tab bar font."""
- self.setFont(config.val.fonts.tabs)
- self._set_icon_size()
- # clear tab size cache
- self._minimum_tab_size_hint_helper.cache_clear()
- self._minimum_tab_height.cache_clear()
-
def _set_icon_size(self):
"""Set the tab bar favicon size."""
size = self.fontMetrics().height() - 2
diff --git a/qutebrowser/misc/backendproblem.py b/qutebrowser/misc/backendproblem.py
index 2ed273547..089e3191f 100644
--- a/qutebrowser/misc/backendproblem.py
+++ b/qutebrowser/misc/backendproblem.py
@@ -23,8 +23,6 @@ import os
import sys
import functools
import html
-import ctypes
-import ctypes.util
import enum
import shutil
import typing
@@ -59,7 +57,7 @@ class _Button:
text = attr.ib() # type: str
setting = attr.ib() # type: str
- value = attr.ib() # type: str
+ value = attr.ib() # type: typing.Any
default = attr.ib(default=False) # type: bool
@@ -81,19 +79,21 @@ def _error_text(because: str, text: str, backend: usertypes.Backend) -> str:
if other_backend == usertypes.Backend.QtWebKit:
warning = ("<i>Note that QtWebKit hasn't been updated since "
"July 2017 (including security updates).</i>")
+ suffix = " (not recommended)"
else:
warning = ""
+ suffix = ""
return ("<b>Failed to start with the {backend} backend!</b>"
"<p>qutebrowser tried to start with the {backend} backend but "
"failed because {because}.</p>{text}"
- "<p><b>Forcing the {other_backend.name} backend</b></p>"
+ "<p><b>Forcing the {other_backend.name} backend{suffix}</b></p>"
"<p>This forces usage of the {other_backend.name} backend by "
"setting the <i>backend = '{other_setting}'</i> option "
"(if you have a <i>config.py</i> file, you'll need to set "
"this manually). {warning}</p>".format(
backend=backend.name, because=because, text=text,
other_backend=other_backend, other_setting=other_setting,
- warning=warning))
+ warning=warning, suffix=suffix))
class _Dialog(QDialog):
@@ -167,6 +167,14 @@ class _BackendProblemChecker:
"""Check for various backend-specific issues."""
+ SOFTWARE_RENDERING_TEXT = (
+ "<p><b>Forcing software rendering</b></p>"
+ "<p>This allows you to use the newer QtWebEngine backend (based on "
+ "Chromium) but could have noticeable performance impact (depending on "
+ "your hardware). This sets the <i>qt.force_software_rendering = "
+ "'chromium'</i> option (if you have a <i>config.py</i> file, you'll "
+ "need to set this manually).</p>")
+
def __init__(self, *,
no_err_windows: bool,
save_manager: savemanager.SaveManager) -> None:
@@ -201,19 +209,10 @@ class _BackendProblemChecker:
def _nvidia_shader_workaround(self) -> None:
"""Work around QOpenGLShaderProgram issues.
- NOTE: This needs to be called before _handle_nouveau_graphics, or some
- setups will segfault in version.opengl_vendor().
-
See https://bugs.launchpad.net/ubuntu/+source/python-qt4/+bug/941826
"""
self._assert_backend(usertypes.Backend.QtWebEngine)
-
- if os.environ.get('QUTE_SKIP_LIBGL_WORKAROUND'):
- return
-
- libgl = ctypes.util.find_library("GL")
- if libgl is not None:
- ctypes.CDLL(libgl, mode=ctypes.RTLD_GLOBAL)
+ utils.libgl_workaround()
def _handle_nouveau_graphics(self) -> None:
"""Force software rendering when using the Nouveau driver.
@@ -231,7 +230,8 @@ class _BackendProblemChecker:
if qtutils.version_check('5.10', compiled=False):
return
- if version.opengl_vendor() != 'nouveau':
+ opengl_info = version.opengl_info()
+ if opengl_info is None or opengl_info.vendor != 'nouveau':
return
if (os.environ.get('LIBGL_ALWAYS_SOFTWARE') == '1' or
@@ -248,36 +248,15 @@ class _BackendProblemChecker:
self._show_dialog(
backend=usertypes.Backend.QtWebEngine,
because="you're using Nouveau graphics",
- text=("<p>There are two ways to fix this:</p>"
- "<p><b>Forcing software rendering</b></p>"
- "<p>This allows you to use the newer QtWebEngine backend "
- "(based on Chromium) but could have noticeable performance "
- "impact (depending on your hardware). This sets the "
- "<i>qt.force_software_rendering = 'chromium'</i> option "
- "(if you have a <i>config.py</i> file, you'll need to set "
- "this manually).</p>"),
+ text=("<p>There are two ways to fix this:</p>" +
+ self.SOFTWARE_RENDERING_TEXT),
buttons=[button],
)
raise utils.Unreachable
- def _handle_wayland(self) -> None:
- self._assert_backend(usertypes.Backend.QtWebEngine)
-
- if os.environ.get('QUTE_SKIP_WAYLAND_CHECK'):
- return
-
- platform = QApplication.instance().platformName()
- if platform not in ['wayland', 'wayland-egl']:
- return
-
- has_qt511 = qtutils.version_check('5.11', compiled=False)
- if has_qt511 and config.val.qt.force_software_rendering == 'chromium':
- return
-
- if qtutils.version_check('5.11.2', compiled=False):
- return
-
+ def _xwayland_options(self) -> typing.Tuple[str, typing.List[_Button]]:
+ """Get buttons/text for a possible XWayland solution."""
buttons = []
text = "<p>You can work around this in one of the following ways:</p>"
@@ -296,23 +275,86 @@ class _BackendProblemChecker:
"<p>This allows you to use the newer QtWebEngine backend "
"(based on Chromium). ")
+ return text, buttons
+
+ def _handle_wayland(self) -> None:
+ self._assert_backend(usertypes.Backend.QtWebEngine)
+
+ if os.environ.get('QUTE_SKIP_WAYLAND_CHECK'):
+ return
+
+ platform = QApplication.instance().platformName()
+ if platform not in ['wayland', 'wayland-egl']:
+ return
+
+ has_qt511 = qtutils.version_check('5.11', compiled=False)
+ if has_qt511 and config.val.qt.force_software_rendering == 'chromium':
+ return
+
+ if qtutils.version_check('5.11.2', compiled=False):
+ return
+
+ text, buttons = self._xwayland_options()
+
if has_qt511:
buttons.append(_Button("Force software rendering",
'qt.force_software_rendering',
'chromium'))
- text += ("<p><b>Forcing software rendering</b></p>"
- "<p>This allows you to use the newer QtWebEngine backend "
- "(based on Chromium) but could have noticeable "
- "performance impact (depending on your hardware). This "
- "sets the <i>qt.force_software_rendering = "
- "'chromium'</i> option (if you have a <i>config.py</i> "
- "file, you'll need to set this manually).</p>")
+ text += self.SOFTWARE_RENDERING_TEXT
self._show_dialog(backend=usertypes.Backend.QtWebEngine,
because="you're using Wayland",
text=text,
buttons=buttons)
+ def _handle_wayland_webgl(self) -> None:
+ """On older graphic hardware, WebGL on Wayland causes segfaults.
+
+ See https://github.com/qutebrowser/qutebrowser/issues/5313
+ """
+ self._assert_backend(usertypes.Backend.QtWebEngine)
+
+ if os.environ.get('QUTE_SKIP_WAYLAND_WEBGL_CHECK'):
+ return
+
+ platform = QApplication.instance().platformName()
+ if platform not in ['wayland', 'wayland-egl']:
+ return
+
+ # Only Qt 5.14 should be affected
+ if not qtutils.version_check('5.14', compiled=False):
+ return
+ if qtutils.version_check('5.15', compiled=False):
+ return
+
+ # Newer graphic hardware isn't affected
+ opengl_info = version.opengl_info()
+ if (opengl_info is None or
+ opengl_info.gles or
+ opengl_info.version is None or
+ opengl_info.version >= (4, 3)):
+ return
+
+ # If WebGL is turned off, we're fine
+ if not config.val.content.webgl:
+ return
+
+ text, buttons = self._xwayland_options()
+
+ buttons.append(_Button("Turn off WebGL (recommended)",
+ 'content.webgl',
+ False))
+ text += ("<p><b>Disable WebGL (recommended)</b></p>"
+ "This sets the <i>content.webgl = False</i> option "
+ "(if you have a <i>config.py</i> file, you'll need to "
+ "set this manually).</p>")
+
+ self._show_dialog(backend=usertypes.Backend.QtWebEngine,
+ because=("of frequent crashes with Qt 5.14 on "
+ "Wayland with older graphics hardware"),
+ text=text,
+ buttons=buttons)
+
def _try_import_backends(self) -> _BackendImports:
"""Check whether backends can be imported and return BackendImports."""
# pylint: disable=unused-import
@@ -320,8 +362,9 @@ class _BackendProblemChecker:
try:
from PyQt5 import QtWebKit
+ from PyQt5.QtWebKit import qWebKitVersion
from PyQt5 import QtWebKitWidgets
- except ImportError as e:
+ except (ImportError, ValueError) as e:
results.webkit_available = False
results.webkit_error = str(e)
else:
@@ -333,7 +376,7 @@ class _BackendProblemChecker:
try:
from PyQt5 import QtWebEngineWidgets
- except ImportError as e:
+ except (ImportError, ValueError) as e:
results.webengine_available = False
results.webengine_error = str(e)
else:
@@ -494,6 +537,7 @@ class _BackendProblemChecker:
self._handle_ssl_support()
self._handle_wayland()
self._nvidia_shader_workaround()
+ self._handle_wayland_webgl()
self._handle_nouveau_graphics()
self._handle_cache_nuking()
self._handle_serviceworker_nuking()
diff --git a/qutebrowser/misc/consolewidget.py b/qutebrowser/misc/consolewidget.py
index 7e46da3c8..aed42237a 100644
--- a/qutebrowser/misc/consolewidget.py
+++ b/qutebrowser/misc/consolewidget.py
@@ -27,7 +27,7 @@ from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt
from PyQt5.QtWidgets import QTextEdit, QWidget, QVBoxLayout, QApplication
from PyQt5.QtGui import QTextCursor
-from qutebrowser.config import config
+from qutebrowser.config import stylesheet
from qutebrowser.misc import cmdhistory, miscwidgets
from qutebrowser.utils import utils, objreg
@@ -55,8 +55,6 @@ class ConsoleLineEdit(miscwidgets.CommandLineEdit):
_namespace: The local namespace of the interpreter.
"""
super().__init__(parent=parent)
- self._update_font()
- config.instance.changed.connect(self._update_font)
self._history = cmdhistory.History(parent=self)
self.returnPressed.connect(self.on_return_pressed)
@@ -106,11 +104,6 @@ class ConsoleLineEdit(miscwidgets.CommandLineEdit):
else:
super().keyPressEvent(e)
- @config.change_filter('fonts.debug_console')
- def _update_font(self):
- """Set the correct font."""
- self.setFont(config.val.fonts.debug_console)
-
class ConsoleTextEdit(QTextEdit):
@@ -120,18 +113,11 @@ class ConsoleTextEdit(QTextEdit):
super().__init__(parent)
self.setAcceptRichText(False)
self.setReadOnly(True)
- config.instance.changed.connect(self._update_font)
- self._update_font()
self.setFocusPolicy(Qt.ClickFocus)
def __repr__(self):
return utils.get_repr(self)
- @config.change_filter('fonts.debug_console')
- def _update_font(self):
- """Update font when config changed."""
- self.setFont(config.val.fonts.debug_console)
-
def append_text(self, text):
"""Append new text and scroll output to bottom.
@@ -157,6 +143,12 @@ class ConsoleWidget(QWidget):
_interpreter: The InteractiveInterpreter to execute code with.
"""
+ STYLESHEET = """
+ ConsoleWidget > ConsoleTextEdit, ConsoleWidget > ConsoleLineEdit {
+ font: {{ conf.fonts.debug_console }};
+ }
+ """
+
def __init__(self, parent=None):
super().__init__(parent)
if not hasattr(sys, 'ps1'):
@@ -182,6 +174,7 @@ class ConsoleWidget(QWidget):
self._vbox.setSpacing(0)
self._vbox.addWidget(self._output)
self._vbox.addWidget(self._lineedit)
+ stylesheet.set_register(self)
self.setLayout(self._vbox)
self._lineedit.setFocus()
self._interpreter = code.InteractiveInterpreter(namespace)
diff --git a/qutebrowser/misc/crashdialog.py b/qutebrowser/misc/crashdialog.py
index 6bd6ec325..4387e479a 100644
--- a/qutebrowser/misc/crashdialog.py
+++ b/qutebrowser/misc/crashdialog.py
@@ -125,9 +125,13 @@ class _CrashDialog(QDialog):
self.setWindowTitle("Whoops!")
self.resize(QSize(640, 600))
self._vbox = QVBoxLayout(self)
+
http_client = httpclient.HTTPClient()
self._paste_client = pastebin.PastebinClient(http_client, self)
self._pypi_client = autoupdate.PyPIVersionClient(self)
+ self._paste_client.success.connect(self.on_paste_success)
+ self._paste_client.error.connect(self.show_error)
+
self._init_text()
self._init_contact_input()
@@ -246,7 +250,7 @@ class _CrashDialog(QDialog):
except Exception:
self._crash_info.append(("Launch time", traceback.format_exc()))
try:
- self._crash_info.append(("Version info", version.version()))
+ self._crash_info.append(("Version info", version.version_info()))
except Exception:
self._crash_info.append(("Version info", traceback.format_exc()))
try:
@@ -296,13 +300,17 @@ class _CrashDialog(QDialog):
except Exception:
log.misc.exception("Failed to save contact information!")
- def report(self):
- """Paste the crash info into the pastebin."""
+ def report(self, *, info=None, contact=None):
+ """Paste the crash info into the pastebin.
+
+ If info/contact are given as arguments, they override the values
+ entered in the dialog.
+ """
lines = []
lines.append("========== Report ==========")
- lines.append(self._info.toPlainText())
+ lines.append(info or self._info.toPlainText())
lines.append("========== Contact ==========")
- lines.append(self._contact.toPlainText())
+ lines.append(contact or self._contact.toPlainText())
lines.append("========== Debug log ==========")
lines.append(self._debug_log.toPlainText())
self._paste_text = '\n\n'.join(lines)
@@ -326,8 +334,6 @@ class _CrashDialog(QDialog):
self._btn_report.setEnabled(False)
self._btn_cancel.setEnabled(False)
self._btn_report.setText("Reporting...")
- self._paste_client.success.connect(self.on_paste_success)
- self._paste_client.error.connect(self.show_error)
self.report()
@pyqtSlot()
@@ -650,7 +656,7 @@ def dump_exception_info(exc, pages, cmdhist, qobjects):
print(''.join(traceback.format_exception(*exc)), file=sys.stderr)
print("\n---- Version info ----", file=sys.stderr)
try:
- print(version.version(), file=sys.stderr)
+ print(version.version_info(), file=sys.stderr)
except Exception:
traceback.print_exc()
print("\n---- Config ----", file=sys.stderr)
diff --git a/qutebrowser/misc/crashsignal.py b/qutebrowser/misc/crashsignal.py
index 5d8bd0ff5..3f80db769 100644
--- a/qutebrowser/misc/crashsignal.py
+++ b/qutebrowser/misc/crashsignal.py
@@ -162,14 +162,25 @@ class CrashHandler(QObject):
earlyinit.init_faulthandler(self._crash_log_file)
@cmdutils.register(instance='crash-handler')
- def report(self):
- """Report a bug in qutebrowser."""
+ def report(self, info=None, contact=None):
+ """Report a bug in qutebrowser.
+
+ Args:
+ info: Information about the bug report. If given, no report dialog
+ shows up.
+ contact: Contact information for the report.
+ """
pages = self._recover_pages()
cmd_history = objreg.get('command-history')[-5:]
all_objects = debug.get_all_objects()
+
self._crash_dialog = crashdialog.ReportDialog(pages, cmd_history,
all_objects)
- self._crash_dialog.show()
+
+ if info is None:
+ self._crash_dialog.show()
+ else:
+ self._crash_dialog.report(info=info, contact=contact)
@pyqtSlot()
def shutdown(self):
diff --git a/qutebrowser/misc/ipc.py b/qutebrowser/misc/ipc.py
index 2cceb2df1..c4cd4f792 100644
--- a/qutebrowser/misc/ipc.py
+++ b/qutebrowser/misc/ipc.py
@@ -36,7 +36,7 @@ from qutebrowser.utils import log, usertypes, error, standarddir, utils
CONNECT_TIMEOUT = 100 # timeout for connecting/disconnecting
WRITE_TIMEOUT = 1000
READ_TIMEOUT = 5000
-ATIME_INTERVAL = 60 * 60 * 3 * 1000 # 3 hours
+ATIME_INTERVAL = 5000 * 60 # 5 minutes
PROTOCOL_VERSION = 1
@@ -397,8 +397,16 @@ class IPCServer(QObject):
if not path:
log.ipc.error("In update_atime with no server path!")
return
+
log.ipc.debug("Touching {}".format(path))
- os.utime(path)
+
+ try:
+ os.utime(path)
+ except OSError:
+ log.ipc.exception("Failed to update IPC socket, trying to "
+ "re-listen...")
+ self._server.close()
+ self.listen()
@pyqtSlot()
def shutdown(self):
diff --git a/qutebrowser/misc/keyhintwidget.py b/qutebrowser/misc/keyhintwidget.py
index 89dac83f2..11bb14d66 100644
--- a/qutebrowser/misc/keyhintwidget.py
+++ b/qutebrowser/misc/keyhintwidget.py
@@ -82,8 +82,8 @@ class KeyHintView(QLabel):
self.update_geometry.emit()
super().showEvent(e)
- @pyqtSlot(str)
- def update_keyhint(self, modename, prefix):
+ @pyqtSlot(usertypes.KeyMode, str)
+ def update_keyhint(self, mode, prefix):
"""Show hints for the given prefix (or hide if prefix is empty).
Args:
@@ -108,7 +108,7 @@ class KeyHintView(QLabel):
cmd = objects.commands.get(cmdname)
return cmd and cmd.takes_count()
- bindings_dict = config.key_instance.get_bindings_for(modename)
+ bindings_dict = config.key_instance.get_bindings_for(mode.name)
bindings = [(k, v) for (k, v) in sorted(bindings_dict.items())
if keyutils.KeySequence.parse(prefix).matches(k) and
not blacklisted(str(k)) and
diff --git a/qutebrowser/misc/utilcmds.py b/qutebrowser/misc/utilcmds.py
index fa8b97628..05fea9501 100644
--- a/qutebrowser/misc/utilcmds.py
+++ b/qutebrowser/misc/utilcmds.py
@@ -225,24 +225,6 @@ def log_capacity(capacity: int) -> None:
@cmdutils.register(debug=True)
-@cmdutils.argument('level', choices=sorted(
- (level.lower() for level in log.LOG_LEVELS),
- key=lambda e: log.LOG_LEVELS[e.upper()]))
-def debug_log_level(level: str) -> None:
- """Change the log level for console logging.
-
- Args:
- level: The log level to set.
- """
- if log.console_handler is None:
- raise cmdutils.CommandError("No log.console_handler. Not attached "
- "to a console?")
-
- log.change_console_formatter(log.LOG_LEVELS[level.upper()])
- log.console_handler.setLevel(log.LOG_LEVELS[level.upper()])
-
-
-@cmdutils.register(debug=True)
def debug_log_filter(filters: str) -> None:
"""Change the log filter for console logging.
@@ -254,16 +236,12 @@ def debug_log_filter(filters: str) -> None:
raise cmdutils.CommandError("No log.console_filter. Not attached "
"to a console?")
- if filters.strip().lower() == 'none':
- log.console_filter.names = None
- return
-
- if not set(filters.split(',')).issubset(log.LOGGER_NAMES):
- raise cmdutils.CommandError("filters: Invalid value {} - expected one "
- "of: {}".format(
- filters, ', '.join(log.LOGGER_NAMES)))
+ try:
+ new_filter = log.LogFilter.parse(filters)
+ except log.InvalidLogFilterError as e:
+ raise cmdutils.CommandError(e)
- log.console_filter.names = filters.split(',')
+ log.console_filter.update_from(new_filter)
@cmdutils.register()
diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py
index 0ffdb5567..8765f5217 100644
--- a/qutebrowser/qutebrowser.py
+++ b/qutebrowser/qutebrowser.py
@@ -96,7 +96,7 @@ def get_argparser():
debug = parser.add_argument_group('debug arguments')
debug.add_argument('-l', '--loglevel', dest='loglevel',
- help="Set loglevel", default='info',
+ help="Override the configured console loglevel",
choices=['critical', 'error', 'warning', 'info',
'debug', 'vdebug'])
debug.add_argument('--logfilter', type=logfilter_error,
@@ -150,12 +150,11 @@ def logfilter_error(logfilter):
logfilter: A comma separated list of logger names.
"""
from qutebrowser.utils import log
- if set(logfilter.lstrip('!').split(',')).issubset(log.LOGGER_NAMES):
- return logfilter
- else:
- raise argparse.ArgumentTypeError(
- "filters: Invalid value {} - expected a list of: {}".format(
- logfilter, ', '.join(log.LOGGER_NAMES)))
+ try:
+ log.LogFilter.parse(logfilter)
+ except log.InvalidLogFilterError as e:
+ raise argparse.ArgumentTypeError(e)
+ return logfilter
def debug_flag_error(flag):
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/log.py b/qutebrowser/utils/log.py
index 2718f10ba..197f594f9 100644
--- a/qutebrowser/utils/log.py
+++ b/qutebrowser/utils/log.py
@@ -41,6 +41,9 @@ try:
except ImportError:
colorama = None
+if typing.TYPE_CHECKING:
+ from qutebrowser.config import config as configmodule
+
_log_inited = False
_args = None
@@ -176,7 +179,7 @@ def stub(suffix: str = '') -> None:
def init_log(args: argparse.Namespace) -> None:
"""Init loggers based on the argparse namespace passed."""
- level = args.loglevel.upper()
+ level = (args.loglevel or "info").upper()
try:
numeric_level = getattr(logging, level)
except AttributeError:
@@ -190,16 +193,7 @@ def init_log(args: argparse.Namespace) -> None:
root = logging.getLogger()
global console_filter
if console is not None:
- if not args.logfilter:
- negate = False
- names = None
- elif args.logfilter.startswith('!'):
- negate = True
- names = args.logfilter[1:].split(',')
- else:
- negate = False
- names = args.logfilter.split(',')
- console_filter = LogFilter(names, negate)
+ console_filter = LogFilter.parse(args.logfilter)
console.addFilter(console_filter)
root.addHandler(console)
if ram is not None:
@@ -293,7 +287,7 @@ def _init_handlers(
ram_handler = None
else:
ram_handler = RAMHandler(capacity=ram_capacity)
- ram_handler.setLevel(logging.NOTSET)
+ ram_handler.setLevel(logging.DEBUG)
ram_handler.setFormatter(ram_fmt)
ram_handler.html_formatter = html_fmt
@@ -526,6 +520,36 @@ def hide_qt_warning(pattern: str, logger: str = 'qt') -> typing.Iterator[None]:
logger_obj.removeFilter(log_filter)
+def init_from_config(conf: 'configmodule.ConfigContainer') -> None:
+ """Initialize logging settings from the config.
+
+ init_log is called before the config module is initialized, so config-based
+ initialization cannot be performed there.
+
+ Args:
+ conf: The global ConfigContainer.
+ This is passed rather than accessed via the module to avoid a
+ cyclic import.
+ """
+ assert _args is not None
+ if _args.debug:
+ init.debug("--debug flag overrides log configs")
+ return
+ if ram_handler:
+ ramlevel = conf.logging.level.ram
+ init.debug("Configuring RAM loglevel to %s", ramlevel)
+ ram_handler.setLevel(LOG_LEVELS[ramlevel.upper()])
+ if console_handler:
+ consolelevel = conf.logging.level.console
+ if _args.loglevel:
+ init.debug("--loglevel flag overrides logging.level.console")
+ else:
+ init.debug("Configuring console loglevel to %s", consolelevel)
+ level = LOG_LEVELS[consolelevel.upper()]
+ console_handler.setLevel(level)
+ change_console_formatter(level)
+
+
class QtWarningFilter(logging.Filter):
"""Filter to filter Qt warnings.
@@ -544,6 +568,17 @@ class QtWarningFilter(logging.Filter):
return do_log
+class InvalidLogFilterError(Exception):
+
+ """Raised when an invalid filter string is passed to LogFilter.parse()."""
+
+ def __init__(self, names: typing.Set[str]):
+ invalid = names - set(LOGGER_NAMES)
+ super().__init__("Invalid log category {} - valid categories: {}"
+ .format(', '.join(sorted(invalid)),
+ ', '.join(LOGGER_NAMES)))
+
+
class LogFilter(logging.Filter):
"""Filter to filter log records based on the commandline argument.
@@ -552,30 +587,58 @@ class LogFilter(logging.Filter):
comma-separated list instead.
Attributes:
- names: A list of record names to filter.
- negated: Whether names is a list of records to log or to suppress.
+ names: A set of logging names to allow.
+ negated: Whether names is a set of names to log or to suppress.
+ only_debug: Only filter debug logs, always show anything more important
+ than debug.
"""
- def __init__(self, names: typing.Optional[typing.Iterable[str]],
- negate: bool = False) -> None:
+ def __init__(self, names: typing.Set[str], *, negated: bool = False,
+ only_debug: bool = True) -> None:
super().__init__()
self.names = names
- self.negated = negate
+ self.negated = negated
+ self.only_debug = only_debug
+
+ @classmethod
+ def parse(cls, filter_str: typing.Optional[str], *,
+ only_debug: bool = True) -> 'LogFilter':
+ """Parse a log filter from a string."""
+ if filter_str is None or filter_str == 'none':
+ names = set()
+ negated = False
+ else:
+ filter_str = filter_str.lower()
+
+ if filter_str.startswith('!'):
+ negated = True
+ filter_str = filter_str[1:]
+ else:
+ negated = False
+
+ names = {e.strip() for e in filter_str.split(',')}
+
+ if not names.issubset(LOGGER_NAMES):
+ raise InvalidLogFilterError(names)
+
+ return cls(names=names, negated=negated, only_debug=only_debug)
+
+ def update_from(self, other: 'LogFilter') -> None:
+ """Update this filter's properties from another filter."""
+ self.names = other.names
+ self.negated = other.negated
+ self.only_debug = other.only_debug
def filter(self, record: logging.LogRecord) -> bool:
"""Determine if the specified record is to be logged."""
- if self.names is None:
+ if not self.names:
+ # No filter
return True
- if record.levelno > logging.DEBUG:
+ elif record.levelno > logging.DEBUG and self.only_debug:
# More important than DEBUG, so we won't filter at all
return True
- for name in self.names:
- if record.name == name:
- return not self.negated
- elif not record.name.startswith(name):
- continue
- elif record.name[len(name)] == '.':
- return not self.negated
+ elif record.name.split('.')[0] in self.names:
+ return not self.negated
return self.negated
@@ -601,19 +664,26 @@ class RAMHandler(logging.Handler):
self._data = collections.deque()
def emit(self, record: logging.LogRecord) -> None:
- if record.levelno >= logging.DEBUG:
- # We don't log VDEBUG to RAM.
- self._data.append(record)
+ self._data.append(record)
- def dump_log(self, html: bool = False, level: str = 'vdebug') -> str:
+ def dump_log(self, html: bool = False, level: str = 'vdebug',
+ logfilter: LogFilter = None) -> str:
"""Dump the complete formatted log data as string.
- FIXME: We should do all the HTML formatter via jinja2.
+ FIXME: We should do all the HTML formatting via jinja2.
(probably obsolete when moving to a widget for logging,
https://github.com/qutebrowser/qutebrowser/issues/34
+
+ Args:
+ html: Produce HTML rather than plaintext output.
+ level: The minimal loglevel to show.
+ logfilter: A LogFilter instance used to filter log lines.
"""
minlevel = LOG_LEVELS.get(level.upper(), VDEBUG_LEVEL)
+ if logfilter is None:
+ logfilter = LogFilter(set())
+
if html:
assert self.html_formatter is not None
fmt = self.html_formatter.format
@@ -624,7 +694,8 @@ class RAMHandler(logging.Handler):
try:
lines = [fmt(record)
for record in self._data
- if record.levelno >= minlevel]
+ if record.levelno >= minlevel and
+ logfilter.filter(record)]
finally:
self.release()
return '\n'.join(lines)
diff --git a/qutebrowser/utils/message.py b/qutebrowser/utils/message.py
index a8c7c8d85..2754d87e7 100644
--- a/qutebrowser/utils/message.py
+++ b/qutebrowser/utils/message.py
@@ -25,7 +25,7 @@
import traceback
import typing
-from PyQt5.QtCore import pyqtSignal, QObject, QUrl
+from PyQt5.QtCore import pyqtSignal, QObject
from qutebrowser.utils import usertypes, log, utils
diff --git a/qutebrowser/utils/qtutils.py b/qutebrowser/utils/qtutils.py
index 3e8afae3f..04db1f0cb 100644
--- a/qutebrowser/utils/qtutils.py
+++ b/qutebrowser/utils/qtutils.py
@@ -35,7 +35,7 @@ import typing
import pkg_resources
from PyQt5.QtCore import (qVersion, QEventLoop, QDataStream, QByteArray,
- QIODevice, QSaveFile, QT_VERSION_STR,
+ QIODevice, QFileDevice, QSaveFile, QT_VERSION_STR,
PYQT_VERSION_STR, QObject, QUrl)
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import QApplication
@@ -44,9 +44,6 @@ try:
except ImportError: # pragma: no cover
qWebKitVersion = None # type: ignore[assignment] # noqa: N816
-if typing.TYPE_CHECKING:
- from PyQt5.QtCore import QFileDevice
-
from qutebrowser.misc import objects
from qutebrowser.utils import usertypes
@@ -74,13 +71,17 @@ class QtOSError(OSError):
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,
@@ -229,7 +230,7 @@ def savefile_open(
if not open_ok:
raise QtOSError(f)
- dev = typing.cast(typing.IO[bytes], PyQIODevice(f))
+ dev = typing.cast(typing.BinaryIO, PyQIODevice(f))
if binary:
new_f = dev # type: typing.IO
diff --git a/qutebrowser/utils/usertypes.py b/qutebrowser/utils/usertypes.py
index 247946497..0b6f9c219 100644
--- a/qutebrowser/utils/usertypes.py
+++ b/qutebrowser/utils/usertypes.py
@@ -256,6 +256,10 @@ class KeyMode(enum.Enum):
jump_mark = 10
record_macro = 11
run_macro = 12
+ # 'register' is a bit of an oddball here: It's not really a "real" mode,
+ # but it's used in the config for common bindings for
+ # set_mark/jump_mark/record_macro/run_macro.
+ register = 13
class Exit(enum.IntEnum):
diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py
index 368cb0ab6..92ca34a08 100644
--- a/qutebrowser/utils/utils.py
+++ b/qutebrowser/utils/utils.py
@@ -36,6 +36,8 @@ import shlex
import glob
import mimetypes
import typing
+import ctypes
+import ctypes.util
from PyQt5.QtCore import QUrl
from PyQt5.QtGui import QColor, QClipboard, QDesktopServices
@@ -776,3 +778,16 @@ def ceil_log(number: int, base: int) -> int:
result += 1
accum *= base
return result
+
+
+def libgl_workaround() -> None:
+ """Work around QOpenGLShaderProgram issues, especially for Nvidia.
+
+ See https://bugs.launchpad.net/ubuntu/+source/python-qt4/+bug/941826
+ """
+ if os.environ.get('QUTE_SKIP_LIBGL_WORKAROUND'):
+ return
+
+ libgl = ctypes.util.find_library("GL")
+ if libgl is not None: # pragma: no branch
+ ctypes.CDLL(libgl, mode=ctypes.RTLD_GLOBAL)
diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py
index 1ad8b22cf..59ef04f1f 100644
--- a/qutebrowser/utils/version.py
+++ b/qutebrowser/utils/version.py
@@ -31,6 +31,7 @@ import enum
import datetime
import getpass
import typing
+import functools
import attr
import pkg_resources
@@ -160,6 +161,14 @@ def _git_str() -> typing.Optional[str]:
return None
+def _call_git(gitpath: str, *args: str) -> str:
+ """Call a git subprocess."""
+ return subprocess.run(
+ ['git'] + list(args),
+ cwd=gitpath, check=True,
+ stdout=subprocess.PIPE).stdout.decode('UTF-8').strip()
+
+
def _git_str_subprocess(gitpath: str) -> typing.Optional[str]:
"""Try to get the git commit ID and timestamp by calling git.
@@ -173,15 +182,11 @@ def _git_str_subprocess(gitpath: str) -> typing.Optional[str]:
return None
try:
# https://stackoverflow.com/questions/21017300/21017394#21017394
- commit_hash = subprocess.run(
- ['git', 'describe', '--match=NeVeRmAtCh', '--always', '--dirty'],
- cwd=gitpath, check=True,
- stdout=subprocess.PIPE).stdout.decode('UTF-8').strip()
- date = subprocess.run(
- ['git', 'show', '-s', '--format=%ci', 'HEAD'],
- cwd=gitpath, check=True,
- stdout=subprocess.PIPE).stdout.decode('UTF-8').strip()
- return '{} ({})'.format(commit_hash, date)
+ commit_hash = _call_git(gitpath, 'describe', '--match=NeVeRmAtCh',
+ '--always', '--dirty')
+ date = _call_git(gitpath, 'show', '-s', '--format=%ci', 'HEAD')
+ branch = _call_git(gitpath, 'rev-parse', '--abbrev-ref', 'HEAD')
+ return '{} on {} ({})'.format(commit_hash, branch, date)
except (subprocess.CalledProcessError, OSError):
return None
@@ -233,7 +238,7 @@ def _module_versions() -> typing.Sequence[str]:
for modname, attributes in modules.items():
try:
module = importlib.import_module(modname)
- except ImportError:
+ except (ImportError, ValueError):
text = '{}: no'.format(modname)
else:
for name in attributes:
@@ -411,7 +416,7 @@ def _config_py_loaded() -> str:
return "no config.py was loaded"
-def version() -> str:
+def version_info() -> str:
"""Return a string with various version information."""
lines = ["qutebrowser v{}".format(qutebrowser.__version__)]
gitver = _git_str()
@@ -442,8 +447,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))
+ lines.append('Platform plugin: {}'.format(qapp.platformName()))
+ lines.append('OpenGL: {}'.format(opengl_info()))
importpath = os.path.dirname(os.path.abspath(qutebrowser.__file__))
@@ -487,7 +492,65 @@ def version() -> str:
return '\n'.join(lines)
-def opengl_vendor() -> typing.Optional[str]: # pragma: no cover
+@attr.s
+class OpenGLInfo:
+
+ """Information about the OpenGL setup in use."""
+
+ # If we're using OpenGL ES. If so, no further information is available.
+ gles = attr.ib(False) # type: bool
+
+ # The name of the vendor. Examples:
+ # - nouveau
+ # - "Intel Open Source Technology Center", "Intel", "Intel Inc."
+ vendor = attr.ib(None) # type: typing.Optional[str]
+
+ # The OpenGL version as a string. See tests for examples.
+ version_str = attr.ib(None) # type: typing.Optional[str]
+
+ # The parsed version as a (major, minor) tuple of ints
+ version = attr.ib(None) # type: typing.Optional[typing.Tuple[int, ...]]
+
+ # The vendor specific information following the version number
+ vendor_specific = attr.ib(None) # type: typing.Optional[str]
+
+ def __str__(self) -> str:
+ if self.gles:
+ return 'OpenGL ES'
+ return '{}, {}'.format(self.vendor, self.version_str)
+
+ @classmethod
+ def parse(cls, *, vendor: str, version: str) -> 'OpenGLInfo':
+ """Parse OpenGL version info from a string.
+
+ The arguments should be the strings returned by OpenGL for GL_VENDOR
+ and GL_VERSION, respectively.
+
+ According to the OpenGL reference, the version string should have the
+ following format:
+
+ <major>.<minor>[.<release>] <vendor-specific info>
+ """
+ if ' ' not in version:
+ log.misc.warning("Failed to parse OpenGL version (missing space): "
+ "{}".format(version))
+ return cls(vendor=vendor, version_str=version)
+
+ num_str, vendor_specific = version.split(' ', maxsplit=1)
+
+ try:
+ parsed_version = tuple(int(i) for i in num_str.split('.'))
+ except ValueError:
+ log.misc.warning("Failed to parse OpenGL version (parsing int): "
+ "{}".format(version))
+ return cls(vendor=vendor, version_str=version)
+
+ return cls(vendor=vendor, version_str=version,
+ version=parsed_version, vendor_specific=vendor_specific)
+
+
+@functools.lru_cache(maxsize=1)
+def opengl_info() -> typing.Optional[OpenGLInfo]: # pragma: no cover
"""Get the OpenGL vendor used.
This returns a string such as 'nouveau' or
@@ -496,10 +559,14 @@ def opengl_vendor() -> typing.Optional[str]: # pragma: no cover
"""
assert QApplication.instance()
- override = os.environ.get('QUTE_FAKE_OPENGL_VENDOR')
+ # Some setups can segfault in here if we don't do this.
+ utils.libgl_workaround()
+
+ override = os.environ.get('QUTE_FAKE_OPENGL')
if override is not None:
log.init.debug("Using override {}".format(override))
- return override
+ vendor, version = override.split(', ', maxsplit=1)
+ return OpenGLInfo.parse(vendor=vendor, version=version)
old_context = typing.cast(typing.Optional[QOpenGLContext],
QOpenGLContext.currentContext())
@@ -522,7 +589,7 @@ def opengl_vendor() -> typing.Optional[str]: # pragma: no cover
try:
if ctx.isOpenGLES():
# Can't use versionFunctions there
- return None
+ return OpenGLInfo(gles=True)
vp = QOpenGLVersionProfile()
vp.setVersion(2, 0)
@@ -537,7 +604,10 @@ def opengl_vendor() -> typing.Optional[str]: # pragma: no cover
log.init.debug("Getting version functions failed!")
return None
- return vf.glGetString(vf.GL_VENDOR)
+ vendor = vf.glGetString(vf.GL_VENDOR)
+ version = vf.glGetString(vf.GL_VERSION)
+
+ return OpenGLInfo.parse(vendor=vendor, version=version)
finally:
ctx.doneCurrent()
if old_context and old_surface:
@@ -580,5 +650,5 @@ def pastebin_version(pbclient: pastebin.PastebinClient = None) -> None:
pbclient.paste(getpass.getuser(),
"qute version info {}".format(qutebrowser.__version__),
- version(),
+ version_info(),
private=True)
diff --git a/scripts/asciidoc2html.py b/scripts/asciidoc2html.py
index d43531ca3..e7e7f680b 100755
--- a/scripts/asciidoc2html.py
+++ b/scripts/asciidoc2html.py
@@ -20,21 +20,24 @@
"""Generate the html documentation based on the asciidoc files."""
+from typing import List, Optional
import re
import os
import os.path
import sys
import subprocess
-import glob
import shutil
import tempfile
import argparse
import io
+import pathlib
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
from scripts import utils
+DOC_DIR = pathlib.Path("qutebrowser/html/doc")
+
class AsciiDoc:
@@ -42,31 +45,32 @@ class AsciiDoc:
FILES = ['faq', 'changelog', 'contributing', 'quickstart', 'userscripts']
- def __init__(self, asciidoc, website):
- self._cmd = None
+ def __init__(self,
+ asciidoc: Optional[List[str]],
+ website: Optional[str]) -> None:
+ self._cmd = None # type: Optional[List[str]]
self._asciidoc = asciidoc
self._website = website
- self._homedir = None
- self._themedir = None
- self._tempdir = None
+ self._homedir = None # type: Optional[pathlib.Path]
+ self._themedir = None # type: Optional[pathlib.Path]
+ self._tempdir = None # type: Optional[pathlib.Path]
self._failed = False
- def prepare(self):
+ def prepare(self) -> None:
"""Get the asciidoc command and create the homedir to use."""
self._cmd = self._get_asciidoc_cmd()
- self._homedir = tempfile.mkdtemp()
- self._themedir = os.path.join(
- self._homedir, '.asciidoc', 'themes', 'qute')
- self._tempdir = os.path.join(self._homedir, 'tmp')
- os.makedirs(self._tempdir)
- os.makedirs(self._themedir)
-
- def cleanup(self):
+ self._homedir = pathlib.Path(tempfile.mkdtemp())
+ self._themedir = self._homedir / '.asciidoc' / 'themes' / 'qute'
+ self._tempdir = self._homedir / 'tmp'
+ self._tempdir.mkdir(parents=True)
+ self._themedir.mkdir(parents=True)
+
+ def cleanup(self) -> None:
"""Clean up the temporary home directory for asciidoc."""
if self._homedir is not None and not self._failed:
shutil.rmtree(self._homedir)
- def build(self):
+ def build(self) -> None:
"""Build either the website or the docs."""
if self._website:
self._build_website()
@@ -74,14 +78,12 @@ class AsciiDoc:
self._build_docs()
self._copy_images()
- def _build_docs(self):
+ def _build_docs(self) -> None:
"""Render .asciidoc files to .html sites."""
- files = [('doc/{}.asciidoc'.format(f),
- 'qutebrowser/html/doc/{}.html'.format(f))
- for f in self.FILES]
- for src in glob.glob('doc/help/*.asciidoc'):
- name, _ext = os.path.splitext(os.path.basename(src))
- dst = 'qutebrowser/html/doc/{}.html'.format(name)
+ files = [(pathlib.Path('doc/{}.asciidoc'.format(f)),
+ DOC_DIR / (f + ".html")) for f in self.FILES]
+ for src in pathlib.Path('doc/help/').glob('*.asciidoc'):
+ dst = DOC_DIR / (src.stem + ".html")
files.append((src, dst))
# patch image links to use local copy
@@ -94,8 +96,8 @@ class AsciiDoc:
asciidoc_args = ['-a', 'source-highlighter=pygments']
for src, dst in files:
- src_basename = os.path.basename(src)
- modified_src = os.path.join(self._tempdir, src_basename)
+ assert self._tempdir is not None # for mypy
+ modified_src = self._tempdir / src.name
with open(modified_src, 'w', encoding='utf-8') as modified_f, \
open(src, 'r', encoding='utf-8') as f:
for line in f:
@@ -104,34 +106,26 @@ class AsciiDoc:
modified_f.write(line)
self.call(modified_src, dst, *asciidoc_args)
- def _copy_images(self):
+ def _copy_images(self) -> None:
"""Copy image files to qutebrowser/html/doc."""
print("Copying files...")
- dst_path = os.path.join('qutebrowser', 'html', 'doc', 'img')
- try:
- os.mkdir(dst_path)
- except FileExistsError:
- pass
+ dst_path = DOC_DIR / 'img'
+ dst_path.mkdir(exist_ok=True)
for filename in ['cheatsheet-big.png', 'cheatsheet-small.png']:
- src = os.path.join('doc', 'img', filename)
- dst = os.path.join(dst_path, filename)
+ src = pathlib.Path('doc') / 'img' / filename
+ dst = dst_path / filename
shutil.copy(src, dst)
- def _build_website_file(self, root, filename):
+ def _build_website_file(self, root: pathlib.Path, filename: str) -> None:
"""Build a single website file."""
- src = os.path.join(root, filename)
- src_basename = os.path.basename(src)
- parts = [self._website[0]]
- dirname = os.path.dirname(src)
- if dirname:
- parts.append(os.path.relpath(os.path.dirname(src)))
- parts.append(
- os.extsep.join((os.path.splitext(src_basename)[0],
- 'html')))
- dst = os.path.join(*parts)
- os.makedirs(os.path.dirname(dst), exist_ok=True)
-
- modified_src = os.path.join(self._tempdir, src_basename)
+ src = root / filename
+ assert self._website is not None # for mypy
+ dst = pathlib.Path(self._website)
+ dst = dst / src.parent.relative_to('.') / (src.stem + ".html")
+ dst.parent.mkdir(exist_ok=True)
+
+ assert self._tempdir is not None # for mypy
+ modified_src = self._tempdir / src.name
shutil.copy('www/header.asciidoc', modified_src)
outfp = io.StringIO()
@@ -187,25 +181,24 @@ class AsciiDoc:
'-a', 'source-highlighter=pygments']
self.call(modified_src, dst, *asciidoc_args)
- def _build_website(self):
+ def _build_website(self) -> None:
"""Prepare and build the website."""
- theme_file = os.path.abspath(os.path.join('www', 'qute.css'))
+ theme_file = (pathlib.Path('www') / 'qute.css').resolve()
+ assert self._themedir is not None # for mypy
shutil.copy(theme_file, self._themedir)
- outdir = self._website[0]
+ assert self._website is not None # for mypy
+ outdir = pathlib.Path(self._website)
- for root, _dirs, files in os.walk(os.getcwd()):
- for filename in files:
- basename, ext = os.path.splitext(filename)
- if (ext != '.asciidoc' or
- basename in ['header', 'OpenSans-License']):
- continue
- self._build_website_file(root, filename)
+ for item_path in pathlib.Path().rglob('*.asciidoc'):
+ if item_path.stem in ['header', 'OpenSans-License']:
+ continue
+ self._build_website_file(item_path.parent, item_path.name)
copy = {'icons': 'icons', 'doc/img': 'doc/img', 'www/media': 'media/'}
for src, dest in copy.items():
- full_dest = os.path.join(outdir, dest)
+ full_dest = outdir / dest
try:
shutil.rmtree(full_dest)
except FileNotFoundError:
@@ -214,13 +207,15 @@ class AsciiDoc:
for dst, link_name in [
('README.html', 'index.html'),
- (os.path.join('doc', 'quickstart.html'), 'quickstart.html')]:
+ ((pathlib.Path('doc') / 'quickstart.html'),
+ 'quickstart.html')]:
+ assert isinstance(dst, (str, pathlib.Path)) # for mypy
try:
- os.symlink(dst, os.path.join(outdir, link_name))
+ (outdir / link_name).symlink_to(dst)
except FileExistsError:
pass
- def _get_asciidoc_cmd(self):
+ def _get_asciidoc_cmd(self) -> List[str]:
"""Try to find out what commandline to use to invoke asciidoc."""
if self._asciidoc is not None:
return self._asciidoc
@@ -243,7 +238,7 @@ class AsciiDoc:
raise FileNotFoundError
- def call(self, src, dst, *args):
+ def call(self, src: pathlib.Path, dst: pathlib.Path, *args):
"""Call asciidoc for the given files.
Args:
@@ -251,15 +246,16 @@ class AsciiDoc:
dst: The destination .html file, or None to auto-guess.
*args: Additional arguments passed to asciidoc.
"""
- print("Calling asciidoc for {}...".format(os.path.basename(src)))
+ print("Calling asciidoc for {}...".format(src.name))
+ assert self._cmd is not None # for mypy
cmdline = self._cmd[:]
if dst is not None:
- cmdline += ['--out-file', dst]
+ cmdline += ['--out-file', str(dst)]
cmdline += args
- cmdline.append(src)
+ cmdline.append(str(src))
try:
env = os.environ.copy()
- env['HOME'] = self._homedir
+ env['HOME'] = str(self._homedir)
subprocess.run(cmdline, check=True, env=env)
except (subprocess.CalledProcessError, OSError) as e:
self._failed = True
@@ -269,11 +265,11 @@ class AsciiDoc:
sys.exit(1)
-def parse_args():
+def parse_args() -> argparse.Namespace:
"""Parse command-line arguments."""
parser = argparse.ArgumentParser()
parser.add_argument('--website', help="Build website into a given "
- "directory.", nargs=1)
+ "directory.")
parser.add_argument('--asciidoc', help="Full path to python and "
"asciidoc.py. If not given, it's searched in PATH.",
nargs=2, required=False,
@@ -281,12 +277,9 @@ def parse_args():
return parser.parse_args()
-def run(**kwargs):
+def run(**kwargs) -> None:
"""Regenerate documentation."""
- try:
- os.mkdir('qutebrowser/html/doc')
- except FileExistsError:
- pass
+ DOC_DIR.mkdir(exist_ok=True)
asciidoc = AsciiDoc(**kwargs)
try:
@@ -303,7 +296,7 @@ def run(**kwargs):
asciidoc.cleanup()
-def main(colors=False):
+def main(colors: bool = False) -> None:
"""Generate html files for the online documentation."""
utils.change_cwd()
utils.use_color = colors
diff --git a/scripts/dev/misc_checks.py b/scripts/dev/misc_checks.py
index 24c3a1ddc..6bf411bba 100644
--- a/scripts/dev/misc_checks.py
+++ b/scripts/dev/misc_checks.py
@@ -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/src2asciidoc.py b/scripts/dev/src2asciidoc.py
index 51f4a3633..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, '')
diff --git a/scripts/setupcommon.py b/scripts/setupcommon.py
index e07096546..65e2a498a 100644
--- a/scripts/setupcommon.py
+++ b/scripts/setupcommon.py
@@ -38,6 +38,14 @@ BASEDIR = os.path.join(os.path.dirname(os.path.realpath(__file__)),
os.path.pardir)
+def _call_git(gitpath, *args):
+ """Call a git subprocess."""
+ return subprocess.run(
+ ['git'] + list(args),
+ cwd=gitpath, check=True,
+ stdout=subprocess.PIPE).stdout.decode('UTF-8').strip()
+
+
def _git_str():
"""Try to find out git version.
@@ -51,15 +59,11 @@ def _git_str():
return None
try:
# https://stackoverflow.com/questions/21017300/21017394#21017394
- commit_hash = subprocess.run(
- ['git', 'describe', '--match=NeVeRmAtCh', '--always', '--dirty'],
- cwd=BASEDIR, check=True,
- stdout=subprocess.PIPE).stdout.decode('UTF-8').strip()
- date = subprocess.run(
- ['git', 'show', '-s', '--format=%ci', 'HEAD'],
- cwd=BASEDIR, check=True,
- stdout=subprocess.PIPE).stdout.decode('UTF-8').strip()
- return '{} ({})'.format(commit_hash, date)
+ commit_hash = _call_git(BASEDIR, 'describe', '--match=NeVeRmAtCh',
+ '--always', '--dirty')
+ date = _call_git(BASEDIR, 'show', '-s', '--format=%ci', 'HEAD')
+ branch = _call_git(BASEDIR, 'rev-parse', '--abbrev-ref', 'HEAD')
+ return '{} on {} ({})'.format(commit_hash, branch, date)
except (subprocess.CalledProcessError, OSError):
return None
diff --git a/tests/conftest.py b/tests/conftest.py
index c6b6c2efc..e698bde74 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -25,8 +25,6 @@ import os
import sys
import warnings
import pathlib
-import ctypes
-import ctypes.util
import pytest
import hypothesis
@@ -258,9 +256,7 @@ def set_backend(monkeypatch, request):
@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")
- if libgl is not None:
- ctypes.CDLL(libgl, mode=ctypes.RTLD_GLOBAL)
+ utils.libgl_workaround()
@pytest.fixture(autouse=True)
diff --git a/tests/end2end/features/caret.feature b/tests/end2end/features/caret.feature
index e540bafcb..ec45efaea 100644
--- a/tests/end2end/features/caret.feature
+++ b/tests/end2end/features/caret.feature
@@ -5,7 +5,8 @@ Feature: Caret mode
Background:
Given I open data/caret.html
- And I run :tab-only ;; enter-mode caret
+ And I run :tab-only
+ And I also run :enter-mode caret
# :yank selection
diff --git a/tests/end2end/features/conftest.py b/tests/end2end/features/conftest.py
index 6ac5f281d..c1e7e32ae 100644
--- a/tests/end2end/features/conftest.py
+++ b/tests/end2end/features/conftest.py
@@ -152,6 +152,17 @@ def run_command_given(quteproc, command):
quteproc.send_cmd(command)
+@bdd.given(bdd.parsers.parse("I also run {command}"))
+def run_command_given_2(quteproc, command):
+ """Run a qutebrowser command.
+
+ Separate from the above as a hack to run two commands in a Background
+ without having to use ";;". This is needed because pytest-bdd doesn't allow
+ re-using a Given step...
+ """
+ quteproc.send_cmd(command)
+
+
@bdd.given("I have a fresh instance")
def fresh_instance(quteproc):
"""Restart qutebrowser instance for tests needing a fresh state."""
diff --git a/tests/end2end/features/hints.feature b/tests/end2end/features/hints.feature
index 190e95f79..d0563a77b 100644
--- a/tests/end2end/features/hints.feature
+++ b/tests/end2end/features/hints.feature
@@ -323,8 +323,8 @@ Feature: Using hints
And I wait until data/hello.txt is loaded
And I press the key ","
# Waiting here so we don't affect the next test
- And I wait for "Releasing inhibition state of normal mode." in the log
- Then "Ignoring key ',', because the normal mode is currently inhibited." should be logged
+ And I wait for "NormalKeyParser for mode normal: Releasing inhibition state of normal mode." in the log
+ Then "NormalKeyParser for mode normal: Ignoring key ',', because the normal mode is currently inhibited." should be logged
Scenario: Turning off auto_follow_timeout
When I set hints.auto_follow_timeout to 0
diff --git a/tests/end2end/features/private.feature b/tests/end2end/features/private.feature
index 35097f545..6ea9e7b33 100644
--- a/tests/end2end/features/private.feature
+++ b/tests/end2end/features/private.feature
@@ -153,7 +153,7 @@ Feature: Using private browsing
- url: http://localhost:*/data/numbers/1.txt
- url: http://localhost:*/data/numbers/2.txt
-
+ @flaky
Scenario: Saving a private session with only-active-window
When I open data/numbers/1.txt
And I open data/numbers/2.txt in a new tab
diff --git a/tests/end2end/features/qutescheme.feature b/tests/end2end/features/qutescheme.feature
index 35c110dc5..2325912c5 100644
--- a/tests/end2end/features/qutescheme.feature
+++ b/tests/end2end/features/qutescheme.feature
@@ -258,20 +258,37 @@ Feature: Special qute:// pages
And the page should contain the plaintext "the-warning-message"
And the page should contain the plaintext "the-info-message"
+ Scenario: Showing messages of category 'message'
+ When I run :message-info the-info-message
+ And I run :messages -f message
+ Then qute://log/?level=info&logfilter=message should be loaded
+ And the page should contain the plaintext "the-info-message"
+
+ Scenario: Showing messages of category 'misc'
+ When I run :message-info the-info-message
+ And I run :messages -f misc
+ Then qute://log/?level=info&logfilter=misc should be loaded
+ And the page should not contain the plaintext "the-info-message"
+
@qtwebengine_flaky
Scenario: Showing messages of an invalid level
When I run :messages cataclysmic
Then the error "Invalid log level cataclysmic!" should be shown
+ Scenario: Showing messages with an invalid category
+ When I run :messages -f invalid
+ Then the error "Invalid log category invalid - *" should be shown
+
Scenario: Using qute://log directly
When I open qute://log without waiting
# With Qt 5.9, we don't get a loaded message?
And I wait for "Changing title for idx * to 'log'" in the log
Then no crash should happen
- Scenario: Using qute://plainlog directly
- When I open qute://plainlog
- Then no crash should happen
+ # FIXME More possible tests:
+ # :message --plain
+ # Using qute://log directly with invalid category
+ # same with invalid level
# :version
diff --git a/tests/end2end/features/sessions.feature b/tests/end2end/features/sessions.feature
index 494feb0ba..69c58f3c3 100644
--- a/tests/end2end/features/sessions.feature
+++ b/tests/end2end/features/sessions.feature
@@ -282,6 +282,7 @@ Feature: Saving and loading sessions
Then "Saved session quiet_session." should be logged with level debug
And the session quiet_session should exist
+ @flaky
Scenario: Saving session with --only-active-window
When I open data/numbers/1.txt
And I open data/numbers/2.txt in a new tab
diff --git a/tests/end2end/features/utilcmds.feature b/tests/end2end/features/utilcmds.feature
index 9b4eb5760..94db7c403 100644
--- a/tests/end2end/features/utilcmds.feature
+++ b/tests/end2end/features/utilcmds.feature
@@ -166,13 +166,9 @@ Feature: Miscellaneous utility commands exposed to the user.
# Other :debug-log-{level,filter} features are tested in
# unit/utils/test_log.py as using them would break end2end tests.
- Scenario: Using debug-log-level with invalid level
- When I run :debug-log-level hello
- Then the error "level: Invalid value hello - expected one of: vdebug, debug, info, warning, error, critical" should be shown
-
Scenario: Using debug-log-filter with invalid filter
When I run :debug-log-filter blah
- Then the error "filters: Invalid value blah - expected one of: statusbar, *" should be shown
+ Then the error "Invalid log category blah - valid categories: statusbar, *" should be shown
Scenario: Using debug-log-filter
When I run :debug-log-filter commands,ipc,webview
diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py
index 5f8263334..2e47c9e43 100644
--- a/tests/end2end/fixtures/quteprocess.py
+++ b/tests/end2end/fixtures/quteprocess.py
@@ -285,6 +285,23 @@ def is_ignored_chromium_message(line):
# [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)',
+
+ # Qt 5.15 with AppVeyor
+ # [2968:3108:0601/123442.125:ERROR:mf_helpers.cc(14)] Error in
+ # dxva_video_decode_accelerator_win.cc on line 517
+ 'Error in dxva_video_decode_accelerator_win.cc on line 517',
+
+ # Qt 5.15 and debug build
+ # [134188:134199:0609/132454.797229:WARNING:
+ # simple_synchronous_entry.cc(1389)]
+ # Could not open platform files for entry.
+ # [134151:134187:0609/132456.754321:ERROR:process_posix.cc(333)]
+ # Unable to terminate process 134188: No such process (3)
+ # [134151:134187:0609/132456.754414:WARNING:internal_linux.cc(64)]
+ # Failed to read /proc/134188/stat
+ 'Could not open platform files for entry.',
+ 'Unable to terminate process *: No such process (3)',
+ 'Failed to read /proc/*/stat',
]
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/test_invocations.py b/tests/end2end/test_invocations.py
index d61458ef3..b4a343a37 100644
--- a/tests/end2end/test_invocations.py
+++ b/tests/end2end/test_invocations.py
@@ -381,6 +381,9 @@ def test_qute_settings_persistence(short_tmpdir, request, quteproc_new):
quteproc_new.send_cmd(':jseval --world main '
'cset("search.ignore_case", "always")')
quteproc_new.wait_for(message='No output or error')
+ quteproc_new.wait_for(category='config',
+ message='Config option changed: '
+ 'search.ignore_case = always')
assert quteproc_new.get_setting('search.ignore_case') == 'always'
diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py
index ced27a9f8..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,11 +235,25 @@ 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):
diff --git a/tests/helpers/stubs.py b/tests/helpers/stubs.py
index b72907d93..bc8044461 100644
--- a/tests/helpers/stubs.py
+++ b/tests/helpers/stubs.py
@@ -615,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:
@@ -653,6 +657,9 @@ class FakeHintManager:
def handle_partial_key(self, keystr):
self.keystr = keystr
+ def current_mode(self):
+ return 'letter'
+
class FakeWebEngineProfile:
diff --git a/tests/helpers/utils.py b/tests/helpers/utils.py
index 25c3fb9a1..70a10436c 100644
--- a/tests/helpers/utils.py
+++ b/tests/helpers/utils.py
@@ -25,6 +25,7 @@ import gzip
import pprint
import os.path
import contextlib
+import pathlib
import pytest
@@ -187,6 +188,17 @@ def nop_contextmanager():
@contextlib.contextmanager
+def change_cwd(path):
+ """Use a path as current working directory."""
+ old_cwd = pathlib.Path.cwd()
+ os.chdir(str(path))
+ try:
+ yield
+ finally:
+ os.chdir(str(old_cwd))
+
+
+@contextlib.contextmanager
def ignore_bs4_warning():
"""WORKAROUND for https://bugs.launchpad.net/beautifulsoup/+bug/1847592."""
with log.ignore_py_warnings(
diff --git a/tests/manual/mouse.html b/tests/manual/mouse.html
index eb75df44d..d1f0f7dee 100644
--- a/tests/manual/mouse.html
+++ b/tests/manual/mouse.html
@@ -10,7 +10,8 @@
<li>When clicking the link with shift, <code>tabs.background</code> should be reversed accordingly.</li>
<li>Ctrl + Mousewheel should zoom in/out</li>
<li>Back/forward keys on mouse should navigate back/forward</li>
- <li>With <code>input.rocker_gestures</code> set, no context menu should be shown, but pressing left+right/right+left buttons should navigate back/forward</li>
- <li>When setting <code>input.rocker_gestures</code> dynamically, the context menu should be hidden/shown accordingly.</li>
+ <li>If <code>input.mouse.back_forward_buttons</code> is set to <code>false</code>, those buttons should not have any effect</li>
+ <li>With <code>input.mouse.rocker_gestures</code> set, no context menu should be shown, but pressing left+right/right+left buttons should navigate back/forward</li>
+ <li>When setting <code>input.mouse.rocker_gestures</code> dynamically, the context menu should be hidden/shown accordingly.</li>
</body>
</html>
diff --git a/tests/unit/api/test_cmdutils.py b/tests/unit/api/test_cmdutils.py
index 1d2cd3f46..58643640c 100644
--- a/tests/unit/api/test_cmdutils.py
+++ b/tests/unit/api/test_cmdutils.py
@@ -140,9 +140,30 @@ class TestRegister:
@cmdutils.register()
def fun(*args):
"""Blah."""
+ assert args == ['one', 'two']
+
+ objects.commands['fun'].parser.parse_args(['one', 'two'])
+
+ def test_star_args_empty(self):
+ """Check handling of *args without any value."""
+ @cmdutils.register()
+ def fun(*args):
+ """Blah."""
+ assert not args
+
with pytest.raises(argparser.ArgumentParserError):
objects.commands['fun'].parser.parse_args([])
+ def test_star_args_type(self):
+ """Check handling of *args with a type.
+
+ This isn't implemented, so be sure we catch it.
+ """
+ with pytest.raises(AssertionError):
+ @cmdutils.register()
+ def fun(*args: int):
+ """Blah."""
+
def test_star_args_optional(self):
"""Check handling of *args withstar_args_optional."""
@cmdutils.register(star_args_optional=True)
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_pdfjs.py b/tests/unit/browser/test_pdfjs.py
index e95f665c7..d05ff1fc0 100644
--- a/tests/unit/browser/test_pdfjs.py
+++ b/tests/unit/browser/test_pdfjs.py
@@ -52,6 +52,15 @@ def test_generate_pdfjs_page(available, snippet, monkeypatch):
assert snippet in content
+def test_broken_installation(data_tmpdir, monkeypatch):
+ """Make sure we don't crash with a broken local installation."""
+ monkeypatch.setattr(pdfjs, '_SYSTEM_PATHS', [])
+ (data_tmpdir / 'pdfjs' / 'pdf.js').ensure() # But no viewer.html
+
+ content = pdfjs.generate_pdfjs_page('example.pdf', QUrl())
+ assert '<h1>No pdf.js installation found</h1>' in content
+
+
# Note that we got double protection, once because we use QUrl.FullyEncoded and
# because we use qutebrowser.utils.javascript.to_js. Characters like " are
# already replaced by QUrl.
diff --git a/tests/unit/browser/urlmarks.py b/tests/unit/browser/test_urlmarks.py
index b795d5b10..ac86dd338 100644
--- a/tests/unit/browser/urlmarks.py
+++ b/tests/unit/browser/test_urlmarks.py
@@ -17,7 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
-"""Tests for the global page history."""
+"""Tests for bookmarks/quickmarks."""
+
+import unittest.mock
import pytest
from PyQt5.QtCore import QUrl
@@ -44,8 +46,8 @@ def test_init(bm_file, fake_save_manager):
bm = urlmarks.BookmarkManager()
fake_save_manager.add_saveable.assert_called_once_with(
'bookmark-manager',
- bm.save,
- bm.changed,
+ unittest.mock.ANY,
+ unittest.mock.ANY,
filename=str(bm_file),
)
diff --git a/tests/unit/config/test_configcommands.py b/tests/unit/config/test_configcommands.py
index b793a49ce..5718f6dc9 100644
--- a/tests/unit/config/test_configcommands.py
+++ b/tests/unit/config/test_configcommands.py
@@ -635,6 +635,19 @@ class TestWritePy:
lines = confpy.read_text('utf-8').splitlines()
assert '# Autogenerated config.py' in lines
+ @pytest.mark.posix
+ def test_expanduser(self, commands, monkeypatch, tmpdir):
+ """Make sure that using a path with ~/... works correctly."""
+ home = tmpdir / 'home'
+ home.ensure(dir=True)
+ monkeypatch.setenv('HOME', str(home))
+
+ commands.config_write_py('~/config.py')
+
+ confpy = home / 'config.py'
+ lines = confpy.read_text('utf-8').splitlines()
+ assert '# Autogenerated config.py' in lines
+
def test_existing_file(self, commands, tmpdir):
confpy = tmpdir / 'config.py'
confpy.ensure()
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 4c0b6305c..3cd0c3339 100644
--- a/tests/unit/config/test_configfiles.py
+++ b/tests/unit/config/test_configfiles.py
@@ -578,8 +578,6 @@ class TestYamlMigrations:
@pytest.mark.parametrize('setting, old, new', [
# Font
('fonts.hints', '10pt monospace', '10pt default_family'),
- # QtFont
- ('fonts.debug_console', '10pt monospace', '10pt default_family'),
# String
('content.headers.accept_language', 'x monospace', 'x monospace'),
# Not at end of string
@@ -588,6 +586,17 @@ class TestYamlMigrations:
def test_font_replacements(self, migration_test, setting, old, new):
migration_test(setting, old, new)
+ def test_fonts_tabs(self, yaml, autoconfig):
+ val = '10pt default_family'
+ autoconfig.write({'fonts.tabs': {'global': val}})
+
+ yaml.load()
+ yaml._save()
+
+ data = autoconfig.read()
+ assert data['fonts.tabs.unselected']['global'] == val
+ assert data['fonts.tabs.selected']['global'] == val
+
class ConfPy:
@@ -1052,6 +1061,13 @@ class TestConfigPyWriter:
assert text == textwrap.dedent("""
# Autogenerated config.py
+ #
+ # NOTE: config.py is intended for advanced users who are comfortable
+ # with manually migrating the config file on qutebrowser upgrades. If
+ # you prefer, you can also configure qutebrowser using the
+ # :set/:bind/:config-* commands without having to write a config.py
+ # file.
+ #
# Documentation:
# qute://help/configuring.html
# qute://help/settings.html
@@ -1156,17 +1172,10 @@ class TestConfigPyWriter:
def test_empty(self):
writer = configfiles.ConfigPyWriter(options=[], bindings={},
commented=False)
- text = '\n'.join(writer._gen_lines())
- expected = textwrap.dedent("""
- # Autogenerated config.py
- # Documentation:
- # qute://help/configuring.html
- # qute://help/settings.html
-
- # Uncomment this to still load settings configured via autoconfig.yml
- # config.load_autoconfig()
- """).lstrip()
- assert text == expected
+ lines = list(writer._gen_lines())
+ assert lines[0] == '# Autogenerated config.py'
+ assert lines[-2] == '# config.load_autoconfig()'
+ assert not lines[-1]
def test_pattern(self):
opt = configdata.Option(
diff --git a/tests/unit/config/test_configinit.py b/tests/unit/config/test_configinit.py
index 731c62a66..6e95cadbe 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
@@ -344,12 +344,10 @@ class TestLateInit:
# fonts.default_family and font settings customized
# https://github.com/qutebrowser/qutebrowser/issues/3096
([('fonts.default_family', 'Comic Sans MS'),
- ('fonts.tabs', '12pt default_family'),
('fonts.keyhint', '12pt default_family')], 12, 'Comic Sans MS'),
# as above, but with default_size
([('fonts.default_family', 'Comic Sans MS'),
('fonts.default_size', '23pt'),
- ('fonts.tabs', 'default_size default_family'),
('fonts.keyhint', 'default_size default_family')],
23, 'Comic Sans MS'),
])
@@ -381,10 +379,6 @@ class TestLateInit:
# Font
expected = '{}pt "{}"'.format(size, family)
assert config.instance.get('fonts.keyhint') == expected
- # QtFont
- font = config.instance.get('fonts.tabs')
- assert font.pointSize() == size
- assert font.family() == family
@pytest.fixture
def run_configinit(self, init_patch, fake_save_manager, args):
@@ -405,10 +399,6 @@ class TestLateInit:
assert 'fonts.keyhint' in changed_options # Font
assert config.instance.get('fonts.keyhint') == '23pt "Comic Sans MS"'
- assert 'fonts.tabs' in changed_options # QtFont
- tabs_font = config.instance.get('fonts.tabs')
- assert tabs_font.family() == 'Comic Sans MS'
- assert tabs_font.pointSize() == 23
# Font subclass, but doesn't end with "default_family"
assert 'fonts.web.family.standard' not in changed_options
@@ -705,6 +695,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 e49075500..8b0c4b191 100644
--- a/tests/unit/config/test_configtypes.py
+++ b/tests/unit/config/test_configtypes.py
@@ -216,13 +216,21 @@ class TestAll:
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
@@ -247,8 +255,8 @@ class TestAll:
# For some types, we don't actually get the internal (YAML-like) value
# back from from_str(), so we can't convert it back.
- if klass in [configtypes.FuzzyUrl, configtypes.QtFont,
- configtypes.ShellCommand, configtypes.Url]:
+ if klass in [configtypes.FuzzyUrl, configtypes.ShellCommand,
+ configtypes.Url]:
return
converted = typ.to_str(val)
@@ -263,8 +271,10 @@ class TestAll:
]:
return
elif (isinstance(typ, functools.partial) and
- isinstance(typ.func, configtypes.ListOrValue)):
- # "- /" -> "/"
+ isinstance(typ.func, (configtypes.ListOrValue,
+ configtypes.List))):
+ # ListOrValue: "- /" -> "/"
+ # List: "- /" -> ["/"]
return
elif (isinstance(typ, configtypes.ListOrValue) and
isinstance(typ.valtype, configtypes.Int)):
@@ -1037,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:
@@ -1367,8 +1381,6 @@ class FontDesc:
class TestFont:
- """Test Font/QtFont."""
-
TESTS = {
# (style, weight, pointsize, pixelsize, family
'"Foobar Neue"':
@@ -1416,52 +1428,17 @@ class TestFont:
font_xfail = pytest.mark.xfail(reason='FIXME: #103')
- @pytest.fixture(params=[configtypes.Font, configtypes.QtFont])
- def klass(self, request):
- return request.param
-
@pytest.fixture
- def font_class(self):
+ def klass(self):
return configtypes.Font
@pytest.fixture
- def qtfont_class(self):
- return configtypes.QtFont
+ def font_class(self):
+ return configtypes.Font
@pytest.mark.parametrize('val, desc', sorted(TESTS.items()))
def test_to_py_valid(self, klass, val, desc):
- if klass is configtypes.Font:
- expected = val
- elif klass is configtypes.QtFont:
- expected = Font.fromdesc(desc)
- assert klass().to_py(val) == expected
-
- def test_qtfont(self, qtfont_class):
- """Test QtFont's to_py."""
- value = Font(qtfont_class().to_py('10pt "Foobar Neue", Fubar'))
-
- if hasattr(value, 'families'):
- # Added in Qt 5.13
- assert value.family() == 'Foobar Neue'
- assert value.families() == ['Foobar Neue', 'Fubar']
- else:
- assert value.family() == 'Foobar Neue, Fubar'
-
- assert value.weight() == QFont.Normal
- assert value.style() == QFont.StyleNormal
-
- assert value.pointSize() == 10
-
- def test_qtfont_float(self, qtfont_class):
- """Test QtFont's to_py with a float as point size.
-
- We can't test the point size for equality as Qt seems to do some
- rounding as appropriate.
- """
- value = Font(qtfont_class().to_py('10.5pt Test'))
- assert value.family() == 'Test'
- assert value.pointSize() >= 10
- assert value.pointSize() <= 11
+ assert klass().to_py(val) == val
@pytest.mark.parametrize('val', [
pytest.param('green "Foobar Neue"', marks=font_xfail),
@@ -1481,13 +1458,7 @@ class TestFont:
def test_defaults_replacement(self, klass, monkeypatch):
configtypes.FontBase.set_defaults(['Terminus'], '23pt')
- if klass is configtypes.Font:
- expected = '23pt Terminus'
- elif klass is configtypes.QtFont:
- desc = FontDesc(QFont.StyleNormal, QFont.Normal, 23, None,
- 'Terminus')
- expected = Font.fromdesc(desc)
- assert klass().to_py('23pt default_family') == expected
+ assert klass().to_py('23pt default_family') == '23pt Terminus'
class TestFontFamily:
diff --git a/tests/unit/keyinput/conftest.py b/tests/unit/keyinput/conftest.py
index 62ffa07cf..ba7a19f79 100644
--- a/tests/unit/keyinput/conftest.py
+++ b/tests/unit/keyinput/conftest.py
@@ -21,11 +21,6 @@
import pytest
-from PyQt5.QtCore import QEvent, Qt
-from PyQt5.QtGui import QKeyEvent
-
-from qutebrowser.keyinput import keyutils
-
BINDINGS = {'prompt': {'<Ctrl-a>': 'message-info ctrla',
'a': 'message-info a',
@@ -50,14 +45,3 @@ def keyinput_bindings(config_stub, key_config_stub):
config_stub.val.bindings.default = {}
config_stub.val.bindings.commands = dict(BINDINGS)
config_stub.val.bindings.key_mappings = dict(MAPPINGS)
-
-
-@pytest.fixture
-def fake_keyevent():
- """Fixture that when called will return a mock instance of a QKeyEvent."""
- def func(key, modifiers=Qt.NoModifier, typ=QEvent.KeyPress):
- """Generate a new fake QKeyPressEvent."""
- text = keyutils.KeyInfo(key, modifiers).text()
- return QKeyEvent(QKeyEvent.KeyPress, key, modifiers, text)
-
- return func
diff --git a/tests/unit/keyinput/test_basekeyparser.py b/tests/unit/keyinput/test_basekeyparser.py
index a5a1eb553..f8caaf1af 100644
--- a/tests/unit/keyinput/test_basekeyparser.py
+++ b/tests/unit/keyinput/test_basekeyparser.py
@@ -25,7 +25,7 @@ from PyQt5.QtCore import Qt
import pytest
from qutebrowser.keyinput import basekeyparser, keyutils
-from qutebrowser.utils import utils
+from qutebrowser.utils import utils, usertypes
# Alias because we need this a lot in here.
@@ -33,24 +33,29 @@ def keyseq(s):
return keyutils.KeySequence.parse(s)
-@pytest.fixture
-def keyparser(key_config_stub):
- """Fixture providing a BaseKeyParser supporting count/chains."""
- kp = basekeyparser.BaseKeyParser(win_id=0)
+def _create_keyparser(mode):
+ kp = basekeyparser.BaseKeyParser(mode=mode, win_id=0)
kp.execute = mock.Mock()
- yield kp
+ return kp
+
+
+@pytest.fixture
+def keyparser(key_config_stub, keyinput_bindings):
+ return _create_keyparser(usertypes.KeyMode.normal)
@pytest.fixture
-def handle_text(fake_keyevent, keyparser):
- """Helper function to handle multiple fake keypresses.
-
- Automatically uses the keyparser of the current test via the keyparser
- fixture.
- """
- def func(*args):
- for enumval in args:
- keyparser.handle(fake_keyevent(enumval))
+def prompt_keyparser(key_config_stub, keyinput_bindings):
+ return _create_keyparser(usertypes.KeyMode.prompt)
+
+
+@pytest.fixture
+def handle_text():
+ """Helper function to handle multiple fake keypresses."""
+ def func(kp, *args):
+ for key in args:
+ info = keyutils.KeyInfo(key, Qt.NoModifier)
+ kp.handle(info.to_event())
return func
@@ -60,10 +65,10 @@ class TestDebugLog:
def test_log(self, keyparser, caplog):
keyparser._debug_log('foo')
- assert caplog.messages == ['foo']
+ assert caplog.messages == ['BaseKeyParser for mode normal: foo']
def test_no_log(self, keyparser, caplog):
- keyparser.do_log = False
+ keyparser._do_log = False
keyparser._debug_log('foo')
assert not caplog.records
@@ -79,9 +84,8 @@ class TestDebugLog:
])
def test_split_count(config_stub, key_config_stub,
input_key, supports_count, count, command):
- kp = basekeyparser.BaseKeyParser(win_id=0)
- kp.supports_count = supports_count
- kp._read_config('normal')
+ kp = basekeyparser.BaseKeyParser(mode=usertypes.KeyMode.normal, win_id=0,
+ supports_count=supports_count)
for info in keyseq(input_key):
kp.handle(info.to_event())
@@ -90,80 +94,55 @@ def test_split_count(config_stub, key_config_stub,
assert kp._sequence == keyseq(command)
-@pytest.mark.usefixtures('keyinput_bindings')
-class TestReadConfig:
-
- def test_read_config_invalid(self, keyparser):
- """Test reading config without setting modename before."""
- with pytest.raises(ValueError):
- keyparser._read_config()
-
- def test_read_config_modename(self, keyparser):
- """Test reading config with _modename set."""
- keyparser._modename = 'normal'
- keyparser._read_config()
- assert keyseq('a') in keyparser.bindings
-
- def test_read_config_valid(self, keyparser):
- """Test reading config."""
- keyparser._read_config('prompt')
- assert keyseq('ccc') in keyparser.bindings
- assert keyseq('<ctrl+a>') in keyparser.bindings
- keyparser._read_config('command')
- assert keyseq('ccc') not in keyparser.bindings
- assert keyseq('<ctrl+a>') not in keyparser.bindings
- assert keyseq('foo') in keyparser.bindings
- assert keyseq('<ctrl+x>') in keyparser.bindings
-
- def test_read_config_empty_binding(self, keyparser, config_stub):
- """Make sure setting an empty binding doesn't crash."""
- keyparser._read_config('normal')
- config_stub.val.bindings.commands = {'normal': {'co': ''}}
- # The config is re-read automatically
-
- def test_read_config_modename_none(self, keyparser):
- assert keyparser._modename is None
-
- # No config set so self._modename is None
- with pytest.raises(ValueError, match="read_config called with no mode "
- "given, but None defined so far!"):
- keyparser._read_config(None)
-
- @pytest.mark.parametrize('mode, changed_mode, expected', [
- ('normal', 'normal', True), ('normal', 'command', False),
- ])
- def test_read_config(self, keyparser, key_config_stub,
- mode, changed_mode, expected):
- keyparser._read_config(mode)
- # Sanity checks
- assert keyseq('a') in keyparser.bindings
- assert keyseq('new') not in keyparser.bindings
+def test_empty_binding(keyparser, config_stub):
+ """Make sure setting an empty binding doesn't crash."""
+ config_stub.val.bindings.commands = {'normal': {'co': ''}}
+ # The config is re-read automatically
- key_config_stub.bind(keyseq('new'), 'message-info new',
- mode=changed_mode)
- assert keyseq('a') in keyparser.bindings
- assert (keyseq('new') in keyparser.bindings) == expected
+@pytest.mark.parametrize('changed_mode, expected', [
+ ('normal', True), ('command', False),
+])
+def test_read_config(keyparser, key_config_stub, changed_mode, expected):
+ keyparser._read_config()
+ # Sanity checks
+ assert keyseq('a') in keyparser.bindings
+ assert keyseq('new') not in keyparser.bindings
+ key_config_stub.bind(keyseq('new'), 'message-info new',
+ mode=changed_mode)
-class TestHandle:
+ assert keyseq('a') in keyparser.bindings
+ assert (keyseq('new') in keyparser.bindings) == expected
- @pytest.fixture(autouse=True)
- def read_config(self, keyinput_bindings, keyparser):
- keyparser._read_config('prompt')
- def test_valid_key(self, fake_keyevent, keyparser):
+class TestHandle:
+
+ def test_valid_key(self, prompt_keyparser, handle_text):
modifier = Qt.MetaModifier if utils.is_mac else Qt.ControlModifier
- keyparser.handle(fake_keyevent(Qt.Key_A, modifier))
- keyparser.handle(fake_keyevent(Qt.Key_X, modifier))
- keyparser.execute.assert_called_once_with('message-info ctrla', None)
- assert not keyparser._sequence
- def test_valid_key_count(self, fake_keyevent, keyparser):
+ infos = [
+ keyutils.KeyInfo(Qt.Key_A, modifier),
+ keyutils.KeyInfo(Qt.Key_X, modifier),
+ ]
+ for info in infos:
+ prompt_keyparser.handle(info.to_event())
+
+ prompt_keyparser.execute.assert_called_once_with(
+ 'message-info ctrla', None)
+ assert not prompt_keyparser._sequence
+
+ def test_valid_key_count(self, prompt_keyparser):
modifier = Qt.MetaModifier if utils.is_mac else Qt.ControlModifier
- keyparser.handle(fake_keyevent(Qt.Key_5))
- keyparser.handle(fake_keyevent(Qt.Key_A, modifier))
- keyparser.execute.assert_called_once_with('message-info ctrla', 5)
+
+ infos = [
+ keyutils.KeyInfo(Qt.Key_5, Qt.NoModifier),
+ keyutils.KeyInfo(Qt.Key_A, modifier),
+ ]
+ for info in infos:
+ prompt_keyparser.handle(info.to_event())
+ prompt_keyparser.execute.assert_called_once_with(
+ 'message-info ctrla', 5)
@pytest.mark.parametrize('keys', [
[(Qt.Key_B, Qt.NoModifier), (Qt.Key_C, Qt.NoModifier)],
@@ -171,106 +150,113 @@ class TestHandle:
# Only modifier
[(Qt.Key_Shift, Qt.ShiftModifier)],
])
- def test_invalid_keys(self, fake_keyevent, keyparser, keys):
+ def test_invalid_keys(self, prompt_keyparser, keys):
for key, modifiers in keys:
- keyparser.handle(fake_keyevent(key, modifiers))
- assert not keyparser.execute.called
- assert not keyparser._sequence
-
- def test_dry_run(self, fake_keyevent, keyparser):
- keyparser.handle(fake_keyevent(Qt.Key_B))
- keyparser.handle(fake_keyevent(Qt.Key_A), dry_run=True)
- assert not keyparser.execute.called
- assert keyparser._sequence
-
- def test_dry_run_count(self, fake_keyevent, keyparser):
- keyparser.handle(fake_keyevent(Qt.Key_9), dry_run=True)
- assert not keyparser._count
-
- def test_invalid_key(self, fake_keyevent, keyparser):
- keyparser.handle(fake_keyevent(Qt.Key_B))
- keyparser.handle(fake_keyevent(0x0))
- assert not keyparser._sequence
-
- def test_valid_keychain(self, handle_text, keyparser):
- # Press 'x' which is ignored because of no match
- handle_text(Qt.Key_X,
+ info = keyutils.KeyInfo(key, modifiers)
+ prompt_keyparser.handle(info.to_event())
+ assert not prompt_keyparser.execute.called
+ assert not prompt_keyparser._sequence
+
+ def test_dry_run(self, prompt_keyparser):
+ b_info = keyutils.KeyInfo(Qt.Key_B, Qt.NoModifier)
+ prompt_keyparser.handle(b_info.to_event())
+
+ a_info = keyutils.KeyInfo(Qt.Key_A, Qt.NoModifier)
+ prompt_keyparser.handle(a_info.to_event(), dry_run=True)
+
+ assert not prompt_keyparser.execute.called
+ assert prompt_keyparser._sequence
+
+ def test_dry_run_count(self, prompt_keyparser):
+ info = keyutils.KeyInfo(Qt.Key_9, Qt.NoModifier)
+ prompt_keyparser.handle(info.to_event(), dry_run=True)
+ assert not prompt_keyparser._count
+
+ def test_invalid_key(self, prompt_keyparser):
+ keys = [Qt.Key_B, 0x0]
+ for key in keys:
+ info = keyutils.KeyInfo(key, Qt.NoModifier)
+ prompt_keyparser.handle(info.to_event())
+ assert not prompt_keyparser._sequence
+
+ def test_valid_keychain(self, handle_text, prompt_keyparser):
+ handle_text(prompt_keyparser,
+ # Press 'x' which is ignored because of no match
+ Qt.Key_X,
# Then start the real chain
Qt.Key_B, Qt.Key_A)
- keyparser.execute.assert_called_with('message-info ba', None)
- assert not keyparser._sequence
+ prompt_keyparser.execute.assert_called_with('message-info ba', None)
+ assert not prompt_keyparser._sequence
@pytest.mark.parametrize('key, modifiers, number', [
(Qt.Key_0, Qt.NoModifier, 0),
(Qt.Key_1, Qt.NoModifier, 1),
(Qt.Key_1, Qt.KeypadModifier, 1),
])
- def test_number_press(self, fake_keyevent, keyparser,
+ def test_number_press(self, prompt_keyparser,
key, modifiers, number):
- keyparser.handle(fake_keyevent(key, modifiers))
+ prompt_keyparser.handle(keyutils.KeyInfo(key, modifiers).to_event())
command = 'message-info {}'.format(number)
- keyparser.execute.assert_called_once_with(command, None)
- assert not keyparser._sequence
+ prompt_keyparser.execute.assert_called_once_with(command, None)
+ assert not prompt_keyparser._sequence
@pytest.mark.parametrize('modifiers, text', [
(Qt.NoModifier, '2'),
(Qt.KeypadModifier, 'num-2'),
])
- def test_number_press_keypad(self, fake_keyevent, keyparser, config_stub,
+ def test_number_press_keypad(self, keyparser, config_stub,
modifiers, text):
"""Make sure a <Num+2> binding overrides the 2 binding."""
config_stub.val.bindings.commands = {'normal': {
'2': 'message-info 2',
'<Num+2>': 'message-info num-2'}}
- keyparser._read_config('normal')
- keyparser.handle(fake_keyevent(Qt.Key_2, modifiers))
+ keyparser.handle(keyutils.KeyInfo(Qt.Key_2, modifiers).to_event())
command = 'message-info {}'.format(text)
keyparser.execute.assert_called_once_with(command, None)
assert not keyparser._sequence
def test_umlauts(self, handle_text, keyparser, config_stub):
config_stub.val.bindings.commands = {'normal': {'ü': 'message-info ü'}}
- keyparser._read_config('normal')
- handle_text(Qt.Key_Udiaeresis)
+ handle_text(keyparser, Qt.Key_Udiaeresis)
keyparser.execute.assert_called_once_with('message-info ü', None)
- def test_mapping(self, config_stub, handle_text, keyparser):
- handle_text(Qt.Key_X)
- keyparser.execute.assert_called_once_with('message-info a', None)
+ def test_mapping(self, config_stub, handle_text, prompt_keyparser):
+ handle_text(prompt_keyparser, Qt.Key_X)
+ prompt_keyparser.execute.assert_called_once_with(
+ 'message-info a', None)
- def test_mapping_keypad(self, config_stub, fake_keyevent, keyparser):
+ def test_mapping_keypad(self, config_stub, keyparser):
"""Make sure falling back to non-numpad keys works with mappings."""
config_stub.val.bindings.commands = {'normal': {'a': 'nop'}}
config_stub.val.bindings.key_mappings = {'1': 'a'}
- keyparser._read_config('normal')
- keyparser.handle(fake_keyevent(Qt.Key_1, Qt.KeypadModifier))
+ info = keyutils.KeyInfo(Qt.Key_1, Qt.KeypadModifier)
+ keyparser.handle(info.to_event())
keyparser.execute.assert_called_once_with('nop', None)
- def test_binding_and_mapping(self, config_stub, handle_text, keyparser):
+ def test_binding_and_mapping(self, config_stub, handle_text, prompt_keyparser):
"""with a conflicting binding/mapping, the binding should win."""
- handle_text(Qt.Key_B)
- assert not keyparser.execute.called
+ handle_text(prompt_keyparser, Qt.Key_B)
+ assert not prompt_keyparser.execute.called
def test_mapping_in_key_chain(self, config_stub, handle_text, keyparser):
"""A mapping should work even as part of a keychain."""
config_stub.val.bindings.commands = {'normal':
{'aa': 'message-info aa'}}
- keyparser._read_config('normal')
- handle_text(Qt.Key_A, Qt.Key_X)
+ handle_text(keyparser, Qt.Key_A, Qt.Key_X)
keyparser.execute.assert_called_once_with('message-info aa', None)
- def test_binding_with_shift(self, keyparser, fake_keyevent):
+ def test_binding_with_shift(self, prompt_keyparser):
"""Simulate a binding which involves shift."""
for key, modifiers in [(Qt.Key_Y, Qt.NoModifier),
(Qt.Key_Shift, Qt.ShiftModifier),
(Qt.Key_Y, Qt.ShiftModifier)]:
- keyparser.handle(fake_keyevent(key, modifiers))
+ info = keyutils.KeyInfo(key, modifiers)
+ prompt_keyparser.handle(info.to_event())
- keyparser.execute.assert_called_once_with('yank -s', None)
+ prompt_keyparser.execute.assert_called_once_with('yank -s', None)
- def test_partial_before_full_match(self, keyparser, fake_keyevent,
- config_stub):
+ def test_partial_before_full_match(self, keyparser, config_stub):
"""Make sure full matches always take precedence over partial ones."""
config_stub.val.bindings.commands = {
'normal': {
@@ -278,8 +264,8 @@ class TestHandle:
'a': 'message-info foo'
}
}
- keyparser._read_config('normal')
- keyparser.handle(fake_keyevent(Qt.Key_A))
+ info = keyutils.KeyInfo(Qt.Key_A, Qt.NoModifier)
+ keyparser.handle(info.to_event())
keyparser.execute.assert_called_once_with('message-info foo', None)
@@ -287,59 +273,62 @@ class TestCount:
"""Test execute() with counts."""
- @pytest.fixture(autouse=True)
- def read_keyparser_config(self, keyinput_bindings, keyparser):
- keyparser._read_config('prompt')
-
- def test_no_count(self, handle_text, keyparser):
+ def test_no_count(self, handle_text, prompt_keyparser):
"""Test with no count added."""
- handle_text(Qt.Key_B, Qt.Key_A)
- keyparser.execute.assert_called_once_with('message-info ba', None)
- assert not keyparser._sequence
+ handle_text(prompt_keyparser, Qt.Key_B, Qt.Key_A)
+ prompt_keyparser.execute.assert_called_once_with(
+ 'message-info ba', None)
+ assert not prompt_keyparser._sequence
- def test_count_0(self, handle_text, keyparser):
- handle_text(Qt.Key_0, Qt.Key_B, Qt.Key_A)
+ def test_count_0(self, handle_text, prompt_keyparser):
+ handle_text(prompt_keyparser, Qt.Key_0, Qt.Key_B, Qt.Key_A)
calls = [mock.call('message-info 0', None),
mock.call('message-info ba', None)]
- keyparser.execute.assert_has_calls(calls)
- assert not keyparser._sequence
+ prompt_keyparser.execute.assert_has_calls(calls)
+ assert not prompt_keyparser._sequence
- def test_count_42(self, handle_text, keyparser):
- handle_text(Qt.Key_4, Qt.Key_2, Qt.Key_B, Qt.Key_A)
- keyparser.execute.assert_called_once_with('message-info ba', 42)
- assert not keyparser._sequence
+ def test_count_42(self, handle_text, prompt_keyparser):
+ handle_text(prompt_keyparser, Qt.Key_4, Qt.Key_2, Qt.Key_B, Qt.Key_A)
+ prompt_keyparser.execute.assert_called_once_with('message-info ba', 42)
+ assert not prompt_keyparser._sequence
- def test_count_42_invalid(self, handle_text, keyparser):
+ def test_count_42_invalid(self, handle_text, prompt_keyparser):
# Invalid call with ccx gets ignored
- handle_text(Qt.Key_4, Qt.Key_2, Qt.Key_C, Qt.Key_C, Qt.Key_X)
- assert not keyparser.execute.called
- assert not keyparser._sequence
+ handle_text(prompt_keyparser,
+ Qt.Key_4, Qt.Key_2, Qt.Key_C, Qt.Key_C, Qt.Key_X)
+ assert not prompt_keyparser.execute.called
+ assert not prompt_keyparser._sequence
# Valid call with ccc gets the correct count
- handle_text(Qt.Key_2, Qt.Key_3, Qt.Key_C, Qt.Key_C, Qt.Key_C)
- keyparser.execute.assert_called_once_with('message-info ccc', 23)
- assert not keyparser._sequence
+ handle_text(prompt_keyparser,
+ Qt.Key_2, Qt.Key_3, Qt.Key_C, Qt.Key_C, Qt.Key_C)
+ prompt_keyparser.execute.assert_called_once_with(
+ 'message-info ccc', 23)
+ assert not prompt_keyparser._sequence
- def test_superscript(self, handle_text, keyparser):
+ def test_superscript(self, handle_text, prompt_keyparser):
# https://github.com/qutebrowser/qutebrowser/issues/3743
- handle_text(Qt.Key_twosuperior, Qt.Key_B, Qt.Key_A)
+ handle_text(prompt_keyparser, Qt.Key_twosuperior, Qt.Key_B, Qt.Key_A)
- def test_count_keystring_update(self, qtbot, handle_text, keyparser):
+ def test_count_keystring_update(self, qtbot,
+ handle_text, prompt_keyparser):
"""Make sure the keystring is updated correctly when entering count."""
- with qtbot.waitSignals([keyparser.keystring_updated,
- keyparser.keystring_updated]) as blocker:
- handle_text(Qt.Key_4, Qt.Key_2)
+ with qtbot.waitSignals([
+ prompt_keyparser.keystring_updated,
+ prompt_keyparser.keystring_updated]) as blocker:
+ handle_text(prompt_keyparser, Qt.Key_4, Qt.Key_2)
sig1, sig2 = blocker.all_signals_and_args
assert sig1.args == ('4',)
assert sig2.args == ('42',)
- def test_numpad(self, fake_keyevent, keyparser):
+ def test_numpad(self, prompt_keyparser):
"""Make sure we can enter a count via numpad."""
for key, modifiers in [(Qt.Key_4, Qt.KeypadModifier),
(Qt.Key_2, Qt.KeypadModifier),
(Qt.Key_B, Qt.NoModifier),
(Qt.Key_A, Qt.NoModifier)]:
- keyparser.handle(fake_keyevent(key, modifiers))
- keyparser.execute.assert_called_once_with('message-info ba', 42)
+ info = keyutils.KeyInfo(key, modifiers)
+ prompt_keyparser.handle(info.to_event())
+ prompt_keyparser.execute.assert_called_once_with('message-info ba', 42)
def test_clear_keystring(qtbot, keyparser):
diff --git a/tests/unit/keyinput/test_bindingtrie.py b/tests/unit/keyinput/test_bindingtrie.py
index d7b3e4729..9a2ef10b9 100644
--- a/tests/unit/keyinput/test_bindingtrie.py
+++ b/tests/unit/keyinput/test_bindingtrie.py
@@ -21,6 +21,7 @@
import string
import itertools
+import textwrap
import pytest
@@ -45,6 +46,39 @@ def test_matches_single(entered, configured, match_type):
assert trie.matches(entered) == result
+def test_str():
+ bindings = {
+ keyutils.KeySequence.parse('a'): 'cmd-a',
+ keyutils.KeySequence.parse('ba'): 'cmd-ba',
+ keyutils.KeySequence.parse('bb'): 'cmd-bb',
+ keyutils.KeySequence.parse('cax'): 'cmd-cax',
+ keyutils.KeySequence.parse('cby'): 'cmd-cby',
+ }
+ trie = basekeyparser.BindingTrie()
+ trie.update(bindings)
+
+ expected = """
+ a:
+ => cmd-a
+
+ b:
+ a:
+ => cmd-ba
+ b:
+ => cmd-bb
+
+ c:
+ a:
+ x:
+ => cmd-cax
+ b:
+ y:
+ => cmd-cby
+ """
+
+ assert str(trie) == textwrap.dedent(expected).lstrip('\n')
+
+
@pytest.mark.parametrize('configured, expected', [
([],
# null match
diff --git a/tests/unit/keyinput/test_keyutils.py b/tests/unit/keyinput/test_keyutils.py
index a8783f772..0df721c68 100644
--- a/tests/unit/keyinput/test_keyutils.py
+++ b/tests/unit/keyinput/test_keyutils.py
@@ -458,11 +458,11 @@ class TestKeySequence:
Qt.ControlModifier | Qt.ShiftModifier),
(Qt.ShiftModifier, Qt.ShiftModifier),
])
- def test_fake_mac(self, fake_keyevent, modifiers, expected):
+ def test_fake_mac(self, modifiers, expected):
"""Make sure Control/Meta are swapped with a simulated Mac."""
seq = keyutils.KeySequence()
- event = fake_keyevent(key=Qt.Key_A, modifiers=modifiers)
- new = seq.append_event(event)
+ info = keyutils.KeyInfo(key=Qt.Key_A, modifiers=modifiers)
+ new = seq.append_event(info.to_event())
assert new[0] == keyutils.KeyInfo(Qt.Key_A, expected)
@pytest.mark.parametrize('key', [Qt.Key_unknown, 0x0])
@@ -585,28 +585,6 @@ def test_is_printable(key, printable):
(Qt.Key_Escape, Qt.ControlModifier, True),
(Qt.Key_X, Qt.ControlModifier, True),
(Qt.Key_X, Qt.NoModifier, False),
- (Qt.Key_2, Qt.NoModifier, False),
-
- # Keypad should not reset hint keychain - see #3735
- (Qt.Key_2, Qt.KeypadModifier, False),
-
- # Modifiers should not reset hint keychain - see #4264
- (Qt.Key_Shift, Qt.ShiftModifier, False),
- (Qt.Key_Control, Qt.ControlModifier, False),
- (Qt.Key_Alt, Qt.AltModifier, False),
- (Qt.Key_Meta, Qt.MetaModifier, False),
- (Qt.Key_Mode_switch, Qt.GroupSwitchModifier, False),
-])
-def test_is_special_hint_mode(key, modifiers, special):
- assert keyutils.is_special_hint_mode(key, modifiers) == special
-
-
-@pytest.mark.parametrize('key, modifiers, special', [
- (Qt.Key_Escape, Qt.NoModifier, True),
- (Qt.Key_Escape, Qt.ShiftModifier, True),
- (Qt.Key_Escape, Qt.ControlModifier, True),
- (Qt.Key_X, Qt.ControlModifier, True),
- (Qt.Key_X, Qt.NoModifier, False),
(Qt.Key_2, Qt.KeypadModifier, True),
(Qt.Key_2, Qt.NoModifier, False),
(Qt.Key_Shift, Qt.ShiftModifier, True),
diff --git a/tests/unit/keyinput/test_modeman.py b/tests/unit/keyinput/test_modeman.py
index 89296f06b..b473294f8 100644
--- a/tests/unit/keyinput/test_modeman.py
+++ b/tests/unit/keyinput/test_modeman.py
@@ -22,12 +22,14 @@ import pytest
from PyQt5.QtCore import Qt, QObject, pyqtSignal
from qutebrowser.utils import usertypes
+from qutebrowser.keyinput import keyutils
class FakeKeyparser(QObject):
"""A fake BaseKeyParser which doesn't handle anything."""
+ keystring_updated = pyqtSignal(str)
request_leave = pyqtSignal(usertypes.KeyMode, str, bool)
def __init__(self):
@@ -51,7 +53,7 @@ def modeman(mode_manager):
(Qt.Key_A, Qt.ShiftModifier, True),
(Qt.Key_A, Qt.ShiftModifier | Qt.ControlModifier, False),
])
-def test_non_alphanumeric(key, modifiers, filtered, fake_keyevent, modeman):
+def test_non_alphanumeric(key, modifiers, filtered, modeman):
"""Make sure non-alphanumeric keys are passed through correctly."""
- evt = fake_keyevent(key=key, modifiers=modifiers)
+ evt = keyutils.KeyInfo(key=key, modifiers=modifiers).to_event()
assert modeman.handle_event(evt) == filtered
diff --git a/tests/unit/keyinput/test_modeparsers.py b/tests/unit/keyinput/test_modeparsers.py
index ebaafa076..1f1bcfe11 100644
--- a/tests/unit/keyinput/test_modeparsers.py
+++ b/tests/unit/keyinput/test_modeparsers.py
@@ -46,18 +46,18 @@ class TestsNormalKeyParser:
kp = modeparsers.NormalKeyParser(win_id=0, commandrunner=commandrunner)
return kp
- def test_keychain(self, keyparser, fake_keyevent, commandrunner):
+ def test_keychain(self, keyparser, commandrunner):
"""Test valid keychain."""
# Press 'z' which is ignored because of no match
- keyparser.handle(fake_keyevent(Qt.Key_Z))
# Then start the real chain
- keyparser.handle(fake_keyevent(Qt.Key_B))
- keyparser.handle(fake_keyevent(Qt.Key_A))
+ chain = keyutils.KeySequence.parse('zba')
+ for info in chain:
+ keyparser.handle(info.to_event())
assert commandrunner.commands == [('message-info ba', None)]
assert not keyparser._sequence
def test_partial_keychain_timeout(self, keyparser, config_stub,
- fake_keyevent, qtbot, commandrunner):
+ qtbot, commandrunner):
"""Test partial keychain timeout."""
config_stub.val.input.partial_timeout = 100
timer = keyparser._partial_timer
@@ -65,7 +65,7 @@ class TestsNormalKeyParser:
# Press 'b' for a partial match.
# Then we check if the timer has been set up correctly
- keyparser.handle(fake_keyevent(Qt.Key_B))
+ keyparser.handle(keyutils.KeyInfo(Qt.Key_B, Qt.NoModifier).to_event())
assert timer.isSingleShot()
assert timer.interval() == 100
assert timer.isActive()
@@ -95,32 +95,81 @@ class TestHintKeyParser:
hintmanager=hintmanager,
commandrunner=commandrunner)
- @pytest.mark.parametrize('bindings, event1, event2, prefix, command', [
+ @pytest.mark.parametrize('bindings, keychain, prefix, hint', [
(
['aa', 'as'],
- [Qt.Key_A],
- [Qt.Key_S],
+ 'as',
'a',
- 'follow-hint -s as'
+ 'as'
),
(
['21', '22'],
- [Qt.Key_2, Qt.KeypadModifier],
- [Qt.Key_2, Qt.KeypadModifier],
+ '<Num+2><Num+2>',
'2',
- 'follow-hint -s 22'
+ '22'
+ ),
+ (
+ ['äa', 'äs'],
+ 'äs',
+ 'ä',
+ 'äs'
+ ),
+ (
+ ['не', 'на'],
+ 'не',
+ '<Н>',
+ 'не',
),
])
- def test_match(self, keyparser, fake_keyevent, commandrunner, hintmanager,
- bindings, event1, event2, prefix, command):
+ def test_match(self, keyparser, hintmanager,
+ bindings, keychain, prefix, hint):
keyparser.update_bindings(bindings)
- match = keyparser.handle(fake_keyevent(*event1))
+ seq = keyutils.KeySequence.parse(keychain)
+ assert len(seq) == 2
+
+ match = keyparser.handle(seq[0].to_event())
assert match == QKeySequence.PartialMatch
assert hintmanager.keystr == prefix
- match = keyparser.handle(fake_keyevent(*event2))
+ match = keyparser.handle(seq[1].to_event())
assert match == QKeySequence.ExactMatch
- assert not hintmanager.keystr
+ assert hintmanager.keystr == hint
- assert commandrunner.commands == [(command, None)]
+ def test_match_key_mappings(self, config_stub, keyparser, hintmanager):
+ config_stub.val.bindings.key_mappings = {'α': 'a', 'σ': 's'}
+ keyparser.update_bindings(['aa', 'as'])
+
+ seq = keyutils.KeySequence.parse('ασ')
+ assert len(seq) == 2
+
+ match = keyparser.handle(seq[0].to_event())
+ assert match == QKeySequence.PartialMatch
+ assert hintmanager.keystr == 'a'
+
+ match = keyparser.handle(seq[1].to_event())
+ assert match == QKeySequence.ExactMatch
+ assert hintmanager.keystr == 'as'
+
+ def test_command(self, keyparser, config_stub, hintmanager, commandrunner):
+ config_stub.val.bindings.commands = {
+ 'hint': {'abc': 'message-info abc'}
+ }
+
+ keyparser.update_bindings(['xabcy'])
+
+ steps = [
+ (Qt.Key_X, QKeySequence.PartialMatch, 'x'),
+ (Qt.Key_A, QKeySequence.PartialMatch, ''),
+ (Qt.Key_B, QKeySequence.PartialMatch, ''),
+ (Qt.Key_C, QKeySequence.ExactMatch, ''),
+ ]
+ for key, expected_match, keystr in steps:
+ info = keyutils.KeyInfo(key, Qt.NoModifier)
+ match = keyparser.handle(info.to_event())
+ assert match == expected_match
+ assert hintmanager.keystr == keystr
+ if key != Qt.Key_C:
+ assert not commandrunner.commands
+
+ assert commandrunner.commands == [('message-info abc', None)]
diff --git a/tests/unit/mainwindow/test_tabbedbrowser.py b/tests/unit/mainwindow/test_tabbedbrowser.py
new file mode 100644
index 000000000..a0f772cf9
--- /dev/null
+++ b/tests/unit/mainwindow/test_tabbedbrowser.py
@@ -0,0 +1,32 @@
+# 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/>.
+
+
+import pytest
+
+from qutebrowser.mainwindow import tabbedbrowser
+
+
+class TestTabDeque:
+
+ @pytest.mark.parametrize('size', [-1, 5])
+ def test_size_handling(self, size, config_stub):
+ config_stub.val.tabs.focus_stack_size = size
+ dq = tabbedbrowser.TabDeque()
+ dq.update_size()
diff --git a/tests/unit/misc/test_editor.py b/tests/unit/misc/test_editor.py
index edd32b5a5..96dd558ff 100644
--- a/tests/unit/misc/test_editor.py
+++ b/tests/unit/misc/test_editor.py
@@ -20,8 +20,8 @@
"""Tests for qutebrowser.misc.editor."""
import time
+import pathlib
import os
-import os.path
import logging
from PyQt5.QtCore import QProcess
@@ -76,16 +76,16 @@ class TestFileHandling:
def test_ok(self, editor):
"""Test file handling when closing with an exit status == 0."""
editor.edit("")
- filename = editor._filename
- assert os.path.exists(filename)
- assert os.path.basename(filename).startswith('qutebrowser-editor-')
+ filename = pathlib.Path(editor._filename)
+ assert filename.exists()
+ assert filename.name.startswith('qutebrowser-editor-')
editor._proc.finished.emit(0, QProcess.NormalExit)
- assert not os.path.exists(filename)
+ assert not filename.exists()
- def test_existing_file(self, editor, tmpdir):
+ def test_existing_file(self, editor, tmp_path):
"""Test editing an existing file."""
- path = tmpdir / 'foo.txt'
- path.ensure()
+ path = tmp_path / 'foo.txt'
+ path.touch()
editor.edit_file(str(path))
editor._proc.finished.emit(0, QProcess.NormalExit)
@@ -95,62 +95,62 @@ class TestFileHandling:
def test_error(self, editor):
"""Test file handling when closing with an exit status != 0."""
editor.edit("")
- filename = editor._filename
- assert os.path.exists(filename)
+ filename = pathlib.Path(editor._filename)
+ assert filename.exists()
editor._proc._proc.exitStatus = lambda: QProcess.CrashExit
editor._proc.finished.emit(1, QProcess.NormalExit)
- assert os.path.exists(filename)
+ assert filename.exists()
- os.remove(filename)
+ filename.unlink()
def test_crash(self, editor):
"""Test file handling when closing with a crash."""
editor.edit("")
- filename = editor._filename
- assert os.path.exists(filename)
+ filename = pathlib.Path(editor._filename)
+ assert filename.exists()
editor._proc._proc.exitStatus = lambda: QProcess.CrashExit
editor._proc.error.emit(QProcess.Crashed)
editor._proc.finished.emit(0, QProcess.CrashExit)
- assert os.path.exists(filename)
+ assert filename.exists()
- os.remove(filename)
+ filename.unlink()
def test_unreadable(self, message_mock, editor, caplog, qtbot):
"""Test file handling when closing with an unreadable file."""
editor.edit("")
- filename = editor._filename
- assert os.path.exists(filename)
- os.chmod(filename, 0o277)
- if os.access(filename, os.R_OK):
+ filename = pathlib.Path(editor._filename)
+ assert filename.exists()
+ filename.chmod(0o277)
+ if os.access(str(filename), os.R_OK):
# Docker container or similar
pytest.skip("File was still readable")
with caplog.at_level(logging.ERROR):
editor._proc.finished.emit(0, QProcess.NormalExit)
- assert not os.path.exists(filename)
+ assert not filename.exists()
msg = message_mock.getmsg(usertypes.MessageLevel.error)
assert msg.text.startswith("Failed to read back edited file: ")
@pytest.fixture
- def unwritable_tmpdir(self, tmpdir):
- tmpdir.chmod(0)
- if os.access(str(tmpdir), os.W_OK):
+ def unwritable_tmp_path(self, tmp_path):
+ tmp_path.chmod(0)
+ if os.access(str(tmp_path), os.W_OK):
# Docker container or similar
pytest.skip("File was still writable")
- yield tmpdir
+ yield tmp_path
- tmpdir.chmod(0o755)
+ tmp_path.chmod(0o755)
def test_unwritable(self, monkeypatch, message_mock, editor,
- unwritable_tmpdir, caplog):
+ unwritable_tmp_path, caplog):
"""Test file handling when the initial file is not writable."""
monkeypatch.setattr(editormod.tempfile, 'tempdir',
- str(unwritable_tmpdir))
+ str(unwritable_tmp_path))
with caplog.at_level(logging.ERROR):
editor.edit("")
@@ -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 4b94162c6..95858f837 100644
--- a/tests/unit/misc/test_ipc.py
+++ b/tests/unit/misc/test_ipc.py
@@ -20,6 +20,7 @@
"""Tests for qutebrowser.misc.ipc."""
import os
+import pathlib
import getpass
import logging
import json
@@ -35,7 +36,7 @@ from PyQt5.QtTest import QSignalSpy
import qutebrowser
from qutebrowser.misc import ipc
from qutebrowser.utils import standarddir, utils
-from helpers import stubs
+from helpers import stubs, utils as testutils
pytestmark = pytest.mark.usefixtures('qapp')
@@ -297,10 +298,10 @@ class TestListen:
def test_permissions_posix(self, ipc_server):
ipc_server.listen()
sockfile = ipc_server._server.fullServerName()
- sockdir = os.path.dirname(sockfile)
+ sockdir = pathlib.Path(sockfile).parent
file_stat = os.stat(sockfile)
- dir_stat = os.stat(sockdir)
+ dir_stat = sockdir.stat()
# pylint: disable=no-member,useless-suppression
file_owner_ok = file_stat.st_uid == os.getuid()
@@ -319,7 +320,7 @@ class TestListen:
@pytest.mark.posix
def test_atime_update(self, qtbot, ipc_server):
- ipc_server._atime_timer.setInterval(500) # We don't want to wait 6h
+ ipc_server._atime_timer.setInterval(500) # We don't want to wait
ipc_server.listen()
old_atime = os.stat(ipc_server._server.fullServerName()).st_atime_ns
@@ -347,6 +348,25 @@ class TestListen:
ipc_server._atime_timer.timeout.disconnect(ipc_server.update_atime)
ipc_server.shutdown()
+ @pytest.mark.posix
+ def test_vanished_runtime_file(self, qtbot, caplog, ipc_server):
+ ipc_server._atime_timer.setInterval(500) # We don't want to wait
+ ipc_server.listen()
+
+ sockfile = pathlib.Path(ipc_server._server.fullServerName())
+ sockfile.unlink()
+
+ with caplog.at_level(logging.ERROR):
+ with qtbot.waitSignal(ipc_server._atime_timer.timeout,
+ timeout=2000):
+ pass
+
+ msg = 'Failed to update IPC socket, trying to re-listen...'
+ assert caplog.messages[-1] == msg
+
+ assert ipc_server._server.isListening()
+ assert sockfile.exists()
+
class TestOnError:
@@ -504,7 +524,7 @@ class TestSendToRunningInstance:
@pytest.mark.parametrize('has_cwd', [True, False])
@pytest.mark.linux(reason="Causes random trouble on Windows and macOS")
- def test_normal(self, qtbot, tmpdir, ipc_server, mocker, has_cwd):
+ def test_normal(self, qtbot, tmp_path, ipc_server, mocker, has_cwd):
ipc_server.listen()
with qtbot.assertNotEmitted(ipc_server.got_invalid_data):
@@ -512,7 +532,7 @@ class TestSendToRunningInstance:
timeout=5000) as blocker:
with qtbot.waitSignal(ipc_server.got_raw,
timeout=5000) as raw_blocker:
- with tmpdir.as_cwd():
+ with testutils.change_cwd(tmp_path):
if not has_cwd:
m = mocker.patch('qutebrowser.misc.ipc.os')
m.getcwd.side_effect = OSError
@@ -521,7 +541,7 @@ class TestSendToRunningInstance:
assert sent
- expected_cwd = str(tmpdir) if has_cwd else ''
+ expected_cwd = str(tmp_path) if has_cwd else ''
assert blocker.args == [['foo'], '', expected_cwd]
@@ -529,7 +549,7 @@ class TestSendToRunningInstance:
'version': qutebrowser.__version__,
'protocol_version': ipc.PROTOCOL_VERSION}
if has_cwd:
- raw_expected['cwd'] = str(tmpdir)
+ raw_expected['cwd'] = str(tmp_path)
assert len(raw_blocker.args) == 1
parsed = json.loads(raw_blocker.args[0].decode('utf-8'))
diff --git a/tests/unit/misc/test_keyhints.py b/tests/unit/misc/test_keyhints.py
index 2e9ea1aaf..a9f8ed311 100644
--- a/tests/unit/misc/test_keyhints.py
+++ b/tests/unit/misc/test_keyhints.py
@@ -21,6 +21,7 @@
import pytest
+from qutebrowser.utils import usertypes
from qutebrowser.misc import objects
from qutebrowser.misc.keyhintwidget import KeyHintView
@@ -57,7 +58,7 @@ def test_show_and_hide(qtbot, keyhint):
with qtbot.waitSignal(keyhint.update_geometry):
with qtbot.waitExposed(keyhint):
keyhint.show()
- keyhint.update_keyhint('normal', '')
+ keyhint.update_keyhint(usertypes.KeyMode.normal, '')
assert not keyhint.isVisible()
@@ -84,7 +85,7 @@ def test_suggestions(keyhint, config_stub):
config_stub.val.bindings.default = default_bindings
config_stub.val.bindings.commands = bindings
- keyhint.update_keyhint('normal', 'a')
+ keyhint.update_keyhint(usertypes.KeyMode.normal, 'a')
assert keyhint.text() == expected_text(
('a', 'yellow', 'a', 'message-info cmd-aa'),
('a', 'yellow', 'b', 'message-info cmd-ab'),
@@ -109,7 +110,7 @@ def test_suggestions_special(keyhint, config_stub):
config_stub.val.bindings.default = default_bindings
config_stub.val.bindings.commands = bindings
- keyhint.update_keyhint('normal', '<Ctrl+c>')
+ keyhint.update_keyhint(usertypes.KeyMode.normal, '<Ctrl+c>')
assert keyhint.text() == expected_text(
('&lt;Ctrl+c&gt;', 'yellow', 'a', 'message-info cmd-Cca'),
('&lt;Ctrl+c&gt;', 'yellow', 'c', 'message-info cmd-Ccc'),
@@ -130,7 +131,7 @@ def test_suggestions_with_count(keyhint, config_stub, monkeypatch, stubs):
config_stub.val.bindings.default = bindings
config_stub.val.bindings.commands = bindings
- keyhint.update_keyhint('normal', '2a')
+ keyhint.update_keyhint(usertypes.KeyMode.normal, '2a')
assert keyhint.text() == expected_text(
('a', 'yellow', 'b', 'bar'),
)
@@ -146,7 +147,7 @@ def test_special_bindings(keyhint, config_stub):
config_stub.val.bindings.default = {}
config_stub.val.bindings.commands = bindings
- keyhint.update_keyhint('normal', '<')
+ keyhint.update_keyhint(usertypes.KeyMode.normal, '<')
assert keyhint.text() == expected_text(
('&lt;', 'yellow', 'a', 'message-info cmd-&lt;a'),
@@ -159,7 +160,7 @@ def test_color_switch(keyhint, config_stub):
config_stub.val.colors.keyhint.suffix.fg = '#ABCDEF'
config_stub.val.bindings.default = {}
config_stub.val.bindings.commands = bindings
- keyhint.update_keyhint('normal', 'a')
+ keyhint.update_keyhint(usertypes.KeyMode.normal, 'a')
assert keyhint.text() == expected_text(('a', '#ABCDEF', 'a',
'message-info cmd-aa'))
@@ -173,7 +174,7 @@ def test_no_matches(keyhint, config_stub):
config_stub.val.bindings.default = {}
config_stub.val.bindings.commands = bindings
- keyhint.update_keyhint('normal', 'z')
+ keyhint.update_keyhint(usertypes.KeyMode.normal, 'z')
assert not keyhint.text()
assert not keyhint.isVisible()
@@ -196,7 +197,7 @@ def test_blacklist(keyhint, config_stub, blacklist, expected):
config_stub.val.bindings.default = {}
config_stub.val.bindings.commands = bindings
- keyhint.update_keyhint('normal', 'a')
+ keyhint.update_keyhint(usertypes.KeyMode.normal, 'a')
assert keyhint.text() == expected
@@ -213,6 +214,6 @@ def test_delay(qtbot, stubs, monkeypatch, config_stub, key_config_stub):
config_stub.val.bindings.commands = bindings
keyhint = KeyHintView(0, None)
- keyhint.update_keyhint('normal', 'a')
+ keyhint.update_keyhint(usertypes.KeyMode.normal, 'a')
assert timer.isSingleShot()
assert timer.interval() == interval
diff --git a/tests/unit/misc/test_lineparser.py b/tests/unit/misc/test_lineparser.py
index 9ddeaa93e..cdb16d04a 100644
--- a/tests/unit/misc/test_lineparser.py
+++ b/tests/unit/misc/test_lineparser.py
@@ -19,7 +19,7 @@
"""Tests for qutebrowser.misc.lineparser."""
-import os
+import pathlib
from unittest import mock
import pytest
@@ -66,7 +66,7 @@ class TestBaseLineParser:
lineparser._write(f, [testdata])
open_mock.assert_called_once_with(
- os.path.join(self.CONFDIR, self.FILENAME), 'rb')
+ str(pathlib.Path(self.CONFDIR) / self.FILENAME), 'rb')
open_mock().write.assert_has_calls([
mock.call(testdata),
@@ -77,30 +77,31 @@ class TestBaseLineParser:
class TestLineParser:
@pytest.fixture
- def lineparser(self, tmpdir):
+ def lineparser(self, tmp_path):
"""Fixture to get a LineParser for tests."""
- lp = lineparsermod.LineParser(str(tmpdir), 'file')
+ lp = lineparsermod.LineParser(str(tmp_path), 'file')
lp.save()
return lp
- def test_init(self, tmpdir):
+ def test_init(self, tmp_path):
"""Test if creating a line parser correctly reads its file."""
- (tmpdir / 'file').write('one\ntwo\n')
- lineparser = lineparsermod.LineParser(str(tmpdir), 'file')
+ (tmp_path / 'file').write_text('one\ntwo\n')
+ lineparser = lineparsermod.LineParser(str(tmp_path), 'file')
assert lineparser.data == ['one', 'two']
- (tmpdir / 'file').write_binary(b'\xfe\n\xff\n')
- lineparser = lineparsermod.LineParser(str(tmpdir), 'file', binary=True)
+ (tmp_path / 'file').write_bytes(b'\xfe\n\xff\n')
+ lineparser = lineparsermod.LineParser(str(tmp_path), 'file',
+ binary=True)
assert lineparser.data == [b'\xfe', b'\xff']
- def test_clear(self, tmpdir, lineparser):
+ def test_clear(self, tmp_path, lineparser):
"""Test if clear() empties its file."""
lineparser.data = ['one', 'two']
lineparser.save()
- assert (tmpdir / 'file').read() == 'one\ntwo\n'
+ assert (tmp_path / 'file').read_text() == 'one\ntwo\n'
lineparser.clear()
assert not lineparser.data
- assert (tmpdir / 'file').read() == ''
+ assert (tmp_path / 'file').read_text() == ''
def test_double_open(self, lineparser):
"""Test if save() bails on an already open file."""
@@ -109,10 +110,10 @@ class TestLineParser:
match="Refusing to double-open LineParser."):
lineparser.save()
- def test_prepare_save(self, tmpdir, lineparser):
+ def test_prepare_save(self, tmp_path, lineparser):
"""Test if save() bails when _prepare_save() returns False."""
- (tmpdir / 'file').write('pristine\n')
+ (tmp_path / 'file').write_text('pristine\n')
lineparser.data = ['changed']
lineparser._prepare_save = lambda: False
lineparser.save()
- assert (tmpdir / 'file').read() == 'pristine\n'
+ assert (tmp_path / 'file').read_text() == 'pristine\n'
diff --git a/tests/unit/misc/test_sessions.py b/tests/unit/misc/test_sessions.py
index 4aec19dc5..e052751b5 100644
--- a/tests/unit/misc/test_sessions.py
+++ b/tests/unit/misc/test_sessions.py
@@ -40,9 +40,9 @@ webengine_refactoring_xfail = pytest.mark.xfail(
@pytest.fixture
-def sess_man(tmpdir):
+def sess_man(tmp_path):
"""Fixture providing a SessionManager."""
- return sessions.SessionManager(base_path=str(tmpdir))
+ return sessions.SessionManager(base_path=str(tmp_path))
class TestInit:
@@ -57,11 +57,12 @@ class TestInit:
pass
@pytest.mark.parametrize('create_dir', [True, False])
- def test_with_standarddir(self, tmpdir, monkeypatch, create_dir):
- monkeypatch.setattr(sessions.standarddir, 'data', lambda: str(tmpdir))
- session_dir = tmpdir / 'sessions'
+ def test_with_standarddir(self, tmp_path, monkeypatch, create_dir):
+ monkeypatch.setattr(sessions.standarddir, 'data',
+ lambda: str(tmp_path))
+ session_dir = tmp_path / 'sessions'
if create_dir:
- session_dir.ensure(dir=True)
+ session_dir.mkdir()
sessions.init()
@@ -76,14 +77,14 @@ def test_did_not_load(sess_man):
class TestExists:
@pytest.mark.parametrize('absolute', [True, False])
- def test_existent(self, tmpdir, absolute):
- session_dir = tmpdir / 'sessions'
- abs_session = tmpdir / 'foo.yml'
+ def test_existent(self, tmp_path, absolute):
+ session_dir = tmp_path / 'sessions'
+ abs_session = tmp_path / 'foo.yml'
rel_session = session_dir / 'foo.yml'
- session_dir.ensure(dir=True)
- abs_session.ensure()
- rel_session.ensure()
+ session_dir.mkdir()
+ abs_session.touch()
+ rel_session.touch()
man = sessions.SessionManager(str(session_dir))
@@ -95,11 +96,11 @@ class TestExists:
assert man.exists(name)
@pytest.mark.parametrize('absolute', [True, False])
- def test_inexistent(self, tmpdir, absolute):
- man = sessions.SessionManager(str(tmpdir))
+ def test_inexistent(self, tmp_path, absolute):
+ man = sessions.SessionManager(str(tmp_path))
if absolute:
- name = str(tmpdir / 'foo')
+ name = str(tmp_path / 'foo')
else:
name = 'foo'
@@ -208,13 +209,13 @@ class TestSave:
objreg.delete('main-window', scope='window', window=0)
objreg.delete('tabbed-browser', scope='window', window=0)
- def test_no_state_config(self, sess_man, tmpdir, state_config):
- session_path = tmpdir / 'foo.yml'
+ def test_no_state_config(self, sess_man, tmp_path, state_config):
+ session_path = tmp_path / 'foo.yml'
sess_man.save(str(session_path))
assert 'session' not in state_config['general']
- def test_last_window_session_none(self, caplog, sess_man, tmpdir):
- session_path = tmpdir / 'foo.yml'
+ def test_last_window_session_none(self, caplog, sess_man, tmp_path):
+ session_path = tmp_path / 'foo.yml'
with caplog.at_level(logging.ERROR):
sess_man.save(str(session_path), last_window=True)
@@ -222,9 +223,9 @@ class TestSave:
assert caplog.messages == [msg]
assert not session_path.exists()
- def test_last_window_session(self, sess_man, tmpdir):
+ def test_last_window_session(self, sess_man, tmp_path):
sess_man.save_last_window_session()
- session_path = tmpdir / 'foo.yml'
+ session_path = tmp_path / 'foo.yml'
sess_man.save(str(session_path), last_window=True)
data = session_path.read_text('utf-8')
assert data == 'windows: []\n'
@@ -232,24 +233,24 @@ class TestSave:
@pytest.mark.parametrize('exception', [
OSError('foo'), UnicodeEncodeError('ascii', '', 0, 2, 'foo'),
yaml.YAMLError('foo')])
- def test_fake_exception(self, mocker, sess_man, tmpdir, exception):
+ def test_fake_exception(self, mocker, sess_man, tmp_path, exception):
mocker.patch('qutebrowser.misc.sessions.yaml.dump',
side_effect=exception)
with pytest.raises(sessions.SessionError, match=str(exception)):
- sess_man.save(str(tmpdir / 'foo.yml'))
+ sess_man.save(str(tmp_path / 'foo.yml'))
- assert not tmpdir.listdir()
+ assert not list(tmp_path.glob('*'))
- def test_load_next_time(self, tmpdir, state_config, sess_man):
- session_path = tmpdir / 'foo.yml'
+ def test_load_next_time(self, tmp_path, state_config, sess_man):
+ session_path = tmp_path / 'foo.yml'
sess_man.save(str(session_path), load_next_time=True)
assert state_config['general']['session'] == str(session_path)
@webengine_refactoring_xfail
- def test_utf_8_invalid(self, tmpdir, sess_man, fake_history):
+ def test_utf_8_invalid(self, tmp_path, sess_man, fake_history):
"""Make sure data containing invalid UTF8 raises SessionError."""
- session_path = tmpdir / 'foo.yml'
+ session_path = tmp_path / 'foo.yml'
fake_history([Item(QUrl('http://www.qutebrowser.org/'), '\ud800',
active=True)])
@@ -356,18 +357,18 @@ class TestLoadTab:
class TestListSessions:
- def test_no_sessions(self, tmpdir):
- sess_man = sessions.SessionManager(str(tmpdir))
+ def test_no_sessions(self, tmp_path):
+ sess_man = sessions.SessionManager(str(tmp_path))
assert not sess_man.list_sessions()
- def test_with_sessions(self, tmpdir):
- (tmpdir / 'foo.yml').ensure()
- (tmpdir / 'bar.yml').ensure()
- sess_man = sessions.SessionManager(str(tmpdir))
+ def test_with_sessions(self, tmp_path):
+ (tmp_path / 'foo.yml').touch()
+ (tmp_path / 'bar.yml').touch()
+ sess_man = sessions.SessionManager(str(tmp_path))
assert sess_man.list_sessions() == ['bar', 'foo']
- def test_with_other_files(self, tmpdir):
- (tmpdir / 'foo.yml').ensure()
- (tmpdir / 'bar.html').ensure()
- sess_man = sessions.SessionManager(str(tmpdir))
+ def test_with_other_files(self, tmp_path):
+ (tmp_path / 'foo.yml').touch()
+ (tmp_path / 'bar.html').touch()
+ sess_man = sessions.SessionManager(str(tmp_path))
assert sess_man.list_sessions() == ['foo']
diff --git a/tests/unit/misc/test_utilcmds.py b/tests/unit/misc/test_utilcmds.py
index 3066dcc7a..e8f651dc8 100644
--- a/tests/unit/misc/test_utilcmds.py
+++ b/tests/unit/misc/test_utilcmds.py
@@ -19,8 +19,6 @@
"""Tests for qutebrowser.misc.utilcmds."""
-import logging
-
import pytest
from PyQt5.QtCore import QUrl
@@ -42,17 +40,6 @@ def test_repeat_command_initial(mocker, mode_manager):
utilcmds.repeat_command(win_id=0)
-def test_debug_log_level(mocker):
- """Test interactive log level changing."""
- formatter_mock = mocker.patch(
- 'qutebrowser.misc.utilcmds.log.change_console_formatter')
- handler_mock = mocker.patch(
- 'qutebrowser.misc.utilcmds.log.console_handler')
- utilcmds.debug_log_level(level='debug')
- formatter_mock.assert_called_with(logging.DEBUG)
- handler_mock.setLevel.assert_called_with(logging.DEBUG)
-
-
class FakeWindow:
"""Mock class for window_only."""
diff --git a/tests/unit/scripts/test_check_coverage.py b/tests/unit/scripts/test_check_coverage.py
index bb23db512..d805eb184 100644
--- a/tests/unit/scripts/test_check_coverage.py
+++ b/tests/unit/scripts/test_check_coverage.py
@@ -19,7 +19,7 @@
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
import sys
-import os.path
+import pathlib
import pytest
@@ -216,15 +216,14 @@ def test_skipped_non_linux(covtest):
def _generate_files():
"""Get filenames from WHITELISTED_/PERFECT_FILES."""
for src_file in check_coverage.WHITELISTED_FILES:
- yield os.path.join('qutebrowser', src_file)
+ yield pathlib.Path('qutebrowser') / src_file
for test_file, src_file in check_coverage.PERFECT_FILES:
if test_file is not None:
- yield test_file
- yield os.path.join('qutebrowser', src_file)
+ yield pathlib.Path(test_file)
+ yield pathlib.Path('qutebrowser') / src_file
@pytest.mark.parametrize('filename', list(_generate_files()))
def test_files_exist(filename):
- basedir = os.path.join(os.path.dirname(check_coverage.__file__),
- os.pardir, os.pardir)
- assert os.path.exists(os.path.join(basedir, filename))
+ basedir = pathlib.Path(check_coverage.__file__).parents[2]
+ assert (basedir / filename).exists()
diff --git a/tests/unit/scripts/test_dictcli.py b/tests/unit/scripts/test_dictcli.py
index 8f02974d9..9add389d8 100644
--- a/tests/unit/scripts/test_dictcli.py
+++ b/tests/unit/scripts/test_dictcli.py
@@ -19,7 +19,8 @@
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
-import py.path # pylint: disable=no-name-in-module
+import pathlib
+
import pytest
from qutebrowser.browser.webengine import spell
@@ -59,13 +60,13 @@ def configdata_init():
@pytest.fixture(autouse=True)
-def dict_tmpdir(tmpdir, monkeypatch):
- monkeypatch.setattr(spell, 'dictionary_dir', lambda: str(tmpdir))
- return tmpdir
+def dict_tmp_path(tmp_path, monkeypatch):
+ monkeypatch.setattr(spell, 'dictionary_dir', lambda: str(tmp_path))
+ return tmp_path
-def test_language(dict_tmpdir):
- (dict_tmpdir / 'pl-PL-2-0.bdic').ensure()
+def test_language(dict_tmp_path):
+ (dict_tmp_path / 'pl-PL-2-0.bdic').touch()
assert english().local_filename is None
assert polish()
@@ -82,9 +83,9 @@ def test_latest_yet():
assert dictcli.latest_yet(code2file, 'en-US', 'en-US-8-0.bdic')
-def test_available_languages(dict_tmpdir, monkeypatch):
+def test_available_languages(dict_tmp_path, monkeypatch):
for f in ['pl-PL-2-0.bdic', english().remote_filename]:
- (dict_tmpdir / f).ensure()
+ (dict_tmp_path / f).touch()
monkeypatch.setattr(dictcli, 'language_list_from_api', lambda: [
(lang.code, lang.remote_filename) for lang in langs()
])
@@ -118,27 +119,27 @@ def test_filter_languages():
dictcli.filter_languages(langs(), ['pl-PL', 'en-GB'])
-def test_install(dict_tmpdir, monkeypatch):
+def test_install(dict_tmp_path, monkeypatch):
# given
monkeypatch.setattr(
dictcli, 'download_dictionary',
- lambda _url, dest: py.path.local(dest).ensure()) # pylint: disable=no-member
+ lambda _url, dest: pathlib.Path(dest).touch())
# when
dictcli.install(langs())
# then
- installed_files = [f.basename for f in dict_tmpdir.listdir()]
+ installed_files = [f.name for f in dict_tmp_path.glob('*')]
expected_files = [lang.remote_filename for lang in langs()]
assert sorted(installed_files) == sorted(expected_files)
-def test_update(dict_tmpdir, monkeypatch):
+def test_update(dict_tmp_path, monkeypatch):
# given
monkeypatch.setattr(
dictcli, 'download_dictionary',
- lambda _url, dest: py.path.local(dest).ensure()) # pylint: disable=no-member
- (dict_tmpdir / 'pl-PL-2-0.bdic').ensure()
+ lambda _url, dest: pathlib.Path(dest).touch())
+ (dict_tmp_path / 'pl-PL-2-0.bdic').touch()
assert polish().local_version < polish().remote_version
# when
@@ -148,20 +149,20 @@ def test_update(dict_tmpdir, monkeypatch):
assert polish().local_version == polish().remote_version
-def test_remove_old(dict_tmpdir, monkeypatch):
+def test_remove_old(dict_tmp_path, monkeypatch):
# given
monkeypatch.setattr(
dictcli, 'download_dictionary',
- lambda _url, dest: py.path.local(dest).ensure()) # pylint: disable=no-member
+ lambda _url, dest: pathlib.Path(dest).touch())
for f in ['pl-PL-2-0.bdic',
polish().remote_filename,
english().remote_filename]:
- (dict_tmpdir / f).ensure()
+ (dict_tmp_path / f).touch()
# when
dictcli.remove_old(langs())
# then
- installed_files = [f.basename for f in dict_tmpdir.listdir()]
+ installed_files = [f.name for f in dict_tmp_path.glob('*')]
expected_files = [polish().remote_filename, english().remote_filename]
assert sorted(installed_files) == sorted(expected_files)
diff --git a/tests/unit/scripts/test_importer.py b/tests/unit/scripts/test_importer.py
index 950987afc..4a70ae63e 100644
--- a/tests/unit/scripts/test_importer.py
+++ b/tests/unit/scripts/test_importer.py
@@ -18,37 +18,31 @@
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
-import os
+import pathlib
import pytest
from scripts import importer
-_samples = 'tests/unit/scripts/importer_sample'
+_samples = pathlib.Path('tests/unit/scripts/importer_sample')
def qm_expected(input_format):
"""Read expected quickmark-formatted output."""
- with open(os.path.join(_samples, input_format, 'quickmarks'),
- 'r', encoding='utf-8') as f:
- return f.read()
+ return (_samples / input_format / 'quickmarks').read_text(encoding='utf-8')
def bm_expected(input_format):
"""Read expected bookmark-formatted output."""
- with open(os.path.join(_samples, input_format, 'bookmarks'),
- 'r', encoding='utf-8') as f:
- return f.read()
+ return (_samples / input_format / 'bookmarks').read_text(encoding='utf-8')
def search_expected(input_format):
"""Read expected search-formatted (config.py) output."""
- with open(os.path.join(_samples, input_format, 'config_py'),
- 'r', encoding='utf-8') as f:
- return f.read()
+ return (_samples / input_format / 'config_py').read_text(encoding='utf-8')
def sample_input(input_format):
"""Get the sample input path."""
- return os.path.join(_samples, input_format, 'input')
+ return str(_samples / input_format / 'input')
def test_opensearch_convert():
diff --git a/tests/unit/scripts/test_run_vulture.py b/tests/unit/scripts/test_run_vulture.py
index 25630b9fc..edf3451cb 100644
--- a/tests/unit/scripts/test_run_vulture.py
+++ b/tests/unit/scripts/test_run_vulture.py
@@ -23,6 +23,8 @@ import textwrap
import pytest
+from tests.helpers import utils
+
try:
from scripts.dev import run_vulture
except ImportError:
@@ -41,29 +43,29 @@ class VultureDir:
"""Fixture similar to pytest's testdir fixture for vulture.
Attributes:
- _tmpdir: The pytest tmpdir fixture.
+ _tmp_path: The pytest tmp_path fixture.
"""
- def __init__(self, tmpdir):
- self._tmpdir = tmpdir
+ def __init__(self, tmp_path):
+ self._tmp_path = tmp_path
def run(self):
"""Run vulture over all generated files and return the output."""
- files = self._tmpdir.listdir()
- assert files
- with self._tmpdir.as_cwd():
- return run_vulture.run([str(e.basename) for e in files])
+ names = [p.name for p in self._tmp_path.glob('*')]
+ assert names
+ with utils.change_cwd(self._tmp_path):
+ return run_vulture.run(names)
def makepyfile(self, **kwargs):
"""Create a python file, similar to TestDir.makepyfile."""
for filename, data in kwargs.items():
text = textwrap.dedent(data)
- (self._tmpdir / filename + '.py').write_text(text, 'utf-8')
+ (self._tmp_path / (filename + '.py')).write_text(text, 'utf-8')
@pytest.fixture
-def vultdir(tmpdir):
- return VultureDir(tmpdir)
+def vultdir(tmp_path):
+ return VultureDir(tmp_path)
def test_used(vultdir):
diff --git a/tests/unit/test_qutebrowser.py b/tests/unit/test_qutebrowser.py
new file mode 100644
index 000000000..5a792a6d2
--- /dev/null
+++ b/tests/unit/test_qutebrowser.py
@@ -0,0 +1,62 @@
+# 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/>.
+
+"""Tests for qutebrowser.qutebrowser.
+
+(Mainly commandline flag parsing)
+"""
+
+import pytest
+
+from qutebrowser import qutebrowser
+
+
+@pytest.fixture
+def parser():
+ return qutebrowser.get_argparser()
+
+
+class TestDebugFlag:
+
+ def test_valid(self, parser):
+ args = parser.parse_args(['--debug-flag', 'chromium',
+ '--debug-flag', 'stack'])
+ assert args.debug_flags == ['chromium', 'stack']
+
+ def test_invalid(self, parser, capsys):
+ with pytest.raises(SystemExit):
+ parser.parse_args(['--debug-flag', 'invalid'])
+
+ _out, err = capsys.readouterr()
+ assert 'Invalid debug flag - valid flags:' in err
+
+
+class TestLogFilter:
+
+ def test_valid(self, parser):
+ args = parser.parse_args(['--logfilter', 'misc'])
+ assert args.logfilter == 'misc'
+
+ def test_invalid(self, parser, capsys):
+ with pytest.raises(SystemExit):
+ parser.parse_args(['--logfilter', 'invalid'])
+
+ _out, err = capsys.readouterr()
+ print(err)
+ assert 'Invalid log category invalid - valid categories' in err
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_log.py b/tests/unit/utils/test_log.py
index a74d81600..f73b88b2c 100644
--- a/tests/unit/utils/test_log.py
+++ b/tests/unit/utils/test_log.py
@@ -30,8 +30,10 @@ import pytest
import _pytest.logging
from PyQt5 import QtCore
+from qutebrowser import qutebrowser
from qutebrowser.utils import log
from qutebrowser.misc import utilcmds
+from qutebrowser.api import cmdutils
@pytest.fixture(autouse=True)
@@ -117,51 +119,58 @@ class TestLogFilter:
@pytest.mark.parametrize('filters, negated, category, logged', [
# Filter letting all messages through
- (None, False, 'eggs.bacon.spam', True),
- (None, False, 'eggs', True),
- (None, True, 'ham', True),
+ (set(), False, 'eggs.bacon.spam', True),
+ (set(), False, 'eggs', True),
+ (set(), True, 'ham', True),
# Matching records
- (['eggs', 'bacon'], False, 'eggs', True),
- (['eggs', 'bacon'], False, 'bacon', True),
- (['eggs.bacon'], False, 'eggs.bacon', True),
+ ({'eggs', 'bacon'}, False, 'eggs', True),
+ ({'eggs', 'bacon'}, False, 'bacon', True),
+ ({'eggs'}, False, 'eggs.fried', True),
# Non-matching records
- (['eggs', 'bacon'], False, 'spam', False),
- (['eggs'], False, 'eggsauce', False),
- (['eggs.bacon'], False, 'eggs.baconstrips', False),
- # Child loggers
- (['eggs.bacon', 'spam.ham'], False, 'eggs.bacon.spam', True),
- (['eggs.bacon', 'spam.ham'], False, 'spam.ham.salami', True),
+ ({'eggs', 'bacon'}, False, 'spam', False),
+ ({'eggs'}, False, 'eggsauce', False),
+ ({'fried'}, False, 'eggs.fried', False),
# Suppressed records
- (['eggs', 'bacon'], True, 'eggs', False),
- (['eggs', 'bacon'], True, 'bacon', False),
- (['eggs.bacon'], True, 'eggs.bacon', False),
+ ({'eggs', 'bacon'}, True, 'eggs', False),
+ ({'eggs', 'bacon'}, True, 'bacon', False),
# Non-suppressed records
- (['eggs', 'bacon'], True, 'spam', True),
- (['eggs'], True, 'eggsauce', True),
- (['eggs.bacon'], True, 'eggs.baconstrips', True),
+ ({'eggs', 'bacon'}, True, 'spam', True),
+ ({'eggs'}, True, 'eggsauce', True),
])
def test_logfilter(self, logger, filters, negated, category, logged):
"""Ensure the multi-record filtering filterer filters multiple records.
(Blame @toofar for this comment)
"""
- logfilter = log.LogFilter(filters, negated)
+ logfilter = log.LogFilter(filters, negated=negated)
record = self._make_record(logger, category)
assert logfilter.filter(record) == logged
- @pytest.mark.parametrize('category', ['eggs', 'bacon'])
- def test_debug(self, logger, category):
- """Test if messages more important than debug are never filtered."""
- logfilter = log.LogFilter(['eggs'])
- record = self._make_record(logger, category, level=logging.INFO)
- assert logfilter.filter(record)
+ def test_logfilter_benchmark(self, logger, benchmark):
+ record = self._make_record(logger, 'unfiltered')
+ filters = set(log.LOGGER_NAMES) # Extreme case
+ logfilter = log.LogFilter(filters, negated=False)
+ benchmark(lambda: logfilter.filter(record))
- @pytest.mark.parametrize('category, logged_before, logged_after', [
- ('init', True, False), ('url', False, True), ('js', False, True)])
+ @pytest.mark.parametrize('only_debug', [True, False])
+ def test_debug(self, logger, only_debug):
+ """Test if messages more important than debug are never filtered."""
+ logfilter = log.LogFilter({'eggs'}, only_debug=only_debug)
+ record = self._make_record(logger, 'bacon', level=logging.INFO)
+ assert logfilter.filter(record) == only_debug
+
+ @pytest.mark.parametrize(
+ 'category, filter_str, logged_before, logged_after', [
+ ('init', 'url,js', True, False),
+ ('url', 'url,js', False, True),
+ ('js', 'url,js', False, True),
+ ('js', 'none', False, True),
+ ]
+ )
def test_debug_log_filter_cmd(self, monkeypatch, logger, category,
- logged_before, logged_after):
+ filter_str, logged_before, logged_after):
"""Test the :debug-log-filter command handler."""
- logfilter = log.LogFilter(["init"])
+ logfilter = log.LogFilter({"init"})
monkeypatch.setattr(log, 'console_filter', logfilter)
record = self._make_record(logger, category)
@@ -170,6 +179,37 @@ class TestLogFilter:
utilcmds.debug_log_filter('url,js')
assert logfilter.filter(record) == logged_after
+ def test_debug_log_filter_cmd_invalid(self, monkeypatch):
+ logfilter = log.LogFilter(set())
+ monkeypatch.setattr(log, 'console_filter', logfilter)
+ with pytest.raises(cmdutils.CommandError,
+ match='Invalid log category blabla'):
+ utilcmds.debug_log_filter('blabla')
+
+ @pytest.mark.parametrize('filter_str, expected_names, negated', [
+ ('!js,misc', {'js', 'misc'}, True),
+ ('js,misc', {'js', 'misc'}, False),
+ ('js, misc', {'js', 'misc'}, False),
+ ('JS, Misc', {'js', 'misc'}, False),
+ (None, set(), False),
+ ('none', set(), False),
+ ])
+ def test_parsing(self, filter_str, expected_names, negated):
+ logfilter = log.LogFilter.parse(filter_str)
+ assert logfilter.names == expected_names
+ assert logfilter.negated == negated
+
+ @pytest.mark.parametrize('filter_str, invalid', [
+ ('js,!misc', '!misc'),
+ ('blabla,js,blablub', 'blabla, blablub'),
+ ])
+ def test_parsing_invalid(self, filter_str, invalid):
+ with pytest.raises(
+ log.InvalidLogFilterError,
+ match='Invalid log category {} - '
+ 'valid categories: statusbar, .*'.format(invalid)):
+ log.LogFilter.parse(filter_str)
+
@pytest.mark.parametrize('data, expected', [
# Less data
@@ -198,8 +238,9 @@ class TestInitLog:
def _get_default_args(self):
return argparse.Namespace(debug=True, loglevel='debug', color=True,
- loglines=10, logfilter="", force_color=False,
- json_logging=False, debug_flags=set())
+ loglines=10, logfilter=None,
+ force_color=False, json_logging=False,
+ debug_flags=set())
@pytest.fixture(autouse=True)
def setup(self, mocker):
@@ -215,6 +256,15 @@ class TestInitLog:
"""Fixture providing an argparse namespace for init_log."""
return self._get_default_args()
+ @pytest.fixture
+ def parser(self):
+ return qutebrowser.get_argparser()
+
+ @pytest.fixture
+ def empty_args(self, parser):
+ """Logging commandline arguments without any customization."""
+ return parser.parse_args([])
+
def test_stderr_none(self, args):
"""Test init_log with sys.stderr = None."""
old_stderr = sys.stderr
@@ -222,22 +272,6 @@ class TestInitLog:
log.init_log(args)
sys.stderr = old_stderr
- @pytest.mark.parametrize('logfilter, expected_names, negated', [
- ('!one,two', ['one', 'two'], True),
- ('one,two', ['one', 'two'], False),
- ('one,!two', ['one', '!two'], False),
- (None, None, False),
- ])
- def test_negation_parser(self, args, mocker,
- logfilter, expected_names, negated):
- """Test parsing the --logfilter argument."""
- filter_mock = mocker.patch('qutebrowser.utils.log.LogFilter',
- autospec=True)
- args.logfilter = logfilter
- log.init_log(args)
- assert filter_mock.called
- assert filter_mock.call_args[0] == (expected_names, negated)
-
def test_python_warnings(self, args, caplog):
log.init_log(args)
@@ -254,6 +288,62 @@ class TestInitLog:
with pytest.raises(PendingDeprecationWarning):
warnings.warn("test warning", PendingDeprecationWarning)
+ @pytest.mark.parametrize('cli, conf, expected', [
+ (None, 'info', logging.INFO),
+ (None, 'warning', logging.WARNING),
+ ('info', 'warning', logging.INFO),
+ ('warning', 'info', logging.WARNING),
+ ])
+ def test_init_from_config_console(self, cli, conf, expected, args,
+ config_stub):
+ args.debug = False
+ args.loglevel = cli
+ log.init_log(args)
+
+ config_stub.val.logging.level.console = conf
+ log.init_from_config(config_stub.val)
+ assert log.console_handler.level == expected
+
+ @pytest.mark.parametrize('conf, expected', [
+ ('vdebug', logging.VDEBUG),
+ ('debug', logging.DEBUG),
+ ('info', logging.INFO),
+ ('critical', logging.CRITICAL),
+ ])
+ def test_init_from_config_ram(self, conf, expected, args, config_stub):
+ args.debug = False
+ log.init_log(args)
+
+ config_stub.val.logging.level.ram = conf
+ log.init_from_config(config_stub.val)
+ assert log.ram_handler.level == expected
+
+ def test_init_from_config_consistent_default(self, config_stub, empty_args):
+ """Ensure config defaults are consistent with the builtin defaults."""
+ log.init_log(empty_args)
+
+ assert log.ram_handler.level == logging.DEBUG
+ assert log.console_handler.level == logging.INFO
+
+ log.init_from_config(config_stub.val)
+
+ assert log.ram_handler.level == logging.DEBUG
+ assert log.console_handler.level == logging.INFO
+
+ def test_init_from_config_format(self, config_stub, empty_args):
+ """If we change to the debug level, make sure the format changes."""
+ log.init_log(empty_args)
+ assert log.console_handler.formatter._fmt == log.SIMPLE_FMT
+
+ config_stub.val.logging.level.console = 'debug'
+ log.init_from_config(config_stub.val)
+ assert log.console_handler.formatter._fmt == log.EXTENDED_FMT
+
+ def test_logfilter(self, parser):
+ args = parser.parse_args(['--logfilter', 'misc'])
+ log.init_log(args)
+ assert log.console_filter.names == {'misc'}
+
class TestHideQtWarning:
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 c2d2c6cd7..064c51b30 100644
--- a/tests/unit/utils/test_standarddir.py
+++ b/tests/unit/utils/test_standarddir.py
@@ -79,6 +79,7 @@ def test_unset_organization_no_qapp(monkeypatch):
@pytest.mark.fake_os('mac')
+@pytest.mark.posix
def test_fake_mac_config(tmpdir, monkeypatch):
"""Test standardir.config on a fake Mac."""
monkeypatch.setenv('HOME', str(tmpdir))
diff --git a/tests/unit/utils/test_urlutils.py b/tests/unit/utils/test_urlutils.py
index 39a43479b..a9f32161d 100644
--- a/tests/unit/utils/test_urlutils.py
+++ b/tests/unit/utils/test_urlutils.py
@@ -716,6 +716,9 @@ class TestProxyFromUrl:
def test_proxy_from_url_valid(self, url, expected):
assert urlutils.proxy_from_url(QUrl(url)) == expected
+ @pytest.mark.qt_log_ignore(
+ r'^QHttpNetworkConnectionPrivate::_q_hostLookupFinished could not '
+ r'de-queue request, failed to report HostNotFoundError')
@pytest.mark.parametrize('scheme', ['pac+http', 'pac+https'])
def test_proxy_from_url_pac(self, scheme, qapp):
fetcher = urlutils.proxy_from_url(QUrl('{}://foo'.format(scheme)))
diff --git a/tests/unit/utils/test_utils.py b/tests/unit/utils/test_utils.py
index 18abd444e..35f04201e 100644
--- a/tests/unit/utils/test_utils.py
+++ b/tests/unit/utils/test_utils.py
@@ -885,3 +885,10 @@ def test_ceil_log_invalid(number, base):
math.log(number, base)
with pytest.raises(ValueError):
utils.ceil_log(number, base)
+
+
+@pytest.mark.parametrize('skip', [True, False])
+def test_libgl_workaround(monkeypatch, skip):
+ if skip:
+ monkeypatch.setenv('QUTE_SKIP_LIBGL_WORKAROUND', '1')
+ utils.libgl_workaround() # Just make sure it doesn't crash.
diff --git a/tests/unit/utils/test_version.py b/tests/unit/utils/test_version.py
index 0a3c5e4aa..8d3542cd7 100644
--- a/tests/unit/utils/test_version.py
+++ b/tests/unit/utils/test_version.py
@@ -35,6 +35,8 @@ import datetime
import attr
import pkg_resources
import pytest
+import hypothesis
+import hypothesis.strategies
import qutebrowser
from qutebrowser.config import config
@@ -401,7 +403,7 @@ class TestGitStrSubprocess:
def test_real_git(self, git_repo):
"""Test with a real git repository."""
ret = version._git_str_subprocess(str(git_repo))
- assert ret == '6e4b65a (1970-01-01 01:00:00 +0100)'
+ assert ret == '6e4b65a on master (1970-01-01 01:00:00 +0100)'
def test_missing_dir(self, tmpdir):
"""Test with a directory which doesn't exist."""
@@ -925,8 +927,8 @@ class VersionParams:
VersionParams('no-autoconfig-loaded', autoconfig_loaded=False),
VersionParams('no-config-py-loaded', config_py_loaded=False),
], ids=lambda param: param.name)
-def test_version_output(params, stubs, monkeypatch, config_stub):
- """Test version.version()."""
+def test_version_info(params, stubs, monkeypatch, config_stub):
+ """Test version.version_info()."""
config.instance.config_py_loaded = params.config_py_loaded
import_path = os.path.abspath('/IMPORTPATH')
@@ -956,11 +958,15 @@ def test_version_output(params, stubs, monkeypatch, config_stub):
'config.instance.yaml_loaded': params.autoconfig_loaded,
}
+ version.opengl_info.cache_clear()
+ monkeypatch.setenv('QUTE_FAKE_OPENGL', 'VENDOR, 1.0 VERSION')
+
substitutions = {
'git_commit': '\nGit commit: GIT COMMIT' if params.git_commit else '',
'style': '\nStyle: STYLE' if params.qapp else '',
'platform_plugin': ('\nPlatform plugin: PLATFORM' if params.qapp
else ''),
+ 'opengl': '\nOpenGL: VENDOR, 1.0 VERSION' if params.qapp else '',
'qt': 'QT VERSION',
'frozen': str(params.frozen),
'import_path': import_path,
@@ -1026,7 +1032,7 @@ def test_version_output(params, stubs, monkeypatch, config_stub):
pdf.js: PDFJS VERSION
sqlite: SQLITE VERSION
QtNetwork SSL: {ssl}
- {style}{platform_plugin}
+ {style}{platform_plugin}{opengl}
Platform: PLATFORM, ARCHITECTURE{linuxdist}
Frozen: {frozen}
Imported from {import_path}
@@ -1042,13 +1048,79 @@ def test_version_output(params, stubs, monkeypatch, config_stub):
""".lstrip('\n'))
expected = template.rstrip('\n').format(**substitutions)
- assert version.version() == expected
+ assert version.version_info() == expected
+
+
+class TestOpenGLInfo:
+
+ @pytest.fixture(autouse=True)
+ def cache_clear(self):
+ """Clear the lru_cache between tests."""
+ version.opengl_info.cache_clear()
+ def test_func(self, qapp):
+ """Simply call version.opengl_info() and see if it doesn't crash."""
+ pytest.importorskip("PyQt5.QtOpenGL")
+ version.opengl_info()
+
+ def test_func_fake(self, qapp, monkeypatch):
+ monkeypatch.setenv('QUTE_FAKE_OPENGL', 'Outtel Inc., 3.0 Messiah 20.0')
+ info = version.opengl_info()
+ assert info.vendor == 'Outtel Inc.'
+ assert info.version_str == '3.0 Messiah 20.0'
+ assert info.version == (3, 0)
+ assert info.vendor_specific == 'Messiah 20.0'
+
+ @pytest.mark.parametrize('version_str, reason', [
+ ('blah', 'missing space'),
+ ('2,x blah', 'parsing int'),
+ ])
+ def test_parse_invalid(self, caplog, version_str, reason):
+ with caplog.at_level(logging.WARNING):
+ info = version.OpenGLInfo.parse(vendor="vendor",
+ version=version_str)
+
+ assert info.version is None
+ assert info.vendor_specific is None
+ assert info.vendor == 'vendor'
+ assert info.version_str == version_str
+
+ msg = "Failed to parse OpenGL version ({}): {}".format(
+ reason, version_str)
+ assert caplog.messages == [msg]
+
+ @hypothesis.given(vendor=hypothesis.strategies.text(),
+ version_str=hypothesis.strategies.text())
+ def test_parse_hypothesis(self, caplog, vendor, version_str):
+ with caplog.at_level(logging.WARNING):
+ info = version.OpenGLInfo.parse(vendor=vendor, version=version_str)
+
+ assert info.vendor == vendor
+ assert info.version_str == version_str
+ assert vendor in str(info)
+ assert version_str in str(info)
+
+ if info.version is not None:
+ reconstructed = ' '.join(['.'.join(str(part)
+ for part in info.version),
+ info.vendor_specific])
+ assert reconstructed == info.version_str
+
+ @pytest.mark.parametrize('version_str, expected', [
+ ("2.1 INTEL-10.36.26", (2, 1)),
+ ("4.6 (Compatibility Profile) Mesa 20.0.7", (4, 6)),
+ ("3.0 Mesa 20.0.7", (3, 0)),
+ ("3.0 Mesa 20.0.6", (3, 0)),
+ # Not from the wild, but can happen according to standards
+ ("3.0.2 Mesa 20.0.6", (3, 0, 2)),
+ ])
+ def test_version(self, version_str, expected):
+ info = version.OpenGLInfo.parse(vendor='vendor', version=version_str)
+ assert info.version == expected
-def test_opengl_vendor(qapp):
- """Simply call version.opengl_vendor() and see if it doesn't crash."""
- pytest.importorskip("PyQt5.QtOpenGL")
- return version.opengl_vendor()
+ def test_str_gles(self):
+ info = version.OpenGLInfo(gles=True)
+ assert str(info) == 'OpenGL ES'
@pytest.fixture
@@ -1061,7 +1133,7 @@ def pbclient(stubs):
def test_pastebin_version(pbclient, message_mock, monkeypatch, qtbot):
"""Test version.pastebin_version() sets the url."""
- monkeypatch.setattr('qutebrowser.utils.version.version',
+ monkeypatch.setattr('qutebrowser.utils.version.version_info',
lambda: "dummy")
monkeypatch.setattr('qutebrowser.utils.utils.log_clipboard', True)
@@ -1076,7 +1148,7 @@ def test_pastebin_version(pbclient, message_mock, monkeypatch, qtbot):
def test_pastebin_version_twice(pbclient, monkeypatch):
"""Test whether calling pastebin_version twice sends no data."""
- monkeypatch.setattr('qutebrowser.utils.version.version',
+ monkeypatch.setattr('qutebrowser.utils.version.version_info',
lambda: "dummy")
version.pastebin_version(pbclient)
@@ -1094,7 +1166,7 @@ def test_pastebin_version_twice(pbclient, monkeypatch):
def test_pastebin_version_error(pbclient, caplog, message_mock, monkeypatch):
"""Test version.pastebin_version() with errors."""
- monkeypatch.setattr('qutebrowser.utils.version.version',
+ monkeypatch.setattr('qutebrowser.utils.version.version_info',
lambda: "dummy")
version.pastebin_url = None
diff --git a/tox.ini b/tox.ini
index 00b14bfb0..4e16742cc 100644
--- a/tox.ini
+++ b/tox.ini
@@ -4,15 +4,15 @@
# and then run "tox" from this directory.
[tox]
-envlist = py37-pyqt514-cov,misc,vulture,flake8,pylint,pyroma,check-manifest,eslint
+envlist = py37-pyqt515-cov,misc,vulture,flake8,pylint,pyroma,check-manifest,eslint
distshare = {toxworkdir}
skipsdist = true
[testenv]
setenv =
PYTEST_QT_API=pyqt5
- pyqt{,57,59,510,511,512,513,514}: LINK_PYQT_SKIP=true
- pyqt{,57,59,510,511,512,513,514}: QUTE_BDD_WEBENGINE=true
+ pyqt{,57,59,510,511,512,513,514,515}: LINK_PYQT_SKIP=true
+ pyqt{,57,59,510,511,512,513,514,515}: QUTE_BDD_WEBENGINE=true
cov: PYTEST_ADDOPTS=--cov --cov-report xml --cov-report=html --cov-report=
passenv = PYTHON DISPLAY XAUTHORITY HOME USERNAME USER CI TRAVIS XDG_* QUTE_* DOCKER QT_QUICK_BACKEND
basepython =
@@ -32,6 +32,7 @@ deps =
pyqt512: -r{toxinidir}/misc/requirements/requirements-pyqt-5.12.txt
pyqt513: -r{toxinidir}/misc/requirements/requirements-pyqt-5.13.txt
pyqt514: -r{toxinidir}/misc/requirements/requirements-pyqt-5.14.txt
+ pyqt515: -r{toxinidir}/misc/requirements/requirements-pyqt-5.15.txt
commands =
{envpython} scripts/link_pyqt.py --tox {envdir}
{envpython} -bb -m pytest {posargs:tests}