summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÁrni Dagur <arni@dagur.eu>2020-12-19 20:30:03 +0000
committerÁrni Dagur <arni@dagur.eu>2020-12-19 20:30:03 +0000
commit317af23593584366a4eb1d7c077389162cb70c32 (patch)
tree553b3605cf89bd1919fda863757ede09561de3cb
parent6e5e80d39af5c258fb67a444d1a0a961474d1c05 (diff)
parent31cd414664ed8600a82c09aec75b13b28befeb5b (diff)
downloadqutebrowser-317af23593584366a4eb1d7c077389162cb70c32.tar.gz
qutebrowser-317af23593584366a4eb1d7c077389162cb70c32.zip
Merge branch 'master' into more-sophisticated-adblock
-rw-r--r--.github/workflows/ci.yml47
-rw-r--r--.github/workflows/docker.yml61
-rw-r--r--.github/workflows/recompile-requirements.yml2
-rw-r--r--.mypy.ini4
-rw-r--r--.pylintrc2
-rw-r--r--.travis.yml16
-rw-r--r--.yamllint1
-rw-r--r--README.asciidoc10
-rw-r--r--doc/changelog.asciidoc148
-rw-r--r--doc/contributing.asciidoc10
-rw-r--r--doc/faq.asciidoc14
-rw-r--r--doc/help/commands.asciidoc6
-rw-r--r--doc/help/configuring.asciidoc43
-rw-r--r--doc/help/settings.asciidoc82
-rw-r--r--doc/install.asciidoc78
-rw-r--r--doc/qutebrowser.1.asciidoc3
-rw-r--r--misc/org.qutebrowser.qutebrowser.desktop2
-rw-r--r--misc/requirements/requirements-check-manifest.txt8
-rw-r--r--misc/requirements/requirements-dev.txt17
-rw-r--r--misc/requirements/requirements-dev.txt-raw1
-rw-r--r--misc/requirements/requirements-flake8.txt4
-rw-r--r--misc/requirements/requirements-mypy.txt4
-rw-r--r--misc/requirements/requirements-pyinstaller.txt4
-rw-r--r--misc/requirements/requirements-pylint.txt10
-rw-r--r--misc/requirements/requirements-pyqt-5.10.txt4
-rw-r--r--misc/requirements/requirements-pyqt-5.10.txt-raw4
-rw-r--r--misc/requirements/requirements-pyqt-5.11.txt4
-rw-r--r--misc/requirements/requirements-pyqt-5.11.txt-raw4
-rw-r--r--misc/requirements/requirements-pyqt-5.15.txt4
-rw-r--r--misc/requirements/requirements-pyqt-5.7.txt4
-rw-r--r--misc/requirements/requirements-pyqt-5.7.txt-raw4
-rw-r--r--misc/requirements/requirements-pyqt-5.9.txt4
-rw-r--r--misc/requirements/requirements-pyqt-5.9.txt-raw4
-rw-r--r--misc/requirements/requirements-pyqt.txt4
-rw-r--r--misc/requirements/requirements-pyqt.txt-raw2
-rw-r--r--misc/requirements/requirements-qutebrowser.txt-raw1
-rw-r--r--misc/requirements/requirements-sphinx.txt12
-rw-r--r--misc/requirements/requirements-tests-git.txt1
-rw-r--r--misc/requirements/requirements-tests.txt22
-rw-r--r--misc/requirements/requirements-tests.txt-raw2
-rw-r--r--misc/requirements/requirements-tox.txt6
-rw-r--r--misc/requirements/requirements-tox.txt-raw2
-rw-r--r--misc/requirements/requirements-vulture.txt2
-rw-r--r--misc/requirements/requirements-yamllint.txt2
-rw-r--r--misc/userscripts/README.md2
-rwxr-xr-xmisc/userscripts/dmenu_qutebrowser5
-rwxr-xr-xmisc/userscripts/qutedmenu11
-rw-r--r--pytest.ini4
-rw-r--r--qutebrowser/api/downloads.py4
-rw-r--r--qutebrowser/app.py16
-rw-r--r--qutebrowser/browser/browsertab.py22
-rw-r--r--qutebrowser/browser/commands.py4
-rw-r--r--qutebrowser/browser/downloads.py8
-rw-r--r--qutebrowser/browser/downloadview.py41
-rw-r--r--qutebrowser/browser/eventfilter.py47
-rw-r--r--qutebrowser/browser/greasemonkey.py13
-rw-r--r--qutebrowser/browser/inspector.py7
-rw-r--r--qutebrowser/browser/navigate.py4
-rw-r--r--qutebrowser/browser/pdfjs.py18
-rw-r--r--qutebrowser/browser/qtnetworkdownloads.py13
-rw-r--r--qutebrowser/browser/qutescheme.py28
-rw-r--r--qutebrowser/browser/shared.py16
-rw-r--r--qutebrowser/browser/webengine/cookies.py24
-rw-r--r--qutebrowser/browser/webengine/darkmode.py34
-rw-r--r--qutebrowser/browser/webengine/interceptor.py14
-rw-r--r--qutebrowser/browser/webengine/spell.py34
-rw-r--r--qutebrowser/browser/webengine/webenginedownloads.py32
-rw-r--r--qutebrowser/browser/webengine/webengineelem.py9
-rw-r--r--qutebrowser/browser/webengine/webengineinspector.py47
-rw-r--r--qutebrowser/browser/webengine/webenginequtescheme.py41
-rw-r--r--qutebrowser/browser/webengine/webenginesettings.py101
-rw-r--r--qutebrowser/browser/webengine/webenginetab.py281
-rw-r--r--qutebrowser/browser/webengine/webview.py84
-rw-r--r--qutebrowser/browser/webkit/cache.py5
-rw-r--r--qutebrowser/browser/webkit/mhtml.py53
-rw-r--r--qutebrowser/browser/webkit/network/networkmanager.py12
-rw-r--r--qutebrowser/browser/webkit/webkitsettings.py2
-rw-r--r--qutebrowser/browser/webkit/webkittab.py8
-rw-r--r--qutebrowser/browser/webkit/webpage.py2
-rw-r--r--qutebrowser/browser/webkit/webview.py5
-rw-r--r--qutebrowser/completion/completiondelegate.py1
-rw-r--r--qutebrowser/completion/completionwidget.py10
-rw-r--r--qutebrowser/completion/models/completionmodel.py10
-rw-r--r--qutebrowser/completion/models/listcategory.py1
-rw-r--r--qutebrowser/components/misccommands.py7
-rw-r--r--qutebrowser/config/config.py46
-rw-r--r--qutebrowser/config/configcache.py6
-rw-r--r--qutebrowser/config/configcommands.py28
-rw-r--r--qutebrowser/config/configdata.py59
-rw-r--r--qutebrowser/config/configdata.yml96
-rw-r--r--qutebrowser/config/configdiff.py761
-rw-r--r--qutebrowser/config/configexc.py17
-rw-r--r--qutebrowser/config/configfiles.py62
-rw-r--r--qutebrowser/config/configtypes.py394
-rw-r--r--qutebrowser/config/configutils.py107
-rw-r--r--qutebrowser/config/qtargs.py65
-rw-r--r--qutebrowser/config/stylesheet.py6
-rw-r--r--qutebrowser/config/websettings.py100
-rw-r--r--qutebrowser/html/warning-old-qt.html32
-rw-r--r--qutebrowser/javascript/.eslintrc.yaml8
-rw-r--r--qutebrowser/javascript/caret.js11
-rw-r--r--qutebrowser/javascript/object_fromentries_quirk.user.js46
-rw-r--r--qutebrowser/javascript/print.js30
-rw-r--r--qutebrowser/javascript/webelem.js21
-rw-r--r--qutebrowser/keyinput/keyutils.py218
-rw-r--r--qutebrowser/keyinput/modeman.py16
-rw-r--r--qutebrowser/mainwindow/mainwindow.py6
-rw-r--r--qutebrowser/mainwindow/prompt.py1
-rw-r--r--qutebrowser/mainwindow/tabbedbrowser.py43
-rw-r--r--qutebrowser/mainwindow/tabwidget.py2
-rw-r--r--qutebrowser/misc/backendproblem.py85
-rw-r--r--qutebrowser/misc/checkpyver.py2
-rw-r--r--qutebrowser/misc/consolewidget.py4
-rw-r--r--qutebrowser/misc/crashdialog.py9
-rw-r--r--qutebrowser/misc/crashsignal.py5
-rw-r--r--qutebrowser/misc/earlyinit.py39
-rw-r--r--qutebrowser/misc/httpclient.py10
-rw-r--r--qutebrowser/misc/ipc.py31
-rw-r--r--qutebrowser/misc/miscwidgets.py41
-rw-r--r--qutebrowser/misc/sessions.py2
-rw-r--r--qutebrowser/misc/sql.py10
-rw-r--r--qutebrowser/qt.py7
-rw-r--r--qutebrowser/qutebrowser.py10
-rw-r--r--qutebrowser/utils/debug.py22
-rw-r--r--qutebrowser/utils/docutils.py5
-rw-r--r--qutebrowser/utils/log.py14
-rw-r--r--qutebrowser/utils/objreg.py4
-rw-r--r--qutebrowser/utils/qtutils.py113
-rw-r--r--qutebrowser/utils/standarddir.py85
-rw-r--r--qutebrowser/utils/urlutils.py77
-rw-r--r--qutebrowser/utils/usertypes.py16
-rw-r--r--qutebrowser/utils/utils.py129
-rw-r--r--qutebrowser/utils/version.py45
-rw-r--r--requirements.txt1
-rwxr-xr-xscripts/asciidoc2html.py8
-rwxr-xr-xscripts/dev/build_release.py18
-rw-r--r--scripts/dev/check_coverage.py7
-rw-r--r--scripts/dev/ci/docker/Dockerfile.j227
-rw-r--r--scripts/dev/ci/docker/README.md9
-rw-r--r--scripts/dev/ci/docker/generate.py45
-rw-r--r--scripts/dev/ci/problemmatchers.py14
-rw-r--r--scripts/dev/misc_checks.py128
-rw-r--r--scripts/dev/recompile_requirements.py151
-rwxr-xr-xscripts/dev/run_vulture.py2
-rwxr-xr-xscripts/dictcli.py33
-rw-r--r--scripts/mkvenv.py222
-rw-r--r--tests/conftest.py20
-rw-r--r--tests/end2end/conftest.py5
-rw-r--r--tests/end2end/features/downloads.feature38
-rw-r--r--tests/end2end/features/hints.feature12
-rw-r--r--tests/end2end/features/javascript.feature22
-rw-r--r--tests/end2end/features/keyinput.feature29
-rw-r--r--tests/end2end/features/misc.feature31
-rw-r--r--tests/end2end/features/prompts.feature7
-rw-r--r--tests/end2end/features/qutescheme.feature4
-rw-r--r--tests/end2end/features/tabs.feature11
-rw-r--r--tests/end2end/features/test_downloads_bdd.py6
-rw-r--r--tests/end2end/features/test_prompts_bdd.py19
-rw-r--r--tests/end2end/features/test_qutescheme_bdd.py9
-rw-r--r--tests/end2end/features/test_search_bdd.py10
-rw-r--r--tests/end2end/fixtures/quteprocess.py98
-rw-r--r--tests/end2end/fixtures/testprocess.py18
-rw-r--r--tests/end2end/fixtures/webserver.py41
-rw-r--r--tests/end2end/fixtures/webserver_sub.py45
-rw-r--r--tests/end2end/templates/headers-link.html10
-rw-r--r--tests/end2end/test_invocations.py61
-rw-r--r--tests/end2end/test_mkvenv.py28
-rw-r--r--tests/helpers/fixtures.py8
-rw-r--r--tests/helpers/stubs.py8
-rw-r--r--tests/helpers/utils.py17
-rw-r--r--tests/unit/api/test_cmdutils.py12
-rw-r--r--tests/unit/browser/test_caret.py4
-rw-r--r--tests/unit/browser/test_hints.py6
-rw-r--r--tests/unit/browser/test_history.py3
-rw-r--r--tests/unit/browser/test_navigate.py2
-rw-r--r--tests/unit/browser/test_pdfjs.py54
-rw-r--r--tests/unit/browser/test_qutescheme.py3
-rw-r--r--tests/unit/browser/webengine/test_darkmode.py33
-rw-r--r--tests/unit/browser/webengine/test_spell.py59
-rw-r--r--tests/unit/browser/webengine/test_webengine_cookies.py26
-rw-r--r--tests/unit/browser/webengine/test_webenginedownloads.py7
-rw-r--r--tests/unit/browser/webengine/test_webengineinterceptor.py6
-rw-r--r--tests/unit/browser/webengine/test_webenginesettings.py12
-rw-r--r--tests/unit/browser/webengine/test_webenginetab.py3
-rw-r--r--tests/unit/browser/webkit/network/test_networkreply.py7
-rw-r--r--tests/unit/browser/webkit/test_cache.py7
-rw-r--r--tests/unit/browser/webkit/test_mhtml.py38
-rw-r--r--tests/unit/browser/webkit/test_tabhistory.py3
-rw-r--r--tests/unit/completion/test_completiondelegate.py11
-rw-r--r--tests/unit/completion/test_completionmodel.py4
-rw-r--r--tests/unit/completion/test_completionwidget.py1
-rw-r--r--tests/unit/completion/test_models.py12
-rw-r--r--tests/unit/config/test_config.py7
-rw-r--r--tests/unit/config/test_configcommands.py8
-rw-r--r--tests/unit/config/test_configdata.py2
-rw-r--r--tests/unit/config/test_configinit.py5
-rw-r--r--tests/unit/config/test_configtypes.py41
-rw-r--r--tests/unit/config/test_configutils.py43
-rw-r--r--tests/unit/config/test_qtargs.py80
-rw-r--r--tests/unit/config/test_websettings.py4
-rw-r--r--tests/unit/javascript/test_greasemonkey.py25
-rw-r--r--tests/unit/keyinput/test_basekeyparser.py16
-rw-r--r--tests/unit/keyinput/test_keyutils.py33
-rw-r--r--tests/unit/mainwindow/statusbar/test_url.py6
-rw-r--r--tests/unit/misc/test_earlyinit.py17
-rw-r--r--tests/unit/misc/test_guiprocess.py29
-rw-r--r--tests/unit/misc/test_ipc.py10
-rw-r--r--tests/unit/misc/test_sql.py16
-rw-r--r--tests/unit/utils/test_qtutils.py129
-rw-r--r--tests/unit/utils/test_standarddir.py146
-rw-r--r--tests/unit/utils/test_urlutils.py50
-rw-r--r--tests/unit/utils/test_utils.py120
-rw-r--r--tests/unit/utils/test_version.py41
-rw-r--r--tests/unit/utils/usertypes/test_question.py14
-rw-r--r--tox.ini30
215 files changed, 2567 insertions, 4535 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 182f935be..8e1f1341f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -13,7 +13,7 @@ jobs:
linters:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
timeout-minutes: 10
- runs-on: ubuntu-latest
+ runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
@@ -100,45 +100,34 @@ jobs:
fail-fast: false
matrix:
include:
- ### PyQt 5.9 (Python 3.6)
- - testenv: py36-pyqt59
- os: ubuntu-18.04
- python: 3.6
- ### PyQt 5.10 (Python 3.6)
- - testenv: py36-pyqt510
+ ### PyQt 5.12 (Python 3.6)
+ - testenv: py36-pyqt512
os: ubuntu-20.04
python: 3.6
- ### PyQt 5.11 (Python 3.7)
- - testenv: py37-pyqt511
+ ### PyQt 5.13 (Python 3.7)
+ - testenv: py37-pyqt513
os: ubuntu-20.04
python: 3.7
- ### PyQt 5.12 (Python 3.8)
- - testenv: py38-pyqt512
- os: ubuntu-20.04
- python: 3.8
- ### PyQt 5.13 (Python 3.8)
- - testenv: py38-pyqt513
- os: ubuntu-20.04
- python: 3.8
### PyQt 5.14 (Python 3.8)
- testenv: py38-pyqt514
os: ubuntu-20.04
python: 3.8
- ### PyQt 5.15 (Python 3.9)
- - testenv: py39-pyqt515
+ ### PyQt 5.15 (Python 3.9, with coverage)
+ - testenv: py39-pyqt515-cov
os: ubuntu-20.04
python: 3.9
- ### PyQt 5.15 (Python 3.8, with coverage)
- - testenv: py38-pyqt515-cov
- os: ubuntu-20.04
- python: 3.8
- ### macOS: PyQt 5.14 (Python 3.7)
- - testenv: py37-pyqt514
+ ### macOS: PyQt 5.15 (Python 3.7 to match PyInstaller env)
+ - testenv: py37-pyqt515
os: macos-10.15
python: 3.7
args: "tests/unit" # Only run unit tests on macOS
- ### Windows: PyQt 5.14 (Python 3.7)
- - testenv: py37-pyqt514
+ ### macOS Big Sur
+ - testenv: py37-pyqt515
+ os: macos-11.0
+ python: 3.7
+ args: "tests/unit" # Only run unit tests on macOS
+ ### Windows: PyQt 5.15 (Python 3.7 to match PyInstaller env)
+ - testenv: py37-pyqt515
os: windows-2019
python: 3.7
runs-on: "${{ matrix.os }}"
@@ -180,7 +169,7 @@ jobs:
codeql:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
timeout-minutes: 30
- runs-on: ubuntu-latest
+ runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
@@ -202,7 +191,7 @@ jobs:
irc:
timeout-minutes: 2
continue-on-error: true
- runs-on: ubuntu-latest
+ runs-on: ubuntu-20.04
needs: [linters, tests, tests-docker, codeql]
if: "always() && github.repository_owner == 'qutebrowser'"
steps:
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
new file mode 100644
index 000000000..03510ad6e
--- /dev/null
+++ b/.github/workflows/docker.yml
@@ -0,0 +1,61 @@
+name: Rebuild Docker CI images
+
+on:
+ workflow_dispatch:
+ schedule:
+ - cron: "23 5 * * *" # daily at 5:23
+
+jobs:
+ docker:
+ runs-on: ubuntu-20.04
+ strategy:
+ matrix:
+ image:
+ - archlinux-webkit
+ - archlinux-webengine
+ - archlinux-webengine-unstable
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-python@v2
+ with:
+ python-version: '3.x'
+ - run: pip install jinja2
+ - name: Generate Dockerfile
+ run: python3 generate.py ${{ matrix.image }}
+ working-directory: scripts/dev/ci/docker/
+ - uses: docker/setup-buildx-action@v1
+ - uses: docker/login-action@v1
+ with:
+ username: qutebrowser
+ password: ${{ secrets.DOCKER_TOKEN }}
+ - uses: docker/build-push-action@v2
+ with:
+ file: scripts/dev/ci/docker/Dockerfile
+ context: .
+ tags: "qutebrowser/ci:${{ matrix.image }}"
+ push: ${{ github.ref == 'refs/heads/master' }}
+
+ irc:
+ timeout-minutes: 2
+ continue-on-error: true
+ runs-on: ubuntu-20.04
+ needs: [docker]
+ if: "always() && github.repository == 'qutebrowser/qutebrowser'"
+ steps:
+ - name: Send success IRC notification
+ uses: Gottox/irc-message-action@v1.1
+ if: "needs.docker.result == 'success'"
+ with:
+ server: chat.freenode.net
+ channel: '#qutebrowser-dev'
+ nickname: qutebrowser-bot
+ message: "[${{ github.workflow }}] \u00033Success:\u0003 ${{ github.ref }} https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} (@${{ github.actor }})"
+ - name: Send non-success IRC notification
+ uses: Gottox/irc-message-action@v1.1
+ if: "needs.docker.result != 'success'"
+ with:
+ server: chat.freenode.net
+ channel: '#qutebrowser-dev'
+ nickname: qutebrowser-bot
+ message: "[${{ github.workflow }}] \u00034FAIL:\u0003 ${{ github.ref }} https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} (@${{ github.actor }})\n
+ linters: ${{ needs.linters.result }}, tests: ${{ needs.tests.result }}, tests-docker: ${{ needs.tests-docker.result }}, codeql: ${{ needs.codeql.result }}"
diff --git a/.github/workflows/recompile-requirements.yml b/.github/workflows/recompile-requirements.yml
index c41f67810..c939aa81d 100644
--- a/.github/workflows/recompile-requirements.yml
+++ b/.github/workflows/recompile-requirements.yml
@@ -31,7 +31,7 @@ jobs:
run: "python3 scripts/dev/recompile_requirements.py ${{ github.events.input.environments }}"
id: requirements
- name: Create pull request
- uses: peter-evans/create-pull-request@v2
+ uses: peter-evans/create-pull-request@v3
with:
committer: qutebrowser bot <bot@qutebrowser.org>
author: qutebrowser bot <bot@qutebrowser.org>
diff --git a/.mypy.ini b/.mypy.ini
index dfef7d3e5..d629f012c 100644
--- a/.mypy.ini
+++ b/.mypy.ini
@@ -36,10 +36,6 @@ ignore_missing_imports = True
# https://bitbucket.org/birkenfeld/pygments-main/issues/1485/type-hints
ignore_missing_imports = True
-[mypy-cssutils]
-# Pretty much inactive currently
-ignore_missing_imports = True
-
[mypy-pypeg2]
# Pretty much inactive currently
ignore_missing_imports = True
diff --git a/.pylintrc b/.pylintrc
index bc1d88d90..f4fe8cdbb 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -75,7 +75,7 @@ valid-metaclass-classmethod-first-arg=cls
[TYPECHECK]
ignored-modules=PyQt5,PyQt5.QtWebKit
-ignored-classes=DummyBox
+ignored-classes=DummyBox,__cause__
[IMPORTS]
known-third-party=sip
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index b75081477..000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-dist: xenial
-language: python
-python: 3.6
-os: linux
-env: TESTENV=py36-pyqt57
-
-install:
- - python -m pip install -U pip
- - python -m pip install -U -r misc/requirements/requirements-tox.txt
- - ulimit -c unlimited
-
-script:
- - tox -e "$TESTENV"
-
-after_failure:
- - bash scripts/dev/ci/backtrace.sh
diff --git a/.yamllint b/.yamllint
index 638c16210..8e4d4a388 100644
--- a/.yamllint
+++ b/.yamllint
@@ -9,6 +9,7 @@ ignore: |
rules:
document-start: disable
line-length:
+ max: 88
ignore: |
/.github/*.yml
/.github/workflows/*.yml
diff --git a/README.asciidoc b/README.asciidoc
index 903c1415e..203327127 100644
--- a/README.asciidoc
+++ b/README.asciidoc
@@ -110,8 +110,8 @@ Requirements
The following software and libraries are required to run qutebrowser:
* https://www.python.org/[Python] 3.6 or newer
-* https://www.qt.io/[Qt] 5.7.1 or newer (5.14 recommended; support for < 5.11
- will be dropped with qutebrowser v2.0.0) with the following modules:
+* https://www.qt.io/[Qt] 5.12.0 or newer (5.12 LTS or 5.15 recommended)
+ with the following modules:
- QtCore / qtbase
- QtQuick (part of qtbase in some distributions)
- QtSQL (part of qtbase in some distributions)
@@ -123,8 +123,8 @@ The following software and libraries are required to run qutebrowser:
revision with known unpatched vulnerabilities. Please use it carefully and
avoid visiting untrusted websites and using it for transmission of
sensitive data.**
-* https://www.riverbankcomputing.com/software/pyqt/intro[PyQt] 5.7.0 or newer
- (5.14 recommended, support for < 5.11 will be dropped soon) for Python 3
+* https://www.riverbankcomputing.com/software/pyqt/intro[PyQt] 5.12.0 or newer
+ for Python 3
* https://pypi.python.org/pypi/setuptools/[pkg_resources/setuptools]
* https://fdik.org/pyPEG/[pyPEG2]
* http://jinja.pocoo.org/[jinja2]
@@ -135,8 +135,6 @@ The following software and libraries are required to run qutebrowser:
The following libraries are optional:
* https://pypi.org/project/adblock/[adblock] (for improved adblocking using ABP syntax)
-* http://cthedot.de/cssutils/[cssutils] (for an improved `:download --mhtml`
- with QtWebKit).
* On Windows, https://pypi.python.org/pypi/colorama/[colorama] for colored log
output.
* http://asciidoc.org/[asciidoc] to generate the documentation for the `:help`
diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc
index 129378b07..9cfa73806 100644
--- a/doc/changelog.asciidoc
+++ b/doc/changelog.asciidoc
@@ -25,6 +25,45 @@ Major changes
3.5 is dropped. Note that Python 3.5 is
https://www.python.org/downloads/release/python-3510/[no longer supported
upstream] since September 2020.
+- At least Qt/PyQt 5.12 is now required to run qutebrowser, support for 5.7 to
+ 5.11 (inclusive) is dropped. While Debian Buster ships Qt 5.11, it's based on a
+ Chromium version from 2018 with
+ https://www.debian.org/releases/buster/amd64/release-notes/ch-information.en.html#browser-security[no Debian security support]
+ and unsupported upstream since May 2019.
+ It also has compatibility issues with various websites (GitHub, Twitch, Android
+ Developer documentation, YouTube, ...). Since no newer Debian Stable is released
+ at the time of writing, it's recommended to
+ https://github.com/qutebrowser/qutebrowser/blob/master/doc/install.asciidoc#installing-qutebrowser-with-virtualenv[install qutebrowser in a virtualenv]
+ with a newer version of Qt/PyQt.
+- Windows 7 is not supported anymore by the Windows binaries.
+- The (formerly optional) `cssutils` dependency is now removed. It was only
+ needed for improved behavior in corner cases when using `:download --mhtml`
+ with the (non-default) QtWebKit backend, and as such it's unlikely anyone is
+ still relying on it. The `cssutils` project is also dead upstream, with its
+ repository being gone after Bitbucket
+ https://bitbucket.org/blog/sunsetting-mercurial-support-in-bitbucket[removed Mercurial support].
+
+Removed
+~~~~~~~
+
+- The `--enable-webengine-inspector` flag (which was only needed for Qt 5.10 and
+ below) is now dropped. With Qt 5.11 and newer, the inspector/devtools are
+ enabled unconditionally.
+- Support for moving qutebrowser data from versions before v1.0.0 has been
+ removed.
+- The `--old` flag for `:config-diff` has been removed. It used to show
+ customized options for the old pre-v1.0 config files (in order to aid
+ migration to v1.0).
+- The `:inspector` command which was deprecated in v1.13.0 (in favor of
+ `:devtools`) is now removed.
+
+Added
+~~~~~
+
+- When QtWebEngine has been updated but PyQtWebEngine hasn't yet, the dark mode
+ settings might stop working. As a (currently undocumented) escape hatch, this
+ version adds a `QUTE_DARKMODE_VARIANT=qt_515_2` environment variable which can
+ be set to get the correct behavior in (transitive) situations like this.
Changed
~~~~~~~
@@ -32,13 +71,120 @@ Changed
- `config.py` files now are required to have either
`config.load_autoconfig(False)` (don't load `autoconfig.yml`) or
`config.load_autoconfig()` (do load `autoconfig.yml`) in them.
+- (TODO) Windows and macOS releases now ship Python 3.9 rather than 3.7.
- The `colors.webpage.darkmode.*` settings are now also supported with older Qt
- versions (Qt 5.10 to 5.13) rather than just with Qt 5.14 and above.
+ versions (Qt 5.12 and 5.13) rather than just with Qt 5.14 and above.
- For regexes in the config (`hints.{prev,next}_regexes`), certain patterns
which will change meanings in future Python versions are now disallowed. This is
the case for character sets starting with a literal `[` or containing literal
character sequences `--`, `&&`, `~~`, or `||`. To avoid a warning, remove the
duplicate characters or escape them with a backslash.
+- If `prompt(..., "default")` is used via JS, the default text is now
+ pre-selected in the prompt shown by qutebrowser.
+- URLs such as `::1/foo` are now handled as a search term or local file rather
+ than IPv6. Use `[::1]/foo` to force parsing as IPv6 instead.
+
+Fixed
+~~~~~
+
+- With interpolated color settings (`colors.tabs.indicator.*` and
+ `colors.downloads.*`), the alpha channel is now handled correctly.
+
+v1.14.1 (unreleased)
+--------------------
+
+Added
+~~~~~
+
+- With v1.14.0, qutebrowser configures the main window to be transparent, so
+ that it's possible to configure a translucent tab- or statusbar. However, that
+ change introduced various issues, such as performance degradation on some
+ systems or breaking dmenu window embedding with its `-w` option. To avoid those
+ issues for people who are not using transparency, the default behavior is
+ reverted to versions before v1.14.0 in this release. A new `window.transparent`
+ setting can be set to `true` to restore the behavior of v1.14.0.
+
+Changed
+~~~~~~~
+
+- Windows and macOS releases now ship Qt 5.15.2, which is based on
+ Chromium 83.0.4103.122 with security fixes up to 86.0.4240.183. This includes
+ CVE-2020-15999 in the bundled freetype library, which is known to be exploited
+ in the wild. It also includes various other bugfixes/features compared to
+ Qt 5.15.0 included in qutebrowser v1.14.0, such as:
+ * Correct handling of AltGr on Windows
+ * Fix for `content.cookies.accept` not working properly
+ * Fixes for screen sharing (some websites are still broken until an upcoming Qt
+ 5.15.3)
+ * Support for FIDO U2F / WebAuth
+ * Fix for the unwanted creation of directories such as `databases-incognito` in
+ the home directory
+ * Proper autocompletion in the devtools console
+ * Proper signalisation of a tab's audible status (`[A]`)
+ * Fix for a hang when opening the context menu on macOS Big Sur (11.0)
+ * Hardware accelerated graphics on macOS
+
+Fixed
+~~~~~
+
+- Setting the `content.headers.referer` setting to `same-domain` (the default)
+ was supposed to truncate referers to only the host with QtWebEngine.
+ Unfortunately, this functionality broke in Qt 5.14. It works properly again
+ with this release, including a test so this won't happen again.
+- With QtWebEngine 5.15, setting the `content.headers.referer` setting to
+ `never` did still send referers. This is now fixed as well.
+- In v1.14.0, a regression was introduced, causing a crash when qutebrowser was
+ closed after opening a download with PDF.js. This is now fixed.
+- With Qt 5.12, the `Object.fromEntries` JavaScript API is unavailable (it was
+ introduced in Chromium 73, while Qt 5.12 is based on 69). This caused
+ https://www.vr.fi/en and possibly other websites to break when accessed with Qt
+ 5.12. A suitable polyfill is now included with qutebrowser if
+ `content.site_specific_quirks` is enabled (which is the default).
+- While XDG startup notifications (e.g. launch feedback via the bouncy cursor
+ in KDE Plasma) were supported ever since Qt 5.1, qutebrowser's desktop file
+ accidentally declared that it wasn't supported. This is now fixed.
+- The `dmenu_qutebrowser` and `qutedmenu` userscripts now correctly read the
+ qutebrowser sqlite history which has been in use since v1.0.0.
+- With Python 3.8+ and vertical tabs, a deprecation warning for an implicit int
+ conversion was shown. This is now fixed.
+- Ever since Qt 5.11, fetching more completion data when that data is loaded
+ lazily (such as with history) and the last visible item is selected was broken.
+ The exact reason is currently unknown, but this release adds a tenative fix.
+- When PgUp/PgDown were used to go beyond the last visible item, the above issue
+ caused a crash, which is now also fixed.
+- As a workaround for an overzealous Microsoft Defender false-positive detecting
+ a "trojan" in the (unprocessed) adblock list, `:adblock-update` now doesn't
+ cache the HTTP response anymore.
+- With the QtWebKit backend and `content.headers` set to `same-domain` (the
+ default), origins with the same domain but different schemes or ports were
+ treated as the same domain. They now are correctly treated as different domains.
+- When a URL path uses percent escapes (such as
+ `https://example.com/embedded%2Fpath`), using `:navigate up` would treat the
+ `%2F` as a path separator and replace any remaining percent escapes by their
+ unescaped equivalents. Those are now handled correctly.
+- On macOS 11.0 (Big Sur), the default monospace font name caused a parsing error, thus
+ resulting in broken styling for the completion, hints, and other UI components.
+ They now look properly again.
+- Due to a Qt bug, installing Qt/PyQt from prebuilt binaries on systems with a
+ very old `libxcb-utils` version (notably, Debian Stable, but not Ubuntu since
+ 16.04 LTS) results in a setup which fails to start. This also affects the
+ `mkvenv.py` script, which now includes a workaround for this case.
+- The `open_url_instance.sh` userscript now complains when `socat` is not
+ installed, rather than silencing the error.
+- The example AppArmor profile in `misc/` was outdated and written for the
+ older QtWebKit backend. It is now updated to serve as an useful starting
+ point with QtWebEngine.
+- When running `:devtools` on Fedora without the needed (optional) dependency
+ installed, it was suggested to install `qt5-webengine-devtools`, which does
+ not, in fact, exist. It's now correctly suggested to install
+ `qt5-qtwebengine-devtools` instead.
+- Minor performance improvements.
+- (TODO) Fix for various functionality breaking in private windows with v1.14.0,
+ after the last private window is closed. This includes:
+ * Ad blocking
+ * Downloads
+ * Site-specific quirks (e.g. for Google login)
+ * Certain settings such as `content.javascript.enabled`
v1.14.0 (2020-10-15)
--------------------
diff --git a/doc/contributing.asciidoc b/doc/contributing.asciidoc
index b8c9b9010..3960dec27 100644
--- a/doc/contributing.asciidoc
+++ b/doc/contributing.asciidoc
@@ -112,8 +112,8 @@ Currently, the following tox environments are available:
* Tests using https://www.pytest.org[pytest]:
- `py36`, `py37`, ...: Run pytest for python 3.6/3.7/... with the system-wide PyQt.
- - `py36-pyqt57`, ..., `py36-pyqt59`: Run pytest with the given PyQt version (`py35-*` also works).
- - `py36-pyqt59-cov`: Run with coverage support (other Python/PyQt versions work too).
+ - `py36-pyqt512`, ..., `py36-pyqt515`: Run pytest with the given PyQt version (`py35-*` also works).
+ - `py36-pyqt515-cov`: Run with coverage support (other Python/PyQt versions work too).
* `flake8`: Run various linting checks via https://pypi.python.org/pypi/flake8[flake8].
* `vulture`: Run https://pypi.python.org/pypi/vulture[vulture] to find
unused code portions.
@@ -586,9 +586,9 @@ can be useful for debugging:
- chrome://gpuclean/ (crashes the current renderer process!)
- chrome://ppapiflashcrash/
- chrome://ppapiflashhang/
-- chrome://quota-internals/ (Qt 5.11)
-- chrome://taskscheduler-internals/ (Qt 5.11)
-- chrome://sandbox/ (Qt 5.11, Linux only)
+- chrome://quota-internals/
+- chrome://taskscheduler-internals/
+- chrome://sandbox/ (Linux only)
QtWebEngine internals
~~~~~~~~~~~~~~~~~~~~~
diff --git a/doc/faq.asciidoc b/doc/faq.asciidoc
index 275f82df2..39df56faa 100644
--- a/doc/faq.asciidoc
+++ b/doc/faq.asciidoc
@@ -190,7 +190,6 @@ For QtWebKit:
+
For QtWebEngine:
-. Make sure your versions of PyQt and Qt are 5.8 or higher.
. Use `dictcli.py` script to install dictionaries.
Run the script with `-h` for the parameter description.
. Set `spellcheck.languages` to the desired list of languages, e.g.:
@@ -253,11 +252,6 @@ Note that there are some missing features which you may run into:
. Some scripts expect `GM_xmlhttpRequest` to ignore Cross Origin Resource
Sharing restrictions, this is currently not supported, so scripts making
requests to third party sites will often fail to function correctly.
-. If your backend is a QtWebEngine version 5.8, 5.9 or 5.10 then regular
- expressions are not supported in `@include` or `@exclude` rules. If your
- script uses them you can re-write them to use glob expressions or convert
- them to `@match` rules.
- See https://wiki.greasespot.net/Metadata_Block[the wiki] for more info.
. Any greasemonkey API function to do with adding UI elements is not currently
supported. That means context menu extentensions and background pages.
@@ -330,8 +324,14 @@ There is a total of four possible approaches to get dark websites:
The setting requires a restart and QtWebEngine with at least Qt 5.14.
- The `colors.webpage.darkmode.*` settings enable the dark mode of the underlying
Chromium. Those setting require a restart and QtWebEngine with at least Qt 5.14. It's
- unfortunately not possible (due to limitations in Chromium and/or QtWebEngine) to
+ unfortunately not possible (due to limitations
+ https://bugs.chromium.org/p/chromium/issues/detail?id=952419[in Chromium] and/or
+ https://bugreports.qt.io/browse/QTBUG-84484[QtWebEngine]) to
change them dynamically or to specify a list of excluded websites.
+ There is some remaining hope to
+ https://github.com/qutebrowser/qutebrowser/issues/5542[allow for this]
+ using HTML/CSS features, but so far nobody has been able to get things to
+ work (even with Chromium) - help welcome!
- The `content.user_stylesheets` setting allows specifying a custom CSS such as
https://github.com/alphapapa/solarized-everything-css/[Solarized Everything]. Despite
the name, the repository also offers themes other than just Solarized. This approach
diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc
index 5dd6c7718..3103bfa15 100644
--- a/doc/help/commands.asciidoc
+++ b/doc/help/commands.asciidoc
@@ -332,14 +332,8 @@ Remove a key from a dict.
[[config-diff]]
=== config-diff
-Syntax: +:config-diff [*--old*]+
-
Show all customized options.
-==== optional arguments
-* +*-o*+, +*--old*+: Show difference for the pre-v1.0 files (qutebrowser.conf/keys.conf).
-
-
[[config-edit]]
=== config-edit
Syntax: +:config-edit [*--no-source*]+
diff --git a/doc/help/configuring.asciidoc b/doc/help/configuring.asciidoc
index aa1dfc12e..89866ccce 100644
--- a/doc/help/configuring.asciidoc
+++ b/doc/help/configuring.asciidoc
@@ -9,9 +9,7 @@ qutebrowser's config files
--------------------------
qutebrowser releases before v1.0.0 had a `qutebrowser.conf` and `keys.conf`
-file. Those are not used anymore since that release - see
-<<migrating,"Migrating older configurations">> for information on how to
-migrate to the new config.
+file. Those are not used anymore since v1.0.0.
When using `:set` and `:bind`, changes are saved to an `autoconfig.yml` file
automatically. If you don't want to have a config file which is curated by
@@ -422,8 +420,8 @@ stable across qutebrowser versions):
# pylint: disable=C0111
from qutebrowser.config.configfiles import ConfigAPI # noqa: F401
from qutebrowser.config.config import ConfigContainer # noqa: F401
-config = config # type: ConfigAPI # noqa: F821 pylint: disable=E0602,C0103
-c = c # type: ConfigContainer # noqa: F821 pylint: disable=E0602,C0103
+config: ConfigAPI = config # noqa: F821 pylint: disable=E0602,C0103
+c: ConfigContainer = c # noqa: F821 pylint: disable=E0602,C0103
----
emacs-like config
@@ -439,38 +437,3 @@ Various emacs/conkeror-like keybinding configs exist:
It's also mostly possible to get rid of modal keybindings by setting
`input.insert_mode.auto_enter` to `false`, and `input.forward_unbound_keys` to
`all`.
-
-[[migrating]]
-Migrating older configurations
-------------------------------
-
-qutebrowser does no automatic migration for the new configuration. However,
-there's a special link:qute://configdiff/old[configdiff] page
-(`qute://configdiff/old`) in qutebrowser, which will show you the changes you
-did in your old configuration, compared to the old defaults.
-
-Other changes in default settings:
-
-- In v1.1.x and newer, `<Up>` and `<Down>` navigate through command history
- if no text was entered yet.
- With v1.0.x, they always navigate through command history instead of selecting
- completion items. Use `<Tab>`/`<Shift-Tab>` to cycle through the completion
- instead.
- You can get back the old behavior by doing:
-+
-----
-:bind -m command <Up> completion-item-focus prev
-:bind -m command <Down> completion-item-focus next
-----
-+
-or always navigate through command history with
-+
-----
-:bind -m command <Up> command-history-prev
-:bind -m command <Down> command-history-next
-----
-
-- The default for `completion.web_history.max_items` is now set to `-1`, showing
- an unlimited number of items in the completion for `:open` as the new
- sqlite-based completion is much faster. If the `:open` completion is too slow
- on your machine, set an appropriate limit again.
diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc
index 94a884db9..1bca04f8c 100644
--- a/doc/help/settings.asciidoc
+++ b/doc/help/settings.asciidoc
@@ -329,6 +329,7 @@
|<<url.yank_ignored_parameters,url.yank_ignored_parameters>>|URL parameters to strip with `:yank url`.
|<<window.hide_decoration,window.hide_decoration>>|Hide the window decoration.
|<<window.title_format,window.title_format>>|Format to use for the window title. The same placeholders like for
+|<<window.transparent,window.transparent>>|Set the main window background to transparent.
|<<zoom.default,zoom.default>>|Default zoom level.
|<<zoom.levels,zoom.levels>>|Available zoom levels.
|<<zoom.mouse_divider,zoom.mouse_divider>>|Number of zoom increments to divide the mouse wheel movements to.
@@ -1586,9 +1587,7 @@ Valid values:
Default: +pass:[lightness-cielab]+
-On QtWebEngine, this setting requires Qt 5.10 or newer.
-
-On QtWebKit, this setting is unavailable.
+This setting is only available with the QtWebEngine backend.
[[colors.webpage.darkmode.contrast]]
=== colors.webpage.darkmode.contrast
@@ -1601,9 +1600,7 @@ Type: <<types,Float>>
Default: +pass:[0.0]+
-On QtWebEngine, this setting requires Qt 5.10 or newer.
-
-On QtWebKit, this setting is unavailable.
+This setting is only available with the QtWebEngine backend.
[[colors.webpage.darkmode.enabled]]
=== colors.webpage.darkmode.enabled
@@ -1629,9 +1626,7 @@ Type: <<types,Bool>>
Default: +pass:[false]+
-On QtWebEngine, this setting requires Qt 5.10 or newer.
-
-On QtWebKit, this setting is unavailable.
+This setting is only available with the QtWebEngine backend.
[[colors.webpage.darkmode.grayscale.all]]
=== colors.webpage.darkmode.grayscale.all
@@ -1644,9 +1639,7 @@ Type: <<types,Bool>>
Default: +pass:[false]+
-On QtWebEngine, this setting requires Qt 5.10 or newer.
-
-On QtWebKit, this setting is unavailable.
+This setting is only available with the QtWebEngine backend.
[[colors.webpage.darkmode.grayscale.images]]
=== colors.webpage.darkmode.grayscale.images
@@ -1666,7 +1659,7 @@ On QtWebKit, this setting is unavailable.
[[colors.webpage.darkmode.policy.images]]
=== colors.webpage.darkmode.policy.images
Which images to apply dark mode to.
-With QtWebEngine 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]. With QtWebEngine 5.10, this is not available at all. In those cases, the 'smart' setting is ignored and treated like 'never'.
+With QtWebEngine 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.
@@ -1676,13 +1669,11 @@ 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. Not available with Qt 5.10 / 5.15.0.
+ * +smart+: Apply dark mode based on image content. Not available with Qt 5.15.0.
Default: +pass:[smart]+
-On QtWebEngine, this setting requires Qt 5.10 or newer.
-
-On QtWebKit, this setting is unavailable.
+This setting is only available with the QtWebEngine backend.
[[colors.webpage.darkmode.policy.page]]
=== colors.webpage.darkmode.policy.page
@@ -1905,7 +1896,6 @@ Default:
[[content.autoplay]]
=== content.autoplay
Automatically start playing `<video>` elements.
-Note: On Qt < 5.11, this option needs a restart and does not support URL patterns.
This setting supports URL patterns.
@@ -1913,9 +1903,7 @@ Type: <<types,Bool>>
Default: +pass:[true]+
-On QtWebEngine, this setting requires Qt 5.10 or newer.
-
-On QtWebKit, this setting is unavailable.
+This setting is only available with the QtWebEngine backend.
[[content.blocking.adblock.lists]]
=== content.blocking.adblock.lists
@@ -2058,12 +2046,9 @@ Valid values:
Default: +pass:[all]+
-On QtWebEngine, this setting requires Qt 5.11 or newer.
-
[[content.cookies.store]]
=== content.cookies.store
Store cookies.
-Note this option needs a restart with QtWebEngine on Qt < 5.9.
Type: <<types,Bool>>
@@ -2081,7 +2066,6 @@ Default: +pass:[iso-8859-1]+
[[content.desktop_capture]]
=== content.desktop_capture
Allow websites to share screen content.
-On Qt < 5.10, a dialog box is always displayed, even if this is set to "true".
This setting supports URL patterns.
@@ -2105,7 +2089,7 @@ Type: <<types,Bool>>
Default: +pass:[true]+
-On QtWebEngine, this setting requires Qt 5.12 or newer.
+This setting is only available with the QtWebEngine backend.
[[content.frame_flattening]]
=== content.frame_flattening
@@ -2436,9 +2420,7 @@ Valid values:
Default: +pass:[ask]+
-On QtWebEngine, this setting requires Qt 5.8 or newer.
-
-On QtWebKit, this setting is unavailable.
+This setting is only available with the QtWebEngine backend.
[[content.mute]]
=== content.mute
@@ -2505,9 +2487,7 @@ Valid values:
Default: +pass:[ask]+
-On QtWebEngine, this setting requires Qt 5.11 or newer.
-
-On QtWebKit, this setting is unavailable.
+This setting is only available with the QtWebEngine backend.
[[content.plugins]]
=== content.plugins
@@ -2529,7 +2509,7 @@ Type: <<types,Bool>>
Default: +pass:[true]+
-On QtWebEngine, this setting requires Qt 5.8 or newer.
+This setting is only available with the QtWebEngine backend.
[[content.private_browsing]]
=== content.private_browsing
@@ -2580,9 +2560,7 @@ Valid values:
Default: +pass:[ask]+
-On QtWebEngine, this setting requires Qt 5.11 or newer.
-
-On QtWebKit, this setting is unavailable.
+This setting is only available with the QtWebEngine backend.
[[content.site_specific_quirks]]
=== content.site_specific_quirks
@@ -2626,9 +2604,7 @@ Valid values:
Default: +pass:[allow-from-user-interaction]+
-On QtWebEngine, this setting requires Qt 5.11 or newer.
-
-On QtWebKit, this setting is unavailable.
+This setting is only available with the QtWebEngine backend.
[[content.user_stylesheets]]
=== content.user_stylesheets
@@ -2651,7 +2627,6 @@ Default: +pass:[true]+
[[content.webrtc_ip_handling_policy]]
=== content.webrtc_ip_handling_policy
Which interfaces to expose via WebRTC.
-On Qt 5.10, this option doesn't work because of a Qt bug.
This setting requires a restart.
@@ -2666,9 +2641,7 @@ Valid values:
Default: +pass:[all-interfaces]+
-On QtWebEngine, this setting requires Qt 5.9.2 or newer.
-
-On QtWebKit, this setting is unavailable.
+This setting is only available with the QtWebEngine backend.
[[content.xss_auditing]]
=== content.xss_auditing
@@ -3594,7 +3567,7 @@ Valid values:
* +always+: Always show the scrollbar.
* +never+: Never show the scrollbar.
* +when-searching+: Show the scrollbar when searching for text in the webpage. With the QtWebKit backend, this is equal to `never`.
- * +overlay+: Show an overlay scrollbar. With Qt < 5.11 or on macOS, this is unavailable and equal to `when-searching`; with the QtWebKit backend, this is equal to `never`. Enabling/disabling overlay scrollbars requires a restart.
+ * +overlay+: Show an overlay scrollbar. On macOS, this is unavailable and equal to `when-searching`; with the QtWebKit backend, this is equal to `never`. Enabling/disabling overlay scrollbars requires a restart.
Default: +pass:[overlay]+
@@ -3713,9 +3686,7 @@ Valid values:
Default: empty
-On QtWebEngine, this setting requires Qt 5.8 or newer.
-
-On QtWebKit, this setting is unavailable.
+This setting is only available with the QtWebEngine backend.
[[statusbar.padding]]
=== statusbar.padding
@@ -4211,6 +4182,7 @@ characters in the search terms are replaced by safe characters (called
expands to `slash%2Fand%26amp`).
* `{unquoted}` quotes nothing (for `slash/and&amp` this placeholder
expands to `slash/and&amp`).
+* `{0}` means the same as `{}`, but can be used multiple times.
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
@@ -4268,6 +4240,22 @@ Type: <<types,FormatString>>
Default: +pass:[{perc}{current_title}{title_sep}qutebrowser]+
+[[window.transparent]]
+=== window.transparent
+Set the main window background to transparent.
+
+This allows having a transparent tab- or statusbar (might require a compositor such
+as picom). However, it breaks some functionality such as dmenu embedding via its
+`-w` option. On some systems, it was additionally reported that main window
+transparency negatively affects performance.
+
+Note this setting only affects windows opened after setting it.
+
+
+Type: <<types,Bool>>
+
+Default: +pass:[false]+
+
[[zoom.default]]
=== zoom.default
Default zoom level.
diff --git a/doc/install.asciidoc b/doc/install.asciidoc
index 9c71bf2b5..f7a3d8a60 100644
--- a/doc/install.asciidoc
+++ b/doc/install.asciidoc
@@ -28,12 +28,15 @@ How to install qutebrowser depends a lot on the version of Debian/Ubuntu you're
running.
[[ubuntu1604]]
-Ubuntu 16.04 LTS / Linux Mint 18
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Debian Stretch / Ubuntu 16.04 LTS / Linux Mint 18
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Debian Stretch does have QtWebEngine packaged, but only in a very old and insecure
+version (Qt 5.7, based on a Chromium from March 2016). Furthermore, it packages Python
+3.5 which is not supported anymore since qutebrowser v2.0.0.
Ubuntu 16.04 doesn't come with an up-to-date engine (a new enough QtWebKit, or
-QtWebEngine). It also comes with Python 3.5 which is not supported anymore since
-qutebrowser v2.0.0.
+QtWebEngine) and also comes with Python 3.5.
You should be able to install a newer Python (3.6+) using the
https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa[deadsnakes PPA] or
@@ -51,51 +54,23 @@ Note you'll need some basic libraries to use the virtualenv-installed PyQt:
// FIXME not needed anymore?
// libxi6 libxrender1 libegl1-mesa
-Debian Stretch
-~~~~~~~~~~~~~~
-
-WARNING: Debian Stretch packages Qt 5.7 which is very old (based on a Chromium
-from March 2016 with security fixes from November 2016) and insecure. It is also
-https://www.debian.org/releases/stretch/amd64/release-notes/ch-information.en.html#browser-security[not covered]
-by Debian's security patches. Support for it will be dropped in qutebrowser
-v2.0.0, preliminarily planned for December 2020. It is recommended to
-<<tox,install qutebrowser in a virtualenv>> with a newer PyQt/Qt binary
-instead.
-
-Debian Stretch comes with QtWebEngine in the repositories. This makes it possible
-to install qutebrowser via the Debian package.
-
-You'll need to download three packages:
-
-- https://packages.debian.org/sid/all/python3-pypeg2/download[PyPEG2] (a library
- used by qutebrowser which is not in the earlier repositories)
-- https://packages.debian.org/sid/all/qutebrowser/download[qutebrowser] itself
-- Either https://packages.debian.org/sid/all/qutebrowser-qtwebengine/download[qutebrowser-qtwebengine]
- or https://packages.debian.org/sid/all/qutebrowser-qtwebkit/download[qutebrowser-qtwebkit]
- (or both) depending on the backend you want to use. QtWebEngine is the
- default/recommended choice.
-
-After downloading, install the packages (make sure to install all the
-downloaded qutebrowser deb files in one apt command):
+Debian Buster / Ubuntu 18.04 LTS / Linux Mint 19
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----
-# apt install ./python3-pypeg2_*_all.deb
-# apt install ./qutebrowser*.deb
-----
-
-For an update after the initial install, you only need to download/install the
-qutebrowser package.
+Debian Buster packages qutebrowser, but ships a very old version (v1.6.1 from March
+2019). The QtWebEngine library used for rendering web contents is also very old (Qt
+5.11, based on a Chromium from March 2018) and insecure. It is
+https://www.debian.org/releases/buster/amd64/release-notes/ch-information.en.html#browser-security[not covered]
+by Debian's security patches. It's recommended to <<tox,install qutebrowser in a
+virtualenv>> with a newer PyQt/Qt binary instead.
-Debian Buster / Ubuntu 18.04 LTS / Linux Mint 19 (or newer)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+With Ubuntu 18.04, the situation looks similar (but worse): There, qutebrowser v1.1.1
+from January 2018 is packaged, with QtWebEngine 5.9 based on a Chromium from January
+2017. It's recommended to either upgrade to Ubuntu 20.04 LTS or <<tox,install
+qutebrowser in a virtualenv>> with a newer PyQt/Qt binary instead.
-WARNING: Debian Buster packages Qt 5.11 which is very old (based on a Chromium
-from March 2018 with security fixes from November 2018) and insecure. It is also
-https://www.debian.org/releases/buster/amd64/release-notes/ch-information.en.html#browser-security[not covered]
-by Debian's security patches. Support for it will be dropped in qutebrowser
-v2.0.0, preliminarily planned for December 2020. It is recommended to
-<<tox,install qutebrowser in a virtualenv>> with a newer PyQt/Qt binary
-instead.
+Ubuntu 20.04 LTS / Linux Mint 20 (or newer)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
With those distributions, qutebrowser is in the official repositories, and you
can install it with apt:
@@ -108,7 +83,8 @@ Additional hints
~~~~~~~~~~~~~~~~
- If running from git, run the following to generate the documentation for the
- `:help` command:
+ `:help` command (the `mkvenv.py` script used with a virtualenv install already does
+ this for you):
+
----
# apt install --no-install-recommends asciidoc
@@ -116,14 +92,16 @@ $ python3 scripts/asciidoc2html.py
----
- If you prefer using QtWebKit, there's QtWebKit 5.212 available in
- https://packages.debian.org/buster/libqt5webkit5[Debian Testing]. Note
- however that it is based on an upstream WebKit from September 2016 with known
- security issues and no sandboxing or process isolation.
+ Ubuntu 18.04 / Debian Buster or newer. Note however that it is based on an upstream
+ WebKit from September 2016 with known security issues and no sandboxing or process
+ isolation.
- If video or sound don't work with QtWebKit, try installing the gstreamer plugins:
+
----
# apt install gstreamer1.0-plugins-{bad,base,good,ugly}
----
++
+Note those are only needed with QtWebKit, not with the (default) QtWebEngine backend.
On Fedora
---------
diff --git a/doc/qutebrowser.1.asciidoc b/doc/qutebrowser.1.asciidoc
index 1fcac0609..777eddc65 100644
--- a/doc/qutebrowser.1.asciidoc
+++ b/doc/qutebrowser.1.asciidoc
@@ -62,9 +62,6 @@ show it.
*--backend* '{webkit,webengine}'::
Which backend to use.
-*--enable-webengine-inspector*::
- Enable the web inspector / devtools for QtWebEngine. Note that this is a SECURITY RISK and you should not visit untrusted websites with the inspector turned on. See https://bugreports.qt.io/browse/QTBUG-50725 for more details. This is not needed anymore since Qt 5.11 where the inspector is always enabled and secure.
-
=== debug arguments
*-l* '{critical,error,warning,info,debug,vdebug}', *--loglevel* '{critical,error,warning,info,debug,vdebug}'::
Override the configured console loglevel
diff --git a/misc/org.qutebrowser.qutebrowser.desktop b/misc/org.qutebrowser.qutebrowser.desktop
index a1deb319f..cf3ee0422 100644
--- a/misc/org.qutebrowser.qutebrowser.desktop
+++ b/misc/org.qutebrowser.qutebrowser.desktop
@@ -46,7 +46,7 @@ Type=Application
Categories=Network;WebBrowser;
Exec=qutebrowser %u
Terminal=false
-StartupNotify=false
+StartupNotify=true
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/qute;
Keywords=Browser
Actions=new-window;preferences;
diff --git a/misc/requirements/requirements-check-manifest.txt b/misc/requirements/requirements-check-manifest.txt
index 9993cf4dd..8b8f6ba1a 100644
--- a/misc/requirements/requirements-check-manifest.txt
+++ b/misc/requirements/requirements-check-manifest.txt
@@ -1,5 +1,9 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
-check-manifest==0.44
+build==0.1.0
+check-manifest==0.45
+packaging==20.4
pep517==0.9.1
-toml==0.10.1
+pyparsing==2.4.7
+six==1.15.0
+toml==0.10.2
diff --git a/misc/requirements/requirements-dev.txt b/misc/requirements/requirements-dev.txt
index e885b3335..6bc4325cf 100644
--- a/misc/requirements/requirements-dev.txt
+++ b/misc/requirements/requirements-dev.txt
@@ -1,12 +1,11 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
bump2version==1.0.1
-certifi==2020.6.20
-cffi==1.14.3
+certifi==2020.11.8
+cffi==1.14.4
chardet==3.0.4
colorama==0.4.4
-cryptography==3.2
-cssutils==1.0.2
+cryptography==3.2.1
github3.py==1.3.0
hunter==3.3.1
idna==2.10
@@ -16,11 +15,11 @@ packaging==20.4
pycparser==2.20
Pympler==0.9
pyparsing==2.4.7
-PyQt-builder==1.5.0
+PyQt-builder==1.6.0
python-dateutil==2.8.1
-requests==2.24.0
-sip==5.4.0
+requests==2.25.0
+sip==5.5.0
six==1.15.0
-toml==0.10.1
+toml==0.10.2
uritemplate==3.0.1
-# urllib3==1.25.11
+# urllib3==1.26.2
diff --git a/misc/requirements/requirements-dev.txt-raw b/misc/requirements/requirements-dev.txt-raw
index e7758f167..fd840bab1 100644
--- a/misc/requirements/requirements-dev.txt-raw
+++ b/misc/requirements/requirements-dev.txt-raw
@@ -1,5 +1,4 @@
hunter
-cssutils
pympler
github3.py
bump2version
diff --git a/misc/requirements/requirements-flake8.txt b/misc/requirements/requirements-flake8.txt
index d020c02a2..d77bdbbf5 100644
--- a/misc/requirements/requirements-flake8.txt
+++ b/misc/requirements/requirements-flake8.txt
@@ -1,8 +1,8 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
-attrs==20.2.0
+attrs==20.3.0
flake8==3.8.4
-flake8-bugbear==20.1.4
+flake8-bugbear==20.11.1
flake8-builtins==1.5.3
flake8-comprehensions==3.3.0
flake8-copyright==0.2.2
diff --git a/misc/requirements/requirements-mypy.txt b/misc/requirements/requirements-mypy.txt
index ff3d430e8..b564cfa18 100644
--- a/misc/requirements/requirements-mypy.txt
+++ b/misc/requirements/requirements-mypy.txt
@@ -1,7 +1,7 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
diff-cover==4.0.1
-inflect==4.1.0
+inflect==5.0.2
Jinja2==2.11.2
jinja2-pluralize==0.3.0
lxml==4.6.1
@@ -10,6 +10,6 @@ mypy==0.790
mypy-extensions==0.4.3
pluggy==0.13.1
Pygments==2.7.2
--e git+https://github.com/stlehmann/PyQt5-stubs.git@811462b34ee151b898289ae8f1de8af30c690c55#egg=PyQt5_stubs
+-e git+https://github.com/stlehmann/PyQt5-stubs.git@704207e90bee7b36ec9861dfa6b39f06a27c6718#egg=PyQt5_stubs
typed-ast==1.4.1
typing-extensions==3.7.4.3
diff --git a/misc/requirements/requirements-pyinstaller.txt b/misc/requirements/requirements-pyinstaller.txt
index 7941d2772..b1a3e98ee 100644
--- a/misc/requirements/requirements-pyinstaller.txt
+++ b/misc/requirements/requirements-pyinstaller.txt
@@ -1,5 +1,5 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
altgraph==0.17
-pyinstaller==4.0
-pyinstaller-hooks-contrib==2020.9
+pyinstaller==4.1
+pyinstaller-hooks-contrib==2020.10
diff --git a/misc/requirements/requirements-pylint.txt b/misc/requirements/requirements-pylint.txt
index 75a0e8e0f..e3856a40a 100644
--- a/misc/requirements/requirements-pylint.txt
+++ b/misc/requirements/requirements-pylint.txt
@@ -1,10 +1,10 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
astroid==2.3.3 # rq.filter: < 2.4
-certifi==2020.6.20
-cffi==1.14.3
+certifi==2020.11.8
+cffi==1.14.4
chardet==3.0.4
-cryptography==3.2
+cryptography==3.2.1
github3.py==1.3.0
idna==2.10
isort==4.3.21
@@ -15,9 +15,9 @@ pycparser==2.20
pylint==2.4.4 # rq.filter: < 2.5
python-dateutil==2.8.1
./scripts/dev/pylint_checkers
-requests==2.24.0
+requests==2.25.0
six==1.15.0
typed-ast==1.4.1 ; python_version<"3.8"
uritemplate==3.0.1
-# urllib3==1.25.11
+# urllib3==1.26.2
wrapt==1.11.2
diff --git a/misc/requirements/requirements-pyqt-5.10.txt b/misc/requirements/requirements-pyqt-5.10.txt
deleted file mode 100644
index 69c3ccbd0..000000000
--- a/misc/requirements/requirements-pyqt-5.10.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# This file is automatically generated by scripts/dev/recompile_requirements.py
-
-PyQt5==5.10.1 # rq.filter: < 5.11
-sip==4.19.8 # rq.filter: < 5
diff --git a/misc/requirements/requirements-pyqt-5.10.txt-raw b/misc/requirements/requirements-pyqt-5.10.txt-raw
deleted file mode 100644
index 4fbea8575..000000000
--- a/misc/requirements/requirements-pyqt-5.10.txt-raw
+++ /dev/null
@@ -1,4 +0,0 @@
-#@ filter: PyQt5 < 5.11
-PyQt5 >= 5.10, < 5.11
-#@ filter: sip < 5
-sip < 5
diff --git a/misc/requirements/requirements-pyqt-5.11.txt b/misc/requirements/requirements-pyqt-5.11.txt
deleted file mode 100644
index bfee87c0f..000000000
--- a/misc/requirements/requirements-pyqt-5.11.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# This file is automatically generated by scripts/dev/recompile_requirements.py
-
-PyQt5==5.11.3 # rq.filter: < 5.12
-PyQt5-sip==4.19.19 # rq.filter: < 4.20
diff --git a/misc/requirements/requirements-pyqt-5.11.txt-raw b/misc/requirements/requirements-pyqt-5.11.txt-raw
deleted file mode 100644
index bdbe43f19..000000000
--- a/misc/requirements/requirements-pyqt-5.11.txt-raw
+++ /dev/null
@@ -1,4 +0,0 @@
-#@ filter: PyQt5 < 5.12
-PyQt5 >= 5.11, < 5.12
-
-#@ filter: PyQt5-sip < 4.20
diff --git a/misc/requirements/requirements-pyqt-5.15.txt b/misc/requirements/requirements-pyqt-5.15.txt
index 21745c814..e791bb323 100644
--- a/misc/requirements/requirements-pyqt-5.15.txt
+++ b/misc/requirements/requirements-pyqt-5.15.txt
@@ -1,5 +1,5 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
-PyQt5==5.15.1 # rq.filter: < 6
+PyQt5==5.15.2 # rq.filter: < 6
PyQt5-sip==12.8.1
-PyQtWebEngine==5.15.1 # rq.filter: < 6
+PyQtWebEngine==5.15.2 # rq.filter: < 6
diff --git a/misc/requirements/requirements-pyqt-5.7.txt b/misc/requirements/requirements-pyqt-5.7.txt
deleted file mode 100644
index 703c95a92..000000000
--- a/misc/requirements/requirements-pyqt-5.7.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# This file is automatically generated by scripts/dev/recompile_requirements.py
-
-PyQt5==5.7.1 # rq.filter: < 5.8
-sip==4.19.8 # rq.filter: < 5
diff --git a/misc/requirements/requirements-pyqt-5.7.txt-raw b/misc/requirements/requirements-pyqt-5.7.txt-raw
deleted file mode 100644
index 745deb4b9..000000000
--- a/misc/requirements/requirements-pyqt-5.7.txt-raw
+++ /dev/null
@@ -1,4 +0,0 @@
-#@ filter: PyQt5 < 5.8
-#@ filter: sip < 5
-PyQt5 >= 5.7, < 5.8
-sip < 5
diff --git a/misc/requirements/requirements-pyqt-5.9.txt b/misc/requirements/requirements-pyqt-5.9.txt
deleted file mode 100644
index 8f3258721..000000000
--- a/misc/requirements/requirements-pyqt-5.9.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# This file is automatically generated by scripts/dev/recompile_requirements.py
-
-PyQt5==5.9.2 # rq.filter: < 5.10
-sip==4.19.8 # rq.filter: < 5
diff --git a/misc/requirements/requirements-pyqt-5.9.txt-raw b/misc/requirements/requirements-pyqt-5.9.txt-raw
deleted file mode 100644
index 45d4e0c10..000000000
--- a/misc/requirements/requirements-pyqt-5.9.txt-raw
+++ /dev/null
@@ -1,4 +0,0 @@
-#@ filter: PyQt5 < 5.10
-PyQt5 >= 5.9, < 5.10
-#@ filter: sip < 5
-sip < 5
diff --git a/misc/requirements/requirements-pyqt.txt b/misc/requirements/requirements-pyqt.txt
index 148e8d8bb..ec6cfd810 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.15.1
+PyQt5==5.15.2
PyQt5-sip==12.8.1
-PyQtWebEngine==5.15.0
+PyQtWebEngine==5.15.2
diff --git a/misc/requirements/requirements-pyqt.txt-raw b/misc/requirements/requirements-pyqt.txt-raw
index 83ebc7671..9c6afbf16 100644
--- a/misc/requirements/requirements-pyqt.txt-raw
+++ b/misc/requirements/requirements-pyqt.txt-raw
@@ -1,2 +1,2 @@
PyQt5
-PyQtWebEngine!=5.15.1
+PyQtWebEngine
diff --git a/misc/requirements/requirements-qutebrowser.txt-raw b/misc/requirements/requirements-qutebrowser.txt-raw
index eb7ed011d..b43ee7f6e 100644
--- a/misc/requirements/requirements-qutebrowser.txt-raw
+++ b/misc/requirements/requirements-qutebrowser.txt-raw
@@ -3,6 +3,5 @@ Pygments
pyPEG2
PyYAML
colorama
-cssutils
attrs
adblock # Optional, for improved adblocking
diff --git a/misc/requirements/requirements-sphinx.txt b/misc/requirements/requirements-sphinx.txt
index baeea4d40..463bb8e73 100644
--- a/misc/requirements/requirements-sphinx.txt
+++ b/misc/requirements/requirements-sphinx.txt
@@ -1,8 +1,8 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
alabaster==0.7.12
-Babel==2.8.0
-certifi==2020.6.20
+Babel==2.9.0
+certifi==2020.11.8
chardet==3.0.4
docutils==0.16
idna==2.10
@@ -12,15 +12,15 @@ MarkupSafe==1.1.1
packaging==20.4
Pygments==2.7.2
pyparsing==2.4.7
-pytz==2020.1
-requests==2.24.0
+pytz==2020.4
+requests==2.25.0
six==1.15.0
snowballstemmer==2.0.0
-Sphinx==3.2.1
+Sphinx==3.3.1
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==1.0.3
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.4
-urllib3==1.25.11
+urllib3==1.26.2
diff --git a/misc/requirements/requirements-tests-git.txt b/misc/requirements/requirements-tests-git.txt
index 14b6eec04..9efbeca40 100644
--- a/misc/requirements/requirements-tests-git.txt
+++ b/misc/requirements/requirements-tests-git.txt
@@ -27,7 +27,6 @@ git+https://github.com/pallets/werkzeug.git
## qutebrowser dependencies
git+https://github.com/tartley/colorama.git
-hg+https://bitbucket.org/cthedot/cssutils
git+https://github.com/pallets/jinja.git
git+https://github.com/pallets/markupsafe.git
hg+http://bitbucket.org/birkenfeld/pygments-main
diff --git a/misc/requirements/requirements-tests.txt b/misc/requirements/requirements-tests.txt
index 066f4c4db..8b4eb0fba 100644
--- a/misc/requirements/requirements-tests.txt
+++ b/misc/requirements/requirements-tests.txt
@@ -1,11 +1,11 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
apipkg==1.5
-attrs==20.2.0
+attrs==20.3.0
beautifulsoup4==4.9.3
-certifi==2020.6.20
+certifi==2020.11.8
chardet==3.0.4
-cheroot==8.4.5
+cheroot==8.4.7
click==7.1.2
# colorama==0.4.4
coverage==5.3
@@ -15,7 +15,7 @@ filelock==3.0.12
Flask==1.1.2
glob2==0.7
hunter==3.3.1
-hypothesis==5.38.0
+hypothesis==5.41.3
icdiff==1.9.1
idna==2.10
iniconfig==1.1.1
@@ -25,7 +25,7 @@ jaraco.functools==3.0.1
Mako==1.1.3
manhole==1.6.0
# MarkupSafe==1.1.1
-more-itertools==8.5.0
+more-itertools==8.6.0
packaging==20.4
parse==1.18.0
parse-type==0.5.2
@@ -35,7 +35,7 @@ py==1.9.0
py-cpuinfo==7.0.0
Pygments==2.7.2
pyparsing==2.4.7
-pytest==6.1.1
+pytest==6.1.2
pytest-bdd==4.0.1
pytest-benchmark==3.2.3
pytest-clarity==0.3.0a0
@@ -45,19 +45,19 @@ pytest-icdiff==0.5
pytest-instafail==0.4.2
pytest-mock==3.3.1
pytest-qt==3.3.0
-pytest-repeat==0.8.0
+pytest-repeat==0.9.1
pytest-rerunfailures==9.1.1
pytest-xdist==2.1.0
pytest-xvfb==2.0.0
PyVirtualDisplay==1.3.2
-requests==2.24.0
+requests==2.25.0
requests-file==1.5.1
six==1.15.0
-sortedcontainers==2.2.2
+sortedcontainers==2.3.0
soupsieve==2.0.1
termcolor==1.1.0
-tldextract==3.0.2
-toml==0.10.1
+tldextract==3.1.0
+toml==0.10.2
urllib3==1.25.11
vulture==2.1
Werkzeug==1.0.1
diff --git a/misc/requirements/requirements-tests.txt-raw b/misc/requirements/requirements-tests.txt-raw
index fd346d475..19becf94b 100644
--- a/misc/requirements/requirements-tests.txt-raw
+++ b/misc/requirements/requirements-tests.txt-raw
@@ -33,5 +33,7 @@ pytest-clarity
# Needed to test misc/userscripts/qute-lastpass
tldextract
+# https://github.com/urllib3/urllib3/issues/2071
+urllib3!=1.26.0,!=1.26.1,!=1.26.2
#@ ignore: Jinja2, MarkupSafe, colorama
diff --git a/misc/requirements/requirements-tox.txt b/misc/requirements/requirements-tox.txt
index a77333637..95dbdd654 100644
--- a/misc/requirements/requirements-tox.txt
+++ b/misc/requirements/requirements-tox.txt
@@ -8,8 +8,6 @@ pluggy==0.13.1
py==1.9.0
pyparsing==2.4.7
six==1.15.0
-toml==0.10.1
+toml==0.10.2
tox==3.20.1
-tox-pip-version==0.0.7
-tox-venv==0.4.0
-virtualenv==20.1.0
+virtualenv==20.2.1
diff --git a/misc/requirements/requirements-tox.txt-raw b/misc/requirements/requirements-tox.txt-raw
index fab438034..053148f84 100644
--- a/misc/requirements/requirements-tox.txt-raw
+++ b/misc/requirements/requirements-tox.txt-raw
@@ -1,3 +1 @@
tox
-tox-venv
-tox-pip-version
diff --git a/misc/requirements/requirements-vulture.txt b/misc/requirements/requirements-vulture.txt
index 70848d8ef..e0ea82ea2 100644
--- a/misc/requirements/requirements-vulture.txt
+++ b/misc/requirements/requirements-vulture.txt
@@ -1,4 +1,4 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
-toml==0.10.1
+toml==0.10.2
vulture==2.1
diff --git a/misc/requirements/requirements-yamllint.txt b/misc/requirements/requirements-yamllint.txt
index 5f80fd5d5..1d758395c 100644
--- a/misc/requirements/requirements-yamllint.txt
+++ b/misc/requirements/requirements-yamllint.txt
@@ -1,5 +1,5 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
-pathspec==0.8.0
+pathspec==0.8.1
PyYAML==5.3.1
yamllint==1.25.0
diff --git a/misc/userscripts/README.md b/misc/userscripts/README.md
index 0e3a5ffc3..a17f7164c 100644
--- a/misc/userscripts/README.md
+++ b/misc/userscripts/README.md
@@ -65,6 +65,8 @@ The following userscripts can be found on their own repositories.
selections via Google Translate.
- [qute-snippets](https://github.com/Aledosim/qute-snippets): Bind text snippets to a keyword
and retrieve they when you want.
+- [doi](https://github.com/cadadr/configuration/blob/master/qutebrowser/userscripts/doi):
+ Opens DOIs on Sci-Hub.
[Zotero]: https://www.zotero.org/
[Pocket]: https://getpocket.com/
diff --git a/misc/userscripts/dmenu_qutebrowser b/misc/userscripts/dmenu_qutebrowser
index 84be1b619..57bdb805c 100755
--- a/misc/userscripts/dmenu_qutebrowser
+++ b/misc/userscripts/dmenu_qutebrowser
@@ -38,9 +38,10 @@
# (This is unnecessarily long. I use this rarely, feel free to make this script accept parameters.)
#
-[ -z "$QUTE_URL" ] && QUTE_URL='http://google.com'
-url=$(echo "$QUTE_URL" | cat - "$QUTE_CONFIG_DIR/quickmarks" "$QUTE_DATA_DIR/history" | dmenu -l 15 -p qutebrowser)
+[ -z "$QUTE_URL" ] && QUTE_URL='https://duckduckgo.com'
+
+url=$(printf "%s\n%s" "$QUTE_URL" "$(sqlite3 -separator ' ' "$QUTE_DATA_DIR/history.sqlite" 'select title, url from CompletionHistory')" | cat "$QUTE_CONFIG_DIR/quickmarks" - | dmenu -l 15 -p qutebrowser)
url=$(echo "$url" | sed -E 's/[^ ]+ +//g' | grep -E "https?:" || echo "$url")
[ -z "${url// }" ] && exit
diff --git a/misc/userscripts/qutedmenu b/misc/userscripts/qutedmenu
index cc5a44413..bdd0d9b27 100755
--- a/misc/userscripts/qutedmenu
+++ b/misc/userscripts/qutedmenu
@@ -6,8 +6,9 @@
# If you would like to set a custom colorscheme/font use these dirs.
# https://github.com/halfwit/dotfiles/blob/master/.config/dmenu/bemenucolors
-readonly confdir=${XDG_CONFIG_HOME:-$HOME/.config}
+
+readonly confdir=${XDG_CONFIG_HOME:-$HOME/.config}
readonly optsfile=$confdir/dmenu/bemenucolors
create_menu() {
@@ -22,15 +23,13 @@ create_menu() {
done < "$QUTE_CONFIG_DIR"/bookmarks/urls
# Finally history
- while read -r _ url; do
- printf -- '%s\n' "$url"
- done < "$QUTE_DATA_DIR"/history
+ printf -- '%s\n' "$(sqlite3 -separator ' ' "$QUTE_DATA_DIR/history.sqlite" 'select title, url from CompletionHistory')"
}
get_selection() {
opts+=(-p qutebrowser)
- #create_menu | dmenu -l 10 "${opts[@]}"
- create_menu | bemenu -l 10 "${opts[@]}"
+ create_menu | dmenu -l 10 "${opts[@]}"
+ #create_menu | bemenu -l 10 "${opts[@]}"
}
# Main
diff --git a/pytest.ini b/pytest.ini
index 0b4fecf37..f936a02cb 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -30,10 +30,8 @@ markers =
qtwebkit_skip: Tests not applicable with QtWebKit
qtwebengine_flaky: Tests which are flaky (and currently skipped) with QtWebEngine
qtwebengine_mac_xfail: Tests which fail on macOS with QtWebEngine
- js_prompt: Tests needing to display a javascript prompt
this: Used to mark tests during development
no_invalid_lines: Don't fail on unparseable lines in end2end tests
- qtbug60673: Tests which are broken if the conversion from orange selection to real selection is flaky
fake_os: Fake utils.is_* to a fake operating system
unicode_locale: Tests which need a unicode locale to work
qtwebkit6021_xfail: Tests which would fail on WebKit version 602.1
@@ -77,9 +75,11 @@ qt_log_ignore =
^DirectWrite: CreateFontFaceFromHDC\(\) failed .*
^Attribute Qt::AA_ShareOpenGLContexts must be set before QCoreApplication is created\.
^QHttpNetworkConnectionPrivate::_q_hostLookupFinished could not de-queue request, failed to report HostNotFoundError
+ ^The available OpenGL surface format was either not version 3\.2 or higher or not a Core Profile.*
xfail_strict = true
filterwarnings =
error
# See https://github.com/HypothesisWorks/hypothesis/issues/2370
ignore:.*which is reset between function calls but not between test cases generated by:hypothesis.errors.HypothesisDeprecationWarning
+ default:Test process .* failed to terminate!:UserWarning
faulthandler_timeout = 90
diff --git a/qutebrowser/api/downloads.py b/qutebrowser/api/downloads.py
index 5e5d1916a..55656c5b5 100644
--- a/qutebrowser/api/downloads.py
+++ b/qutebrowser/api/downloads.py
@@ -75,4 +75,6 @@ def download_temp(url: QUrl) -> TempDownload:
fobj.name = 'temporary: ' + url.host()
target = downloads.FileObjDownloadTarget(fobj)
download_manager = objreg.get('qtnetwork-download-manager')
- return download_manager.get(url, target=target, auto_remove=True)
+ # cache=False is set as a WORKAROUND for MS Defender thinking we're a trojan
+ # downloader when caching the hostblock list...
+ return download_manager.get(url, target=target, auto_remove=True, cache=False)
diff --git a/qutebrowser/app.py b/qutebrowser/app.py
index 27f03fd54..f722c580f 100644
--- a/qutebrowser/app.py
+++ b/qutebrowser/app.py
@@ -43,7 +43,7 @@ import functools
import tempfile
import datetime
import argparse
-import typing
+from typing import Iterable, Optional, cast
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtGui import QDesktopServices, QPixmap, QIcon
@@ -74,7 +74,7 @@ from qutebrowser.misc import utilcmds
# pylint: enable=unused-import
-q_app = typing.cast(QApplication, None)
+q_app = cast(QApplication, None)
def run(args):
@@ -199,7 +199,7 @@ def _init_pulseaudio():
WORKAROUND for https://bugreports.qt.io/browse/QTBUG-85363
Affected Qt versions:
- - Older than 5.11
+ - Older than 5.11 (which is unsupported)
- 5.14.0 to 5.15.0 (inclusive)
However, we set this on all versions so that qutebrowser's icon gets picked
@@ -256,7 +256,7 @@ def process_pos_args(args, via_ipc=False, cwd=None, target_arg=None):
if command_target in {'window', 'private-window'}:
command_target = 'tab-silent'
- win_id = None # type: typing.Optional[int]
+ win_id: Optional[int] = None
if via_ipc and not args:
win_id = mainwindow.get_window(via_ipc=via_ipc,
@@ -325,7 +325,7 @@ def _open_startpage(win_id=None):
If set, open the startpage in the given window.
"""
if win_id is not None:
- window_ids = [win_id] # type: typing.Iterable[int]
+ window_ids: Iterable[int] = [win_id]
else:
window_ids = objreg.window_registry
for cur_win_id in list(window_ids): # Copying as the dict could change
@@ -366,10 +366,6 @@ def _open_special_pages(args):
objects.backend == usertypes.Backend.QtWebKit,
'qute://warning/webkit'),
- ('old-qt-warning-shown',
- not qtutils.version_check('5.11'),
- 'qute://warning/old-qt'),
-
('session-warning-shown',
qtutils.version_check('5.15', compiled=False),
'qute://warning/sessions'),
@@ -536,7 +532,9 @@ class Application(QApplication):
self.launch_time = datetime.datetime.now()
self.focusObjectChanged.connect( # type: ignore[attr-defined]
self.on_focus_object_changed)
+
self.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
+ self.setAttribute(Qt.AA_MacDontSwapCtrlAndMeta, True)
self.new_window.connect(self._on_new_window)
diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py
index 58c434a42..dd21cd0e0 100644
--- a/qutebrowser/browser/browsertab.py
+++ b/qutebrowser/browser/browsertab.py
@@ -230,14 +230,6 @@ class AbstractPrinting:
"""
raise NotImplementedError
- def check_printer_support(self) -> None:
- """Check whether writing to a printer is supported.
-
- If it's not supported (by the current Qt version), a WebTabError is
- raised.
- """
- raise NotImplementedError
-
def check_preview_support(self) -> None:
"""Check whether showing a print preview is supported.
@@ -263,8 +255,6 @@ class AbstractPrinting:
def show_dialog(self) -> None:
"""Print with a QPrintDialog."""
- self.check_printer_support()
-
def print_callback(ok: bool) -> None:
"""Called when printing finished."""
if not ok:
@@ -1058,9 +1048,6 @@ class AbstractTab(QWidget):
self.data.last_navigation = navigation
if not navigation.url.isValid():
- # Also a WORKAROUND for missing IDNA 2008 support in QUrl, see
- # https://bugreports.qt.io/browse/QTBUG-60364
-
if navigation.navigation_type == navigation.Type.link_clicked:
msg = urlutils.get_errstring(navigation.url,
"Invalid link clicked")
@@ -1129,14 +1116,11 @@ class AbstractTab(QWidget):
def load_status(self) -> usertypes.LoadStatus:
return self._load_status
- def _load_url_prepare(self, url: QUrl, *,
- emit_before_load_started: bool = True) -> None:
+ def _load_url_prepare(self, url: QUrl) -> None:
qtutils.ensure_valid(url)
- if emit_before_load_started:
- self.before_load_started.emit(url)
+ self.before_load_started.emit(url)
- def load_url(self, url: QUrl, *,
- emit_before_load_started: bool = True) -> None:
+ def load_url(self, url: QUrl) -> None:
raise NotImplementedError
def reload(self, *, force: bool = False) -> None:
diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py
index 5a65384f3..34c078d89 100644
--- a/qutebrowser/browser/commands.py
+++ b/qutebrowser/browser/commands.py
@@ -673,7 +673,7 @@ class CommandDispatcher:
url = QUrl(self._current_url())
url_query = QUrlQuery()
- url_query_str = urlutils.query_string(url)
+ url_query_str = url.query()
if '&' not in url_query_str and ';' in url_query_str:
url_query.setQueryDelimiters('=', ';')
url_query.setQuery(url_query_str)
@@ -1304,7 +1304,7 @@ class CommandDispatcher:
if mhtml_:
raise cmdutils.CommandError("Can only download the current "
"page as mhtml.")
- url = urlutils.qurl_from_user_input(url)
+ url = QUrl.fromUserInput(url)
urlutils.raise_cmdexc_if_invalid(url)
download_manager.get(url, target=target)
elif mhtml_:
diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py
index 5430cde20..96220897c 100644
--- a/qutebrowser/browser/downloads.py
+++ b/qutebrowser/browser/downloads.py
@@ -560,8 +560,8 @@ class AbstractDownloadItem(QObject):
elif self.stats.percentage() is None:
return start
else:
- return utils.interpolate_color(start, stop,
- self.stats.percentage(), system)
+ return qtutils.interpolate_color(
+ start, stop, self.stats.percentage(), system)
def _do_cancel(self):
"""Actual cancel implementation."""
@@ -574,6 +574,7 @@ class AbstractDownloadItem(QObject):
Args:
remove_data: Whether to remove the downloaded data.
"""
+ assert not self.done
self._do_cancel()
log.downloads.debug("cancelled")
if remove_data:
@@ -982,7 +983,8 @@ class AbstractDownloadManager(QObject):
def shutdown(self):
"""Cancel all downloads when shutting down."""
for download in self.downloads:
- download.cancel(remove_data=False)
+ if not download.done:
+ download.cancel(remove_data=False)
class DownloadModel(QAbstractListModel):
diff --git a/qutebrowser/browser/downloadview.py b/qutebrowser/browser/downloadview.py
index bff4a8c93..0bb5d4d08 100644
--- a/qutebrowser/browser/downloadview.py
+++ b/qutebrowser/browser/downloadview.py
@@ -22,36 +22,12 @@
import functools
from typing import Callable, MutableSequence, Tuple, Union
-from PyQt5.QtCore import pyqtSlot, QSize, Qt, QTimer
+from PyQt5.QtCore import pyqtSlot, QSize, Qt
from PyQt5.QtWidgets import QListView, QSizePolicy, QMenu, QStyleFactory
from qutebrowser.browser import downloads
from qutebrowser.config import stylesheet
from qutebrowser.utils import qtutils, utils
-from qutebrowser.qt import sip
-
-
-def update_geometry(obj):
- """Weird WORKAROUND for some weird PyQt bug (probably).
-
- This actually should be a method of DownloadView, but for some reason the
- rowsInserted/rowsRemoved signals don't get disconnected from this method
- when the DownloadView is deleted from Qt (e.g. by closing a window).
-
- Here we check if obj ("self") was deleted and just ignore the event if so.
-
- Original bug: https://github.com/qutebrowser/qutebrowser/issues/167
- Workaround bug: https://github.com/qutebrowser/qutebrowser/issues/171
- """
- def _update_geometry():
- """Actually update the geometry if the object still exists."""
- if sip.isdeleted(obj):
- return
- obj.updateGeometry()
-
- # If we don't use a singleShot QTimer, the geometry isn't updated correctly
- # and won't include the new item.
- QTimer.singleShot(0, _update_geometry)
_ActionListType = MutableSequence[
@@ -93,9 +69,9 @@ class DownloadView(QListView):
self.setFlow(QListView.LeftToRight)
self.setSpacing(1)
self._menu = None
- model.rowsInserted.connect(functools.partial(update_geometry, self))
- model.rowsRemoved.connect(functools.partial(update_geometry, self))
- model.dataChanged.connect(functools.partial(update_geometry, self))
+ model.rowsInserted.connect(self._update_geometry)
+ model.rowsRemoved.connect(self._update_geometry)
+ model.dataChanged.connect(self._update_geometry)
self.setModel(model)
self.setWrapping(True)
self.setContextMenuPolicy(Qt.CustomContextMenu)
@@ -110,6 +86,15 @@ class DownloadView(QListView):
count = model.rowCount()
return utils.get_repr(self, count=count)
+ @pyqtSlot()
+ def _update_geometry(self):
+ """Wrapper to call updateGeometry.
+
+ For some reason, this is needed so that PyQt disconnects the signals and handles
+ arguments correctly. Probably a WORKAROUND for an unknown PyQt bug.
+ """
+ self.updateGeometry()
+
@pyqtSlot(bool)
def on_fullscreen_requested(self, on):
"""Hide/show the downloadview when entering/leaving fullscreen."""
diff --git a/qutebrowser/browser/eventfilter.py b/qutebrowser/browser/eventfilter.py
index 78ca67cd8..0195c73ad 100644
--- a/qutebrowser/browser/eventfilter.py
+++ b/qutebrowser/browser/eventfilter.py
@@ -22,48 +22,11 @@
from PyQt5.QtCore import QObject, QEvent, Qt, QTimer
from qutebrowser.config import config
-from qutebrowser.utils import message, log, usertypes, qtutils, objreg
+from qutebrowser.utils import message, log, usertypes, qtutils
from qutebrowser.misc import objects
from qutebrowser.keyinput import modeman
-class FocusWorkaroundEventFilter(QObject):
-
- """An event filter working Qt 5.11 keyboard focus issues.
-
- WORKAROUND for https://bugreports.qt.io/browse/QTBUG-68076
- """
-
- def __init__(self, win_id, widget, parent=None):
- super().__init__(parent)
- self._win_id = win_id
- self._widget = widget
-
- def eventFilter(self, _obj, event):
- """Act on ChildAdded events."""
- if event.type() != QEvent.ChildAdded:
- return False
-
- pass_modes = [usertypes.KeyMode.command,
- usertypes.KeyMode.prompt,
- usertypes.KeyMode.yesno]
-
- if modeman.instance(self._win_id).mode in pass_modes:
- return False
-
- tabbed_browser = objreg.get('tabbed-browser', scope='window',
- window=self._win_id)
- current_index = tabbed_browser.widget.currentIndex()
- try:
- widget_index = tabbed_browser.widget.indexOf(self._widget.parent())
- except RuntimeError:
- widget_index = -1
- if current_index == widget_index:
- QTimer.singleShot(0, self._widget.setFocus)
-
- return False
-
-
class ChildEventFilter(QObject):
"""An event filter re-adding TabEventFilter on ChildEvent.
@@ -204,13 +167,6 @@ class TabEventFilter(QObject):
message.info("Zoom level: {}%".format(perc), replace=True)
self._tab.zoom.set_factor(factor)
return True
- elif (e.modifiers() & Qt.ShiftModifier and
- not qtutils.version_check('5.9', compiled=False)):
- if e.angleDelta().y() > 0:
- self._tab.scroller.left()
- else:
- self._tab.scroller.right()
- return True
return False
@@ -226,7 +182,6 @@ class TabEventFilter(QObject):
True if the event should be filtered, False otherwise.
"""
return (e.isAutoRepeat() and
- qtutils.version_check('5.10', compiled=False) and
not qtutils.version_check('5.14', compiled=False) and
objects.backend == usertypes.Backend.QtWebEngine)
diff --git a/qutebrowser/browser/greasemonkey.py b/qutebrowser/browser/greasemonkey.py
index 5a5d55a6d..0305bd589 100644
--- a/qutebrowser/browser/greasemonkey.py
+++ b/qutebrowser/browser/greasemonkey.py
@@ -32,8 +32,7 @@ import attr
from PyQt5.QtCore import pyqtSignal, QObject, QUrl
from qutebrowser.utils import (log, standarddir, jinja, objreg, utils,
- javascript, urlmatch, version, usertypes,
- qtutils)
+ javascript, urlmatch, version, usertypes)
from qutebrowser.api import cmdutils
from qutebrowser.browser import downloads
from qutebrowser.misc import objects
@@ -125,8 +124,7 @@ class GreasemonkeyScript:
def needs_document_end_workaround(self):
"""Check whether to force @run-at document-end.
- This needs to be done on QtWebEngine with Qt 5.12 for known-broken
- scripts.
+ This needs to be done on QtWebEngine (since Qt 5.12) for known-broken scripts.
On Qt 5.12, accessing the DOM isn't possible with "@run-at
document-start". It was documented to be impossible before, but seems
@@ -135,12 +133,11 @@ class GreasemonkeyScript:
However, some scripts do DOM access with "@run-at document-start". Fix
those by forcing them to use document-end instead.
"""
- if objects.backend != usertypes.Backend.QtWebEngine:
- assert objects.backend == usertypes.Backend.QtWebKit, objects.backend
- return False
- elif not qtutils.version_check('5.12', compiled=False):
+ if objects.backend == usertypes.Backend.QtWebKit:
return False
+ assert objects.backend == usertypes.Backend.QtWebEngine, objects.backend
+
broken_scripts = [
('http://userstyles.org', None),
('https://github.com/ParticleCore', 'Iridium'),
diff --git a/qutebrowser/browser/inspector.py b/qutebrowser/browser/inspector.py
index d8fa1b6f0..813f1ff12 100644
--- a/qutebrowser/browser/inspector.py
+++ b/qutebrowser/browser/inspector.py
@@ -49,12 +49,7 @@ def create(*, splitter: 'miscwidgets.InspectorSplitter',
# argument and to avoid circular imports.
if objects.backend == usertypes.Backend.QtWebEngine:
from qutebrowser.browser.webengine import webengineinspector
- if webengineinspector.supports_new():
- return webengineinspector.WebEngineInspector(
- splitter, win_id, parent)
- else:
- return webengineinspector.LegacyWebEngineInspector(
- splitter, win_id, parent)
+ return webengineinspector.WebEngineInspector(splitter, win_id, parent)
elif objects.backend == usertypes.Backend.QtWebKit:
from qutebrowser.browser.webkit import webkitinspector
return webkitinspector.WebKitInspector(splitter, win_id, parent)
diff --git a/qutebrowser/browser/navigate.py b/qutebrowser/browser/navigate.py
index b852ab29e..bace6fa6a 100644
--- a/qutebrowser/browser/navigate.py
+++ b/qutebrowser/browser/navigate.py
@@ -134,13 +134,13 @@ def path_up(url, count):
"""
urlutils.ensure_valid(url)
url = url.adjusted(QUrl.RemoveFragment | QUrl.RemoveQuery)
- path = url.path()
+ path = url.path(QUrl.FullyEncoded)
if not path or path == '/':
raise Error("Can't go up!")
for _i in range(0, min(count, path.count('/'))):
path = posixpath.join(path, posixpath.pardir)
path = posixpath.normpath(path)
- url.setPath(path)
+ url.setPath(path, QUrl.StrictMode)
return url
diff --git a/qutebrowser/browser/pdfjs.py b/qutebrowser/browser/pdfjs.py
index 0c6d02501..f60061045 100644
--- a/qutebrowser/browser/pdfjs.py
+++ b/qutebrowser/browser/pdfjs.py
@@ -24,9 +24,7 @@ import os
from PyQt5.QtCore import QUrl, QUrlQuery
-from qutebrowser.utils import (utils, javascript, jinja, qtutils, usertypes,
- standarddir, log)
-from qutebrowser.misc import objects
+from qutebrowser.utils import utils, javascript, jinja, standarddir, log
from qutebrowser.config import config
@@ -104,29 +102,17 @@ def _generate_pdfjs_script(filename):
document.addEventListener("DOMContentLoaded", function() {
if (typeof window.PDFJS !== 'undefined') {
// v1.x
- {% if disable_create_object_url %}
- window.PDFJS.disableCreateObjectURL = true;
- {% endif %}
window.PDFJS.verbosity = window.PDFJS.VERBOSITY_LEVELS.info;
} else {
// v2.x
const options = window.PDFViewerApplicationOptions;
- {% if disable_create_object_url %}
- options.set('disableCreateObjectURL', true);
- {% endif %}
options.set('verbosity', pdfjsLib.VerbosityLevel.INFOS);
}
const viewer = window.PDFView || window.PDFViewerApplication;
viewer.open({{ url }});
});
- """).render(
- url=js_url,
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-70420
- disable_create_object_url=(
- not qtutils.version_check('5.12') and
- not qtutils.version_check('5.7.1', exact=True, compiled=False) and
- objects.backend == usertypes.Backend.QtWebEngine))
+ """).render(url=js_url)
def get_pdfjs_res_and_path(path):
diff --git a/qutebrowser/browser/qtnetworkdownloads.py b/qutebrowser/browser/qtnetworkdownloads.py
index 44e6c45d5..0bf165965 100644
--- a/qutebrowser/browser/qtnetworkdownloads.py
+++ b/qutebrowser/browser/qtnetworkdownloads.py
@@ -181,11 +181,16 @@ class DownloadItem(downloads.AbstractDownloadItem):
assert self.done
assert not self.successful
assert self._retry_info is not None
+
+ # Not calling self.cancel() here because the download is done (albeit
+ # unsuccessfully)
+ self.remove()
+ self.delete()
+
new_reply = self._retry_info.manager.get(self._retry_info.request)
new_download = self._manager.fetch(new_reply,
suggested_filename=self.basename)
self.adopt_download.emit(new_download)
- self.cancel()
def _get_open_filename(self):
filename = self._filename
@@ -414,11 +419,12 @@ class DownloadManager(downloads.AbstractDownloadManager):
private=config.val.content.private_browsing, parent=self)
@pyqtSlot('QUrl')
- def get(self, url, **kwargs):
+ def get(self, url, cache=True, **kwargs):
"""Start a download with a link URL.
Args:
url: The URL to get, as QUrl
+ cache: If set to False, don't cache the response.
**kwargs: passed to get_request().
Return:
@@ -432,6 +438,9 @@ class DownloadManager(downloads.AbstractDownloadManager):
user_agent = websettings.user_agent(url)
req.setHeader(QNetworkRequest.UserAgentHeader, user_agent)
+ if not cache:
+ req.setAttribute(QNetworkRequest.CacheSaveControlAttribute, False)
+
return self.get_request(req, **kwargs)
def get_mhtml(self, tab, target):
diff --git a/qutebrowser/browser/qutescheme.py b/qutebrowser/browser/qutescheme.py
index d36bb746a..cb4a9ba61 100644
--- a/qutebrowser/browser/qutescheme.py
+++ b/qutebrowser/browser/qutescheme.py
@@ -34,13 +34,13 @@ import collections
import secrets
from typing import TypeVar, Callable, Dict, List, Optional, Union, Sequence, Tuple
-from PyQt5.QtCore import QUrlQuery, QUrl, qVersion
+from PyQt5.QtCore import QUrlQuery, QUrl
import qutebrowser
from qutebrowser.browser import pdfjs, downloads, history
-from qutebrowser.config import config, configdata, configexc, configdiff
+from qutebrowser.config import config, configdata, configexc
from qutebrowser.utils import (version, utils, jinja, log, message, docutils,
- objreg, urlutils, standarddir)
+ objreg, standarddir)
from qutebrowser.qt import sip
@@ -135,7 +135,7 @@ def data_for_url(url: QUrl) -> Tuple[str, bytes]:
path = url.path()
host = url.host()
- query = urlutils.query_string(url)
+ query = url.query()
# A url like "qute:foo" is split as "scheme:path", not "scheme:host".
log.misc.debug("url: {}, path: {}, host {}".format(
url.toDisplayString(), path, host))
@@ -481,18 +481,10 @@ def qute_back(url: QUrl) -> _HandlerRet:
@add_handler('configdiff')
-def qute_configdiff(url: QUrl) -> _HandlerRet:
+def qute_configdiff(_url: QUrl) -> _HandlerRet:
"""Handler for qute://configdiff."""
- if url.path() == '/old':
- try:
- return 'text/html', configdiff.get_diff()
- except OSError as e:
- error = (b'Failed to read old config: ' +
- str(e.strerror).encode('utf-8'))
- return 'text/plain', error
- else:
- data = config.instance.dump_userconfig().encode('utf-8')
- return 'text/plain', data
+ data = config.instance.dump_userconfig().encode('utf-8')
+ return 'text/plain', data
@add_handler('pastebin-version')
@@ -563,11 +555,7 @@ def qute_pdfjs(url: QUrl) -> _HandlerRet:
def qute_warning(url: QUrl) -> _HandlerRet:
"""Handler for qute://warning."""
path = url.path()
- if path == '/old-qt':
- src = jinja.render('warning-old-qt.html',
- title='Old Qt warning',
- qt_version=qVersion())
- elif path == '/webkit':
+ if path == '/webkit':
src = jinja.render('warning-webkit.html',
title='QtWebKit backend warning')
elif path == '/sessions':
diff --git a/qutebrowser/browser/shared.py b/qutebrowser/browser/shared.py
index fb213ed62..193a2a0e0 100644
--- a/qutebrowser/browser/shared.py
+++ b/qutebrowser/browser/shared.py
@@ -27,8 +27,7 @@ from typing import Callable, Mapping
from PyQt5.QtCore import QUrl
from qutebrowser.config import config
-from qutebrowser.utils import (usertypes, message, log, objreg, jinja, utils,
- qtutils)
+from qutebrowser.utils import usertypes, message, log, objreg, jinja, utils
from qutebrowser.mainwindow import mainwindow
@@ -76,13 +75,12 @@ def authentication_required(url, authenticator, abort_on):
return answer
-def javascript_confirm(url, js_msg, abort_on, *, escape_msg=True):
+def javascript_confirm(url, js_msg, abort_on):
"""Display a javascript confirm prompt."""
log.js.debug("confirm: {}".format(js_msg))
if config.val.content.javascript.modal_dialog:
raise CallSuper
- js_msg = html.escape(js_msg) if escape_msg else js_msg
msg = 'From <b>{}</b>:<br/>{}'.format(html.escape(url.toDisplayString()),
js_msg)
urlstr = url.toString(QUrl.RemovePassword | QUrl.FullyEncoded)
@@ -92,7 +90,7 @@ def javascript_confirm(url, js_msg, abort_on, *, escape_msg=True):
return bool(ans)
-def javascript_prompt(url, js_msg, default, abort_on, *, escape_msg=True):
+def javascript_prompt(url, js_msg, default, abort_on):
"""Display a javascript prompt."""
log.js.debug("prompt: {}".format(js_msg))
if config.val.content.javascript.modal_dialog:
@@ -100,7 +98,6 @@ def javascript_prompt(url, js_msg, default, abort_on, *, escape_msg=True):
if not config.val.content.javascript.prompt:
return (False, "")
- js_msg = html.escape(js_msg) if escape_msg else js_msg
msg = '<b>{}</b> asks:<br/>{}'.format(html.escape(url.toDisplayString()),
js_msg)
urlstr = url.toString(QUrl.RemovePassword | QUrl.FullyEncoded)
@@ -115,7 +112,7 @@ def javascript_prompt(url, js_msg, default, abort_on, *, escape_msg=True):
return (True, answer)
-def javascript_alert(url, js_msg, abort_on, *, escape_msg=True):
+def javascript_alert(url, js_msg, abort_on):
"""Display a javascript alert."""
log.js.debug("alert: {}".format(js_msg))
if config.val.content.javascript.modal_dialog:
@@ -124,7 +121,6 @@ def javascript_alert(url, js_msg, abort_on, *, escape_msg=True):
if not config.val.content.javascript.alert:
return
- js_msg = html.escape(js_msg) if escape_msg else js_msg
msg = 'From <b>{}</b>:<br/>{}'.format(html.escape(url.toDisplayString()),
js_msg)
urlstr = url.toString(QUrl.RemovePassword | QUrl.FullyEncoded)
@@ -287,9 +283,7 @@ def get_user_stylesheet(searching=False):
css += f.read()
setting = config.val.scrolling.bar
- overlay_bar_available = (qtutils.version_check('5.11', compiled=False) and
- not utils.is_mac)
- if setting == 'overlay' and not overlay_bar_available:
+ if setting == 'overlay' and not utils.is_mac:
setting = 'when-searching'
if setting == 'never' or setting == 'when-searching' and not searching:
diff --git a/qutebrowser/browser/webengine/cookies.py b/qutebrowser/browser/webengine/cookies.py
index 697082830..a5d92ef74 100644
--- a/qutebrowser/browser/webengine/cookies.py
+++ b/qutebrowser/browser/webengine/cookies.py
@@ -20,7 +20,7 @@
"""Filter for QtWebEngine cookies."""
from qutebrowser.config import config
-from qutebrowser.utils import utils, qtutils, log
+from qutebrowser.utils import utils, log
from qutebrowser.misc import objects
@@ -31,13 +31,6 @@ def _accept_cookie(request):
if not url.isValid():
url = None
- if qtutils.version_check('5.11.3', compiled=False):
- third_party = request.thirdParty
- else:
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-71393
- third_party = (request.thirdParty and
- not request.firstPartyUrl.isEmpty())
-
accept = config.instance.get('content.cookies.accept',
url=url)
@@ -48,13 +41,13 @@ def _accept_cookie(request):
else request.origin.toDisplayString())
log.network.debug('Cookie from origin {} on {} (third party: {}) '
'-> applying setting {}'
- .format(origin_str, first_party_str, third_party,
+ .format(origin_str, first_party_str, request.thirdParty,
accept))
if accept == 'all':
return True
elif accept in ['no-3rdparty', 'no-unknown-3rdparty']:
- return not third_party
+ return not request.thirdParty
elif accept == 'never':
return False
else:
@@ -62,12 +55,5 @@ def _accept_cookie(request):
def install_filter(profile):
- """Install the cookie filter on the given profile.
-
- On Qt < 5.11, the filter isn't installed.
- """
- store = profile.cookieStore()
- try:
- store.setCookieFilter(_accept_cookie)
- except AttributeError:
- pass
+ """Install the cookie filter on the given profile."""
+ profile.cookieStore().setCookieFilter(_accept_cookie)
diff --git a/qutebrowser/browser/webengine/darkmode.py b/qutebrowser/browser/webengine/darkmode.py
index bf0319702..630a7bf9e 100644
--- a/qutebrowser/browser/webengine/darkmode.py
+++ b/qutebrowser/browser/webengine/darkmode.py
@@ -73,6 +73,7 @@ Prefix changed to "forceDarkMode".
- As with Qt 5.15.0 / .1, but with "forceDarkMode" as prefix.
"""
+import os
import enum
from typing import Any, Iterable, Iterator, Mapping, Optional, Set, Tuple, Union
@@ -90,8 +91,6 @@ class Variant(enum.Enum):
"""A dark mode variant."""
- unavailable = enum.auto()
- qt_510 = enum.auto()
qt_511_to_513 = enum.auto()
qt_514 = enum.auto()
qt_515_0 = enum.auto()
@@ -119,9 +118,6 @@ _IMAGE_POLICIES = {
'never': 1, # kFilterNone
'smart': 2, # kFilterSmart
}
-# Image policy smart is not available with Qt 5.10
-_IMAGE_POLICIES_QT_510 = _IMAGE_POLICIES.copy()
-_IMAGE_POLICIES_QT_510['smart'] = _IMAGE_POLICIES['never']
# Mapping from a colors.webpage.darkmode.policy.page setting value to
# Chromium's DarkModePagePolicy enum values.
@@ -163,8 +159,6 @@ _QT_514_SETTINGS = [
# workaround warning below if the setting wasn't explicitly customized.
_DARK_MODE_DEFINITIONS: Mapping[Variant, _DarkModeDefinitionType] = {
- Variant.unavailable: ([], set()),
-
Variant.qt_515_2: ([
# 'darkMode' renamed to 'forceDarkMode'
('enabled', 'forceDarkModeEnabled', _BOOLS),
@@ -234,19 +228,18 @@ _DARK_MODE_DEFINITIONS: Mapping[Variant, _DarkModeDefinitionType] = {
('contrast', 'highContrastContrast', None),
('grayscale.all', 'highContrastGrayscale', _BOOLS),
], {'algorithm', 'policy.images'}),
-
- Variant.qt_510: ([
- ('algorithm', 'highContrastMode', _ALGORITHMS_BEFORE_QT_514),
-
- ('policy.images', 'highContrastImagePolicy', _IMAGE_POLICIES_QT_510),
- ('contrast', 'highContrastContrast', None),
- ('grayscale.all', 'highContrastGrayscale', _BOOLS),
- ], {'algorithm'}),
}
def _variant() -> Variant:
"""Get the dark mode variant based on the underlying Qt version."""
+ env_var = os.environ.get('QUTE_DARKMODE_VARIANT')
+ if env_var is not None:
+ try:
+ return Variant[env_var]
+ except KeyError:
+ log.init.warning(f"Ignoring invalid QUTE_DARKMODE_VARIANT={env_var}")
+
if PYQT_WEBENGINE_VERSION is not None:
# Available with Qt >= 5.13
if PYQT_WEBENGINE_VERSION >= 0x050f02:
@@ -261,17 +254,12 @@ def _variant() -> Variant:
return Variant.qt_511_to_513
raise utils.Unreachable(hex(PYQT_WEBENGINE_VERSION))
- # If we don't have PYQT_WEBENGINE_VERSION, we'll need to assume based on the Qt
- # version.
+ # If we don't have PYQT_WEBENGINE_VERSION, we're on 5.12 (or older, but 5.12 is the
+ # oldest supported version).
assert not qtutils.version_check( # type: ignore[unreachable]
'5.13', compiled=False)
- if qtutils.version_check('5.11', compiled=False):
- return Variant.qt_511_to_513
- elif qtutils.version_check('5.10', compiled=False):
- return Variant.qt_510
-
- return Variant.unavailable
+ return Variant.qt_511_to_513
def settings() -> Iterator[Tuple[str, str]]:
diff --git a/qutebrowser/browser/webengine/interceptor.py b/qutebrowser/browser/webengine/interceptor.py
index d4dcb522f..b27509552 100644
--- a/qutebrowser/browser/webengine/interceptor.py
+++ b/qutebrowser/browser/webengine/interceptor.py
@@ -25,7 +25,7 @@ from PyQt5.QtCore import QUrl, QByteArray
from PyQt5.QtWebEngineCore import (QWebEngineUrlRequestInterceptor,
QWebEngineUrlRequestInfo)
-from qutebrowser.config import websettings
+from qutebrowser.config import websettings, config
from qutebrowser.browser import shared
from qutebrowser.utils import utils, log, debug, qtutils
from qutebrowser.extensions import interceptors
@@ -39,9 +39,9 @@ class WebEngineRequest(interceptors.Request):
_WHITELISTED_REQUEST_METHODS = {QByteArray(b'GET'), QByteArray(b'HEAD')}
- _webengine_info = attr.ib(default=None) # type: QWebEngineUrlRequestInfo
+ _webengine_info: QWebEngineUrlRequestInfo = attr.ib(default=None)
#: If this request has been redirected already
- _redirected = attr.ib(init=False, default=False) # type: bool
+ _redirected: bool = attr.ib(init=False, default=False)
def redirect(self, url: QUrl) -> None:
if self._redirected:
@@ -129,7 +129,7 @@ class RequestInterceptor(QWebEngineUrlRequestInterceptor):
# Qt >= 5.13, GUI thread
profile.setUrlRequestInterceptor(self)
except AttributeError:
- # Qt <= 5.12, IO thread
+ # Qt 5.12, IO thread
profile.setRequestInterceptor(self)
# Gets called in the IO thread -> showing crash window will fail
@@ -204,5 +204,11 @@ class RequestInterceptor(QWebEngineUrlRequestInterceptor):
for header, value in shared.custom_headers(url=url):
info.setHttpHeader(header, value)
+ # Note this is ignored before Qt 5.12.4 and 5.13.1 due to
+ # https://bugreports.qt.io/browse/QTBUG-60203 - there, we set the
+ # commandline-flag in qtargs.py instead.
+ if config.cache['content.headers.referer'] == 'never':
+ info.setHttpHeader(b'Referer', b'')
+
user_agent = websettings.user_agent(url)
info.setHttpHeader(b'User-Agent', user_agent.encode('ascii'))
diff --git a/qutebrowser/browser/webengine/spell.py b/qutebrowser/browser/webengine/spell.py
index 76f1c86a6..417eae9aa 100644
--- a/qutebrowser/browser/webengine/spell.py
+++ b/qutebrowser/browser/webengine/spell.py
@@ -24,23 +24,12 @@ import glob
import os
import os.path
import re
-import shutil
-from PyQt5.QtCore import QLibraryInfo
-from qutebrowser.utils import log, message, standarddir, qtutils
+from qutebrowser.utils import log, message, standarddir
_DICT_VERSION_RE = re.compile(r".+-(?P<version>[0-9]+-[0-9]+?)\.bdic")
-def can_use_data_path():
- """Whether the current Qt version can use a customized path.
-
- Qt >= 5.10 understands QTWEBENGINE_DICTIONARIES_PATH which means we don't
- need to put them to a fixed root-only folder.
- """
- return qtutils.version_check('5.10', compiled=False)
-
-
def version(filename):
"""Extract the version number from the dictionary file name."""
match = _DICT_VERSION_RE.fullmatch(filename)
@@ -51,13 +40,9 @@ def version(filename):
return tuple(int(n) for n in match.group('version').split('-'))
-def dictionary_dir(old=False):
+def dictionary_dir():
"""Return the path (str) to the QtWebEngine's dictionaries directory."""
- if can_use_data_path() and not old:
- datapath = standarddir.data()
- else:
- datapath = QLibraryInfo.location(QLibraryInfo.DataPath)
- return os.path.join(datapath, 'qtwebengine_dictionaries')
+ return os.path.join(standarddir.data(), 'qtwebengine_dictionaries')
def local_files(code):
@@ -91,13 +76,6 @@ def local_filename(code):
def init():
- """Initialize the dictionary path if supported."""
- if can_use_data_path():
- new_dir = dictionary_dir()
- old_dir = dictionary_dir(old=True)
- os.environ['QTWEBENGINE_DICTIONARIES_PATH'] = new_dir
- try:
- if os.path.exists(old_dir) and not os.path.exists(new_dir):
- shutil.copytree(old_dir, new_dir)
- except OSError:
- log.misc.exception("Failed to copy old dictionaries")
+ """Initialize the dictionary path."""
+ dict_dir = dictionary_dir()
+ os.environ['QTWEBENGINE_DICTIONARIES_PATH'] = dict_dir
diff --git a/qutebrowser/browser/webengine/webenginedownloads.py b/qutebrowser/browser/webengine/webenginedownloads.py
index 16c7f020a..ef592c98c 100644
--- a/qutebrowser/browser/webengine/webenginedownloads.py
+++ b/qutebrowser/browser/webengine/webenginedownloads.py
@@ -21,14 +21,13 @@
import re
import os.path
-import urllib
import functools
from PyQt5.QtCore import pyqtSlot, Qt, QUrl, QObject
from PyQt5.QtWebEngineWidgets import QWebEngineDownloadItem
from qutebrowser.browser import downloads, pdfjs
-from qutebrowser.utils import debug, usertypes, message, log, qtutils, objreg
+from qutebrowser.utils import debug, usertypes, message, log, objreg
class DownloadItem(downloads.AbstractDownloadItem):
@@ -84,12 +83,7 @@ class DownloadItem(downloads.AbstractDownloadItem):
self.stats.finish()
elif state == QWebEngineDownloadItem.DownloadInterrupted:
self.successful = False
- # https://bugreports.qt.io/browse/QTBUG-56839
- try:
- reason = self._qt_item.interruptReasonString()
- except AttributeError:
- # Qt < 5.9
- reason = "Download failed"
+ reason = self._qt_item.interruptReasonString()
self._die(reason)
else:
raise ValueError("_on_state_changed was called with unknown state "
@@ -102,22 +96,21 @@ class DownloadItem(downloads.AbstractDownloadItem):
self._qt_item.cancel()
def _do_cancel(self):
+ state = self._qt_item.state()
+ state_name = debug.qenum_key(QWebEngineDownloadItem, state)
+ assert state not in [QWebEngineDownloadItem.DownloadCompleted,
+ QWebEngineDownloadItem.DownloadCancelled], state_name
self._qt_item.cancel()
def retry(self):
state = self._qt_item.state()
if state != QWebEngineDownloadItem.DownloadInterrupted:
log.downloads.warning(
- "Trying to retry download in state {}".format(
+ "Refusing to retry download in state {}".format(
debug.qenum_key(QWebEngineDownloadItem, state)))
return
- try:
- self._qt_item.resume()
- except AttributeError:
- raise downloads.UnsupportedOperationError(
- "Retrying downloads is unsupported with QtWebEngine on "
- "Qt/PyQt < 5.10")
+ self._qt_item.resume()
def _get_open_filename(self):
return self._filename
@@ -233,14 +226,7 @@ def _get_suggested_filename(path):
(?=\.|$) # Begin of extension, or filename without extension
""", re.VERBOSE)
- filename = suffix_re.sub('', filename)
- if not qtutils.version_check('5.9', compiled=False):
- # https://bugreports.qt.io/browse/QTBUG-58155
- filename = urllib.parse.unquote(filename)
- # Doing basename a *second* time because there could be a %2F in
- # there...
- filename = os.path.basename(filename)
- return filename
+ return suffix_re.sub('', filename)
class DownloadManager(downloads.AbstractDownloadManager):
diff --git a/qutebrowser/browser/webengine/webengineelem.py b/qutebrowser/browser/webengine/webengineelem.py
index 649339c50..37b9de364 100644
--- a/qutebrowser/browser/webengine/webengineelem.py
+++ b/qutebrowser/browser/webengine/webengineelem.py
@@ -22,8 +22,7 @@
from typing import (
TYPE_CHECKING, Any, Callable, Dict, Iterator, Optional, Set, Tuple, Union)
-from PyQt5.QtCore import QRect, Qt, QPoint, QEventLoop
-from PyQt5.QtGui import QMouseEvent
+from PyQt5.QtCore import QRect, QEventLoop
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebEngineWidgets import QWebEngineSettings
@@ -230,11 +229,7 @@ class WebEngineElement(webelem.AbstractWebElement):
return url.scheme() not in urlutils.WEBENGINE_SCHEMES
def _click_editable(self, click_target: usertypes.ClickTarget) -> None:
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-58515
- ev = QMouseEvent(QMouseEvent.MouseButtonPress, QPoint(0, 0),
- QPoint(0, 0), QPoint(0, 0), Qt.NoButton, Qt.NoButton,
- Qt.NoModifier, Qt.MouseEventSynthesizedBySystem)
- self._tab.send_event(ev)
+ self._tab.setFocus() # Needed as WORKAROUND on Qt 5.12
# This actually "clicks" the element by calling focus() on it in JS.
self._js_call('focus')
self._move_text_cursor()
diff --git a/qutebrowser/browser/webengine/webengineinspector.py b/qutebrowser/browser/webengine/webengineinspector.py
index afe0d2b48..5685a9538 100644
--- a/qutebrowser/browser/webengine/webengineinspector.py
+++ b/qutebrowser/browser/webengine/webengineinspector.py
@@ -19,17 +19,16 @@
"""Customized QWebInspector for QtWebEngine."""
-import os
import pathlib
-from PyQt5.QtCore import QUrl, QLibraryInfo
+from PyQt5.QtCore import QLibraryInfo
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage
from PyQt5.QtWidgets import QWidget
from qutebrowser.browser import inspector
from qutebrowser.browser.webengine import webenginesettings
from qutebrowser.misc import miscwidgets
-from qutebrowser.utils import version, qtutils
+from qutebrowser.utils import version
class WebEngineInspectorView(QWebEngineView):
@@ -52,47 +51,9 @@ class WebEngineInspectorView(QWebEngineView):
return self.page().inspectedPage().view().createWindow(wintype)
-def supports_new() -> bool:
- """Check whether a new-style inspector is supported."""
- return hasattr(QWebEnginePage, 'setInspectedPage')
-
-
-class LegacyWebEngineInspector(inspector.AbstractWebInspector):
-
- """A web inspector for QtWebEngine without Qt API support.
-
- Only needed with Qt <= 5.10.
- """
-
- def __init__(self, splitter: miscwidgets.InspectorSplitter,
- win_id: int,
- parent: QWidget = None) -> None:
- super().__init__(splitter, win_id, parent)
- self._ensure_enabled()
- view = WebEngineInspectorView()
- self._settings = webenginesettings.WebEngineSettings(view.settings())
- self._set_widget(view)
-
- def _ensure_enabled(self) -> None:
- if 'QTWEBENGINE_REMOTE_DEBUGGING' not in os.environ:
- raise inspector.Error(
- "QtWebEngine inspector is not enabled. See "
- "'qutebrowser --help' for details.")
-
- def inspect(self, page: QWebEnginePage) -> None: # type: ignore[override]
- # We're lying about the URL here a bit, but this way, URL patterns for
- # Qt 5.11/5.12/5.13 also work in this case.
- self._settings.update_for_url(QUrl('chrome-devtools://devtools'))
- port = int(os.environ['QTWEBENGINE_REMOTE_DEBUGGING'])
- self._widget.load(QUrl('http://localhost:{}/'.format(port)))
-
-
class WebEngineInspector(inspector.AbstractWebInspector):
- """A web inspector for QtWebEngine with Qt API support.
-
- Available since Qt 5.11.
- """
+ """A web inspector for QtWebEngine with Qt API support."""
def __init__(self, splitter: miscwidgets.InspectorSplitter,
win_id: int,
@@ -130,4 +91,4 @@ class WebEngineInspector(inspector.AbstractWebInspector):
WORKAROUND for what's likely an unknown Qt bug.
"""
- return qtutils.version_check('5.12')
+ return True
diff --git a/qutebrowser/browser/webengine/webenginequtescheme.py b/qutebrowser/browser/webengine/webenginequtescheme.py
index 879f8aeca..f1eebd75d 100644
--- a/qutebrowser/browser/webengine/webenginequtescheme.py
+++ b/qutebrowser/browser/webengine/webenginequtescheme.py
@@ -21,12 +21,8 @@
from PyQt5.QtCore import QBuffer, QIODevice, QUrl
from PyQt5.QtWebEngineCore import (QWebEngineUrlSchemeHandler,
- QWebEngineUrlRequestJob)
-try:
- from PyQt5.QtWebEngineCore import QWebEngineUrlScheme
-except ImportError:
- # Added in Qt 5.12
- QWebEngineUrlScheme = None # type: ignore[misc, assignment]
+ QWebEngineUrlRequestJob,
+ QWebEngineUrlScheme)
from qutebrowser.browser import qutescheme
from qutebrowser.utils import log, qtutils
@@ -42,11 +38,6 @@ class QuteSchemeHandler(QWebEngineUrlSchemeHandler):
assert QWebEngineUrlScheme.schemeByName(b'qute') is not None
profile.installUrlSchemeHandler(b'qute', self)
- if (qtutils.version_check('5.11', compiled=False) and
- not qtutils.version_check('5.12', compiled=False)):
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-63378
- profile.installUrlSchemeHandler(b'chrome-error', self)
- profile.installUrlSchemeHandler(b'chrome-extension', self)
def _check_initiator(self, job):
"""Check whether the initiator of the job should be allowed.
@@ -60,29 +51,16 @@ class QuteSchemeHandler(QWebEngineUrlSchemeHandler):
Return:
True if the initiator is allowed, False if it was blocked.
"""
- try:
- initiator = job.initiator()
- request_url = job.requestUrl()
- except AttributeError:
- # Added in Qt 5.11
- return True
+ initiator = job.initiator()
+ request_url = job.requestUrl()
# https://codereview.qt-project.org/#/c/234849/
is_opaque = initiator == QUrl('null')
target = request_url.scheme(), request_url.host()
- if is_opaque and not qtutils.version_check('5.12'):
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-70421
- # When we don't register the qute:// scheme, all requests are
- # flagged as opaque.
- return True
-
- if (target == ('qute', 'testdata') and
- is_opaque and
- qtutils.version_check('5.12')):
- # Allow requests to qute://testdata, as this is needed in Qt 5.12
- # for all tests to work properly. No qute://testdata handler is
- # installed outside of tests.
+ if target == ('qute', 'testdata') and is_opaque:
+ # Allow requests to qute://testdata, as this is needed for all tests to work
+ # properly. No qute://testdata handler is installed outside of tests.
return True
if initiator.isValid() and initiator.scheme() != 'qute':
@@ -105,11 +83,6 @@ class QuteSchemeHandler(QWebEngineUrlSchemeHandler):
"""
url = job.requestUrl()
- if url.scheme() in ['chrome-error', 'chrome-extension']:
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-63378
- job.fail(QWebEngineUrlRequestJob.UrlInvalid)
- return
-
if not self._check_initiator(job):
return
diff --git a/qutebrowser/browser/webengine/webenginesettings.py b/qutebrowser/browser/webengine/webenginesettings.py
index d93f72f56..1526574a7 100644
--- a/qutebrowser/browser/webengine/webenginesettings.py
+++ b/qutebrowser/browser/webengine/webenginesettings.py
@@ -29,14 +29,12 @@ import operator
from typing import cast, Any, List, Optional, Tuple, Union
from PyQt5.QtGui import QFont
-from PyQt5.QtWebEngineWidgets import (QWebEngineSettings, QWebEngineProfile,
- QWebEnginePage)
+from PyQt5.QtWebEngineWidgets import QWebEngineSettings, QWebEngineProfile
from qutebrowser.browser.webengine import spell, webenginequtescheme
from qutebrowser.config import config, websettings
from qutebrowser.config.websettings import AttributeInfo as Attr
-from qutebrowser.utils import (utils, standarddir, qtutils, message, log,
- urlmatch, usertypes)
+from qutebrowser.utils import standarddir, qtutils, message, log, urlmatch, usertypes
# The default QWebEngineProfile
default_profile = cast(QWebEngineProfile, None)
@@ -126,8 +124,7 @@ class WebEngineSettings(websettings.AbstractSettings):
'content.desktop_capture':
Attr(QWebEngineSettings.ScreenCaptureEnabled,
converter=lambda val: True if val == 'ask' else val),
- # 'ask' is handled via the permission system,
- # or a hardcoded dialog on Qt < 5.10
+ # 'ask' is handled via the permission system
'input.spatial_navigation':
Attr(QWebEngineSettings.SpatialNavigationEnabled),
@@ -136,6 +133,16 @@ class WebEngineSettings(websettings.AbstractSettings):
'scrolling.smooth':
Attr(QWebEngineSettings.ScrollAnimatorEnabled),
+
+ 'content.print_element_backgrounds':
+ Attr(QWebEngineSettings.PrintElementBackgrounds),
+
+ 'content.autoplay':
+ Attr(QWebEngineSettings.PlaybackRequiresUserGesture,
+ converter=operator.not_),
+
+ 'content.dns_prefetch':
+ Attr(QWebEngineSettings.DnsPrefetchEnabled),
}
_FONT_SIZES = {
@@ -158,18 +165,14 @@ class WebEngineSettings(websettings.AbstractSettings):
'fonts.web.family.fantasy': QWebEngineSettings.FantasyFont,
}
- # Only Qt >= 5.11 support UnknownUrlSchemePolicy
- try:
- _UNKNOWN_URL_SCHEME_POLICY = {
- 'disallow':
- QWebEngineSettings.DisallowUnknownUrlSchemes,
- 'allow-from-user-interaction':
- QWebEngineSettings.AllowUnknownUrlSchemesFromUserInteraction,
- 'allow-all':
- QWebEngineSettings.AllowAllUnknownUrlSchemes,
- }
- except AttributeError:
- _UNKNOWN_URL_SCHEME_POLICY = None
+ _UNKNOWN_URL_SCHEME_POLICY = {
+ 'disallow':
+ QWebEngineSettings.DisallowUnknownUrlSchemes,
+ 'allow-from-user-interaction':
+ QWebEngineSettings.AllowUnknownUrlSchemesFromUserInteraction,
+ 'allow-all':
+ QWebEngineSettings.AllowAllUnknownUrlSchemes,
+ }
# Mapping from WebEngineSettings::initDefaults in
# qtwebengine/src/core/web_engine_settings.cpp
@@ -200,39 +203,13 @@ class WebEngineSettings(websettings.AbstractSettings):
def _update_setting(self, setting, value):
if setting == 'content.unknown_url_scheme_policy':
- if self._UNKNOWN_URL_SCHEME_POLICY:
- return self.set_unknown_url_scheme_policy(value)
- return False
+ return self.set_unknown_url_scheme_policy(value)
return super()._update_setting(setting, value)
def init_settings(self):
super().init_settings()
self.update_setting('content.unknown_url_scheme_policy')
- def __init__(self, settings):
- super().__init__(settings)
- # Attributes which don't exist in all Qt versions.
- new_attributes = {
- # Qt 5.8
- 'content.print_element_backgrounds':
- ('PrintElementBackgrounds', None),
-
- # Qt 5.11
- 'content.autoplay':
- ('PlaybackRequiresUserGesture', operator.not_),
-
- # Qt 5.12
- 'content.dns_prefetch':
- ('DnsPrefetchEnabled', None),
- }
- for name, (attribute, converter) in new_attributes.items():
- try:
- value = getattr(QWebEngineSettings, attribute)
- except AttributeError:
- continue
-
- self._ATTRIBUTES[name] = Attr(value, converter=converter)
-
class ProfileSetter:
@@ -246,8 +223,7 @@ class ProfileSetter:
self.set_http_headers()
self.set_http_cache_size()
self._set_hardcoded_settings()
- if qtutils.version_check('5.8'):
- self.set_dictionary_language()
+ self.set_dictionary_language()
def _set_hardcoded_settings(self):
"""Set up settings with a fixed value."""
@@ -255,13 +231,8 @@ class ProfileSetter:
settings.setAttribute(
QWebEngineSettings.FullScreenSupportEnabled, True)
-
- try:
- settings.setAttribute(
- QWebEngineSettings.FocusOnNavigationEnabled, False)
- except AttributeError:
- # Added in Qt 5.8
- pass
+ settings.setAttribute(
+ QWebEngineSettings.FocusOnNavigationEnabled, False)
try:
settings.setAttribute(QWebEngineSettings.PdfViewerEnabled, False)
@@ -328,8 +299,7 @@ def _update_settings(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))
+ header_bug_fixed = qtutils.version_check('5.15', compiled=False)
if option in ['content.headers.user_agent',
'content.headers.accept_language'] and header_bug_fixed:
@@ -340,9 +310,7 @@ def _update_settings(option):
default_profile.setter.set_http_cache_size()
if private_profile:
private_profile.setter.set_http_cache_size()
- elif (option == 'content.cookies.store' and
- # https://bugreports.qt.io/browse/QTBUG-58650
- qtutils.version_check('5.9', compiled=False)):
+ elif option == 'content.cookies.store':
default_profile.setter.set_persistent_cookie_policy()
# We're not touching the private profile's cookie policy.
elif option == 'spellcheck.languages':
@@ -436,10 +404,6 @@ def _init_site_specific_quirks():
'https://*.slack.com/*': new_chrome_ua,
}
- if not qtutils.version_check('5.9'):
- # Shows 502 Bad Gateway with the Qt 5.7 UA.
- user_agents['https://www.dell.com/support/*'] = new_chrome_ua
-
for pattern, ua in user_agents.items():
config.instance.set_obj('content.headers.user_agent', ua,
pattern=urlmatch.UrlPattern(pattern),
@@ -450,10 +414,9 @@ def _init_devtools_settings():
"""Make sure the devtools always get images/JS permissions."""
settings: List[Tuple[str, Any]] = [
('content.javascript.enabled', True),
- ('content.images', True)
+ ('content.images', True),
+ ('content.cookies.accept', 'all'),
]
- if qtutils.version_check('5.11'):
- settings.append(('content.cookies.accept', 'all'))
for setting, value in settings:
for pattern in ['chrome-devtools://*', 'devtools://*']:
@@ -462,12 +425,8 @@ def _init_devtools_settings():
hide_userconfig=True)
-def init(args):
+def init():
"""Initialize the global QWebSettings."""
- if (args.enable_webengine_inspector and
- not hasattr(QWebEnginePage, 'setInspectedPage')): # only Qt < 5.11
- os.environ['QTWEBENGINE_REMOTE_DEBUGGING'] = str(utils.random_port())
-
webenginequtescheme.init()
spell.init()
diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py
index f105bf2f4..f026b7c23 100644
--- a/qutebrowser/browser/webengine/webenginetab.py
+++ b/qutebrowser/browser/webengine/webenginetab.py
@@ -23,15 +23,14 @@ import math
import functools
import re
import html as html_utils
-from typing import cast, Optional, Union
+from typing import cast, Union
-from PyQt5.QtCore import (pyqtSignal, pyqtSlot, Qt, QPoint, QPointF, QUrl,
- QTimer, QObject)
+from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QPoint, QPointF, QUrl, QObject
from PyQt5.QtNetwork import QAuthenticator
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtWebEngineWidgets import QWebEnginePage, QWebEngineScript, QWebEngineHistory
-from qutebrowser.config import configdata, config
+from qutebrowser.config import config
from qutebrowser.browser import (browsertab, eventfilter, shared, webelem,
history, greasemonkey)
from qutebrowser.browser.webengine import (webview, webengineelem, tabhistory,
@@ -118,18 +117,7 @@ class WebEngineAction(browsertab.AbstractAction):
self._show_source_pygments()
return
- try:
- self._widget.triggerPageAction(QWebEnginePage.ViewSource)
- except AttributeError:
- # Qt < 5.8
- tb = objreg.get('tabbed-browser', scope='window',
- window=self._tab.win_id)
- urlstr = self._tab.url().toString(
- QUrl.RemoveUserInfo) # type: ignore[arg-type]
- # The original URL becomes the path of a view-source: URL
- # (without a host), but query/fragment should stay.
- url = QUrl('view-source:' + urlstr)
- tb.tabopen(url, background=False, related=True)
+ self._widget.triggerPageAction(QWebEnginePage.ViewSource)
class WebEnginePrinting(browsertab.AbstractPrinting):
@@ -139,11 +127,6 @@ class WebEnginePrinting(browsertab.AbstractPrinting):
def check_pdf_support(self):
pass
- def check_printer_support(self):
- if not hasattr(self._widget.page(), 'print'):
- raise browsertab.WebTabError(
- "Printing is unsupported with QtWebEngine on Qt < 5.8")
-
def check_preview_support(self):
raise browsertab.WebTabError(
"Print previews are unsupported with QtWebEngine")
@@ -360,8 +343,6 @@ class WebEngineCaret(browsertab.AbstractCaret):
def _flags(self):
"""Get flags to pass to JS."""
flags = set()
- if qtutils.version_check('5.7.1', compiled=False):
- flags.add('filter-prefix')
if utils.is_windows:
flags.add('windows')
return list(flags)
@@ -374,7 +355,6 @@ class WebEngineCaret(browsertab.AbstractCaret):
if self._tab.search.search_displayed:
# We are currently in search mode.
# convert the search to a blue selection so we can operate on it
- # https://bugreports.qt.io/browse/QTBUG-60673
self._tab.search.clear()
self._tab.run_js_async(
@@ -507,7 +487,6 @@ class WebEngineCaret(browsertab.AbstractCaret):
if self._tab.search.search_displayed:
# We are currently in search mode.
# let's click the link via a fake-click
- # https://bugreports.qt.io/browse/QTBUG-60673
self._tab.search.clear()
log.webview.debug("Clicking a searched link via fake key press.")
@@ -673,15 +652,6 @@ class WebEngineHistoryPrivate(browsertab.AbstractHistoryPrivate):
self._history = cast(QWebEngineHistory, None)
def serialize(self):
- if not qtutils.version_check('5.9', compiled=False):
- # WORKAROUND for
- # https://github.com/qutebrowser/qutebrowser/issues/2289
- # Don't use the history's currentItem here, because of
- # https://bugreports.qt.io/browse/QTBUG-59599 and because it doesn't
- # contain view-source.
- scheme = self._tab.url().scheme()
- if scheme in ['view-source', 'chrome']:
- raise browsertab.WebTabError("Can't serialize special URL!")
return qtutils.serialize(self._history)
def deserialize(self, data):
@@ -912,8 +882,10 @@ class _WebEnginePermissions(QObject):
QWebEnginePage.Geolocation: 'content.geolocation',
QWebEnginePage.MediaAudioCapture: 'content.media.audio_capture',
QWebEnginePage.MediaVideoCapture: 'content.media.video_capture',
- QWebEnginePage.MediaAudioVideoCapture:
- 'content.media.audio_video_capture',
+ QWebEnginePage.MediaAudioVideoCapture: 'content.media.audio_video_capture',
+ QWebEnginePage.MouseLock: 'content.mouse_lock',
+ QWebEnginePage.DesktopVideoCapture: 'content.desktop_capture',
+ QWebEnginePage.DesktopAudioVideoCapture: 'content.desktop_capture',
}
_messages = {
@@ -922,42 +894,15 @@ class _WebEnginePermissions(QObject):
QWebEnginePage.MediaAudioCapture: 'record audio',
QWebEnginePage.MediaVideoCapture: 'record video',
QWebEnginePage.MediaAudioVideoCapture: 'record audio/video',
+ QWebEnginePage.MouseLock: 'hide your mouse pointer',
+ QWebEnginePage.DesktopVideoCapture: 'capture your desktop',
+ QWebEnginePage.DesktopAudioVideoCapture: 'capture your desktop and audio',
}
def __init__(self, tab, parent=None):
super().__init__(parent)
self._tab = tab
self._widget = cast(QWidget, None)
-
- try:
- self._options.update({
- QWebEnginePage.MouseLock:
- 'content.mouse_lock',
- })
- self._messages.update({
- QWebEnginePage.MouseLock:
- 'hide your mouse pointer',
- })
- except AttributeError:
- # Added in Qt 5.8
- pass
- try:
- self._options.update({
- QWebEnginePage.DesktopVideoCapture:
- 'content.desktop_capture',
- QWebEnginePage.DesktopAudioVideoCapture:
- 'content.desktop_capture',
- })
- self._messages.update({
- QWebEnginePage.DesktopVideoCapture:
- 'capture your desktop',
- QWebEnginePage.DesktopAudioVideoCapture:
- 'capture your desktop and audio',
- })
- except AttributeError:
- # Added in Qt 5.10
- pass
-
assert self._options.keys() == self._messages.keys()
def connect_signals(self):
@@ -968,11 +913,9 @@ class _WebEnginePermissions(QObject):
page.featurePermissionRequested.connect(
self._on_feature_permission_requested)
- if qtutils.version_check('5.11'):
- page.quotaRequested.connect(
- self._on_quota_requested)
- page.registerProtocolHandlerRequested.connect(
- self._on_register_protocol_handler_requested)
+ page.quotaRequested.connect(self._on_quota_requested)
+ page.registerProtocolHandlerRequested.connect(
+ self._on_register_protocol_handler_requested)
@pyqtSlot('QWebEngineFullScreenRequest')
def _on_fullscreen_requested(self, request):
@@ -1021,7 +964,6 @@ class _WebEnginePermissions(QObject):
return
if (
- hasattr(QWebEnginePage, 'DesktopVideoCapture') and
feature in [QWebEnginePage.DesktopVideoCapture,
QWebEnginePage.DesktopAudioVideoCapture] and
qtutils.version_check('5.13', compiled=False) and
@@ -1110,35 +1052,21 @@ class _WebEngineScripts(QObject):
def _inject_early_js(self, name, js_code, *,
world=QWebEngineScript.ApplicationWorld,
subframes=False):
- """Inject the given script to run early on a page load.
-
- This runs the script both on DocumentCreation and DocumentReady as on
- some internal pages, DocumentCreation will not work.
-
- That is a WORKAROUND for https://bugreports.qt.io/browse/QTBUG-66011
- """
- scripts = self._widget.page().scripts()
- for injection in ['creation', 'ready']:
- injection_points = {
- 'creation': QWebEngineScript.DocumentCreation,
- 'ready': QWebEngineScript.DocumentReady,
- }
- script = QWebEngineScript()
- script.setInjectionPoint(injection_points[injection])
- script.setSourceCode(js_code)
- script.setWorldId(world)
- script.setRunsOnSubFrames(subframes)
- script.setName('_qute_{}_{}'.format(name, injection))
- scripts.insert(script)
+ """Inject the given script to run early on a page load."""
+ script = QWebEngineScript()
+ script.setInjectionPoint(QWebEngineScript.DocumentCreation)
+ script.setSourceCode(js_code)
+ script.setWorldId(world)
+ script.setRunsOnSubFrames(subframes)
+ script.setName(f'_qute_{name}')
+ self._widget.page().scripts().insert(script)
def _remove_early_js(self, name):
"""Remove an early QWebEngineScript."""
scripts = self._widget.page().scripts()
- for injection in ['creation', 'ready']:
- full_name = '_qute_{}_{}'.format(name, injection)
- script = scripts.findScript(full_name)
- if not script.isNull():
- scripts.remove(script)
+ script = scripts.findScript(f'_qute_{name}')
+ if not script.isNull():
+ scripts.remove(script)
def init(self):
"""Initialize global qutebrowser JavaScript."""
@@ -1148,29 +1076,14 @@ class _WebEngineScripts(QObject):
utils.read_file('javascript/webelem.js'),
utils.read_file('javascript/caret.js'),
)
- if not qtutils.version_check('5.12'):
- # WORKAROUND for Qt versions < 5.12 not exposing window.print().
- # Qt 5.12 has a printRequested() signal so we don't need this hack
- # anymore.
- self._inject_early_js('js',
- utils.read_file('javascript/print.js'),
- subframes=True,
- world=QWebEngineScript.MainWorld)
# FIXME:qtwebengine what about subframes=True?
self._inject_early_js('js', js_code, subframes=True)
self._init_stylesheet()
- # The Greasemonkey metadata block support in QtWebEngine only starts at
- # Qt 5.8. With 5.7.1, we need to inject the scripts ourselves in
- # response to urlChanged.
- if not qtutils.version_check('5.8'):
- self._tab.url_changed.connect(
- self._inject_greasemonkey_scripts_for_url)
- else:
- self._greasemonkey.scripts_reloaded.connect(
- self._inject_all_greasemonkey_scripts)
- self._inject_all_greasemonkey_scripts()
- self._inject_site_specific_quirks()
+ self._greasemonkey.scripts_reloaded.connect(
+ self._inject_all_greasemonkey_scripts)
+ self._inject_all_greasemonkey_scripts()
+ self._inject_site_specific_quirks()
def _init_stylesheet(self):
"""Initialize custom stylesheets.
@@ -1187,16 +1100,6 @@ class _WebEngineScripts(QObject):
)
self._inject_early_js('stylesheet', js_code, subframes=True)
- @pyqtSlot(QUrl)
- def _inject_greasemonkey_scripts_for_url(self, url):
- matching_scripts = self._greasemonkey.scripts_for(url)
- self._inject_greasemonkey_scripts(
- matching_scripts.start, QWebEngineScript.DocumentCreation, True)
- self._inject_greasemonkey_scripts(
- matching_scripts.end, QWebEngineScript.DocumentReady, False)
- self._inject_greasemonkey_scripts(
- matching_scripts.idle, QWebEngineScript.Deferred, False)
-
@pyqtSlot()
def _inject_all_greasemonkey_scripts(self):
scripts = self._greasemonkey.all_scripts()
@@ -1279,13 +1182,7 @@ class _WebEngineScripts(QObject):
page_scripts.insert(new_script)
def _inject_site_specific_quirks(self):
- """Add site-specific quirk scripts.
-
- NOTE: This isn't implemented for Qt 5.7 because of different UserScript
- 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.
- """
+ """Add site-specific quirk scripts."""
if not config.val.content.site_specific_quirks:
return
@@ -1301,6 +1198,9 @@ class _WebEngineScripts(QObject):
quirks.append(('globalthis_quirk',
QWebEngineScript.DocumentCreation,
QWebEngineScript.MainWorld))
+ quirks.append(('object_fromentries_quirk',
+ QWebEngineScript.DocumentCreation,
+ QWebEngineScript.MainWorld))
for filename, injection_point, world in quirks:
script = QWebEngineScript()
@@ -1376,7 +1276,6 @@ class WebEngineTab(browsertab.AbstractTab):
self.backend = usertypes.Backend.QtWebEngine
self._child_event_filter = None
self._saved_zoom = None
- self._reload_url: Optional[QUrl] = None
self._scripts.init()
def _set_widget(self, widget):
@@ -1396,13 +1295,6 @@ class WebEngineTab(browsertab.AbstractTab):
parent=self)
self._widget.installEventFilter(self._child_event_filter)
- if qtutils.version_check('5.11', compiled=False, exact=True):
- focus_event_filter = eventfilter.FocusWorkaroundEventFilter(
- win_id=self.win_id,
- widget=self._widget,
- parent=self)
- self._widget.installEventFilter(focus_event_filter)
-
@pyqtSlot()
def _restore_zoom(self):
if sip.isdeleted(self._widget):
@@ -1413,20 +1305,17 @@ class WebEngineTab(browsertab.AbstractTab):
self.zoom.set_factor(self._saved_zoom)
self._saved_zoom = None
- def load_url(self, url, *, emit_before_load_started=True):
+ def load_url(self, url):
"""Load the given URL in this tab.
Arguments:
url: The QUrl to load.
- emit_before_load_started: If set to False, before_load_started is
- not emitted.
"""
if sip.isdeleted(self._widget):
# https://github.com/qutebrowser/qutebrowser/issues/3896
return
self._saved_zoom = self.zoom.factor()
- self._load_url_prepare(
- url, emit_before_load_started=emit_before_load_started)
+ self._load_url_prepare(url)
self._widget.load(url)
def url(self, *, requested=False):
@@ -1536,14 +1425,12 @@ class WebEngineTab(browsertab.AbstractTab):
mode=usertypes.PromptMode.user_pwd,
abort_on=[self.abort_questions], url=urlstr)
- if answer is not None:
- authenticator.setUser(answer.user)
- authenticator.setPassword(answer.password)
- else:
- try:
- sip.assign(authenticator, QAuthenticator())
- except AttributeError:
- self._show_error_page(url, "Proxy authentication required")
+ if answer is None:
+ sip.assign(authenticator, QAuthenticator())
+ return
+
+ authenticator.setUser(answer.user)
+ authenticator.setPassword(answer.password)
@pyqtSlot(QUrl, 'QAuthenticator*')
def _on_authentication_required(self, url, authenticator):
@@ -1561,12 +1448,7 @@ class WebEngineTab(browsertab.AbstractTab):
url, authenticator, abort_on=[self.abort_questions])
if not netrc_success and answer is None:
log.network.debug("Aborting auth")
- try:
- sip.assign(authenticator, QAuthenticator())
- except AttributeError:
- # WORKAROUND for
- # https://www.riverbankcomputing.com/pipermail/pyqt/2016-December/038400.html
- self._show_error_page(url, "Authentication required")
+ sip.assign(authenticator, QAuthenticator())
@pyqtSlot()
def _on_load_started(self):
@@ -1614,9 +1496,6 @@ class WebEngineTab(browsertab.AbstractTab):
WORKAROUND for https://bugreports.qt.io/browse/QTBUG-66643
WORKAROUND for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=882805
-
- Needs to check the page content as a WORKAROUND for
- https://bugreports.qt.io/browse/QTBUG-66661
"""
match = re.search(r'"errorCode":"([^"]*)"', html)
if match is None:
@@ -1639,7 +1518,6 @@ class WebEngineTab(browsertab.AbstractTab):
"""
super()._on_load_progress(perc)
if (perc == 100 and
- qtutils.version_check('5.10', compiled=False) and
self.load_status() != usertypes.LoadStatus.error):
self._update_load_status(ok=True)
@@ -1648,28 +1526,14 @@ class WebEngineTab(browsertab.AbstractTab):
"""QtWebEngine-specific loadFinished workarounds."""
super()._on_load_finished(ok)
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-65223
- if qtutils.version_check('5.10', compiled=False):
- if not ok:
- self._update_load_status(ok)
- else:
+ if not ok:
+ # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-65223
self._update_load_status(ok)
- if not ok:
self.dump_async(functools.partial(
self._error_page_workaround,
self.settings.test_attribute('content.javascript.enabled')))
- if ok and self._reload_url is not None:
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-66656
- log.config.debug(
- "Loading {} again because of config change".format(
- self._reload_url.toDisplayString()))
- QTimer.singleShot(100, functools.partial(
- self.load_url, self._reload_url,
- emit_before_load_started=False))
- self._reload_url = None
-
@pyqtSlot(certificateerror.CertificateErrorWrapper)
def _on_ssl_errors(self, error):
url = error.url()
@@ -1687,23 +1551,17 @@ class WebEngineTab(browsertab.AbstractTab):
log.network.debug("ignore {}, URL {}, requested {}".format(
error.ignore, url, self.url(requested=True)))
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-56207
- show_cert_error = (
- not qtutils.version_check('5.9') and
- not error.ignore
- )
# WORKAROUND for https://codereview.qt-project.org/c/qt/qtwebengine/+/270556
show_non_overr_cert_error = (
not error.is_overridable() and (
# Affected Qt versions:
# 5.13 before 5.13.2
# 5.12 before 5.12.6
- # < 5.12
+ # < 5.12 (which is unsupported)
(qtutils.version_check('5.13') and
not qtutils.version_check('5.13.2')) or
(qtutils.version_check('5.12') and
- not qtutils.version_check('5.12.6')) or
- not qtutils.version_check('5.12')
+ not qtutils.version_check('5.12.6'))
)
)
@@ -1712,20 +1570,10 @@ class WebEngineTab(browsertab.AbstractTab):
# However, self.url() is not available yet and the requested URL
# might not match the URL we get from the error - so we just apply a
# heuristic here.
- if ((show_cert_error or show_non_overr_cert_error) and
+ if (show_non_overr_cert_error and
url.matches(self.data.last_navigation.url, QUrl.RemoveScheme)):
self._show_error_page(url, str(error))
- @pyqtSlot(QUrl)
- def _on_before_load_started(self, url):
- """If we know we're going to visit a URL soon, change the settings.
-
- This is a WORKAROUND for https://bugreports.qt.io/browse/QTBUG-66656
- """
- super()._on_before_load_started(url)
- if not qtutils.version_check('5.11.1', compiled=False):
- self.settings.update_for_url(url)
-
@pyqtSlot()
def _on_print_requested(self):
"""Slot for window.print() in JS."""
@@ -1753,38 +1601,10 @@ class WebEngineTab(browsertab.AbstractTab):
def _on_navigation_request(self, navigation):
super()._on_navigation_request(navigation)
- if navigation.url == QUrl('qute://print'):
- self._on_print_requested()
- navigation.accepted = False
-
if not navigation.accepted or not navigation.is_main_frame:
return
- settings_needing_reload = {
- 'content.plugins',
- 'content.javascript.enabled',
- 'content.javascript.can_access_clipboard',
- 'content.print_element_backgrounds',
- 'input.spatial_navigation',
- }
- assert settings_needing_reload.issubset(configdata.DATA)
-
- changed = self.settings.update_for_url(navigation.url)
- reload_needed = bool(changed & settings_needing_reload)
-
- # On Qt < 5.11, we don't don't need a reload when type == link_clicked.
- # On Qt 5.11.0, we always need a reload.
- # On Qt > 5.11.0, we never need a reload:
- # https://codereview.qt-project.org/#/c/229525/1
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-66656
- if qtutils.version_check('5.11.1', compiled=False):
- reload_needed = False
- elif not qtutils.version_check('5.11.0', exact=True, compiled=False):
- if navigation.navigation_type == navigation.Type.link_clicked:
- reload_needed = False
-
- if reload_needed:
- self._reload_url = navigation.url
+ self.settings.update_for_url(navigation.url)
def _on_select_client_certificate(self, selection):
"""Handle client certificates.
@@ -1831,9 +1651,7 @@ class WebEngineTab(browsertab.AbstractTab):
self._on_proxy_authentication_required)
page.contentsSizeChanged.connect(self.contents_size_changed)
page.navigation_request.connect(self._on_navigation_request)
-
- if qtutils.version_check('5.12'):
- page.printRequested.connect(self._on_print_requested)
+ page.printRequested.connect(self._on_print_requested)
try:
# pylint: disable=unused-import
@@ -1861,7 +1679,6 @@ class WebEngineTab(browsertab.AbstractTab):
# Added in Qt 5.15.0
pass
- self.before_load_started.connect(self._on_before_load_started)
self.shutting_down.connect(self.abort_questions)
self.load_started.connect(self.abort_questions)
diff --git a/qutebrowser/browser/webengine/webview.py b/qutebrowser/browser/webengine/webview.py
index 934fe2dee..23af73e59 100644
--- a/qutebrowser/browser/webengine/webview.py
+++ b/qutebrowser/browser/webengine/webview.py
@@ -19,19 +19,15 @@
"""The main browser widget for QtWebEngine."""
-from typing import Optional
-from PyQt5.QtCore import pyqtSignal, QUrl, PYQT_VERSION
+from PyQt5.QtCore import pyqtSignal, QUrl
from PyQt5.QtGui import QPalette
-from PyQt5.QtWidgets import QWidget
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage
from qutebrowser.browser import shared
from qutebrowser.browser.webengine import webenginesettings, certificateerror
from qutebrowser.config import config
-from qutebrowser.utils import log, debug, usertypes, qtutils
-from qutebrowser.misc import miscwidgets, objects
-from qutebrowser.qt import sip
+from qutebrowser.utils import log, debug, usertypes
class WebEngineView(QWebEngineView):
@@ -54,42 +50,9 @@ class WebEngineView(QWebEngineView):
parent=self)
self.setPage(page)
- if qtutils.version_check('5.11.0', compiled=False, exact=True):
- # Set a PseudoLayout as a WORKAROUND for
- # https://bugreports.qt.io/browse/QTBUG-68224
- # and other related issues. (Fixed in Qt 5.11.1)
- sip.delete(self.layout())
- self._layout = miscwidgets.PseudoLayout(self)
-
def render_widget(self):
- """Get the RenderWidgetHostViewQt for this view.
-
- Normally, this would always be the focusProxy().
- However, it sometimes isn't, so we use this as a WORKAROUND for
- https://bugreports.qt.io/browse/QTBUG-68727
-
- The above bug got introduced in Qt 5.11.0 and fixed in 5.12.0.
- """
- proxy: Optional[QWidget] = self.focusProxy()
-
- 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)]
-
- if children:
- log.webview.debug("Found possibly lost focusProxy: {}"
- .format(children))
-
- return children[-1] if children else None
+ """Get the RenderWidgetHostViewQt for this view."""
+ return self.focusProxy()
def shutdown(self):
self.page().shutdown()
@@ -207,42 +170,29 @@ class WebEnginePage(QWebEnginePage):
"""Override javaScriptConfirm to use qutebrowser prompts."""
if self._is_shutting_down:
return False
- escape_msg = qtutils.version_check('5.11', compiled=False)
try:
- return shared.javascript_confirm(url, js_msg,
- abort_on=[self.loadStarted,
- self.shutting_down],
- escape_msg=escape_msg)
+ return shared.javascript_confirm(
+ url, js_msg, abort_on=[self.loadStarted, self.shutting_down])
except shared.CallSuper:
return super().javaScriptConfirm(url, js_msg)
- if PYQT_VERSION > 0x050700:
- # WORKAROUND
- # Can't override javaScriptPrompt with older PyQt versions
- # https://www.riverbankcomputing.com/pipermail/pyqt/2016-November/038293.html
- def javaScriptPrompt(self, url, js_msg, default):
- """Override javaScriptPrompt to use qutebrowser prompts."""
- escape_msg = qtutils.version_check('5.11', compiled=False)
- if self._is_shutting_down:
- return (False, "")
- try:
- return shared.javascript_prompt(url, js_msg, default,
- abort_on=[self.loadStarted,
- self.shutting_down],
- escape_msg=escape_msg)
- except shared.CallSuper:
- return super().javaScriptPrompt(url, js_msg, default)
+ def javaScriptPrompt(self, url, js_msg, default):
+ """Override javaScriptPrompt to use qutebrowser prompts."""
+ if self._is_shutting_down:
+ return (False, "")
+ try:
+ return shared.javascript_prompt(
+ url, js_msg, default, abort_on=[self.loadStarted, self.shutting_down])
+ except shared.CallSuper:
+ return super().javaScriptPrompt(url, js_msg, default)
def javaScriptAlert(self, url, js_msg):
"""Override javaScriptAlert to use qutebrowser prompts."""
if self._is_shutting_down:
return
- escape_msg = qtutils.version_check('5.11', compiled=False)
try:
- shared.javascript_alert(url, js_msg,
- abort_on=[self.loadStarted,
- self.shutting_down],
- escape_msg=escape_msg)
+ shared.javascript_alert(
+ url, js_msg, abort_on=[self.loadStarted, self.shutting_down])
except shared.CallSuper:
super().javaScriptAlert(url, js_msg)
diff --git a/qutebrowser/browser/webkit/cache.py b/qutebrowser/browser/webkit/cache.py
index dd774ea5a..79c4e9e82 100644
--- a/qutebrowser/browser/webkit/cache.py
+++ b/qutebrowser/browser/webkit/cache.py
@@ -25,7 +25,7 @@ import os.path
from PyQt5.QtNetwork import QNetworkDiskCache
from qutebrowser.config import config
-from qutebrowser.utils import utils, qtutils, standarddir
+from qutebrowser.utils import utils, standarddir
diskcache = cast('DiskCache', None)
@@ -52,9 +52,6 @@ class DiskCache(QNetworkDiskCache):
size = config.val.content.cache.size
if size is None:
size = 1024 * 1024 * 50 # default from QNetworkDiskCachePrivate
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-59909
- if not qtutils.version_check('5.9', compiled=False):
- size = 0 # pragma: no cover
self.setMaximumCacheSize(size)
diff --git a/qutebrowser/browser/webkit/mhtml.py b/qutebrowser/browser/webkit/mhtml.py
index 6e2442575..794e1b73b 100644
--- a/qutebrowser/browser/webkit/mhtml.py
+++ b/qutebrowser/browser/webkit/mhtml.py
@@ -62,7 +62,7 @@ _CSS_URL_PATTERNS = [re.compile(x) for x in [
]]
-def _get_css_imports_regex(data):
+def _get_css_imports(data):
"""Return all assets that are referenced in the given CSS document.
The returned URLs are relative to the stylesheet's URL.
@@ -79,55 +79,6 @@ def _get_css_imports_regex(data):
return urls
-def _get_css_imports_cssutils(data, inline=False):
- """Return all assets that are referenced in the given CSS document.
-
- The returned URLs are relative to the stylesheet's URL.
-
- Args:
- data: The content of the stylesheet to scan as string.
- inline: True if the argument is an inline HTML style attribute.
- """
- try:
- import cssutils
- except ImportError:
- return None
-
- # We don't care about invalid CSS data, this will only litter the log
- # output with CSS errors
- parser = cssutils.CSSParser(loglevel=100,
- fetcher=lambda url: (None, ""), validate=False)
- if not inline:
- sheet = parser.parseString(data)
- return list(cssutils.getUrls(sheet))
- else:
- urls = []
- declaration = parser.parseStyle(data)
- # prop = background, color, margin, ...
- for prop in declaration:
- # value = red, 10px, url(foobar), ...
- for value in prop.propertyValue:
- if isinstance(value, cssutils.css.URIValue):
- if value.uri:
- urls.append(value.uri)
- return urls
-
-
-def _get_css_imports(data, inline=False):
- """Return all assets that are referenced in the given CSS document.
-
- The returned URLs are relative to the stylesheet's URL.
-
- Args:
- data: The content of the stylesheet to scan as string.
- inline: True if the argument is an inline HTML style attribute.
- """
- imports = _get_css_imports_cssutils(data, inline)
- if imports is None:
- imports = _get_css_imports_regex(data)
- return imports
-
-
def _check_rel(element):
"""Return true if the element's rel attribute fits our criteria.
@@ -328,7 +279,7 @@ class _Downloader:
for element in web_frame.findAllElements('[style]'):
element = webkitelem.WebKitElement(element, tab=self.tab)
style = element['style']
- for element_url in _get_css_imports(style, inline=True):
+ for element_url in _get_css_imports(style):
self._fetch_url(web_url.resolved(QUrl(element_url)))
# Shortcut if no assets need to be downloaded, otherwise the file would
diff --git a/qutebrowser/browser/webkit/network/networkmanager.py b/qutebrowser/browser/webkit/network/networkmanager.py
index 14c47b1f9..3e393680c 100644
--- a/qutebrowser/browser/webkit/network/networkmanager.py
+++ b/qutebrowser/browser/webkit/network/networkmanager.py
@@ -155,10 +155,7 @@ class NetworkManager(QNetworkAccessManager):
def __init__(self, *, win_id, tab_id, private, parent=None):
log.init.debug("Initializing NetworkManager")
- with log.disable_qt_msghandler():
- # WORKAROUND for a hang when a message is printed - See:
- # http://www.riverbankcomputing.com/pipermail/pyqt/2014-November/035045.html
- super().__init__(parent)
+ super().__init__(parent)
log.init.debug("NetworkManager init done")
self.adopted_downloads = 0
self._win_id = win_id
@@ -368,13 +365,6 @@ class NetworkManager(QNetworkAccessManager):
# https://www.playstation.com/ for example.
pass
- # WORKAROUND for:
- # http://www.riverbankcomputing.com/pipermail/pyqt/2014-September/034806.html
- #
- # By returning False, we provoke a TypeError because of a wrong return
- # type, which does *not* trigger a segfault but invoke our return handler
- # immediately.
- @utils.prevent_exceptions(False)
def createRequest(self, op, req, outgoing_data):
"""Return a new QNetworkReply object.
diff --git a/qutebrowser/browser/webkit/webkitsettings.py b/qutebrowser/browser/webkit/webkitsettings.py
index ec30267d4..db36dc899 100644
--- a/qutebrowser/browser/webkit/webkitsettings.py
+++ b/qutebrowser/browser/webkit/webkitsettings.py
@@ -172,7 +172,7 @@ def _init_user_agent():
parsed_user_agent = websettings.UserAgent.parse(ua)
-def init(_args):
+def init():
"""Initialize the global QWebSettings."""
cache_path = standarddir.cache()
data_path = standarddir.data()
diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py
index 1008169a0..69773fa57 100644
--- a/qutebrowser/browser/webkit/webkittab.py
+++ b/qutebrowser/browser/webkit/webkittab.py
@@ -82,9 +82,6 @@ class WebKitPrinting(browsertab.AbstractPrinting):
def check_pdf_support(self):
pass
- def check_printer_support(self):
- pass
-
def check_preview_support(self):
pass
@@ -850,9 +847,8 @@ class WebKitTab(browsertab.AbstractTab):
settings = widget.settings()
settings.setAttribute(QWebSettings.PrivateBrowsingEnabled, True)
- def load_url(self, url, *, emit_before_load_started=True):
- self._load_url_prepare(
- url, emit_before_load_started=emit_before_load_started)
+ def load_url(self, url):
+ self._load_url_prepare(url)
self._widget.load(url)
def url(self, *, requested=False):
diff --git a/qutebrowser/browser/webkit/webpage.py b/qutebrowser/browser/webkit/webpage.py
index 956b9be9d..c20acb369 100644
--- a/qutebrowser/browser/webkit/webpage.py
+++ b/qutebrowser/browser/webkit/webpage.py
@@ -365,7 +365,7 @@ class BrowserPage(QWebPage):
abort_on=[self.shutting_down, self.loadStarted])
if question is not None:
- self.featurePermissionRequestCanceled.connect( # type: ignore
+ self.featurePermissionRequestCanceled.connect( # type: ignore[attr-defined]
functools.partial(self._on_feature_permission_cancelled,
question, frame, feature))
diff --git a/qutebrowser/browser/webkit/webview.py b/qutebrowser/browser/webkit/webview.py
index 980ae78d0..428e66744 100644
--- a/qutebrowser/browser/webkit/webview.py
+++ b/qutebrowser/browser/webkit/webview.py
@@ -20,7 +20,6 @@
"""The main browser widgets."""
from PyQt5.QtCore import pyqtSignal, Qt, QUrl
-from PyQt5.QtWidgets import QStyleFactory
from PyQt5.QtWebKit import QWebSettings
from PyQt5.QtWebKitWidgets import QWebView, QWebPage
@@ -62,10 +61,6 @@ class WebView(QWebView):
def __init__(self, *, win_id, tab_id, tab, private, parent=None):
super().__init__(parent)
- if utils.is_mac:
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-42948
- # See https://github.com/qutebrowser/qutebrowser/issues/462
- self.setStyle(QStyleFactory.create('Fusion'))
# FIXME:qtwebengine this is only used to set the zoom factor from
# the QWebPage - we should get rid of it somehow (signals?)
self.tab = tab
diff --git a/qutebrowser/completion/completiondelegate.py b/qutebrowser/completion/completiondelegate.py
index a8e58b8a2..4e1290f82 100644
--- a/qutebrowser/completion/completiondelegate.py
+++ b/qutebrowser/completion/completiondelegate.py
@@ -47,6 +47,7 @@ class _Highlighter(QSyntaxHighlighter):
self._expression = QRegularExpression(
pat, QRegularExpression.CaseInsensitiveOption
)
+ qtutils.ensure_valid(self._expression)
def highlightBlock(self, text):
"""Override highlightBlock for custom highlighting."""
diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py
index 4f51ecd4b..86de688a0 100644
--- a/qutebrowser/completion/completionwidget.py
+++ b/qutebrowser/completion/completionwidget.py
@@ -30,7 +30,7 @@ from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QItemSelectionModel, QSize
from qutebrowser.config import config, stylesheet
from qutebrowser.completion import completiondelegate
-from qutebrowser.utils import utils, usertypes, debug, log
+from qutebrowser.utils import utils, usertypes, debug, log, qtutils
from qutebrowser.api import cmdutils
if TYPE_CHECKING:
from qutebrowser.mainwindow.statusbar import command
@@ -223,8 +223,9 @@ class CompletionView(QTreeView):
return model.last_item() if upwards else model.first_item()
# Find height of each CompletionView element
- element_height = self.visualRect(idx).height()
- page_length = self.height() // element_height
+ rect = self.visualRect(idx)
+ qtutils.ensure_valid(rect)
+ page_length = self.height() // rect.height()
# Skip one pageful, except leave one old line visible
offset = -(page_length - 1) if upwards else page_length - 1
@@ -330,7 +331,8 @@ class CompletionView(QTreeView):
QItemSelectionModel.Rows)
# if the last item is focused, try to fetch more
- if idx.row() == self.model().rowCount(idx.parent()) - 1:
+ next_idx = self.indexBelow(idx)
+ if not self.visualRect(next_idx).isValid():
self.expandAll()
count = self.model().count()
diff --git a/qutebrowser/completion/models/completionmodel.py b/qutebrowser/completion/models/completionmodel.py
index 7d65d4439..d992a44f4 100644
--- a/qutebrowser/completion/models/completionmodel.py
+++ b/qutebrowser/completion/models/completionmodel.py
@@ -179,16 +179,10 @@ class CompletionModel(QAbstractItemModel):
pattern: The filter pattern to set.
"""
log.completion.debug("Setting completion pattern '{}'".format(pattern))
- # WORKAROUND:
- # layoutChanged is broken in PyQt 5.7.1, so we must use metaObject
- # https://www.riverbankcomputing.com/pipermail/pyqt/2017-January/038483.html
- meta = self.metaObject()
- meta.invokeMethod(self, # type: ignore[misc, call-overload]
- "layoutAboutToBeChanged")
+ self.layoutAboutToBeChanged.emit() # type: ignore[attr-defined]
for cat in self._categories:
cat.set_pattern(pattern)
- meta.invokeMethod(self, # type: ignore[misc, call-overload]
- "layoutChanged")
+ self.layoutChanged.emit() # type: ignore[attr-defined]
def first_item(self):
"""Return the index of the first child (non-category) in the model."""
diff --git a/qutebrowser/completion/models/listcategory.py b/qutebrowser/completion/models/listcategory.py
index f0cc21da0..79dc0770a 100644
--- a/qutebrowser/completion/models/listcategory.py
+++ b/qutebrowser/completion/models/listcategory.py
@@ -64,6 +64,7 @@ class ListCategory(QSortFilterProxyModel):
val = re.escape(val)
val = val.replace(r'\ ', '.*')
rx = QRegExp(val, Qt.CaseInsensitive)
+ qtutils.ensure_valid(rx)
self.setFilterRegExp(rx)
self.invalidate()
sortcol = 0
diff --git a/qutebrowser/components/misccommands.py b/qutebrowser/components/misccommands.py
index 19ad126c1..f553fce3b 100644
--- a/qutebrowser/components/misccommands.py
+++ b/qutebrowser/components/misccommands.py
@@ -343,10 +343,3 @@ def devtools_focus(tab: apitypes.Tab) -> None:
tab.data.splitter.cycle_focus()
except apitypes.InspectorError as e:
raise cmdutils.CommandError(e)
-
-
-@cmdutils.register(deprecated='Use :devtools instead')
-@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
-def inspector(tab: apitypes.Tab) -> None:
- """Toggle the web inspector."""
- devtools(tab)
diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py
index 8611e46ab..d8e8d612e 100644
--- a/qutebrowser/config/config.py
+++ b/qutebrowser/config/config.py
@@ -22,8 +22,8 @@
import copy
import contextlib
import functools
-import typing
-from typing import Any, Tuple, MutableMapping
+from typing import (TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Mapping,
+ MutableMapping, MutableSequence, Optional, Tuple, cast)
from PyQt5.QtCore import pyqtSignal, QObject, QUrl
@@ -32,15 +32,15 @@ from qutebrowser.utils import utils, log, urlmatch
from qutebrowser.misc import objects
from qutebrowser.keyinput import keyutils
-if typing.TYPE_CHECKING:
+if TYPE_CHECKING:
from qutebrowser.config import configcache, configfiles
from qutebrowser.misc import savemanager
# An easy way to access the config from other code via config.val.foo
-val = typing.cast('ConfigContainer', None)
-instance = typing.cast('Config', None)
-key_instance = typing.cast('KeyConfig', None)
-cache = typing.cast('configcache.ConfigCache', None)
+val = cast('ConfigContainer', None)
+instance = cast('Config', None)
+key_instance = cast('KeyConfig', None)
+cache = cast('configcache.ConfigCache', None)
# Keeping track of all change filters to validate them later.
change_filters = []
@@ -83,7 +83,7 @@ class change_filter: # noqa: N801,N806 pylint: disable=invalid-name
not configdata.is_valid_prefix(self._option)):
raise configexc.NoOptionError(self._option)
- def check_match(self, option: typing.Optional[str]) -> bool:
+ def check_match(self, option: Optional[str]) -> bool:
"""Check if the given option matches the filter."""
if option is None:
# Called directly, not from a config change event.
@@ -96,7 +96,7 @@ class change_filter: # noqa: N801,N806 pylint: disable=invalid-name
else:
return False
- def __call__(self, func: typing.Callable) -> typing.Callable:
+ def __call__(self, func: Callable) -> Callable:
"""Filter calls to the decorated function.
Gets called when a function should be decorated.
@@ -114,7 +114,7 @@ class change_filter: # noqa: N801,N806 pylint: disable=invalid-name
"""
if self._function:
@functools.wraps(func)
- def func_wrapper(option: str = None) -> typing.Any:
+ def func_wrapper(option: str = None) -> Any:
"""Call the underlying function."""
if self.check_match(option):
return func()
@@ -122,8 +122,7 @@ class change_filter: # noqa: N801,N806 pylint: disable=invalid-name
return func_wrapper
else:
@functools.wraps(func)
- def meth_wrapper(wrapper_self: typing.Any,
- option: str = None) -> typing.Any:
+ def meth_wrapper(wrapper_self: Any, option: str = None) -> Any:
"""Call the underlying function."""
if self.check_match(option):
return func(wrapper_self)
@@ -141,7 +140,7 @@ class KeyConfig:
_config: The Config object to be used.
"""
- _ReverseBindings = typing.Dict[str, typing.MutableSequence[str]]
+ _ReverseBindings = Dict[str, MutableSequence[str]]
def __init__(self, config: 'Config') -> None:
self._config = config
@@ -153,10 +152,7 @@ class KeyConfig:
if mode not in configdata.DATA['bindings.default'].default:
raise configexc.KeybindingError("Invalid mode {}!".format(mode))
- def get_bindings_for(
- self,
- mode: str
- ) -> typing.Dict[keyutils.KeySequence, str]:
+ def get_bindings_for(self, mode: str) -> Dict[keyutils.KeySequence, str]:
"""Get the combined bindings for the given mode."""
bindings = dict(val.bindings.default[mode])
for key, binding in val.bindings.commands[mode].items():
@@ -168,7 +164,7 @@ class KeyConfig:
def get_reverse_bindings_for(self, mode: str) -> '_ReverseBindings':
"""Get a dict of commands to a list of bindings for the mode."""
- cmd_to_keys = {} # type: KeyConfig._ReverseBindings
+ cmd_to_keys: KeyConfig._ReverseBindings = {}
bindings = self.get_bindings_for(mode)
for seq, full_cmd in sorted(bindings.items()):
for cmd in full_cmd.split(';;'):
@@ -184,7 +180,7 @@ class KeyConfig:
def get_command(self,
key: keyutils.KeySequence,
mode: str,
- default: bool = False) -> typing.Optional[str]:
+ default: bool = False) -> Optional[str]:
"""Get the command for a given key (or None)."""
self._validate(key, mode)
if default:
@@ -277,7 +273,7 @@ class Config(QObject):
yaml_config: 'configfiles.YamlConfig',
parent: QObject = None) -> None:
super().__init__(parent)
- self._mutables = {} # type: MutableMapping[str, Tuple[Any, Any]]
+ self._mutables: MutableMapping[str, Tuple[Any, Any]] = {}
self._yaml = yaml_config
self._init_values()
self.yaml_loaded = False
@@ -286,11 +282,11 @@ class Config(QObject):
def _init_values(self) -> None:
"""Populate the self._values dict."""
- self._values = {} # type: typing.Mapping
+ self._values: Mapping = {}
for name, opt in configdata.DATA.items():
self._values[name] = configutils.Values(opt)
- def __iter__(self) -> typing.Iterator[configutils.Values]:
+ def __iter__(self) -> Iterator[configutils.Values]:
"""Iterate over configutils.Values items."""
yield from self._values.values()
@@ -391,7 +387,7 @@ class Config(QObject):
def get_obj_for_pattern(
self, name: str, *,
- pattern: typing.Optional[urlmatch.UrlPattern]
+ pattern: Optional[urlmatch.UrlPattern]
) -> Any:
"""Get the given setting as object (for YAML/config.py).
@@ -525,7 +521,7 @@ class Config(QObject):
Return:
The changed config part as string.
"""
- lines = [] # type: typing.List[str]
+ lines: List[str] = []
for values in sorted(self, key=lambda v: v.opt.name):
lines += values.dump()
@@ -564,7 +560,7 @@ class ConfigContainer:
pattern=self._pattern)
@contextlib.contextmanager
- def _handle_error(self, action: str, name: str) -> typing.Iterator[None]:
+ def _handle_error(self, action: str, name: str) -> Iterator[None]:
try:
yield
except configexc.Error as e:
diff --git a/qutebrowser/config/configcache.py b/qutebrowser/config/configcache.py
index 2bc45f0f8..a07a22ee5 100644
--- a/qutebrowser/config/configcache.py
+++ b/qutebrowser/config/configcache.py
@@ -20,7 +20,7 @@
"""Implementation of a basic config cache."""
-import typing
+from typing import Any, Dict
from qutebrowser.config import config
@@ -38,14 +38,14 @@ class ConfigCache:
"""
def __init__(self) -> None:
- self._cache = {} # type: typing.Dict[str, typing.Any]
+ self._cache: Dict[str, Any] = {}
config.instance.changed.connect(self._on_config_changed)
def _on_config_changed(self, attr: str) -> None:
if attr in self._cache:
del self._cache[attr]
- def __getitem__(self, attr: str) -> typing.Any:
+ def __getitem__(self, attr: str) -> Any:
try:
return self._cache[attr]
except KeyError:
diff --git a/qutebrowser/config/configcommands.py b/qutebrowser/config/configcommands.py
index 20702be10..0f57b0a03 100644
--- a/qutebrowser/config/configcommands.py
+++ b/qutebrowser/config/configcommands.py
@@ -19,9 +19,9 @@
"""Commands related to the configuration."""
-import typing
import os.path
import contextlib
+from typing import TYPE_CHECKING, Iterator, List, Optional
from PyQt5.QtCore import QUrl
@@ -32,7 +32,7 @@ from qutebrowser.config import configtypes, configexc, configfiles, configdata
from qutebrowser.misc import editor
from qutebrowser.keyinput import keyutils
-if typing.TYPE_CHECKING:
+if TYPE_CHECKING:
from qutebrowser.config.config import Config, KeyConfig
@@ -47,17 +47,14 @@ class ConfigCommands:
self._keyconfig = keyconfig
@contextlib.contextmanager
- def _handle_config_error(self) -> typing.Iterator[None]:
+ def _handle_config_error(self) -> Iterator[None]:
"""Catch errors in set_command and raise CommandError."""
try:
yield
except configexc.Error as e:
raise cmdutils.CommandError(str(e))
- def _parse_pattern(
- self,
- pattern: typing.Optional[str]
- ) -> typing.Optional[urlmatch.UrlPattern]:
+ def _parse_pattern(self, pattern: Optional[str]) -> Optional[urlmatch.UrlPattern]:
"""Parse a pattern string argument to a pattern."""
if pattern is None:
return None
@@ -75,8 +72,7 @@ class ConfigCommands:
except keyutils.KeyParseError as e:
raise cmdutils.CommandError(str(e))
- def _print_value(self, option: str,
- pattern: typing.Optional[urlmatch.UrlPattern]) -> None:
+ def _print_value(self, option: str, pattern: Optional[urlmatch.UrlPattern]) -> None:
"""Print the value of the given option."""
with self._handle_config_error():
value = self._config.get_str(option, pattern=pattern)
@@ -263,17 +259,9 @@ class ConfigCommands:
@cmdutils.register(instance='config-commands')
@cmdutils.argument('win_id', value=cmdutils.Value.win_id)
- def config_diff(self, win_id: int, old: bool = False) -> None:
- """Show all customized options.
-
- Args:
- old: Show difference for the pre-v1.0 files
- (qutebrowser.conf/keys.conf).
- """
+ def config_diff(self, win_id: int) -> None:
+ """Show all customized options."""
url = QUrl('qute://configdiff')
- if old:
- url.setPath('/old')
-
tabbed_browser = objreg.get('tabbed-browser',
scope='window', window=win_id)
tabbed_browser.load_url(url, newtab=False)
@@ -468,7 +456,7 @@ class ConfigCommands:
raise cmdutils.CommandError("{} already exists - use --force to "
"overwrite!".format(filename))
- options = [] # type: typing.List
+ options: List = []
if defaults:
options = [(None, opt, opt.default)
for _name, opt in sorted(configdata.DATA.items())]
diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py
index 290d897bd..065527bb9 100644
--- a/qutebrowser/config/configdata.py
+++ b/qutebrowser/config/configdata.py
@@ -24,8 +24,8 @@ Module attributes:
DATA: A dict of Option objects after init() has been called.
"""
-import typing
-from typing import Optional
+from typing import (Any, Dict, Iterable, List, Mapping, MutableMapping, Optional,
+ Sequence, Tuple, Union, cast)
import functools
import attr
@@ -33,10 +33,10 @@ from qutebrowser.config import configtypes
from qutebrowser.utils import usertypes, qtutils, utils
from qutebrowser.misc import debugcachestats
-DATA = typing.cast(typing.Mapping[str, 'Option'], None)
-MIGRATIONS = typing.cast('Migrations', None)
+DATA = cast(Mapping[str, 'Option'], None)
+MIGRATIONS = cast('Migrations', None)
-_BackendDict = typing.Mapping[str, typing.Union[str, bool]]
+_BackendDict = Mapping[str, Union[str, bool]]
@attr.s
@@ -47,15 +47,15 @@ class Option:
Note that this is just an option which exists, with no value associated.
"""
- name = attr.ib() # type: str
- typ = attr.ib() # type: configtypes.BaseType
- default = attr.ib() # type: typing.Any
- backends = attr.ib() # type: typing.Iterable[usertypes.Backend]
- raw_backends = attr.ib() # type: Optional[typing.Mapping[str, bool]]
- description = attr.ib() # type: str
- supports_pattern = attr.ib(default=False) # type: bool
- restart = attr.ib(default=False) # type: bool
- no_autoconfig = attr.ib(default=False) # type: bool
+ name: str = attr.ib()
+ typ: configtypes.BaseType = attr.ib()
+ default: Any = attr.ib()
+ backends: Iterable[usertypes.Backend] = attr.ib()
+ raw_backends: Optional[Mapping[str, bool]] = attr.ib()
+ description: str = attr.ib()
+ supports_pattern: bool = attr.ib(default=False)
+ restart: bool = attr.ib(default=False)
+ no_autoconfig: bool = attr.ib(default=False)
@attr.s
@@ -68,13 +68,11 @@ class Migrations:
deleted: A list of option names which have been removed.
"""
- renamed = attr.ib(
- default=attr.Factory(dict)) # type: typing.Dict[str, str]
- deleted = attr.ib(
- default=attr.Factory(list)) # type: typing.List[str]
+ renamed: Dict[str, str] = attr.ib(default=attr.Factory(dict))
+ deleted: List[str] = attr.ib(default=attr.Factory(list))
-def _raise_invalid_node(name: str, what: str, node: typing.Any) -> None:
+def _raise_invalid_node(name: str, what: str, node: Any) -> None:
"""Raise an exception for an invalid configdata YAML node.
Args:
@@ -88,14 +86,14 @@ def _raise_invalid_node(name: str, what: str, node: typing.Any) -> None:
def _parse_yaml_type(
name: str,
- node: typing.Union[str, typing.Mapping[str, typing.Any]],
+ node: Union[str, Mapping[str, Any]],
) -> configtypes.BaseType:
if isinstance(node, str):
# e.g:
# > type: Bool
# -> create the type object without any arguments
type_name = node
- kwargs = {} # type: typing.MutableMapping[str, typing.Any]
+ kwargs: MutableMapping[str, Any] = {}
elif isinstance(node, dict):
# e.g:
# > type:
@@ -136,14 +134,14 @@ def _parse_yaml_type(
def _parse_yaml_backends_dict(
name: str,
node: _BackendDict,
-) -> typing.Sequence[usertypes.Backend]:
+) -> Sequence[usertypes.Backend]:
"""Parse a dict definition for backends.
Example:
backends:
QtWebKit: true
- QtWebEngine: Qt 5.9
+ QtWebEngine: Qt 5.15
"""
str_to_backend = {
'QtWebKit': usertypes.Backend.QtWebKit,
@@ -160,14 +158,9 @@ def _parse_yaml_backends_dict(
conditionals = {
True: True,
False: False,
- 'Qt 5.8': qtutils.version_check('5.8'),
- 'Qt 5.9': qtutils.version_check('5.9'),
- 'Qt 5.9.2': qtutils.version_check('5.9.2'),
- 'Qt 5.10': qtutils.version_check('5.10'),
- 'Qt 5.11': qtutils.version_check('5.11'),
- 'Qt 5.12': qtutils.version_check('5.12'),
'Qt 5.13': qtutils.version_check('5.13'),
'Qt 5.14': qtutils.version_check('5.14'),
+ 'Qt 5.15': qtutils.version_check('5.15'),
}
for key in sorted(node.keys()):
if conditionals[node[key]]:
@@ -178,8 +171,8 @@ def _parse_yaml_backends_dict(
def _parse_yaml_backends(
name: str,
- node: typing.Union[None, str, _BackendDict],
-) -> typing.Sequence[usertypes.Backend]:
+ node: Union[None, str, _BackendDict],
+) -> Sequence[usertypes.Backend]:
"""Parse a backend node in the yaml.
It can have one of those four forms:
@@ -188,7 +181,7 @@ def _parse_yaml_backends(
- backend: QtWebEngine -> setting only available with QtWebEngine
- backend:
QtWebKit: true
- QtWebEngine: Qt 5.9
+ QtWebEngine: Qt 5.15
-> setting available based on the given conditionals.
Return:
@@ -208,7 +201,7 @@ def _parse_yaml_backends(
def _read_yaml(
yaml_data: str,
-) -> typing.Tuple[typing.Mapping[str, Option], Migrations]:
+) -> Tuple[Mapping[str, Option], Migrations]:
"""Read config data from a YAML file.
Args:
diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml
index 460f3bc41..16d081cde 100644
--- a/qutebrowser/config/configdata.yml
+++ b/qutebrowser/config/configdata.yml
@@ -293,16 +293,11 @@ auto_save.session:
content.autoplay:
default: true
type: Bool
- backend:
- QtWebEngine: Qt 5.10
- QtWebKit: false
+ backend: QtWebEngine
supports_pattern: true
desc: >-
Automatically start playing `<video>` elements.
- Note: On Qt < 5.11, this option needs a restart and does not support URL
- patterns.
-
content.cache.size:
default: null
type:
@@ -359,9 +354,6 @@ content.cache.appcache:
content.cookies.accept:
default: all
- backend:
- QtWebKit: true
- QtWebEngine: Qt 5.11
supports_pattern: true
type:
name: String
@@ -390,10 +382,7 @@ content.cookies.accept:
content.cookies.store:
default: true
type: Bool
- desc: >-
- Store cookies.
-
- Note this option needs a restart with QtWebEngine on Qt < 5.9.
+ desc: Store cookies.
content.default_encoding:
type: String
@@ -417,9 +406,7 @@ content.unknown_url_scheme_policy:
- allow-all: "Allows all navigation requests to URLs with unknown
schemes."
default: allow-from-user-interaction
- backend:
- QtWebEngine: Qt 5.11
- QtWebKit: false
+ backend: QtWebEngine
supports_pattern: true
desc: >-
How navigation requests to URLs with unknown schemes are handled.
@@ -448,11 +435,7 @@ content.desktop_capture:
type: BoolAsk
default: ask
supports_pattern: true
- desc: >-
- Allow websites to share screen content.
-
- On Qt < 5.10, a dialog box is always displayed, even if this is set to
- "true".
+ desc: Allow websites to share screen content.
content.developer_extras:
deleted: true
@@ -460,9 +443,7 @@ content.developer_extras:
content.dns_prefetch:
default: true
type: Bool
- backend:
- QtWebKit: true
- QtWebEngine: Qt 5.12
+ backend: QtWebEngine
supports_pattern: true
desc: Try to pre-fetch DNS entries to speed up browsing.
@@ -495,9 +476,7 @@ content.mouse_lock:
default: ask
type: BoolAsk
supports_pattern: true
- backend:
- QtWebKit: false
- QtWebEngine: Qt 5.8
+ backend: QtWebEngine
desc: Allow websites to lock your mouse pointer.
content.headers.accept_language:
@@ -851,9 +830,7 @@ content.persistent_storage:
default: ask
type: BoolAsk
supports_pattern: true
- backend:
- QtWebKit: false
- QtWebEngine: Qt 5.11
+ backend: QtWebEngine
desc: Allow websites to request persistent storage quota via
`navigator.webkitPersistentStorage.requestQuota`.
@@ -866,9 +843,7 @@ content.plugins:
content.print_element_backgrounds:
type: Bool
default: true
- backend:
- QtWebKit: true
- QtWebEngine: Qt 5.8
+ backend: QtWebEngine
supports_pattern: true
desc: >-
Draw the background color and images also when the page is printed.
@@ -901,9 +876,7 @@ content.register_protocol_handler:
default: ask
type: BoolAsk
supports_pattern: true
- backend:
- QtWebKit: false
- QtWebEngine: Qt 5.11
+ backend: QtWebEngine
desc: Allow websites to register protocol handlers via
`navigator.registerProtocolHandler`.
@@ -943,15 +916,11 @@ content.webrtc_ip_handling_policy:
servers unless the proxy server supports UDP. This doesn't expose
any local addresses either.
default: all-interfaces
- backend:
- QtWebKit: false
- QtWebEngine: Qt 5.9.2
+ backend: QtWebEngine
restart: true
desc: >-
Which interfaces to expose via WebRTC.
- On Qt 5.10, this option doesn't work because of a Qt bug.
-
content.xss_auditing:
type: Bool
default: false
@@ -1573,7 +1542,7 @@ scrolling.bar:
- never: Never show the scrollbar.
- when-searching: Show the scrollbar when searching for text in the
webpage. With the QtWebKit backend, this is equal to `never`.
- - overlay: Show an overlay scrollbar. With Qt < 5.11 or on macOS, this is
+ - overlay: Show an overlay scrollbar. On macOS, this is
unavailable and equal to `when-searching`; with the QtWebKit
backend, this is equal to `never`. Enabling/disabling overlay
scrollbars requires a restart.
@@ -1647,9 +1616,7 @@ spellcheck.languages:
You can check for available languages and install dictionaries using
scripts/dictcli.py. Run the script with -h/--help for instructions.
- backend:
- QtWebKit: false
- QtWebEngine: Qt 5.8
+ backend: QtWebEngine
## statusbar
@@ -2081,6 +2048,7 @@ url.searchengines:
expands to `slash%2Fand%26amp`).
* `{unquoted}` quotes nothing (for `slash/and&amp` this placeholder
expands to `slash/and&amp`).
+ * `{0}` means the same as `{}`, but can be used multiple times.
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
@@ -2142,6 +2110,19 @@ window.title_format:
Format to use for the window title. The same placeholders like for
`tabs.title.format` are defined.
+window.transparent:
+ type: Bool
+ default: false
+ desc: |
+ Set the main window background to transparent.
+
+ This allows having a transparent tab- or statusbar (might require a compositor such
+ as picom). However, it breaks some functionality such as dmenu embedding via its
+ `-w` option. On some systems, it was additionally reported that main window
+ transparency negatively affects performance.
+
+ Note this setting only affects windows opened after setting it.
+
## zoom
zoom.default:
@@ -2747,9 +2728,7 @@ colors.webpage.darkmode.enabled:
- "With selective inversion of everything": Combines the two variants
above.
restart: true
- backend:
- QtWebEngine: Qt 5.10
- QtWebKit: false
+ backend: QtWebEngine
colors.webpage.darkmode.algorithm:
default: lightness-cielab
@@ -2771,9 +2750,7 @@ colors.webpage.darkmode.algorithm:
# kInvertBrightness without gamma correction, and only available for
# Chromium's automated tests
restart: true
- backend:
- QtWebEngine: Qt 5.10
- QtWebKit: false
+ backend: QtWebEngine
colors.webpage.darkmode.contrast:
default: 0.0
@@ -2787,9 +2764,7 @@ colors.webpage.darkmode.contrast:
This only has an effect when `colors.webpage.darkmode.algorithm` is set to
`lightness-hsl` or `brightness-rgb`.
restart: true
- backend:
- QtWebEngine: Qt 5.10
- QtWebKit: false
+ backend: QtWebEngine
colors.webpage.darkmode.policy.images:
default: smart
@@ -2799,19 +2774,16 @@ colors.webpage.darkmode.policy.images:
- 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. Not available with Qt
- 5.10 / 5.15.0."
+ 5.15.0."
desc: >-
Which images to apply dark mode to.
With QtWebEngine 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]. With QtWebEngine 5.10, this is not available at all. In those
- cases, the 'smart' setting is ignored and treated like 'never'.
+ in Qt].
restart: true
- backend:
- QtWebEngine: Qt 5.10
- QtWebKit: false
+ backend: QtWebEngine
colors.webpage.darkmode.policy.page:
default: smart
@@ -2872,9 +2844,7 @@ colors.webpage.darkmode.grayscale.all:
This only has an effect when `colors.webpage.darkmode.algorithm` is set to
`lightness-hsl` or `brightness-rgb`.
restart: true
- backend:
- QtWebEngine: Qt 5.10
- QtWebKit: false
+ backend: QtWebEngine
colors.webpage.darkmode.grayscale.images:
default: 0.0
diff --git a/qutebrowser/config/configdiff.py b/qutebrowser/config/configdiff.py
deleted file mode 100644
index 53177134b..000000000
--- a/qutebrowser/config/configdiff.py
+++ /dev/null
@@ -1,761 +0,0 @@
-# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
-
-# Copyright 2017-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/>.
-
-"""Code to show a diff of the legacy config format."""
-
-import typing
-import difflib
-import os.path
-
-import pygments
-import pygments.lexers
-import pygments.formatters
-
-from qutebrowser.utils import standarddir
-
-
-OLD_CONF = """
-[general]
-ignore-case = smart
-startpage = https://start.duckduckgo.com
-yank-ignored-url-parameters = ref,utm_source,utm_medium,utm_campaign,utm_term,utm_content
-default-open-dispatcher =
-default-page = ${startpage}
-auto-search = naive
-auto-save-config = true
-auto-save-interval = 15000
-editor = gvim -f "{}"
-editor-encoding = utf-8
-private-browsing = false
-developer-extras = false
-print-element-backgrounds = true
-xss-auditing = false
-default-encoding = iso-8859-1
-new-instance-open-target = tab
-new-instance-open-target.window = last-focused
-log-javascript-console = debug
-save-session = false
-session-default-name =
-url-incdec-segments = path,query
-[ui]
-history-session-interval = 30
-zoom-levels = 25%,33%,50%,67%,75%,90%,100%,110%,125%,150%,175%,200%,250%,300%,400%,500%
-default-zoom = 100%
-downloads-position = top
-status-position = bottom
-message-timeout = 2000
-message-unfocused = false
-confirm-quit = never
-zoom-text-only = false
-frame-flattening = false
-user-stylesheet =
-hide-scrollbar = true
-smooth-scrolling = false
-remove-finished-downloads = -1
-hide-statusbar = false
-statusbar-padding = 1,1,0,0
-window-title-format = {perc}{title}{title_sep}qutebrowser
-modal-js-dialog = false
-hide-wayland-decoration = false
-keyhint-blacklist =
-keyhint-delay = 500
-prompt-radius = 8
-prompt-filebrowser = true
-[network]
-do-not-track = true
-accept-language = en-US,en
-referer-header = same-domain
-user-agent =
-proxy = system
-proxy-dns-requests = true
-ssl-strict = ask
-dns-prefetch = true
-custom-headers =
-netrc-file =
-[completion]
-show = always
-download-path-suggestion = path
-timestamp-format = %Y-%m-%d
-height = 50%
-cmd-history-max-items = 100
-web-history-max-items = -1
-quick-complete = true
-shrink = false
-scrollbar-width = 12
-scrollbar-padding = 2
-[input]
-timeout = 500
-partial-timeout = 5000
-insert-mode-on-plugins = false
-auto-leave-insert-mode = true
-auto-insert-mode = false
-forward-unbound-keys = auto
-spatial-navigation = false
-links-included-in-focus-chain = true
-rocker-gestures = false
-mouse-zoom-divider = 512
-[tabs]
-background-tabs = false
-select-on-remove = next
-new-tab-position = next
-new-tab-position-explicit = last
-last-close = ignore
-show = always
-show-switching-delay = 800
-wrap = true
-movable = true
-close-mouse-button = middle
-position = top
-show-favicons = true
-favicon-scale = 1.0
-width = 20%
-pinned-width = 43
-indicator-width = 3
-tabs-are-windows = false
-title-format = {index}: {title}
-title-format-pinned = {index}
-title-alignment = left
-mousewheel-tab-switching = true
-padding = 0,0,5,5
-indicator-padding = 2,2,0,4
-[storage]
-download-directory =
-prompt-download-directory = true
-remember-download-directory = true
-maximum-pages-in-cache = 0
-offline-web-application-cache = true
-local-storage = true
-cache-size =
-[content]
-allow-images = true
-allow-javascript = true
-allow-plugins = false
-webgl = true
-hyperlink-auditing = false
-geolocation = ask
-notifications = ask
-media-capture = ask
-javascript-can-open-windows-automatically = false
-javascript-can-close-windows = false
-javascript-can-access-clipboard = false
-ignore-javascript-prompt = false
-ignore-javascript-alert = false
-local-content-can-access-remote-urls = false
-local-content-can-access-file-urls = true
-cookies-accept = no-3rdparty
-cookies-store = true
-host-block-lists = https://www.malwaredomainlist.com/hostslist/hosts.txt,http://someonewhocares.org/hosts/hosts,http://winhelp2002.mvps.org/hosts.zip,http://malwaredomains.lehigh.edu/files/justdomains.zip,https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&mimetype=plaintext
-host-blocking-enabled = true
-host-blocking-whitelist = piwik.org
-enable-pdfjs = false
-[hints]
-border = 1px solid #E3BE23
-mode = letter
-chars = asdfghjkl
-min-chars = 1
-scatter = true
-uppercase = false
-dictionary = /usr/share/dict/words
-auto-follow = unique-match
-auto-follow-timeout = 0
-next-regexes = \\bnext\\b,\\bmore\\b,\\bnewer\\b,\\b[>\u2192\u226b]\\b,\\b(>>|\xbb)\\b,\\bcontinue\\b
-prev-regexes = \\bprev(ious)?\\b,\\bback\\b,\\bolder\\b,\\b[<\u2190\u226a]\\b,\\b(<<|\xab)\\b
-find-implementation = python
-hide-unmatched-rapid-hints = true
-[searchengines]
-DEFAULT = https://duckduckgo.com/?q={}
-[aliases]
-[colors]
-completion.fg = white
-completion.bg = #333333
-completion.alternate-bg = #444444
-completion.category.fg = white
-completion.category.bg = qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #888888, stop:1 #505050)
-completion.category.border.top = black
-completion.category.border.bottom = ${completion.category.border.top}
-completion.item.selected.fg = black
-completion.item.selected.bg = #e8c000
-completion.item.selected.border.top = #bbbb00
-completion.item.selected.border.bottom = ${completion.item.selected.border.top}
-completion.match.fg = #ff4444
-completion.scrollbar.fg = ${completion.fg}
-completion.scrollbar.bg = ${completion.bg}
-statusbar.fg = white
-statusbar.bg = black
-statusbar.fg.private = ${statusbar.fg}
-statusbar.bg.private = #666666
-statusbar.fg.insert = ${statusbar.fg}
-statusbar.bg.insert = darkgreen
-statusbar.fg.command = ${statusbar.fg}
-statusbar.bg.command = ${statusbar.bg}
-statusbar.fg.command.private = ${statusbar.fg.private}
-statusbar.bg.command.private = ${statusbar.bg.private}
-statusbar.fg.caret = ${statusbar.fg}
-statusbar.bg.caret = purple
-statusbar.fg.caret-selection = ${statusbar.fg}
-statusbar.bg.caret-selection = #a12dff
-statusbar.progress.bg = white
-statusbar.url.fg = ${statusbar.fg}
-statusbar.url.fg.success = white
-statusbar.url.fg.success.https = lime
-statusbar.url.fg.error = orange
-statusbar.url.fg.warn = yellow
-statusbar.url.fg.hover = aqua
-tabs.fg.odd = white
-tabs.bg.odd = grey
-tabs.fg.even = white
-tabs.bg.even = darkgrey
-tabs.fg.selected.odd = white
-tabs.bg.selected.odd = black
-tabs.fg.selected.even = ${tabs.fg.selected.odd}
-tabs.bg.selected.even = ${tabs.bg.selected.odd}
-tabs.bg.bar = #555555
-tabs.indicator.start = #0000aa
-tabs.indicator.stop = #00aa00
-tabs.indicator.error = #ff0000
-tabs.indicator.system = rgb
-hints.fg = black
-hints.bg = qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgba(255, 247, 133, 0.8), stop:1 rgba(255, 197, 66, 0.8))
-hints.fg.match = green
-downloads.bg.bar = black
-downloads.fg.start = white
-downloads.bg.start = #0000aa
-downloads.fg.stop = ${downloads.fg.start}
-downloads.bg.stop = #00aa00
-downloads.fg.system = rgb
-downloads.bg.system = rgb
-downloads.fg.error = white
-downloads.bg.error = red
-webpage.bg = white
-keyhint.fg = #FFFFFF
-keyhint.fg.suffix = #FFFF00
-keyhint.bg = rgba(0, 0, 0, 80%)
-messages.fg.error = white
-messages.bg.error = red
-messages.border.error = #bb0000
-messages.fg.warning = white
-messages.bg.warning = darkorange
-messages.border.warning = #d47300
-messages.fg.info = white
-messages.bg.info = black
-messages.border.info = #333333
-prompts.fg = white
-prompts.bg = darkblue
-prompts.selected.bg = #308cc6
-[fonts]
-_monospace = xos4 Terminus, Terminus, Monospace, "DejaVu Sans Mono", Monaco, "Bitstream Vera Sans Mono", "Andale Mono", "Courier New", Courier, "Liberation Mono", monospace, Fixed, Consolas, Terminal
-completion = 8pt ${_monospace}
-completion.category = bold ${completion}
-tabbar = 8pt ${_monospace}
-statusbar = 8pt ${_monospace}
-downloads = 8pt ${_monospace}
-hints = bold 13px ${_monospace}
-debug-console = 8pt ${_monospace}
-web-family-standard =
-web-family-fixed =
-web-family-serif =
-web-family-sans-serif =
-web-family-cursive =
-web-family-fantasy =
-web-size-minimum = 0
-web-size-minimum-logical = 6
-web-size-default = 16
-web-size-default-fixed = 13
-keyhint = 8pt ${_monospace}
-messages.error = 8pt ${_monospace}
-messages.warning = 8pt ${_monospace}
-messages.info = 8pt ${_monospace}
-prompts = 8pt sans-serif
-"""
-
-OLD_KEYS_CONF = """
-[!normal]
-leave-mode
- <escape>
- <ctrl-[>
-[normal]
-clear-keychain ;; search ;; fullscreen --leave
- <escape>
- <ctrl-[>
-set-cmd-text -s :open
- o
-set-cmd-text :open {url:pretty}
- go
-set-cmd-text -s :open -t
- O
-set-cmd-text :open -t -i {url:pretty}
- gO
-set-cmd-text -s :open -b
- xo
-set-cmd-text :open -b -i {url:pretty}
- xO
-set-cmd-text -s :open -w
- wo
-set-cmd-text :open -w {url:pretty}
- wO
-set-cmd-text /
- /
-set-cmd-text ?
- ?
-set-cmd-text :
- :
-open -t
- ga
- <ctrl-t>
-open -w
- <ctrl-n>
-tab-close
- d
- <ctrl-w>
-tab-close -o
- D
-tab-only
- co
-tab-focus
- T
-tab-move
- gm
-tab-move -
- gl
-tab-move +
- gr
-tab-next
- J
- <ctrl-pgdown>
-tab-prev
- K
- <ctrl-pgup>
-tab-clone
- gC
-reload
- r
- <f5>
-reload -f
- R
- <ctrl-f5>
-back
- H
- <back>
-back -t
- th
-back -w
- wh
-forward
- L
- <forward>
-forward -t
- tl
-forward -w
- wl
-fullscreen
- <f11>
-hint
- f
-hint all tab
- F
-hint all window
- wf
-hint all tab-bg
- ;b
-hint all tab-fg
- ;f
-hint all hover
- ;h
-hint images
- ;i
-hint images tab
- ;I
-hint links fill :open {hint-url}
- ;o
-hint links fill :open -t -i {hint-url}
- ;O
-hint links yank
- ;y
-hint links yank-primary
- ;Y
-hint --rapid links tab-bg
- ;r
-hint --rapid links window
- ;R
-hint links download
- ;d
-hint inputs
- ;t
-scroll left
- h
-scroll down
- j
-scroll up
- k
-scroll right
- l
-undo
- u
- <ctrl-shift-t>
-scroll-perc 0
- gg
-scroll-perc
- G
-search-next
- n
-search-prev
- N
-enter-mode insert
- i
-enter-mode caret
- v
-enter-mode set_mark
- `
-enter-mode jump_mark
- '
-yank
- yy
-yank -s
- yY
-yank title
- yt
-yank title -s
- yT
-yank domain
- yd
-yank domain -s
- yD
-yank pretty-url
- yp
-yank pretty-url -s
- yP
-open -- {clipboard}
- pp
-open -- {primary}
- pP
-open -t -- {clipboard}
- Pp
-open -t -- {primary}
- PP
-open -w -- {clipboard}
- wp
-open -w -- {primary}
- wP
-quickmark-save
- m
-set-cmd-text -s :quickmark-load
- b
-set-cmd-text -s :quickmark-load -t
- B
-set-cmd-text -s :quickmark-load -w
- wb
-bookmark-add
- M
-set-cmd-text -s :bookmark-load
- gb
-set-cmd-text -s :bookmark-load -t
- gB
-set-cmd-text -s :bookmark-load -w
- wB
-save
- sf
-set-cmd-text -s :set
- ss
-set-cmd-text -s :set -t
- sl
-set-cmd-text -s :bind
- sk
-zoom-out
- -
-zoom-in
- +
-zoom
- =
-navigate prev
- [[
-navigate next
- ]]
-navigate prev -t
- {{
-navigate next -t
- }}
-navigate up
- gu
-navigate up -t
- gU
-navigate increment
- <ctrl-a>
-navigate decrement
- <ctrl-x>
-inspector
- wi
-download
- gd
-download-cancel
- ad
-download-clear
- cd
-view-source
- gf
-set-cmd-text -s :buffer
- gt
-tab-focus last
- <ctrl-tab>
- <ctrl-6>
- <ctrl-^>
-enter-mode passthrough
- <ctrl-v>
-quit
- <ctrl-q>
- ZQ
-wq
- ZZ
-scroll-page 0 1
- <ctrl-f>
-scroll-page 0 -1
- <ctrl-b>
-scroll-page 0 0.5
- <ctrl-d>
-scroll-page 0 -0.5
- <ctrl-u>
-tab-focus 1
- <alt-1>
- g0
- g^
-tab-focus 2
- <alt-2>
-tab-focus 3
- <alt-3>
-tab-focus 4
- <alt-4>
-tab-focus 5
- <alt-5>
-tab-focus 6
- <alt-6>
-tab-focus 7
- <alt-7>
-tab-focus 8
- <alt-8>
-tab-focus -1
- <alt-9>
- g$
-home
- <ctrl-h>
-stop
- <ctrl-s>
-print
- <ctrl-alt-p>
-open qute://settings
- Ss
-follow-selected
- <return>
- <ctrl-m>
- <ctrl-j>
- <shift-return>
- <enter>
- <shift-enter>
-follow-selected -t
- <ctrl-return>
- <ctrl-enter>
-repeat-command
- .
-tab-pin
- <ctrl-p>
-record-macro
- q
-run-macro
- @
-[insert]
-open-editor
- <ctrl-e>
-insert-text {primary}
- <shift-ins>
-[hint]
-follow-hint
- <return>
- <ctrl-m>
- <ctrl-j>
- <shift-return>
- <enter>
- <shift-enter>
-hint --rapid links tab-bg
- <ctrl-r>
-hint links
- <ctrl-f>
-hint all tab-bg
- <ctrl-b>
-[passthrough]
-[command]
-command-history-prev
- <ctrl-p>
-command-history-next
- <ctrl-n>
-completion-item-focus prev
- <shift-tab>
- <up>
-completion-item-focus next
- <tab>
- <down>
-completion-item-focus next-category
- <ctrl-tab>
-completion-item-focus prev-category
- <ctrl-shift-tab>
-completion-item-del
- <ctrl-d>
-command-accept
- <return>
- <ctrl-m>
- <ctrl-j>
- <shift-return>
- <enter>
- <shift-enter>
-[prompt]
-prompt-accept
- <return>
- <ctrl-m>
- <ctrl-j>
- <shift-return>
- <enter>
- <shift-enter>
-prompt-accept yes
- y
-prompt-accept no
- n
-prompt-open-download
- <ctrl-x>
-prompt-item-focus prev
- <shift-tab>
- <up>
-prompt-item-focus next
- <tab>
- <down>
-[command,prompt]
-rl-backward-char
- <ctrl-b>
-rl-forward-char
- <ctrl-f>
-rl-backward-word
- <alt-b>
-rl-forward-word
- <alt-f>
-rl-beginning-of-line
- <ctrl-a>
-rl-end-of-line
- <ctrl-e>
-rl-unix-line-discard
- <ctrl-u>
-rl-kill-line
- <ctrl-k>
-rl-kill-word
- <alt-d>
-rl-unix-word-rubout
- <ctrl-w>
-rl-backward-kill-word
- <alt-backspace>
-rl-yank
- <ctrl-y>
-rl-delete-char
- <ctrl-?>
-rl-backward-delete-char
- <ctrl-h>
-[caret]
-toggle-selection
- v
- <space>
-drop-selection
- <ctrl-space>
-enter-mode normal
- c
-move-to-next-line
- j
-move-to-prev-line
- k
-move-to-next-char
- l
-move-to-prev-char
- h
-move-to-end-of-word
- e
-move-to-next-word
- w
-move-to-prev-word
- b
-move-to-start-of-next-block
- ]
-move-to-start-of-prev-block
- [
-move-to-end-of-next-block
- }
-move-to-end-of-prev-block
- {
-move-to-start-of-line
- 0
-move-to-end-of-line
- $
-move-to-start-of-document
- gg
-move-to-end-of-document
- G
-yank selection -s
- Y
-yank selection
- y
- <return>
- <ctrl-m>
- <ctrl-j>
- <shift-return>
- <enter>
- <shift-enter>
-scroll left
- H
-scroll down
- J
-scroll up
- K
-scroll right
- L
-"""
-
-
-def get_diff() -> str:
- """Get a HTML diff for the old config files."""
- old_conf_lines = [] # type: typing.MutableSequence[str]
- old_key_lines = [] # type: typing.MutableSequence[str]
-
- for filename, dest in [('qutebrowser.conf', old_conf_lines),
- ('keys.conf', old_key_lines)]:
- path = os.path.join(standarddir.config(), filename)
-
- with open(path, 'r', encoding='utf-8') as f:
- for line in f:
- if not line.strip() or line.startswith('#'):
- continue
- dest.append(line.rstrip())
-
- conf_delta = difflib.unified_diff(OLD_CONF.lstrip().splitlines(),
- old_conf_lines)
- key_delta = difflib.unified_diff(OLD_KEYS_CONF.lstrip().splitlines(),
- old_key_lines)
-
- conf_diff = '\n'.join(conf_delta)
- key_diff = '\n'.join(key_delta)
-
- # pylint: disable=no-member
- # WORKAROUND for https://bitbucket.org/logilab/pylint/issue/491/
- lexer = pygments.lexers.DiffLexer()
- formatter = pygments.formatters.HtmlFormatter(
- full=True, linenos='table',
- title='Diffing pre-1.0 default config with pre-1.0 modified config')
- # pylint: enable=no-member
- return pygments.highlight(conf_diff + key_diff, lexer, formatter)
diff --git a/qutebrowser/config/configexc.py b/qutebrowser/config/configexc.py
index b409bc883..872f777ff 100644
--- a/qutebrowser/config/configexc.py
+++ b/qutebrowser/config/configexc.py
@@ -19,9 +19,9 @@
"""Exceptions related to config parsing."""
-import typing
-import attr
+from typing import Any, Mapping, Optional, Sequence, Union
+import attr
from qutebrowser.utils import usertypes, log
@@ -46,7 +46,7 @@ class BackendError(Error):
def __init__(
self, name: str,
backend: usertypes.Backend,
- raw_backends: typing.Optional[typing.Mapping[str, bool]]
+ raw_backends: Optional[Mapping[str, bool]]
) -> None:
if raw_backends is None or not raw_backends[backend.name]:
msg = ("The {} setting is not available with the {} backend!"
@@ -76,8 +76,7 @@ class ValidationError(Error):
msg: Additional error message.
"""
- def __init__(self, value: typing.Any,
- msg: typing.Union[str, Exception]) -> None:
+ def __init__(self, value: Any, msg: Union[str, Exception]) -> None:
super().__init__("Invalid value '{}' - {}".format(value, msg))
self.option = None
@@ -117,9 +116,9 @@ class ConfigErrorDesc:
traceback: The formatted traceback of the exception.
"""
- text = attr.ib() # type: str
- exception = attr.ib() # type: typing.Union[str, Exception]
- traceback = attr.ib(None) # type: str
+ text: str = attr.ib()
+ exception: Union[str, Exception] = attr.ib()
+ traceback: str = attr.ib(None)
def __str__(self) -> str:
if self.traceback:
@@ -141,7 +140,7 @@ class ConfigFileErrors(Error):
def __init__(self,
basename: str,
- errors: typing.Sequence[ConfigErrorDesc], *,
+ errors: Sequence[ConfigErrorDesc], *,
fatal: bool = False) -> None:
super().__init__("Errors occurred while reading {}:\n{}".format(
basename, '\n'.join(' {}'.format(e) for e in errors)))
diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py
index ae05a2861..5569174c9 100644
--- a/qutebrowser/config/configfiles.py
+++ b/qutebrowser/config/configfiles.py
@@ -27,8 +27,9 @@ import textwrap
import traceback
import configparser
import contextlib
-import typing
import re
+from typing import (TYPE_CHECKING, Any, Dict, Iterable, Iterator, List, Mapping,
+ MutableMapping, Optional, cast)
import yaml
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, QSettings, qVersion
@@ -39,15 +40,15 @@ from qutebrowser.config import (configexc, config, configdata, configutils,
from qutebrowser.keyinput import keyutils
from qutebrowser.utils import standarddir, utils, qtutils, log, urlmatch
-if typing.TYPE_CHECKING:
+if TYPE_CHECKING:
from qutebrowser.misc import savemanager
# The StateConfig instance
-state = typing.cast('StateConfig', None)
+state = cast('StateConfig', None)
-_SettingsType = typing.Dict[str, typing.Dict[str, typing.Any]]
+_SettingsType = Dict[str, Dict[str, Any]]
class StateConfig(configparser.ConfigParser):
@@ -77,6 +78,7 @@ class StateConfig(configparser.ConfigParser):
deleted_keys = [
('general', 'fooled'),
('general', 'backend-warning-shown'),
+ ('general', 'old-qt-warning-shown'),
('geometry', 'inspector'),
]
for sect, key in deleted_keys:
@@ -117,7 +119,7 @@ class YamlConfig(QObject):
'autoconfig.yml')
self._dirty = False
- self._values = {} # type: typing.Dict[str, configutils.Values]
+ self._values: Dict[str, configutils.Values] = {}
for name, opt in configdata.DATA.items():
self._values[name] = configutils.Values(opt)
@@ -130,7 +132,7 @@ class YamlConfig(QObject):
"""
save_manager.add_saveable('yaml-config', self._save, self.changed)
- def __iter__(self) -> typing.Iterator[configutils.Values]:
+ def __iter__(self) -> Iterator[configutils.Values]:
"""Iterate over configutils.Values items."""
yield from self._values.values()
@@ -145,7 +147,7 @@ class YamlConfig(QObject):
if not self._dirty:
return
- settings = {} # type: _SettingsType
+ settings: _SettingsType = {}
for name, values in sorted(self._values.items()):
if not values:
continue
@@ -167,10 +169,7 @@ class YamlConfig(QObject):
""".lstrip('\n')))
utils.yaml_dump(data, f)
- def _pop_object(self,
- yaml_data: typing.Any,
- key: str,
- typ: type) -> typing.Any:
+ def _pop_object(self, yaml_data: Any, key: str, typ: type) -> Any:
"""Get a global object from the given data."""
if not isinstance(yaml_data, dict):
desc = configexc.ConfigErrorDesc("While loading data",
@@ -227,19 +226,18 @@ class YamlConfig(QObject):
self._validate_names(settings)
self._build_values(settings)
- def _load_settings_object(self, yaml_data: typing.Any) -> '_SettingsType':
+ def _load_settings_object(self, yaml_data: Any) -> '_SettingsType':
"""Load the settings from the settings: key."""
return self._pop_object(yaml_data, 'settings', dict)
- def _load_legacy_settings_object(self,
- yaml_data: typing.Any) -> '_SettingsType':
+ def _load_legacy_settings_object(self, yaml_data: Any) -> '_SettingsType':
data = self._pop_object(yaml_data, 'global', dict)
settings = {}
for name, value in data.items():
settings[name] = {'global': value}
return settings
- def _build_values(self, settings: typing.Mapping) -> None:
+ def _build_values(self, settings: Mapping) -> None:
"""Build up self._values from the values in the given dict."""
errors = []
for name, yaml_values in settings.items():
@@ -285,7 +283,7 @@ class YamlConfig(QObject):
for e in sorted(unknown)]
raise configexc.ConfigFileErrors('autoconfig.yml', errors)
- def set_obj(self, name: str, value: typing.Any, *,
+ def set_obj(self, name: str, value: Any, *,
pattern: urlmatch.UrlPattern = None) -> None:
"""Set the given setting to the given value."""
self._values[name].add(value, pattern)
@@ -477,8 +475,7 @@ 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:
+ def _migrate_to_multiple(self, old_name: str, new_names: Iterable[str]) -> None:
if old_name not in self._settings:
return
@@ -541,12 +538,12 @@ class ConfigAPI:
def __init__(self, conf: config.Config, keyconfig: config.KeyConfig):
self._config = conf
self._keyconfig = keyconfig
- self.errors = [] # type: typing.List[configexc.ConfigErrorDesc]
+ self.errors: List[configexc.ConfigErrorDesc] = []
self.configdir = pathlib.Path(standarddir.config())
self.datadir = pathlib.Path(standarddir.data())
@contextlib.contextmanager
- def _handle_error(self, action: str, name: str) -> typing.Iterator[None]:
+ def _handle_error(self, action: str, name: str) -> Iterator[None]:
"""Catch config-related exceptions and save them in self.errors."""
try:
yield
@@ -582,21 +579,19 @@ class ConfigAPI:
with self._handle_error('reading', 'autoconfig.yml'):
read_autoconfig()
- def get(self, name: str, pattern: str = None) -> typing.Any:
+ def get(self, name: str, pattern: str = None) -> Any:
"""Get a setting value from the config, optionally with a pattern."""
with self._handle_error('getting', name):
urlpattern = urlmatch.UrlPattern(pattern) if pattern else None
return self._config.get_mutable_obj(name, pattern=urlpattern)
- def set(self, name: str, value: typing.Any, pattern: str = None) -> None:
+ def set(self, name: str, value: Any, pattern: str = None) -> None:
"""Set a setting value in the config, optionally with a pattern."""
with self._handle_error('setting', name):
urlpattern = urlmatch.UrlPattern(pattern) if pattern else None
self._config.set_obj(name, value, pattern=urlpattern)
- def bind(self, key: str,
- command: typing.Optional[str],
- mode: str = 'normal') -> None:
+ def bind(self, key: str, command: Optional[str], mode: str = 'normal') -> None:
"""Bind a key to a command, with an optional key mode."""
with self._handle_error('binding', key):
seq = keyutils.KeySequence.parse(key)
@@ -625,7 +620,7 @@ class ConfigAPI:
self.errors += e.errors
@contextlib.contextmanager
- def pattern(self, pattern: str) -> typing.Iterator[config.ConfigContainer]:
+ def pattern(self, pattern: str) -> Iterator[config.ConfigContainer]:
"""Get a ConfigContainer for the given pattern."""
# We need to propagate the exception so we don't need to return
# something.
@@ -641,9 +636,8 @@ class ConfigPyWriter:
def __init__(
self,
- options: typing.List,
- bindings: typing.MutableMapping[
- str, typing.Mapping[str, typing.Optional[str]]],
+ options: List,
+ bindings: MutableMapping[str, Mapping[str, Optional[str]]],
*, commented: bool) -> None:
self._options = options
self._bindings = bindings
@@ -664,7 +658,7 @@ class ConfigPyWriter:
else:
return line
- def _gen_lines(self) -> typing.Iterator[str]:
+ def _gen_lines(self) -> Iterator[str]:
"""Generate a config.py with the given settings/bindings.
Yields individual lines.
@@ -673,7 +667,7 @@ class ConfigPyWriter:
yield from self._gen_options()
yield from self._gen_bindings()
- def _gen_header(self) -> typing.Iterator[str]:
+ def _gen_header(self) -> Iterator[str]:
"""Generate the initial header of the config."""
yield self._line("# Autogenerated config.py")
yield self._line("#")
@@ -706,7 +700,7 @@ class ConfigPyWriter:
yield self._line("config.load_autoconfig(False)")
yield ''
- def _gen_options(self) -> typing.Iterator[str]:
+ def _gen_options(self) -> Iterator[str]:
"""Generate the options part of the config."""
for pattern, opt, value in self._options:
if opt.name in ['bindings.commands', 'bindings.default']:
@@ -734,7 +728,7 @@ class ConfigPyWriter:
opt.name, value, str(pattern)))
yield ''
- def _gen_bindings(self) -> typing.Iterator[str]:
+ def _gen_bindings(self) -> Iterator[str]:
"""Generate the bindings part of the config."""
normal_bindings = self._bindings.pop('normal', {})
if normal_bindings:
@@ -835,7 +829,7 @@ def read_autoconfig() -> None:
@contextlib.contextmanager
-def saved_sys_properties() -> typing.Iterator[None]:
+def saved_sys_properties() -> Iterator[None]:
"""Save various sys properties such as sys.path and sys.modules."""
old_path = sys.path.copy()
old_modules = sys.modules.copy()
diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py
index 81c47590d..6328c3140 100644
--- a/qutebrowser/config/configtypes.py
+++ b/qutebrowser/config/configtypes.py
@@ -50,13 +50,14 @@ import itertools
import functools
import operator
import json
-import typing
+from typing import (Any, Callable, Dict as DictType, Iterable, Iterator,
+ List as ListType, Optional, Pattern, Sequence, Tuple, Union)
import attr
import yaml
from PyQt5.QtCore import QUrl, Qt
-from PyQt5.QtGui import QColor, QFontDatabase
-from PyQt5.QtWidgets import QTabWidget, QTabBar, QApplication
+from PyQt5.QtGui import QColor
+from PyQt5.QtWidgets import QTabWidget, QTabBar
from PyQt5.QtNetwork import QNetworkProxy
from qutebrowser.misc import objects, debugcachestats
@@ -79,10 +80,10 @@ BOOLEAN_STATES = {'1': True, 'yes': True, 'true': True, 'on': True,
'0': False, 'no': False, 'false': False, 'off': False}
-_Completions = typing.Optional[typing.Iterable[typing.Tuple[str, str]]]
-_StrUnset = typing.Union[str, usertypes.Unset]
-_UnsetNone = typing.Union[None, usertypes.Unset]
-_StrUnsetNone = typing.Union[str, _UnsetNone]
+_Completions = Optional[Iterable[Tuple[str, str]]]
+_StrUnset = Union[str, usertypes.Unset]
+_UnsetNone = Union[None, usertypes.Unset]
+_StrUnsetNone = Union[str, _UnsetNone]
class ValidValues:
@@ -95,35 +96,40 @@ class ValidValues:
generate_docs: Whether to show the values in the docs.
"""
- def __init__(self,
- *values: typing.Union[str,
- typing.Dict[str, str],
- typing.Tuple[str, str]],
- generate_docs: bool = True) -> None:
+ def __init__(
+ self,
+ *values: Union[
+ str,
+ DictType[str, Optional[str]],
+ Tuple[str, Optional[str]],
+ ],
+ generate_docs: bool = True,
+ ) -> None:
if not values:
raise ValueError("ValidValues with no values makes no sense!")
- self.descriptions = {} # type: typing.Dict[str, str]
- self.values = [] # type: typing.List[str]
+ self.descriptions: DictType[str, str] = {}
+ self.values: ListType[str] = []
self.generate_docs = generate_docs
for value in values:
if isinstance(value, str):
# Value without description
- self.values.append(value)
+ val = value
+ desc = None
elif isinstance(value, dict):
# List of dicts from configdata.yml
assert len(value) == 1, value
- value, desc = list(value.items())[0]
- self.values.append(value)
- self.descriptions[value] = desc
+ val, desc = list(value.items())[0]
else:
- # (value, description) tuple
- self.values.append(value[0])
- self.descriptions[value[0]] = value[1]
+ val, desc = value
+
+ self.values.append(val)
+ if desc is not None:
+ self.descriptions[val] = desc
def __contains__(self, val: str) -> bool:
return val in self.values
- def __iter__(self) -> typing.Iterator[str]:
+ def __iter__(self) -> Iterator[str]:
return self.values.__iter__()
def __repr__(self) -> str:
@@ -150,19 +156,19 @@ class BaseType:
def __init__(self, none_ok: bool = False) -> None:
self.none_ok = none_ok
- self.valid_values = None # type: typing.Optional[ValidValues]
+ self.valid_values: Optional[ValidValues] = None
def get_name(self) -> str:
"""Get a name for the type for documentation."""
return self.__class__.__name__
- def get_valid_values(self) -> typing.Optional[ValidValues]:
+ def get_valid_values(self) -> Optional[ValidValues]:
"""Get the type's valid values for documentation."""
return self.valid_values
def _basic_py_validation(
- self, value: typing.Any,
- pytype: typing.Union[type, typing.Tuple[type, ...]]) -> None:
+ self, value: Any,
+ pytype: Union[type, Tuple[type, ...]]) -> None:
"""Do some basic validation for Python values (emptyness, type).
Arguments:
@@ -214,8 +220,7 @@ class BaseType:
raise configexc.ValidationError(
value, "may not contain unprintable chars!")
- def _validate_surrogate_escapes(self, full_value: typing.Any,
- value: typing.Any) -> None:
+ def _validate_surrogate_escapes(self, full_value: Any, value: Any) -> None:
"""Make sure the given value doesn't contain surrogate escapes.
This is used for values passed to json.dump, as it can't handle those.
@@ -241,7 +246,7 @@ class BaseType:
value,
"valid values: {}".format(', '.join(self.valid_values)))
- def from_str(self, value: str) -> typing.Any:
+ def from_str(self, value: str) -> Any:
"""Get the setting value from a string.
By default this invokes to_py() for validation and returns the
@@ -260,11 +265,11 @@ class BaseType:
return None
return value
- def from_obj(self, value: typing.Any) -> typing.Any:
+ def from_obj(self, value: Any) -> Any:
"""Get the setting value from a config.py/YAML object."""
return value
- def to_py(self, value: typing.Any) -> typing.Any:
+ def to_py(self, value: Any) -> Any:
"""Get the setting value from a Python value.
Args:
@@ -278,7 +283,7 @@ class BaseType:
"""
raise NotImplementedError
- def to_str(self, value: typing.Any) -> str:
+ def to_str(self, value: Any) -> str:
"""Get a string from the setting value.
The resulting string should be parseable again by from_str.
@@ -288,7 +293,7 @@ class BaseType:
assert isinstance(value, str), value
return value
- def to_doc(self, value: typing.Any, indent: int = 0) -> str:
+ def to_doc(self, value: Any, indent: int = 0) -> str:
"""Get a string with the given value for the documentation.
This currently uses asciidoc syntax.
@@ -310,17 +315,10 @@ class BaseType:
"""
if self.valid_values is None:
return None
- else:
- out = []
- for val in self.valid_values:
- try:
- desc = self.valid_values.descriptions[val]
- except KeyError:
- # Some values are self-explaining and don't need a
- # description.
- desc = ""
- out.append((val, desc))
- return out
+ return [
+ (val, self.valid_values.descriptions.get(val, ""))
+ for val in self.valid_values
+ ]
def __repr__(self) -> str:
return utils.get_repr(self, none_ok=self.none_ok)
@@ -331,24 +329,25 @@ class MappingType(BaseType):
"""Base class for any setting which has a mapping to the given values.
Attributes:
- MAPPING: The mapping to use.
+ MAPPING: A mapping from config values to (translated_value, docs) tuples.
"""
- MAPPING = {} # type: typing.Dict[str, typing.Any]
+ MAPPING: DictType[str, Tuple[Any, Optional[str]]] = {}
- def __init__(self, none_ok: bool = False,
- valid_values: ValidValues = None) -> None:
+ def __init__(self, none_ok: bool = False) -> None:
super().__init__(none_ok)
- self.valid_values = valid_values
+ self.valid_values = ValidValues(
+ *[(key, doc) for (key, (_val, doc)) in self.MAPPING.items()])
- def to_py(self, value: typing.Any) -> typing.Any:
+ def to_py(self, value: Any) -> Any:
self._basic_py_validation(value, str)
if isinstance(value, usertypes.Unset):
return value
elif not value:
return None
self._validate_valid_values(value.lower())
- return self.MAPPING[value.lower()]
+ mapped, _doc = self.MAPPING[value.lower()]
+ return mapped
def __repr__(self) -> str:
return utils.get_repr(self, none_ok=self.none_ok,
@@ -491,10 +490,10 @@ class List(BaseType):
name += " of " + self.valtype.get_name()
return name
- def get_valid_values(self) -> typing.Optional[ValidValues]:
+ def get_valid_values(self) -> Optional[ValidValues]:
return self.valtype.get_valid_values()
- def from_str(self, value: str) -> typing.Optional[typing.List]:
+ def from_str(self, value: str) -> Optional[ListType]:
self._basic_str_validation(value)
if not value:
return None
@@ -509,15 +508,15 @@ class List(BaseType):
self.to_py(yaml_val)
return yaml_val
- def from_obj(self, value: typing.Optional[typing.List]) -> typing.List:
+ def from_obj(self, value: Optional[ListType]) -> ListType:
if value is None:
return []
return [self.valtype.from_obj(v) for v in value]
def to_py(
self,
- value: typing.Union[typing.List, usertypes.Unset]
- ) -> typing.Union[typing.List, usertypes.Unset]:
+ value: Union[ListType, usertypes.Unset]
+ ) -> Union[ListType, usertypes.Unset]:
self._basic_py_validation(value, list)
if isinstance(value, usertypes.Unset):
return value
@@ -532,13 +531,13 @@ class List(BaseType):
"be set!".format(self.length))
return [self.valtype.to_py(v) for v in value]
- def to_str(self, value: typing.List) -> str:
+ def to_str(self, value: ListType) -> str:
if not value:
# An empty list is treated just like None -> empty string
return ''
return json.dumps(value)
- def to_doc(self, value: typing.List, indent: int = 0) -> str:
+ def to_doc(self, value: ListType, indent: int = 0) -> str:
if not value:
return 'empty'
@@ -572,14 +571,13 @@ class ListOrValue(BaseType):
def __init__(self, valtype: BaseType, *,
none_ok: bool = False,
- **kwargs: typing.Any) -> None:
+ **kwargs: Any) -> None:
super().__init__(none_ok)
assert not isinstance(valtype, (List, ListOrValue)), valtype
self.listtype = List(valtype, none_ok=none_ok, **kwargs)
self.valtype = valtype
- def _val_and_type(self,
- value: typing.Any) -> typing.Tuple[typing.Any, BaseType]:
+ def _val_and_type(self, value: Any) -> Tuple[Any, BaseType]:
"""Get the value and type to use for to_str/to_doc/from_str."""
if isinstance(value, list):
if len(value) == 1:
@@ -592,21 +590,21 @@ class ListOrValue(BaseType):
def get_name(self) -> str:
return self.listtype.get_name() + ', or ' + self.valtype.get_name()
- def get_valid_values(self) -> typing.Optional[ValidValues]:
+ def get_valid_values(self) -> Optional[ValidValues]:
return self.valtype.get_valid_values()
- def from_str(self, value: str) -> typing.Any:
+ def from_str(self, value: str) -> Any:
try:
return self.listtype.from_str(value)
except configexc.ValidationError:
return self.valtype.from_str(value)
- def from_obj(self, value: typing.Any) -> typing.Any:
+ def from_obj(self, value: Any) -> Any:
if value is None:
return []
return value
- def to_py(self, value: typing.Any) -> typing.Any:
+ def to_py(self, value: Any) -> Any:
if isinstance(value, usertypes.Unset):
return value
@@ -615,14 +613,14 @@ class ListOrValue(BaseType):
except configexc.ValidationError:
return self.listtype.to_py(value)
- def to_str(self, value: typing.Any) -> str:
+ def to_str(self, value: Any) -> str:
if value is None:
return ''
val, typ = self._val_and_type(value)
return typ.to_str(val)
- def to_doc(self, value: typing.Any, indent: int = 0) -> str:
+ def to_doc(self, value: Any, indent: int = 0) -> str:
if value is None:
return 'empty'
@@ -641,7 +639,7 @@ class FlagList(List):
the valid values of the setting.
"""
- combinable_values = None # type: typing.Optional[typing.Sequence]
+ combinable_values: Optional[Sequence] = None
_show_valtype = False
@@ -651,15 +649,15 @@ class FlagList(List):
super().__init__(valtype=String(), none_ok=none_ok, length=length)
self.valtype.valid_values = valid_values
- def _check_duplicates(self, values: typing.List) -> None:
+ def _check_duplicates(self, values: ListType) -> None:
if len(set(values)) != len(values):
raise configexc.ValidationError(
values, "List contains duplicate values!")
def to_py(
self,
- value: typing.Union[usertypes.Unset, typing.List],
- ) -> typing.Union[usertypes.Unset, typing.List]:
+ value: Union[usertypes.Unset, ListType],
+ ) -> Union[usertypes.Unset, ListType]:
vals = super().to_py(value)
if not isinstance(vals, usertypes.Unset):
self._check_duplicates(vals)
@@ -703,13 +701,12 @@ class Bool(BaseType):
super().__init__(none_ok)
self.valid_values = ValidValues('true', 'false', generate_docs=False)
- def to_py(self,
- value: typing.Union[bool, str, None]) -> typing.Optional[bool]:
+ def to_py(self, value: Union[bool, str, None]) -> Optional[bool]:
self._basic_py_validation(value, bool)
assert not isinstance(value, str)
return value
- def from_str(self, value: str) -> typing.Optional[bool]:
+ def from_str(self, value: str) -> Optional[bool]:
self._basic_str_validation(value)
if not value:
return None
@@ -719,7 +716,7 @@ class Bool(BaseType):
except KeyError:
raise configexc.ValidationError(value, "must be a boolean!")
- def to_str(self, value: typing.Optional[bool]) -> str:
+ def to_str(self, value: Optional[bool]) -> str:
mapping = {
None: '',
True: 'true',
@@ -737,7 +734,7 @@ class BoolAsk(Bool):
self.valid_values = ValidValues('true', 'false', 'ask')
def to_py(self, # type: ignore[override]
- value: typing.Union[bool, str]) -> typing.Union[bool, str, None]:
+ value: Union[bool, str]) -> Union[bool, str, None]:
# basic validation unneeded if it's == 'ask' and done by Bool if we
# call super().to_py
if isinstance(value, str) and value.lower() == 'ask':
@@ -745,14 +742,14 @@ class BoolAsk(Bool):
return super().to_py(value)
def from_str(self, # type: ignore[override]
- value: str) -> typing.Union[bool, str, None]:
+ value: str) -> Union[bool, str, None]:
# basic validation unneeded if it's == 'ask' and done by Bool if we
# call super().from_str
if value.lower() == 'ask':
return 'ask'
return super().from_str(value)
- def to_str(self, value: typing.Union[bool, str, None]) -> str:
+ def to_str(self, value: Union[bool, str, None]) -> str:
mapping = {
None: '',
True: 'true',
@@ -785,8 +782,8 @@ class _Numeric(BaseType): # pylint: disable=abstract-method
.format(self.minval, self.maxval))
def _parse_bound(
- self, bound: typing.Union[None, str, int, float]
- ) -> typing.Union[None, int, float]:
+ self, bound: Union[None, str, int, float]
+ ) -> Union[None, int, float]:
"""Get a numeric bound from a string like 'maxint'."""
if bound == 'maxint':
return qtutils.MAXVALS['int']
@@ -798,7 +795,7 @@ class _Numeric(BaseType): # pylint: disable=abstract-method
return bound
def _validate_bounds(self,
- value: typing.Union[int, float, _UnsetNone],
+ value: Union[int, float, _UnsetNone],
suffix: str = '') -> None:
"""Validate self.minval and self.maxval."""
if value is None:
@@ -814,7 +811,7 @@ class _Numeric(BaseType): # pylint: disable=abstract-method
elif not self.zero_ok and value == 0:
raise configexc.ValidationError(value, "must not be 0!")
- def to_str(self, value: typing.Union[None, int, float]) -> str:
+ def to_str(self, value: Union[None, int, float]) -> str:
if value is None:
return ''
return str(value)
@@ -828,7 +825,7 @@ class Int(_Numeric):
"""Base class for an integer setting."""
- def from_str(self, value: str) -> typing.Optional[int]:
+ def from_str(self, value: str) -> Optional[int]:
self._basic_str_validation(value)
if not value:
return None
@@ -840,10 +837,7 @@ class Int(_Numeric):
self.to_py(intval)
return intval
- def to_py(
- self,
- value: typing.Union[int, _UnsetNone]
- ) -> typing.Union[int, _UnsetNone]:
+ def to_py(self, value: Union[int, _UnsetNone]) -> Union[int, _UnsetNone]:
self._basic_py_validation(value, int)
self._validate_bounds(value)
return value
@@ -853,7 +847,7 @@ class Float(_Numeric):
"""Base class for a float setting."""
- def from_str(self, value: str) -> typing.Optional[float]:
+ def from_str(self, value: str) -> Optional[float]:
self._basic_str_validation(value)
if not value:
return None
@@ -867,8 +861,8 @@ class Float(_Numeric):
def to_py(
self,
- value: typing.Union[int, float, _UnsetNone],
- ) -> typing.Union[int, float, _UnsetNone]:
+ value: Union[int, float, _UnsetNone],
+ ) -> Union[int, float, _UnsetNone]:
self._basic_py_validation(value, (int, float))
self._validate_bounds(value)
return value
@@ -880,8 +874,8 @@ class Perc(_Numeric):
def to_py(
self,
- value: typing.Union[float, int, str, _UnsetNone]
- ) -> typing.Union[float, int, _UnsetNone]:
+ value: Union[float, int, str, _UnsetNone]
+ ) -> Union[float, int, _UnsetNone]:
self._basic_py_validation(value, (float, int, str))
if isinstance(value, usertypes.Unset):
return value
@@ -898,7 +892,7 @@ class Perc(_Numeric):
self._validate_bounds(value, suffix='%')
return value
- def to_str(self, value: typing.Union[None, float, int, str]) -> str:
+ def to_str(self, value: Union[None, float, int, str]) -> str:
if value is None:
return ''
elif isinstance(value, str):
@@ -929,7 +923,7 @@ class PercOrInt(_Numeric):
raise ValueError("minperc ({}) needs to be <= maxperc "
"({})!".format(self.minperc, self.maxperc))
- def from_str(self, value: str) -> typing.Union[None, str, int]:
+ def from_str(self, value: str) -> Union[None, str, int]:
self._basic_str_validation(value)
if not value:
return None
@@ -946,10 +940,7 @@ class PercOrInt(_Numeric):
self.to_py(intval)
return intval
- def to_py(
- self,
- value: typing.Union[None, str, int]
- ) -> typing.Union[None, str, int]:
+ def to_py(self, value: Union[None, str, int]) -> Union[None, str, int]:
"""Expect a value like '42%' as string, or 23 as int."""
self._basic_py_validation(value, (int, str))
if value is None:
@@ -1009,20 +1000,11 @@ class ColorSystem(MappingType):
"""The color system to use for color interpolation."""
- def __init__(self, none_ok: bool = False) -> None:
- super().__init__(
- none_ok,
- valid_values=ValidValues(
- ('rgb', "Interpolate in the RGB color system."),
- ('hsv', "Interpolate in the HSV color system."),
- ('hsl', "Interpolate in the HSL color system."),
- ('none', "Don't show a gradient.")))
-
MAPPING = {
- 'rgb': QColor.Rgb,
- 'hsv': QColor.Hsv,
- 'hsl': QColor.Hsl,
- 'none': None,
+ 'rgb': (QColor.Rgb, "Interpolate in the RGB color system."),
+ 'hsv': (QColor.Hsv, "Interpolate in the HSV color system."),
+ 'hsl': (QColor.Hsl, "Interpolate in the HSL color system."),
+ 'none': (None, "Don't show a gradient."),
}
@@ -1030,19 +1012,13 @@ class IgnoreCase(MappingType):
"""Whether to search case insensitively."""
- def __init__(self, none_ok: bool = False) -> None:
- super().__init__(
- none_ok,
- valid_values=ValidValues(
- ('always', "Search case-insensitively."),
- ('never', "Search case-sensitively."),
- ('smart', ("Search case-sensitively if there are capital "
- "characters."))))
-
MAPPING = {
- 'always': usertypes.IgnoreCase.always,
- 'never': usertypes.IgnoreCase.never,
- 'smart': usertypes.IgnoreCase.smart,
+ 'always': (usertypes.IgnoreCase.always, "Search case-insensitively."),
+ 'never': (usertypes.IgnoreCase.never, "Search case-sensitively."),
+ 'smart': (
+ usertypes.IgnoreCase.smart,
+ "Search case-sensitively if there are capital characters."
+ ),
}
@@ -1076,7 +1052,7 @@ class QtColor(BaseType):
except ValueError:
raise configexc.ValidationError(val, "must be a valid color value")
- def to_py(self, value: _StrUnset) -> typing.Union[_UnsetNone, QColor]:
+ def to_py(self, value: _StrUnset) -> Union[_UnsetNone, QColor]:
self._basic_py_validation(value, str)
if isinstance(value, usertypes.Unset):
return value
@@ -1088,12 +1064,12 @@ class QtColor(BaseType):
kind = value[:openparen]
vals = value[openparen+1:-1].split(',')
- converters = {
+ converters: DictType[str, Callable[..., QColor]] = {
'rgba': QColor.fromRgb,
'rgb': QColor.fromRgb,
'hsva': QColor.fromHsv,
'hsv': QColor.fromHsv,
- } # type: typing.Dict[str, typing.Callable[..., QColor]]
+ }
conv = converters.get(kind)
if not conv:
@@ -1159,8 +1135,8 @@ class FontBase(BaseType):
"""Base class for Font/FontFamily."""
# Gets set when the config is initialized.
- default_family = None # type: str
- default_size = None # type: str
+ default_family: Optional[str] = None
+ default_size: Optional[str] = None
font_regex = re.compile(r"""
(
(
@@ -1178,61 +1154,21 @@ class FontBase(BaseType):
(?P<family>.+) # mandatory font family""", re.VERBOSE)
@classmethod
- def set_defaults(cls, default_family: typing.List[str],
- default_size: str) -> None:
+ def set_defaults(cls, default_family: ListType[str], default_size: str) -> None:
"""Make sure default_family/default_size are available.
If the given family value (fonts.default_family in the config) is
unset, a system-specific default monospace font is used.
-
- Note that (at least) three ways of getting the default monospace font
- exist:
-
- 1) f = QFont()
- f.setStyleHint(QFont.Monospace)
- print(f.defaultFamily())
-
- 2) f = QFont()
- f.setStyleHint(QFont.TypeWriter)
- print(f.defaultFamily())
-
- 3) f = QFontDatabase.systemFont(QFontDatabase.FixedFont)
- print(f.family())
-
- They yield different results depending on the OS:
-
- QFont.Monospace | QFont.TypeWriter | QFontDatabase
- ------------------------------------------------------
- Windows: Courier New | Courier New | Courier New
- Linux: DejaVu Sans Mono | DejaVu Sans Mono | monospace
- macOS: Menlo | American Typewriter | Monaco
-
- Test script: https://p.cmpl.cc/d4dfe573
-
- On Linux, it seems like both actually resolve to the same font.
-
- On macOS, "American Typewriter" looks like it indeed tries to imitate a
- typewriter, so it's not really a suitable UI font.
-
- Looking at those Wikipedia articles:
-
- https://en.wikipedia.org/wiki/Monaco_(typeface)
- https://en.wikipedia.org/wiki/Menlo_(typeface)
-
- the "right" choice isn't really obvious. Thus, let's go for the
- QFontDatabase approach here, since it's by far the simplest one.
"""
if default_family:
families = configutils.FontFamilies(default_family)
else:
- assert QApplication.instance() is not None
- font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
- families = configutils.FontFamilies([font.family()])
+ families = configutils.FontFamilies.from_system_default()
cls.default_family = families.to_str(quote=True)
cls.default_size = default_size
- def to_py(self, value: typing.Any) -> typing.Any:
+ def to_py(self, value: Any) -> Any:
raise NotImplementedError
@@ -1315,7 +1251,7 @@ class Regex(BaseType):
operator.or_,
(getattr(re, flag.strip()) for flag in flags.split(' | ')))
- def _compile_regex(self, pattern: str) -> typing.Pattern[str]:
+ def _compile_regex(self, pattern: str) -> Pattern[str]:
"""Check if the given regex is valid.
Some semi-invalid regexes can also raise warnings - we also treat them as
@@ -1336,8 +1272,8 @@ class Regex(BaseType):
def to_py(
self,
- value: typing.Union[str, typing.Pattern[str], usertypes.Unset]
- ) -> typing.Union[_UnsetNone, typing.Pattern[str]]:
+ value: Union[str, Pattern[str], usertypes.Unset]
+ ) -> Union[_UnsetNone, 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):
@@ -1349,8 +1285,7 @@ class Regex(BaseType):
else:
return value
- def to_str(self,
- value: typing.Union[None, str, typing.Pattern[str]]) -> str:
+ def to_str(self, value: Union[None, str, Pattern[str]]) -> str:
if value is None:
return ''
elif isinstance(value, self._regex_type):
@@ -1370,10 +1305,10 @@ class Dict(BaseType):
When setting from a string, pass a json-like dict, e.g. `{"key", "value"}`.
"""
- def __init__(self, keytype: typing.Union[String, 'Key'],
+ def __init__(self, keytype: Union[String, 'Key'],
valtype: BaseType, *,
- fixed_keys: typing.Iterable = None,
- required_keys: typing.Iterable = None,
+ fixed_keys: Iterable = None,
+ required_keys: Iterable = None,
none_ok: bool = False) -> None:
super().__init__(none_ok)
# If the keytype is not a string, we'll get problems with showing it as
@@ -1384,7 +1319,7 @@ class Dict(BaseType):
self.fixed_keys = fixed_keys
self.required_keys = required_keys
- def _validate_keys(self, value: typing.Dict) -> None:
+ def _validate_keys(self, value: DictType) -> None:
if (self.fixed_keys is not None and not
set(value.keys()).issubset(self.fixed_keys)):
raise configexc.ValidationError(
@@ -1395,7 +1330,7 @@ class Dict(BaseType):
raise configexc.ValidationError(
value, "Required keys {}".format(self.required_keys))
- def from_str(self, value: str) -> typing.Optional[typing.Dict]:
+ def from_str(self, value: str) -> Optional[DictType]:
self._basic_str_validation(value)
if not value:
return None
@@ -1410,14 +1345,14 @@ class Dict(BaseType):
self.to_py(yaml_val)
return yaml_val
- def from_obj(self, value: typing.Optional[typing.Dict]) -> typing.Dict:
+ def from_obj(self, value: Optional[DictType]) -> DictType:
if value is None:
return {}
return {self.keytype.from_obj(key): self.valtype.from_obj(val)
for key, val in value.items()}
- def _fill_fixed_keys(self, value: typing.Dict) -> typing.Dict:
+ def _fill_fixed_keys(self, value: DictType) -> DictType:
"""Fill missing fixed keys with a None-value."""
if self.fixed_keys is None:
return value
@@ -1428,8 +1363,8 @@ class Dict(BaseType):
def to_py(
self,
- value: typing.Union[typing.Dict, _UnsetNone]
- ) -> typing.Union[typing.Dict, usertypes.Unset]:
+ value: Union[DictType, _UnsetNone]
+ ) -> Union[DictType, usertypes.Unset]:
self._basic_py_validation(value, dict)
if isinstance(value, usertypes.Unset):
return value
@@ -1445,13 +1380,13 @@ class Dict(BaseType):
for key, val in value.items()}
return self._fill_fixed_keys(d)
- def to_str(self, value: typing.Dict) -> str:
+ def to_str(self, value: DictType) -> str:
if not value:
# An empty Dict is treated just like None -> empty string
return ''
return json.dumps(value, sort_keys=True)
- def to_doc(self, value: typing.Dict, indent: int = 0) -> str:
+ def to_doc(self, value: DictType, indent: int = 0) -> str:
if not value:
return 'empty'
lines = ['\n']
@@ -1474,7 +1409,7 @@ class File(BaseType):
"""A file on the local filesystem."""
- def __init__(self, required: bool = True, **kwargs: typing.Any) -> None:
+ def __init__(self, required: bool = True, **kwargs: Any) -> None:
super().__init__(**kwargs)
self.required = required
@@ -1540,7 +1475,7 @@ class FormatString(BaseType):
completions: completions to be used, or None
"""
- def __init__(self, fields: typing.Iterable[str],
+ def __init__(self, fields: Iterable[str],
none_ok: bool = False,
completions: _Completions = None) -> None:
super().__init__(none_ok)
@@ -1593,8 +1528,8 @@ class ShellCommand(List):
def to_py(
self,
- value: typing.Union[typing.List, usertypes.Unset],
- ) -> typing.Union[typing.List, usertypes.Unset]:
+ value: Union[ListType, usertypes.Unset],
+ ) -> Union[ListType, usertypes.Unset]:
py_value = super().to_py(value)
if isinstance(py_value, usertypes.Unset):
return py_value
@@ -1627,7 +1562,7 @@ class Proxy(BaseType):
def to_py(
self,
value: _StrUnset
- ) -> typing.Union[_UnsetNone, QNetworkProxy, _SystemProxy, pac.PACFetcher]:
+ ) -> Union[_UnsetNone, QNetworkProxy, _SystemProxy, pac.PACFetcher]:
self._basic_py_validation(value, str)
if isinstance(value, usertypes.Unset):
return value
@@ -1697,7 +1632,7 @@ class FuzzyUrl(BaseType):
"""A URL which gets interpreted as search if needed."""
- def to_py(self, value: _StrUnset) -> typing.Union[QUrl, _UnsetNone]:
+ def to_py(self, value: _StrUnset) -> Union[QUrl, _UnsetNone]:
self._basic_py_validation(value, str)
if isinstance(value, usertypes.Unset):
return value
@@ -1715,10 +1650,10 @@ class PaddingValues:
"""Four padding values."""
- top = attr.ib() # type: int
- bottom = attr.ib() # type: int
- left = attr.ib() # type: int
- right = attr.ib() # type: int
+ top: int = attr.ib()
+ bottom: int = attr.ib()
+ left: int = attr.ib()
+ right: int = attr.ib()
class Padding(Dict):
@@ -1735,8 +1670,8 @@ class Padding(Dict):
def to_py( # type: ignore[override]
self,
- value: typing.Union[typing.Dict, _UnsetNone],
- ) -> typing.Union[usertypes.Unset, PaddingValues]:
+ value: Union[DictType, _UnsetNone],
+ ) -> Union[usertypes.Unset, PaddingValues]:
d = super().to_py(value)
if isinstance(d, usertypes.Unset):
return d
@@ -1766,33 +1701,23 @@ class Position(MappingType):
"""The position of the tab bar."""
MAPPING = {
- 'top': QTabWidget.North,
- 'bottom': QTabWidget.South,
- 'left': QTabWidget.West,
- 'right': QTabWidget.East,
+ 'top': (QTabWidget.North, None),
+ 'bottom': (QTabWidget.South, None),
+ 'left': (QTabWidget.West, None),
+ 'right': (QTabWidget.East, None),
}
- def __init__(self, none_ok: bool = False) -> None:
- super().__init__(
- none_ok,
- valid_values=ValidValues('top', 'bottom', 'left', 'right'))
-
class TextAlignment(MappingType):
"""Alignment of text."""
MAPPING = {
- 'left': Qt.AlignLeft,
- 'right': Qt.AlignRight,
- 'center': Qt.AlignCenter,
+ 'left': (Qt.AlignLeft, None),
+ 'right': (Qt.AlignRight, None),
+ 'center': (Qt.AlignCenter, None),
}
- def __init__(self, none_ok: bool = False) -> None:
- super().__init__(
- none_ok,
- valid_values=ValidValues('left', 'right', 'center'))
-
class VerticalPosition(String):
@@ -1807,7 +1732,7 @@ class Url(BaseType):
"""A URL as a string."""
- def to_py(self, value: _StrUnset) -> typing.Union[_UnsetNone, QUrl]:
+ def to_py(self, value: _StrUnset) -> Union[_UnsetNone, QUrl]:
self._basic_py_validation(value, str)
if isinstance(value, usertypes.Unset):
return value
@@ -1841,21 +1766,22 @@ class SelectOnRemove(MappingType):
"""Which tab to select when the focused tab is removed."""
MAPPING = {
- 'prev': QTabBar.SelectLeftTab,
- 'next': QTabBar.SelectRightTab,
- 'last-used': QTabBar.SelectPreviousTab,
+ 'prev': (
+ QTabBar.SelectLeftTab,
+ ("Select the tab which came before the closed one "
+ "(left in horizontal, above in vertical)."),
+ ),
+ 'next': (
+ QTabBar.SelectRightTab,
+ ("Select the tab which came after the closed one "
+ "(right in horizontal, below in vertical)."),
+ ),
+ 'last-used': (
+ QTabBar.SelectPreviousTab,
+ "Select the previously selected tab.",
+ ),
}
- def __init__(self, none_ok: bool = False) -> None:
- super().__init__(
- none_ok,
- valid_values=ValidValues(
- ('prev', "Select the tab which came before the closed one "
- "(left in horizontal, above in vertical)."),
- ('next', "Select the tab which came after the closed one "
- "(right in horizontal, below in vertical)."),
- ('last-used', "Select the previously selected tab.")))
-
class ConfirmQuit(FlagList):
@@ -1877,8 +1803,8 @@ class ConfirmQuit(FlagList):
def to_py(
self,
- value: typing.Union[usertypes.Unset, typing.List],
- ) -> typing.Union[typing.List, usertypes.Unset]:
+ value: Union[usertypes.Unset, ListType],
+ ) -> Union[ListType, usertypes.Unset]:
values = super().to_py(value)
if isinstance(values, usertypes.Unset):
return values
@@ -1931,7 +1857,7 @@ class Key(BaseType):
def to_py(
self,
value: _StrUnset
- ) -> typing.Union[_UnsetNone, keyutils.KeySequence]:
+ ) -> Union[_UnsetNone, keyutils.KeySequence]:
self._basic_py_validation(value, str)
if isinstance(value, usertypes.Unset):
return value
@@ -1955,7 +1881,7 @@ class UrlPattern(BaseType):
def to_py(
self,
value: _StrUnset
- ) -> typing.Union[_UnsetNone, urlmatch.UrlPattern]:
+ ) -> Union[_UnsetNone, urlmatch.UrlPattern]:
self._basic_py_validation(value, str)
if isinstance(value, usertypes.Unset):
return value
diff --git a/qutebrowser/config/configutils.py b/qutebrowser/config/configutils.py
index 3f7823772..e7a60a7eb 100644
--- a/qutebrowser/config/configutils.py
+++ b/qutebrowser/config/configutils.py
@@ -21,21 +21,25 @@
"""Utilities and data structures used by various config code."""
-import typing
import collections
import itertools
import operator
+from typing import (
+ TYPE_CHECKING, Any, Dict, Iterable, Iterator, List, Optional, Sequence, Set, Union,
+ MutableMapping)
from PyQt5.QtCore import QUrl
+from PyQt5.QtGui import QFontDatabase
+from PyQt5.QtWidgets import QApplication
from qutebrowser.utils import utils, urlmatch, usertypes, qtutils
from qutebrowser.config import configexc
-if typing.TYPE_CHECKING:
+if TYPE_CHECKING:
from qutebrowser.config import configdata
-def _widened_hostnames(hostname: str) -> typing.Iterable[str]:
+def _widened_hostnames(hostname: str) -> Iterable[str]:
"""A generator for widening string hostnames.
Ex: a.c.foo -> [a.c.foo, c.foo, foo]"""
@@ -56,8 +60,8 @@ class ScopedValue:
id_gen = itertools.count(0)
- def __init__(self, value: typing.Any,
- pattern: typing.Optional[urlmatch.UrlPattern],
+ def __init__(self, value: Any,
+ pattern: Optional[urlmatch.UrlPattern],
hide_userconfig: bool = False) -> None:
self.value = value
self.pattern = pattern
@@ -90,17 +94,17 @@ class Values:
_domain_map: A mapping from hostnames to all associated ScopedValues.
"""
- _VmapKeyType = typing.Optional[urlmatch.UrlPattern]
+ _VmapKeyType = Optional[urlmatch.UrlPattern]
def __init__(self,
opt: 'configdata.Option',
- values: typing.Sequence[ScopedValue] = ()) -> None:
+ values: Sequence[ScopedValue] = ()) -> None:
self.opt = opt
- self._vmap = collections.OrderedDict() \
- # type: collections.OrderedDict[Values._VmapKeyType, ScopedValue]
+ self._vmap: MutableMapping[
+ Values._VmapKeyType, ScopedValue] = collections.OrderedDict()
# A map from domain parts to rules that fall under them.
- self._domain_map = collections.defaultdict(set) \
- # type: typing.Dict[typing.Optional[str], typing.Set[ScopedValue]]
+ self._domain_map: Dict[
+ Optional[str], Set[ScopedValue]] = collections.defaultdict(set)
for scoped in values:
self._add_scoped(scoped)
@@ -117,7 +121,7 @@ class Values:
return '\n'.join(lines)
return '{}: <unchanged>'.format(self.opt.name)
- def dump(self, include_hidden: bool = False) -> typing.Sequence[str]:
+ def dump(self, include_hidden: bool = False) -> Sequence[str]:
"""Dump all customizations for this value.
Arguments:
@@ -138,7 +142,7 @@ class Values:
return lines
- def __iter__(self) -> typing.Iterator['ScopedValue']:
+ def __iter__(self) -> Iterator['ScopedValue']:
"""Yield ScopedValue elements.
This yields in "normal" order, i.e. global and then first-set settings
@@ -151,12 +155,12 @@ class Values:
return bool(self._vmap)
def _check_pattern_support(
- self, arg: typing.Union[urlmatch.UrlPattern, QUrl, None]) -> None:
+ self, arg: Union[urlmatch.UrlPattern, QUrl, None]) -> None:
"""Make sure patterns are supported if one was given."""
if arg is not None and not self.opt.supports_pattern:
raise configexc.NoPatternError(self.opt.name)
- def add(self, value: typing.Any,
+ def add(self, value: Any,
pattern: urlmatch.UrlPattern = None, *,
hide_userconfig: bool = False) -> None:
"""Add a value with the given pattern to the list of values.
@@ -201,7 +205,7 @@ class Values:
self._vmap.clear()
self._domain_map.clear()
- def _get_fallback(self, fallback: bool) -> typing.Any:
+ def _get_fallback(self, fallback: bool) -> Any:
"""Get the fallback global/default value."""
if None in self._vmap:
return self._vmap[None].value
@@ -211,8 +215,7 @@ class Values:
else:
return usertypes.UNSET
- def get_for_url(self, url: QUrl = None, *,
- fallback: bool = True) -> typing.Any:
+ def get_for_url(self, url: QUrl = None, *, fallback: bool = True) -> Any:
"""Get a config value, falling back when needed.
This first tries to find a value matching the URL (if given).
@@ -225,7 +228,7 @@ class Values:
return self._get_fallback(fallback)
qtutils.ensure_valid(url)
- candidates = [] # type: typing.List[ScopedValue]
+ candidates: List[ScopedValue] = []
# Urls trailing with '.' are equivalent to non-trailing types.
# urlutils strips them, so in order to match we will need to as well.
widened_hosts = _widened_hostnames(url.host().rstrip('.'))
@@ -247,8 +250,8 @@ class Values:
return self._get_fallback(fallback)
def get_for_pattern(self,
- pattern: typing.Optional[urlmatch.UrlPattern], *,
- fallback: bool = True) -> typing.Any:
+ pattern: Optional[urlmatch.UrlPattern], *,
+ fallback: bool = True) -> Any:
"""Get a value only if it's been overridden for the given pattern.
This is useful when showing values to the user.
@@ -272,22 +275,25 @@ class FontFamilies:
"""A list of font family names."""
- def __init__(self, families: typing.Sequence[str]) -> None:
+ def __init__(self, families: Sequence[str]) -> None:
self._families = families
self.family = families[0] if families else None
- def __iter__(self) -> typing.Iterator[str]:
+ def __iter__(self) -> Iterator[str]:
yield from self._families
+ def __len__(self) -> int:
+ return len(self._families)
+
def __repr__(self) -> str:
return utils.get_repr(self, families=self._families, constructor=True)
def __str__(self) -> str:
return self.to_str()
- def _quoted_families(self) -> typing.Iterator[str]:
+ def _quoted_families(self) -> Iterator[str]:
for f in self._families:
- needs_quoting = any(c in f for c in ', ')
+ needs_quoting = any(c in f for c in '., ')
yield '"{}"'.format(f) if needs_quoting else f
def to_str(self, *, quote: bool = True) -> str:
@@ -295,6 +301,57 @@ class FontFamilies:
return ', '.join(families)
@classmethod
+ def from_system_default(
+ cls,
+ font_type: QFontDatabase.SystemFont = QFontDatabase.FixedFont,
+ ) -> 'FontFamilies':
+ """Get a FontFamilies object for the default system font.
+
+ By default, the monospace font is returned, though via the "font_type" argument,
+ other types can be requested as well.
+
+ Note that (at least) three ways of getting the default monospace font
+ exist:
+
+ 1) f = QFont()
+ f.setStyleHint(QFont.Monospace)
+ print(f.defaultFamily())
+
+ 2) f = QFont()
+ f.setStyleHint(QFont.TypeWriter)
+ print(f.defaultFamily())
+
+ 3) f = QFontDatabase.systemFont(QFontDatabase.FixedFont)
+ print(f.family())
+
+ They yield different results depending on the OS:
+
+ QFont.Monospace | QFont.TypeWriter | QFontDatabase
+ ------------------------------------------------------
+ Windows: Courier New | Courier New | Courier New
+ Linux: DejaVu Sans Mono | DejaVu Sans Mono | monospace
+ macOS: Menlo | American Typewriter | Monaco
+
+ Test script: https://p.cmpl.cc/d4dfe573
+
+ On Linux, it seems like both actually resolve to the same font.
+
+ On macOS, "American Typewriter" looks like it indeed tries to imitate a
+ typewriter, so it's not really a suitable UI font.
+
+ Looking at those Wikipedia articles:
+
+ https://en.wikipedia.org/wiki/Monaco_(typeface)
+ https://en.wikipedia.org/wiki/Menlo_(typeface)
+
+ the "right" choice isn't really obvious. Thus, let's go for the
+ QFontDatabase approach here, since it's by far the simplest one.
+ """
+ assert QApplication.instance() is not None
+ font = QFontDatabase.systemFont(font_type)
+ return cls([font.family()])
+
+ @classmethod
def from_str(cls, family_str: str) -> 'FontFamilies':
"""Parse a CSS-like string of font families."""
families = []
diff --git a/qutebrowser/config/qtargs.py b/qutebrowser/config/qtargs.py
index 868f4d669..8ab93c904 100644
--- a/qutebrowser/config/qtargs.py
+++ b/qutebrowser/config/qtargs.py
@@ -21,15 +21,15 @@
import os
import sys
-import typing
import argparse
+from typing import Any, Dict, Iterator, List, Optional, Sequence
from qutebrowser.config import config
from qutebrowser.misc import objects
from qutebrowser.utils import usertypes, qtutils, utils
-def qt_args(namespace: argparse.Namespace) -> typing.List[str]:
+def qt_args(namespace: argparse.Namespace) -> List[str]:
"""Get the Qt QApplication arguments based on an argparse namespace.
Args:
@@ -61,9 +61,7 @@ def qt_args(namespace: argparse.Namespace) -> typing.List[str]:
return argv
-def _qtwebengine_enabled_features(
- feature_flags: typing.Sequence[str],
-) -> typing.Iterator[str]:
+def _qtwebengine_enabled_features(feature_flags: Sequence[str]) -> Iterator[str]:
"""Get --enable-features flags for QtWebEngine.
Args:
@@ -95,7 +93,7 @@ def _qtwebengine_enabled_features(
# just turn it on unconditionally on Linux, which shouldn't hurt.
yield 'WebRTCPipeWireCapturer'
- if qtutils.version_check('5.11', compiled=False) and not utils.is_mac:
+ if not utils.is_mac:
# Enable overlay scrollbars.
#
# There are two additional flags in Chromium:
@@ -111,22 +109,27 @@ def _qtwebengine_enabled_features(
if config.val.scrolling.bar == 'overlay':
yield 'OverlayScrollbar'
+ if (qtutils.version_check('5.14', compiled=False) and
+ config.val.content.headers.referer == 'same-domain'):
+ # Handling of reduced-referrer-granularity in Chromium 76+
+ # https://chromium-review.googlesource.com/c/chromium/src/+/1572699
+ #
+ # Note that this is removed entirely (and apparently the default) starting with
+ # Chromium 89 (Qt 5.15.x or 6.x):
+ # https://chromium-review.googlesource.com/c/chromium/src/+/2545444
+ yield 'ReducedReferrerGranularity'
+
def _qtwebengine_args(
namespace: argparse.Namespace,
- feature_flags: typing.Sequence[str],
-) -> typing.Iterator[str]:
+ feature_flags: Sequence[str],
+) -> Iterator[str]:
"""Get the QtWebEngine arguments to use based on the config."""
is_qt_514 = (qtutils.version_check('5.14', compiled=False) and
not qtutils.version_check('5.15', compiled=False))
- if not qtutils.version_check('5.11', compiled=False) or is_qt_514:
- # WORKAROUND equivalent to
- # https://codereview.qt-project.org/#/c/217932/
- # Needed for Qt < 5.9.5 and < 5.10.1
- #
- # For Qt 5,14, WORKAROUND for
- # https://bugreports.qt.io/browse/QTBUG-82105
+ if is_qt_514:
+ # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-82105
yield '--disable-shared-workers'
# WORKAROUND equivalent to
@@ -152,8 +155,7 @@ def _qtwebengine_args(
from qutebrowser.browser.webengine import darkmode
blink_settings = list(darkmode.settings())
if blink_settings:
- yield '--blink-settings=' + ','.join('{}={}'.format(k, v)
- for k, v in blink_settings)
+ yield '--blink-settings=' + ','.join(f'{k}={v}' for k, v in blink_settings)
enabled_features = list(_qtwebengine_enabled_features(feature_flags))
if enabled_features:
@@ -162,8 +164,8 @@ def _qtwebengine_args(
yield from _qtwebengine_settings_args()
-def _qtwebengine_settings_args() -> typing.Iterator[str]:
- settings = {
+def _qtwebengine_settings_args() -> Iterator[str]:
+ settings: Dict[str, Dict[Any, Optional[str]]] = {
'qt.force_software_rendering': {
'software-opengl': None,
'qt-quick': None,
@@ -198,23 +200,26 @@ def _qtwebengine_settings_args() -> typing.Iterator[str]:
},
'content.headers.referer': {
'always': None,
- 'never': '--no-referrers',
- 'same-domain': '--reduced-referrer-granularity',
}
- } # type: typing.Dict[str, typing.Dict[typing.Any, typing.Optional[str]]]
+ }
- if not qtutils.version_check('5.11'):
- # On Qt 5.11, we can control this via QWebEngineSettings
- settings['content.autoplay'] = {
- True: None,
- False: '--autoplay-policy=user-gesture-required',
- }
-
- if qtutils.version_check('5.14'):
+ referrer_setting = settings['content.headers.referer']
+ if qtutils.version_check('5.14', compiled=False):
settings['colors.webpage.prefers_color_scheme_dark'] = {
True: '--force-dark-mode',
False: None,
}
+ # Starting with Qt 5.14, this is handled via --enable-features
+ referrer_setting['same-domain'] = None
+ else:
+ referrer_setting['same-domain'] = '--reduced-referrer-granularity'
+
+ can_override_referer = (
+ qtutils.version_check('5.12.4', compiled=False) and
+ not qtutils.version_check('5.13.0', compiled=False, exact=True)
+ )
+ # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-60203
+ referrer_setting['never'] = None if can_override_referer else '--no-referrers'
for setting, args in sorted(settings.items()):
arg = args[config.instance.get(setting)]
diff --git a/qutebrowser/config/stylesheet.py b/qutebrowser/config/stylesheet.py
index 10e6e4e52..3c68fc0b9 100644
--- a/qutebrowser/config/stylesheet.py
+++ b/qutebrowser/config/stylesheet.py
@@ -81,13 +81,13 @@ class _StyleSheetObserver(QObject):
if update:
self.setParent(self._obj)
if stylesheet is None:
- self._stylesheet = obj.STYLESHEET # type: str
+ self._stylesheet: str = obj.STYLESHEET
else:
self._stylesheet = stylesheet
if update:
- self._options = jinja.template_config_variables(
- self._stylesheet) # type: Optional[FrozenSet[str]]
+ self._options: Optional[FrozenSet[str]] = jinja.template_config_variables(
+ self._stylesheet)
else:
self._options = None
diff --git a/qutebrowser/config/websettings.py b/qutebrowser/config/websettings.py
index cc307dd75..e1cb393dc 100644
--- a/qutebrowser/config/websettings.py
+++ b/qutebrowser/config/websettings.py
@@ -20,9 +20,9 @@
"""Bridge from QWeb(Engine)Settings to our own settings."""
import re
-import typing
import argparse
import functools
+from typing import Any, Callable, Dict, Optional
import attr
from PyQt5.QtCore import QUrl, pyqtSlot, qVersion
@@ -30,7 +30,7 @@ from PyQt5.QtGui import QFont
import qutebrowser
from qutebrowser.config import config
-from qutebrowser.utils import log, usertypes, urlmatch, qtutils, utils
+from qutebrowser.utils import usertypes, urlmatch, qtutils, utils
from qutebrowser.misc import objects, debugcachestats
UNSET = object()
@@ -41,11 +41,11 @@ class UserAgent:
"""A parsed user agent."""
- os_info = attr.ib() # type: str
- webkit_version = attr.ib() # type: str
- upstream_browser_key = attr.ib() # type: str
- upstream_browser_version = attr.ib() # type: str
- qt_key = attr.ib() # type: str
+ os_info: str = attr.ib()
+ webkit_version: str = attr.ib()
+ upstream_browser_key: str = attr.ib()
+ upstream_browser_version: str = attr.ib()
+ qt_key: str = attr.ib()
@classmethod
def parse(cls, ua: str) -> 'UserAgent':
@@ -82,8 +82,7 @@ class AttributeInfo:
"""Info about a settings attribute."""
- def __init__(self, *attributes: typing.Any,
- converter: typing.Callable = None) -> None:
+ def __init__(self, *attributes: Any, converter: Callable = None) -> None:
self.attributes = attributes
if converter is None:
self.converter = lambda val: val
@@ -95,37 +94,28 @@ class AbstractSettings:
"""Abstract base class for settings set via QWeb(Engine)Settings."""
- _ATTRIBUTES = {} # type: typing.Dict[str, AttributeInfo]
- _FONT_SIZES = {} # type: typing.Dict[str, typing.Any]
- _FONT_FAMILIES = {} # type: typing.Dict[str, typing.Any]
- _FONT_TO_QFONT = {} # type: typing.Dict[typing.Any, QFont.StyleHint]
+ _ATTRIBUTES: Dict[str, AttributeInfo] = {}
+ _FONT_SIZES: Dict[str, Any] = {}
+ _FONT_FAMILIES: Dict[str, Any] = {}
+ _FONT_TO_QFONT: Dict[Any, QFont.StyleHint] = {}
- def __init__(self, settings: typing.Any) -> None:
+ def __init__(self, settings: Any) -> None:
self._settings = settings
- def _assert_not_unset(self, value: typing.Any) -> None:
+ def _assert_not_unset(self, value: Any) -> None:
assert value is not usertypes.UNSET
- def set_attribute(self, name: str, value: typing.Any) -> bool:
+ def set_attribute(self, name: str, value: Any) -> None:
"""Set the given QWebSettings/QWebEngineSettings attribute.
If the value is usertypes.UNSET, the value is reset instead.
-
- Return:
- True if there was a change, False otherwise.
"""
- old_value = self.test_attribute(name)
-
info = self._ATTRIBUTES[name]
for attribute in info.attributes:
if value is usertypes.UNSET:
self._settings.resetAttribute(attribute)
- new_value = self.test_attribute(name)
else:
self._settings.setAttribute(attribute, info.converter(value))
- new_value = value
-
- return old_value != new_value
def test_attribute(self, name: str) -> bool:
"""Get the value for the given attribute.
@@ -136,26 +126,17 @@ class AbstractSettings:
info = self._ATTRIBUTES[name]
return self._settings.testAttribute(info.attributes[0])
- def set_font_size(self, name: str, value: int) -> bool:
- """Set the given QWebSettings/QWebEngineSettings font size.
-
- Return:
- True if there was a change, False otherwise.
- """
+ def set_font_size(self, name: str, value: int) -> None:
+ """Set the given QWebSettings/QWebEngineSettings font size."""
self._assert_not_unset(value)
family = self._FONT_SIZES[name]
- old_value = self._settings.fontSize(family)
self._settings.setFontSize(family, value)
- return old_value != value
- def set_font_family(self, name: str, value: typing.Optional[str]) -> bool:
+ def set_font_family(self, name: str, value: Optional[str]) -> None:
"""Set the given QWebSettings/QWebEngineSettings font family.
With None (the default), QFont is used to get the default font for the
family.
-
- Return:
- True if there was a change, False otherwise.
"""
self._assert_not_unset(value)
family = self._FONT_FAMILIES[name]
@@ -164,23 +145,14 @@ class AbstractSettings:
font.setStyleHint(self._FONT_TO_QFONT[family])
value = font.defaultFamily()
- old_value = self._settings.fontFamily(family)
self._settings.setFontFamily(family, value)
- return value != old_value
-
- def set_default_text_encoding(self, encoding: str) -> bool:
- """Set the default text encoding to use.
-
- Return:
- True if there was a change, False otherwise.
- """
+ def set_default_text_encoding(self, encoding: str) -> None:
+ """Set the default text encoding to use."""
self._assert_not_unset(encoding)
- old_value = self._settings.defaultTextEncoding()
self._settings.setDefaultTextEncoding(encoding)
- return old_value != encoding
- def _update_setting(self, setting: str, value: typing.Any) -> bool:
+ def _update_setting(self, setting: str, value: Any) -> bool:
"""Update the given setting/value.
Unknown settings are ignored.
@@ -189,13 +161,13 @@ class AbstractSettings:
True if there was a change, False otherwise.
"""
if setting in self._ATTRIBUTES:
- return self.set_attribute(setting, value)
+ self.set_attribute(setting, value)
elif setting in self._FONT_SIZES:
- return self.set_font_size(setting, value)
+ self.set_font_size(setting, value)
elif setting in self._FONT_FAMILIES:
- return self.set_font_family(setting, value)
+ self.set_font_family(setting, value)
elif setting == 'content.default_encoding':
- return self.set_default_text_encoding(value)
+ self.set_default_text_encoding(value)
return False
def update_setting(self, setting: str) -> None:
@@ -203,27 +175,15 @@ class AbstractSettings:
value = config.instance.get(setting)
self._update_setting(setting, value)
- def update_for_url(self, url: QUrl) -> typing.Set[str]:
- """Update settings customized for the given tab.
-
- Return:
- A set of settings which actually changed.
- """
+ def update_for_url(self, url: QUrl) -> None:
+ """Update settings customized for the given tab."""
qtutils.ensure_valid(url)
- changed_settings = set()
for values in config.instance:
if not values.opt.supports_pattern:
continue
value = values.get_for_url(url, fallback=False)
-
- changed = self._update_setting(values.opt.name, value)
- if changed:
- log.config.debug("Changed for {}: {} = {}".format(
- url.toDisplayString(), values.opt.name, value))
- changed_settings.add(values.opt.name)
-
- return changed_settings
+ self._update_setting(values.opt.name, value)
def init_settings(self) -> None:
"""Set all supported settings correctly."""
@@ -268,10 +228,10 @@ def init(args: argparse.Namespace) -> None:
"""Initialize all QWeb(Engine)Settings."""
if objects.backend == usertypes.Backend.QtWebEngine:
from qutebrowser.browser.webengine import webenginesettings
- webenginesettings.init(args)
+ webenginesettings.init()
elif objects.backend == usertypes.Backend.QtWebKit:
from qutebrowser.browser.webkit import webkitsettings
- webkitsettings.init(args)
+ webkitsettings.init()
else:
raise utils.Unreachable(objects.backend)
diff --git a/qutebrowser/html/warning-old-qt.html b/qutebrowser/html/warning-old-qt.html
deleted file mode 100644
index e5da57548..000000000
--- a/qutebrowser/html/warning-old-qt.html
+++ /dev/null
@@ -1,32 +0,0 @@
-{% extends "styled.html" %}
-
-{% block content %}
-<h1>{{ title }}</h1>
-<span class="note">Note this warning will only appear once. Use <span class="mono">:open
-qute://warning/old-qt</span> to show it again at a later time.</span>
-
-<p>You're using qutebrowser with Qt {{qt_version}}.</p>
-
-{% if qt_version.startswith('5.7.') %}
-<p>Qt 5.7 was released in June 2016, with the 5.7.1 patch release in December
-2016. It is based on Chromium 49 (March 2016) with (some) security fixes up to
-Chromium 54 (October 2016).</p>
-{% elif qt_version.startswith('5.8.') %}
-<p>Qt 5.8 has had various bugs, and has been unsupported (but working to some
-degree) in qutebrowser for a while.</p>
-{% elif qt_version.startswith('5.9.') %}
-<p>Qt 5.9 LTS was released in May 2017 and is based on Chromium 56 (January 2017). It is a long term support release with the 5.9.9 patch release in December 2019 including (some) security fixes up to Chromium 78 (November 2019). However, its usage was found to be low, and the next LTS (Qt 5.12) was released in December 2018.</p>
-{% elif qt_version.startswith('5.10.') %}
-<p>Qt 5.10 was released in December 2017, with the 5.10.1 patch release in February
-2018. It is based on Chromium 65 (March 2018) with (some) security fixes up to
-Chromium 70 (November 2018).</p>
-{% endif %}
-
-Also, note that QtWebEngine is <a href="https://www.debian.org/releases/stable/amd64/release-notes/ch-information.en.html#browser-security">not covered</a> by Debian security updates.
-
-<p>Because of those security issues and the maintaince burden coming with
-supporting old versions, support for Qt < 5.11 will be dropped in qutebrowser
-v2.0. You might want to check
-<a href="https://qutebrowser.org/doc/install.html">alternate installation methods</a>
-which allow you to get a newer Qt.</p>
-{% endblock %}
diff --git a/qutebrowser/javascript/.eslintrc.yaml b/qutebrowser/javascript/.eslintrc.yaml
index cbb8e17c0..939500aa3 100644
--- a/qutebrowser/javascript/.eslintrc.yaml
+++ b/qutebrowser/javascript/.eslintrc.yaml
@@ -12,9 +12,7 @@
env:
browser: true
-
-parserOptions:
- ecmaVersion: 6
+ es6: true
extends:
"eslint:all"
@@ -31,7 +29,7 @@ rules:
init-declarations: "off"
no-plusplus: "off"
no-extra-parens: "off"
- id-length: ["error", {"exceptions": ["i", "k", "x", "y"]}]
+ id-length: ["error", {"exceptions": ["i", "k", "v", "x", "y"]}]
object-shorthand: "off"
max-statements: ["error", {"max": 40}]
quotes: ["error", "double", {"avoidEscape": true}]
@@ -43,7 +41,7 @@ rules:
func-names: "off"
sort-keys: "off"
no-warning-comments: "off"
- max-len: ["error", {"ignoreUrls": true}]
+ max-len: ["error", {"ignoreUrls": true, "code": 88}]
capitalized-comments: "off"
prefer-destructuring: "off"
line-comment-position: "off"
diff --git a/qutebrowser/javascript/caret.js b/qutebrowser/javascript/caret.js
index d7ba88fe6..0e8de5e6e 100644
--- a/qutebrowser/javascript/caret.js
+++ b/qutebrowser/javascript/caret.js
@@ -774,13 +774,6 @@ window._qutebrowser.caret = (function() {
CaretBrowsing.isWindows = null;
/**
- * Whether we're running on on old Qt 5.7.1.
- * There, we need to use -webkit-filter.
- * @type {boolean}
- */
- CaretBrowsing.needsFilterPrefix = null;
-
- /**
* The id returned by window.setInterval for our stopAnimation function, so
* we can cancel it when we call stopAnimation again.
* @type {number?}
@@ -863,7 +856,6 @@ window._qutebrowser.caret = (function() {
};
CaretBrowsing.injectCaretStyles = function() {
- const prefix = CaretBrowsing.needsFilterPrefix ? "-webkit-" : "";
const style = `
.CaretBrowsing_Caret {
position: absolute;
@@ -875,7 +867,7 @@ window._qutebrowser.caret = (function() {
background-color: var(--inherited-color, #000);
color: var(--inherited-color, #000);
mix-blend-mode: difference;
- ${prefix}filter: invert(85%);
+ filter: invert(85%);
}
@keyframes blink {
50% { visibility: hidden; }
@@ -1355,7 +1347,6 @@ window._qutebrowser.caret = (function() {
funcs.setFlags = (flags) => {
CaretBrowsing.isWindows = flags.includes("windows");
- CaretBrowsing.needsFilterPrefix = flags.includes("filter-prefix");
};
funcs.disableCaret = () => {
diff --git a/qutebrowser/javascript/object_fromentries_quirk.user.js b/qutebrowser/javascript/object_fromentries_quirk.user.js
new file mode 100644
index 000000000..6f6ad8b31
--- /dev/null
+++ b/qutebrowser/javascript/object_fromentries_quirk.user.js
@@ -0,0 +1,46 @@
+// Based on: https://gitlab.com/moongoal/js-polyfill-object.fromentries/-/tree/master
+
+/*
+ Copyright 2018 Alfredo Mungo <alfredo.mungo@protonmail.ch>
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ IN THE SOFTWARE.
+*/
+
+"use strict";
+
+if (!Object.fromEntries) {
+ Object.defineProperty(Object, "fromEntries", {
+ value(entries) {
+ if (!entries || !entries[Symbol.iterator]) {
+ throw new Error(
+ "Object.fromEntries() requires a single iterable argument");
+ }
+
+ const obj = {};
+
+ Object.keys(entries).forEach((key) => {
+ const [k, v] = entries[key];
+ obj[k] = v;
+ });
+
+ return obj;
+ },
+ });
+}
+
diff --git a/qutebrowser/javascript/print.js b/qutebrowser/javascript/print.js
deleted file mode 100644
index ee38f1aa1..000000000
--- a/qutebrowser/javascript/print.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright 2018-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/>.
- */
-
-/*
- * this is a hack based on the QupZilla solution, https://github.com/QupZilla/qupzilla/commit/d3f0d766fb052dc504de2426d42f235d96b5eb60
- *
- * We go to a qute://print which triggers the print, then we cancel the request.
- */
-
-"use strict";
-
-window.print = function() {
- window.location = "qute://print";
-};
diff --git a/qutebrowser/javascript/webelem.js b/qutebrowser/javascript/webelem.js
index 5cc2bd014..86b41aef4 100644
--- a/qutebrowser/javascript/webelem.js
+++ b/qutebrowser/javascript/webelem.js
@@ -67,25 +67,6 @@ window._qutebrowser.webelem = (function() {
};
}
- function get_caret_position(elem, frame) {
- // With older Chromium versions (and QtWebKit), InvalidStateError will
- // be thrown if elem doesn't have selectionStart.
- // With newer Chromium versions (>= Qt 5.10), we get null.
- try {
- return elem.selectionStart;
- } catch (err) {
- if ((err instanceof DOMException ||
- (frame && err instanceof frame.DOMException)) &&
- err.name === "InvalidStateError") {
- // nothing to do, caret_position is already null
- } else {
- // not the droid we're looking for
- throw err;
- }
- }
- return null;
- }
-
function serialize_elem(elem, frame = null) {
if (!elem) {
return null;
@@ -94,7 +75,7 @@ window._qutebrowser.webelem = (function() {
const id = elements.length;
elements[id] = elem;
- const caret_position = get_caret_position(elem, frame);
+ const caret_position = elem.selectionStart;
// isContentEditable occasionally returns undefined.
const is_content_editable = elem.isContentEditable || false;
diff --git a/qutebrowser/keyinput/keyutils.py b/qutebrowser/keyinput/keyutils.py
index aa5457c6d..bc8c4a5fe 100644
--- a/qutebrowser/keyinput/keyutils.py
+++ b/qutebrowser/keyinput/keyutils.py
@@ -56,112 +56,96 @@ _NIL_KEY = Qt.Key(0)
_ModifierType = Union[Qt.KeyboardModifier, Qt.KeyboardModifiers]
-def _build_special_names() -> Mapping[Qt.Key, str]:
- """Build _SPECIAL_NAMES dict from the special_names_str mapping below.
-
- The reason we don't do this directly is that certain Qt versions don't have
- all the keys, so we want to ignore AttributeErrors.
- """
- special_names_str = {
- # Some keys handled in a weird way by QKeySequence::toString.
- # See https://bugreports.qt.io/browse/QTBUG-40030
- # Most are unlikely to be ever needed, but you never know ;)
- # For dead/combining keys, we return the corresponding non-combining
- # key, as that's easier to add to the config.
-
- 'Super_L': 'Super L',
- 'Super_R': 'Super R',
- 'Hyper_L': 'Hyper L',
- 'Hyper_R': 'Hyper R',
- 'Direction_L': 'Direction L',
- 'Direction_R': 'Direction R',
-
- 'Shift': 'Shift',
- 'Control': 'Control',
- 'Meta': 'Meta',
- 'Alt': 'Alt',
-
- 'AltGr': 'AltGr',
- 'Multi_key': 'Multi key',
- 'SingleCandidate': 'Single Candidate',
- 'Mode_switch': 'Mode switch',
- 'Dead_Grave': '`',
- 'Dead_Acute': '´',
- 'Dead_Circumflex': '^',
- 'Dead_Tilde': '~',
- 'Dead_Macron': '¯',
- 'Dead_Breve': '˘',
- 'Dead_Abovedot': '˙',
- 'Dead_Diaeresis': '¨',
- 'Dead_Abovering': '˚',
- 'Dead_Doubleacute': '˝',
- 'Dead_Caron': 'ˇ',
- 'Dead_Cedilla': '¸',
- 'Dead_Ogonek': '˛',
- 'Dead_Iota': 'Iota',
- 'Dead_Voiced_Sound': 'Voiced Sound',
- 'Dead_Semivoiced_Sound': 'Semivoiced Sound',
- 'Dead_Belowdot': 'Belowdot',
- 'Dead_Hook': 'Hook',
- 'Dead_Horn': 'Horn',
-
- 'Dead_Stroke': '\u0335', # '̵'
- 'Dead_Abovecomma': '\u0313', # '̓'
- 'Dead_Abovereversedcomma': '\u0314', # '̔'
- 'Dead_Doublegrave': '\u030f', # '̏'
- 'Dead_Belowring': '\u0325', # '̥'
- 'Dead_Belowmacron': '\u0331', # '̱'
- 'Dead_Belowcircumflex': '\u032d', # '̭'
- 'Dead_Belowtilde': '\u0330', # '̰'
- 'Dead_Belowbreve': '\u032e', # '̮'
- 'Dead_Belowdiaeresis': '\u0324', # '̤'
- 'Dead_Invertedbreve': '\u0311', # '̑'
- 'Dead_Belowcomma': '\u0326', # '̦'
- 'Dead_Currency': '¤',
- 'Dead_a': 'a',
- 'Dead_A': 'A',
- 'Dead_e': 'e',
- 'Dead_E': 'E',
- 'Dead_i': 'i',
- 'Dead_I': 'I',
- 'Dead_o': 'o',
- 'Dead_O': 'O',
- 'Dead_u': 'u',
- 'Dead_U': 'U',
- 'Dead_Small_Schwa': 'ə',
- 'Dead_Capital_Schwa': 'Ə',
- 'Dead_Greek': 'Greek',
- 'Dead_Lowline': '\u0332', # '̲'
- 'Dead_Aboveverticalline': '\u030d', # '̍'
- 'Dead_Belowverticalline': '\u0329',
- 'Dead_Longsolidusoverlay': '\u0338', # '̸'
-
- 'Memo': 'Memo',
- 'ToDoList': 'To Do List',
- 'Calendar': 'Calendar',
- 'ContrastAdjust': 'Contrast Adjust',
- 'LaunchG': 'Launch (G)',
- 'LaunchH': 'Launch (H)',
-
- 'MediaLast': 'Media Last',
-
- 'unknown': 'Unknown',
-
- # For some keys, we just want a different name
- 'Escape': 'Escape',
- }
- special_names = {_NIL_KEY: 'nil'}
-
- for k, v in special_names_str.items():
- try:
- special_names[getattr(Qt, 'Key_' + k)] = v
- except AttributeError: # pragma: no cover
- pass
-
- return special_names
-
-
-_SPECIAL_NAMES = _build_special_names()
+_SPECIAL_NAMES = {
+ # Some keys handled in a weird way by QKeySequence::toString.
+ # See https://bugreports.qt.io/browse/QTBUG-40030
+ # Most are unlikely to be ever needed, but you never know ;)
+ # For dead/combining keys, we return the corresponding non-combining
+ # key, as that's easier to add to the config.
+
+ Qt.Key_Super_L: 'Super L',
+ Qt.Key_Super_R: 'Super R',
+ Qt.Key_Hyper_L: 'Hyper L',
+ Qt.Key_Hyper_R: 'Hyper R',
+ Qt.Key_Direction_L: 'Direction L',
+ Qt.Key_Direction_R: 'Direction R',
+
+ Qt.Key_Shift: 'Shift',
+ Qt.Key_Control: 'Control',
+ Qt.Key_Meta: 'Meta',
+ Qt.Key_Alt: 'Alt',
+
+ Qt.Key_AltGr: 'AltGr',
+ Qt.Key_Multi_key: 'Multi key',
+ Qt.Key_SingleCandidate: 'Single Candidate',
+ Qt.Key_Mode_switch: 'Mode switch',
+ Qt.Key_Dead_Grave: '`',
+ Qt.Key_Dead_Acute: '´',
+ Qt.Key_Dead_Circumflex: '^',
+ Qt.Key_Dead_Tilde: '~',
+ Qt.Key_Dead_Macron: '¯',
+ Qt.Key_Dead_Breve: '˘',
+ Qt.Key_Dead_Abovedot: '˙',
+ Qt.Key_Dead_Diaeresis: '¨',
+ Qt.Key_Dead_Abovering: '˚',
+ Qt.Key_Dead_Doubleacute: '˝',
+ Qt.Key_Dead_Caron: 'ˇ',
+ Qt.Key_Dead_Cedilla: '¸',
+ Qt.Key_Dead_Ogonek: '˛',
+ Qt.Key_Dead_Iota: 'Iota',
+ Qt.Key_Dead_Voiced_Sound: 'Voiced Sound',
+ Qt.Key_Dead_Semivoiced_Sound: 'Semivoiced Sound',
+ Qt.Key_Dead_Belowdot: 'Belowdot',
+ Qt.Key_Dead_Hook: 'Hook',
+ Qt.Key_Dead_Horn: 'Horn',
+
+ Qt.Key_Dead_Stroke: '\u0335', # '̵'
+ Qt.Key_Dead_Abovecomma: '\u0313', # '̓'
+ Qt.Key_Dead_Abovereversedcomma: '\u0314', # '̔'
+ Qt.Key_Dead_Doublegrave: '\u030f', # '̏'
+ Qt.Key_Dead_Belowring: '\u0325', # '̥'
+ Qt.Key_Dead_Belowmacron: '\u0331', # '̱'
+ Qt.Key_Dead_Belowcircumflex: '\u032d', # '̭'
+ Qt.Key_Dead_Belowtilde: '\u0330', # '̰'
+ Qt.Key_Dead_Belowbreve: '\u032e', # '̮'
+ Qt.Key_Dead_Belowdiaeresis: '\u0324', # '̤'
+ Qt.Key_Dead_Invertedbreve: '\u0311', # '̑'
+ Qt.Key_Dead_Belowcomma: '\u0326', # '̦'
+ Qt.Key_Dead_Currency: '¤',
+ Qt.Key_Dead_a: 'a',
+ Qt.Key_Dead_A: 'A',
+ Qt.Key_Dead_e: 'e',
+ Qt.Key_Dead_E: 'E',
+ Qt.Key_Dead_i: 'i',
+ Qt.Key_Dead_I: 'I',
+ Qt.Key_Dead_o: 'o',
+ Qt.Key_Dead_O: 'O',
+ Qt.Key_Dead_u: 'u',
+ Qt.Key_Dead_U: 'U',
+ Qt.Key_Dead_Small_Schwa: 'ə',
+ Qt.Key_Dead_Capital_Schwa: 'Ə',
+ Qt.Key_Dead_Greek: 'Greek',
+ Qt.Key_Dead_Lowline: '\u0332', # '̲'
+ Qt.Key_Dead_Aboveverticalline: '\u030d', # '̍'
+ Qt.Key_Dead_Belowverticalline: '\u0329',
+ Qt.Key_Dead_Longsolidusoverlay: '\u0338', # '̸'
+
+ Qt.Key_Memo: 'Memo',
+ Qt.Key_ToDoList: 'To Do List',
+ Qt.Key_Calendar: 'Calendar',
+ Qt.Key_ContrastAdjust: 'Contrast Adjust',
+ Qt.Key_LaunchG: 'Launch (G)',
+ Qt.Key_LaunchH: 'Launch (H)',
+
+ Qt.Key_MediaLast: 'Media Last',
+
+ Qt.Key_unknown: 'Unknown',
+
+ # For some keys, we just want a different name
+ Qt.Key_Escape: 'Escape',
+
+ _NIL_KEY: 'nil',
+}
def _assert_plain_key(key: Qt.Key) -> None:
@@ -352,7 +336,7 @@ def _parse_single_key(keystr: str) -> str:
return 'Shift+' + keystr if keystr.isupper() else keystr
-@attr.s(frozen=True, hash=False)
+@attr.s(frozen=True)
class KeyInfo:
"""A key with optional modifiers.
@@ -378,14 +362,6 @@ class KeyInfo:
_assert_plain_modifier(modifiers)
return cls(key, cast(Qt.KeyboardModifier, modifiers))
- def __hash__(self) -> int:
- """Convert KeyInfo to int before hashing.
-
- This is needed as a WORKAROUND because enum members aren't hashable
- with PyQt 5.7.
- """
- return hash(self.to_int())
-
def __str__(self) -> str:
"""Convert this KeyInfo to a meaningful name.
@@ -635,18 +611,6 @@ class KeySequence:
not ev.text().isupper()):
modifiers = Qt.KeyboardModifiers() # type: ignore[assignment]
- # On macOS, swap Ctrl and Meta back
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-51293
- if utils.is_mac:
- if modifiers & Qt.ControlModifier and modifiers & Qt.MetaModifier:
- pass
- elif modifiers & Qt.ControlModifier:
- modifiers &= ~Qt.ControlModifier
- modifiers |= Qt.MetaModifier
- elif modifiers & Qt.MetaModifier:
- modifiers &= ~Qt.MetaModifier
- modifiers |= Qt.ControlModifier
-
keys = list(self._iter_keys())
keys.append(key | int(modifiers))
diff --git a/qutebrowser/keyinput/modeman.py b/qutebrowser/keyinput/modeman.py
index 27e4be34e..dcc6fa949 100644
--- a/qutebrowser/keyinput/modeman.py
+++ b/qutebrowser/keyinput/modeman.py
@@ -54,8 +54,8 @@ class KeyEvent:
text: A string (QKeyEvent::text).
"""
- key = attr.ib() # type: Qt.Key
- text = attr.ib() # type: str
+ key: Qt.Key = attr.ib()
+ text: str = attr.ib()
@classmethod
def from_event(cls, event: QKeyEvent) -> 'KeyEvent':
@@ -89,7 +89,7 @@ def init(win_id: int, parent: QObject) -> 'ModeManager':
modeman.hintmanager = hintmanager
- keyparsers = {
+ keyparsers: ParserDictType = {
usertypes.KeyMode.normal:
modeparsers.NormalKeyParser(
win_id=win_id,
@@ -186,7 +186,7 @@ def init(win_id: int, parent: QObject) -> 'ModeManager':
win_id=win_id,
commandrunner=commandrunner,
parent=modeman),
- } # type: ParserDictType
+ }
for mode, parser in keyparsers.items():
modeman.register(mode, parser)
@@ -259,10 +259,10 @@ class ModeManager(QObject):
def __init__(self, win_id: int, parent: QObject = None) -> None:
super().__init__(parent)
self._win_id = win_id
- self.parsers = {} # type: ParserDictType
+ self.parsers: ParserDictType = {}
self._prev_mode = usertypes.KeyMode.normal
self.mode = usertypes.KeyMode.normal
- self._releaseevents_to_pass = set() # type: Set[KeyEvent]
+ self._releaseevents_to_pass: Set[KeyEvent] = set()
# Set after __init__
self.hintmanager = cast(hints.HintManager, None)
@@ -457,12 +457,12 @@ class ModeManager(QObject):
Return:
True if event should be filtered, False otherwise.
"""
- handlers = {
+ handlers: Mapping[QEvent.Type, Callable[[QKeyEvent], bool]] = {
QEvent.KeyPress: self._handle_keypress,
QEvent.KeyRelease: self._handle_keyrelease,
QEvent.ShortcutOverride:
functools.partial(self._handle_keypress, dry_run=True),
- } # type: Mapping[QEvent.Type, Callable[[QKeyEvent], bool]]
+ }
handler = handlers[event.type()]
return handler(cast(QKeyEvent, event))
diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py
index b8228545a..6273b3382 100644
--- a/qutebrowser/mainwindow/mainwindow.py
+++ b/qutebrowser/mainwindow/mainwindow.py
@@ -203,8 +203,10 @@ class MainWindow(QWidget):
from qutebrowser.mainwindow.statusbar import bar
self.setAttribute(Qt.WA_DeleteOnClose)
- self.setAttribute(Qt.WA_TranslucentBackground)
- self.palette().setColor(QPalette.Window, Qt.transparent)
+ if config.val.window.transparent:
+ self.setAttribute(Qt.WA_TranslucentBackground)
+ self.palette().setColor(QPalette.Window, Qt.transparent)
+
self._overlays: MutableSequence[_OverlayInfoType] = []
self.win_id = next(win_id_gen)
self.registry = objreg.ObjectRegistry()
diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py
index 32fd9709e..42b6c3d97 100644
--- a/qutebrowser/mainwindow/prompt.py
+++ b/qutebrowser/mainwindow/prompt.py
@@ -590,6 +590,7 @@ class LineEditPrompt(_BasePrompt):
self._vbox.addWidget(self._lineedit)
if question.default:
self._lineedit.setText(question.default)
+ self._lineedit.selectAll()
self.setFocusProxy(self._lineedit)
self._init_key_label()
diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py
index 2523cdaeb..c67e5fa0e 100644
--- a/qutebrowser/mainwindow/tabbedbrowser.py
+++ b/qutebrowser/mainwindow/tabbedbrowser.py
@@ -215,11 +215,9 @@ class TabbedBrowser(QWidget):
self.cur_fullscreen_requested.connect(self.widget.tabBar().maybe_hide)
self.widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-65223
- if qtutils.version_check('5.10', compiled=False):
- self.cur_load_finished.connect(self._leave_modes_on_load)
- else:
- self.cur_load_started.connect(self._leave_modes_on_load)
+ # load_finished instead of load_started as WORKAROUND for
+ # https://bugreports.qt.io/browse/QTBUG-65223
+ self.cur_load_finished.connect(self._leave_modes_on_load)
# This init is never used, it is immediately thrown away in the next
# line.
@@ -481,16 +479,7 @@ class TabbedBrowser(QWidget):
tab.private_api.shutdown()
self.widget.removeTab(idx)
- if not crashed:
- # WORKAROUND for a segfault when we delete the crashed tab.
- # see https://bugreports.qt.io/browse/QTBUG-58698
-
- if not qtutils.version_check('5.12'):
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-58982
- # Seems to affect Qt 5.7-5.11 as well.
- tab.layout().unwrap()
-
- tab.deleteLater()
+ tab.deleteLater()
def undo(self, depth=1):
"""Undo removing of a tab or tabs."""
@@ -633,9 +622,6 @@ class TabbedBrowser(QWidget):
self.widget.currentWidget().setFocus()
else:
self.widget.setCurrentWidget(tab)
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-68076
- # Still seems to be needed with Qt 5.11.1
- tab.setFocus()
mode = modeman.instance(self._win_id).mode
if mode in [usertypes.KeyMode.command, usertypes.KeyMode.prompt,
@@ -877,7 +863,7 @@ class TabbedBrowser(QWidget):
start = config.cache['colors.tabs.indicator.start']
stop = config.cache['colors.tabs.indicator.stop']
system = config.cache['colors.tabs.indicator.system']
- color = utils.interpolate_color(start, stop, perc, system)
+ color = qtutils.interpolate_color(start, stop, perc, system)
self.widget.set_tab_indicator_color(idx, color)
self.widget.update_tab_title(idx)
if idx == self.widget.currentIndex():
@@ -894,7 +880,7 @@ class TabbedBrowser(QWidget):
start = config.cache['colors.tabs.indicator.start']
stop = config.cache['colors.tabs.indicator.stop']
system = config.cache['colors.tabs.indicator.system']
- color = utils.interpolate_color(start, stop, 100, system)
+ color = qtutils.interpolate_color(start, stop, 100, system)
else:
color = config.cache['colors.tabs.indicator.error']
self.widget.set_tab_indicator_color(idx, color)
@@ -951,18 +937,11 @@ class TabbedBrowser(QWidget):
tab.set_html(html)
log.webview.error(msg)
- if qtutils.version_check('5.9', compiled=False):
- url_string = tab.url(requested=True).toDisplayString()
- error_page = jinja.render(
- 'error.html', title="Error loading {}".format(url_string),
- url=url_string, error=msg)
- QTimer.singleShot(100, lambda: show_error_page(error_page))
- else:
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-58698
- message.error(msg)
- self._remove_tab(tab, crashed=True)
- if self.widget.count() == 0:
- self.tabopen(QUrl('about:blank'))
+ url_string = tab.url(requested=True).toDisplayString()
+ error_page = jinja.render(
+ 'error.html', title="Error loading {}".format(url_string),
+ url=url_string, error=msg)
+ QTimer.singleShot(100, lambda: show_error_page(error_page))
def resizeEvent(self, e):
"""Extend resizeEvent of QWidget to emit a resized signal afterwards.
diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py
index b40c59bd5..f853f8fd9 100644
--- a/qutebrowser/mainwindow/tabwidget.py
+++ b/qutebrowser/mainwindow/tabwidget.py
@@ -639,7 +639,7 @@ class TabBar(QTabBar):
main_window = objreg.get('main-window', scope='window',
window=self._win_id)
perc = int(confwidth.rstrip('%'))
- width = main_window.width() * perc / 100
+ width = main_window.width() * perc // 100
else:
width = int(confwidth)
size = QSize(width, height)
diff --git a/qutebrowser/misc/backendproblem.py b/qutebrowser/misc/backendproblem.py
index f9c210f15..e459d81c1 100644
--- a/qutebrowser/misc/backendproblem.py
+++ b/qutebrowser/misc/backendproblem.py
@@ -165,14 +165,6 @@ 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:
@@ -212,47 +204,6 @@ class _BackendProblemChecker:
self._assert_backend(usertypes.Backend.QtWebEngine)
utils.libgl_workaround()
- def _handle_nouveau_graphics(self) -> None:
- """Force software rendering when using the Nouveau driver.
-
- WORKAROUND for
- https://bugreports.qt.io/browse/QTBUG-41242
- Should be fixed in Qt 5.10 via
- https://codereview.qt-project.org/#/c/208664/
- """
- self._assert_backend(usertypes.Backend.QtWebEngine)
-
- if os.environ.get('QUTE_SKIP_NOUVEAU_CHECK'):
- return
-
- if qtutils.version_check('5.10', compiled=False):
- return
-
- 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
- # qt.force_software_rendering = 'software-opengl'
- 'QT_XCB_FORCE_SOFTWARE_OPENGL' in os.environ or
- # qt.force_software_rendering = 'chromium', also see:
- # https://build.opensuse.org/package/view_file/openSUSE:Factory/libqt5-qtwebengine/disable-gpu-when-using-nouveau-boo-1005323.diff?expand=1
- 'QT_WEBENGINE_DISABLE_NOUVEAU_WORKAROUND' in os.environ):
- return
-
- button = _Button("Force software rendering",
- 'qt.force_software_rendering',
- 'chromium')
- self._show_dialog(
- backend=usertypes.Backend.QtWebEngine,
- because="you're using Nouveau graphics",
- text=("<p>There are two ways to fix this:</p>" +
- self.SOFTWARE_RENDERING_TEXT),
- buttons=[button],
- )
-
- raise utils.Unreachable
-
def _xwayland_options(self) -> Tuple[str, List[_Button]]:
"""Get buttons/text for a possible XWayland solution."""
buttons = []
@@ -275,36 +226,6 @@ class _BackendProblemChecker:
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 += 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.
@@ -480,9 +401,7 @@ class _BackendProblemChecker:
# It seems these issues started with Qt 5.12.
# They should be fixed with Qt 5.12.5:
# https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/265408
- affected = (qtutils.version_check('5.12', compiled=False) and not
- qtutils.version_check('5.12.5', compiled=False))
- if not affected:
+ if qtutils.version_check('5.12.5', compiled=False):
return
log.init.info("Qt version changed, nuking QtWebEngine cache")
@@ -533,10 +452,8 @@ class _BackendProblemChecker:
self._check_backend_modules()
if objects.backend == usertypes.Backend.QtWebEngine:
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()
else:
diff --git a/qutebrowser/misc/checkpyver.py b/qutebrowser/misc/checkpyver.py
index 116514b8d..6f6659a24 100644
--- a/qutebrowser/misc/checkpyver.py
+++ b/qutebrowser/misc/checkpyver.py
@@ -31,7 +31,7 @@ except ImportError: # pragma: no cover
try:
# Python2
from Tkinter import Tk # type: ignore[import, no-redef]
- import tkMessageBox as messagebox # type: ignore # noqa: N813
+ import tkMessageBox as messagebox # type: ignore[import, no-redef] # noqa: N813
except ImportError:
# Some Python without Tk
Tk = None # type: ignore[misc, assignment]
diff --git a/qutebrowser/misc/consolewidget.py b/qutebrowser/misc/consolewidget.py
index aed42237a..14e4a7dc3 100644
--- a/qutebrowser/misc/consolewidget.py
+++ b/qutebrowser/misc/consolewidget.py
@@ -21,7 +21,7 @@
import sys
import code
-import typing
+from typing import MutableSequence
from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt
from PyQt5.QtWidgets import QTextEdit, QWidget, QVBoxLayout, QApplication
@@ -165,7 +165,7 @@ class ConsoleWidget(QWidget):
'objreg': objreg,
}
self._more = False
- self._buffer = [] # type: typing.MutableSequence[str]
+ self._buffer: MutableSequence[str] = []
self._lineedit = ConsoleLineEdit(namespace, self)
self._lineedit.execute.connect(self.push)
self._output = ConsoleTextEdit()
diff --git a/qutebrowser/misc/crashdialog.py b/qutebrowser/misc/crashdialog.py
index 850883bf4..52cb8ad0c 100644
--- a/qutebrowser/misc/crashdialog.py
+++ b/qutebrowser/misc/crashdialog.py
@@ -28,9 +28,8 @@ import fnmatch
import traceback
import datetime
import enum
-import typing
+from typing import List, Tuple
-import pkg_resources
from PyQt5.QtCore import pyqtSlot, Qt, QSize
from PyQt5.QtWidgets import (QDialog, QLabel, QTextEdit, QPushButton,
QVBoxLayout, QHBoxLayout, QCheckBox,
@@ -119,7 +118,7 @@ class _CrashDialog(QDialog):
super().__init__(parent)
# We don't set WA_DeleteOnClose here as on an exception, we'll get
# closed anyways, and it only could have unintended side-effects.
- self._crash_info = [] # type: typing.List[typing.Tuple[str, str]]
+ self._crash_info: List[Tuple[str, str]] = []
self._btn_box = None
self._paste_text = None
self.setWindowTitle("Whoops!")
@@ -361,8 +360,8 @@ class _CrashDialog(QDialog):
Args:
newest: The newest version as a string.
"""
- new_version = pkg_resources.parse_version(newest)
- cur_version = pkg_resources.parse_version(qutebrowser.__version__)
+ new_version = utils.parse_version(newest)
+ cur_version = utils.parse_version(qutebrowser.__version__)
lines = ['The report has been sent successfully. Thanks!']
if new_version > cur_version:
lines.append("<b>Note:</b> The newest available version is v{}, "
diff --git a/qutebrowser/misc/crashsignal.py b/qutebrowser/misc/crashsignal.py
index 65e584bc9..d07d8e49c 100644
--- a/qutebrowser/misc/crashsignal.py
+++ b/qutebrowser/misc/crashsignal.py
@@ -30,11 +30,6 @@ import functools
import threading
import faulthandler
from typing import TYPE_CHECKING, Optional, MutableMapping, cast
-try:
- # WORKAROUND for segfaults when using pdb in pytest for some reason...
- import readline # pylint: disable=unused-import
-except ImportError:
- pass
import attr
from PyQt5.QtCore import (pyqtSlot, qInstallMessageHandler, QObject,
diff --git a/qutebrowser/misc/earlyinit.py b/qutebrowser/misc/earlyinit.py
index 704db1777..d1c57760e 100644
--- a/qutebrowser/misc/earlyinit.py
+++ b/qutebrowser/misc/earlyinit.py
@@ -170,29 +170,21 @@ def qt_version(qversion=None, qt_version_str=None):
def check_qt_version():
"""Check if the Qt version is recent enough."""
- from PyQt5.QtCore import (qVersion, QT_VERSION, PYQT_VERSION,
- PYQT_VERSION_STR)
- from pkg_resources import parse_version
- from qutebrowser.utils import log
- parsed_qversion = parse_version(qVersion())
-
- if (QT_VERSION < 0x050701 or PYQT_VERSION < 0x050700 or
- parsed_qversion < parse_version('5.7.1')):
- text = ("Fatal error: Qt >= 5.7.1 and PyQt >= 5.7 are required, "
+ from PyQt5.QtCore import QT_VERSION, PYQT_VERSION, PYQT_VERSION_STR
+ try:
+ from PyQt5.QtCore import QVersionNumber, QLibraryInfo
+ qt_ver = QLibraryInfo.version().normalized()
+ recent_qt_runtime = qt_ver >= QVersionNumber(5, 12) # type: ignore[operator]
+ except (ImportError, AttributeError):
+ # QVersionNumber was added in Qt 5.6, QLibraryInfo.version() in 5.8
+ recent_qt_runtime = False
+
+ if QT_VERSION < 0x050C00 or PYQT_VERSION < 0x050C00 or not recent_qt_runtime:
+ text = ("Fatal error: Qt >= 5.12.0 and PyQt >= 5.12.0 are required, "
"but Qt {} / PyQt {} is installed.".format(qt_version(),
PYQT_VERSION_STR))
_die(text)
- if qVersion().startswith('5.8.'):
- log.init.warning("Running qutebrowser with Qt 5.8 is untested and "
- "unsupported!")
-
- if (parsed_qversion >= parse_version('5.12') and
- (PYQT_VERSION < 0x050c00 or QT_VERSION < 0x050c00)):
- log.init.warning("Combining PyQt {} with Qt {} is unsupported! Ensure "
- "all versions are newer than 5.12 to avoid potential "
- "issues.".format(PYQT_VERSION_STR, qt_version()))
-
def check_ssl_support():
"""Check if SSL support is available."""
@@ -251,18 +243,13 @@ def configure_pyqt():
from PyQt5 import QtCore
QtCore.pyqtRemoveInputHook()
try:
- QtCore.pyqt5_enable_new_onexit_scheme( # type: ignore[attr-defined]
- True)
+ QtCore.pyqt5_enable_new_onexit_scheme(True) # type: ignore[attr-defined]
except AttributeError:
# Added in PyQt 5.13 somewhere, going to be the default in 5.14
pass
from qutebrowser.qt import sip
- try:
- # Added in sip 4.19.4
- sip.enableoverflowchecking(True)
- except AttributeError:
- pass
+ sip.enableoverflowchecking(True)
def init_log(args):
diff --git a/qutebrowser/misc/httpclient.py b/qutebrowser/misc/httpclient.py
index b9502ca43..778b53a94 100644
--- a/qutebrowser/misc/httpclient.py
+++ b/qutebrowser/misc/httpclient.py
@@ -33,14 +33,8 @@ class HTTPRequest(QNetworkRequest):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
- try:
- self.setAttribute(QNetworkRequest.RedirectPolicyAttribute,
- QNetworkRequest.NoLessSafeRedirectPolicy)
- except AttributeError:
- # RedirectPolicyAttribute was introduced in 5.9 to replace
- # FollowRedirectsAttribute.
- self.setAttribute(QNetworkRequest.FollowRedirectsAttribute,
- True)
+ self.setAttribute(QNetworkRequest.RedirectPolicyAttribute,
+ QNetworkRequest.NoLessSafeRedirectPolicy)
class HTTPClient(QObject):
diff --git a/qutebrowser/misc/ipc.py b/qutebrowser/misc/ipc.py
index 207915a57..e7f370557 100644
--- a/qutebrowser/misc/ipc.py
+++ b/qutebrowser/misc/ipc.py
@@ -196,9 +196,14 @@ class IPCServer(QObject):
self._socket = None
self._old_socket = None
+
if utils.is_windows: # pragma: no cover
- # If we use setSocketOptions on Unix with Qt < 5.4, we get a
- # NameError while listening...
+ # As a WORKAROUND for a Qt bug, we can't use UserAccessOption on Unix. If we
+ # do, we don't get an AddressInUseError anymore:
+ # https://bugreports.qt.io/browse/QTBUG-48635
+ #
+ # Thus, we only do so on Windows, and handle permissions manually in
+ # listen() on Linux.
log.ipc.debug("Calling setSocketOptions")
self._server.setSocketOptions(QLocalServer.UserAccessOption)
else: # pragma: no cover
@@ -222,15 +227,9 @@ class IPCServer(QObject):
if self._server.serverError() == QAbstractSocket.AddressInUseError:
raise AddressInUseError(self._server)
raise ListenError(self._server)
+
if not utils.is_windows: # pragma: no cover
- # If we use setSocketOptions on Unix with Qt < 5.4, we get a
- # NameError while listening.
- # (see b135569d5c6e68c735ea83f42e4baf51f7972281)
- #
- # Also, we don't get an AddressInUseError with Qt 5.5:
- # https://bugreports.qt.io/browse/QTBUG-48635
- #
- # This means we only use setSocketOption on Windows...
+ # WORKAROUND for QTBUG-48635, see the comment in __init__ for details.
try:
os.chmod(self._server.fullServerName(), 0o700)
except FileNotFoundError:
@@ -269,8 +268,8 @@ class IPCServer(QObject):
"No new connection to handle.")
return
log.ipc.debug("Client connected (socket 0x{:x}).".format(id(socket)))
- self._timer.start()
self._socket = socket
+ self._timer.start()
socket.readyRead.connect( # type: ignore[attr-defined]
self.on_ready_read)
if socket.canReadLine():
@@ -310,7 +309,7 @@ class IPCServer(QObject):
self._socket.disconnectFromServer()
def _handle_data(self, data):
- """Handle data (as bytes) we got from on_ready_ready_read."""
+ """Handle data (as bytes) we got from on_ready_read."""
try:
decoded = data.decode('utf-8')
except UnicodeDecodeError:
@@ -383,14 +382,14 @@ class IPCServer(QObject):
log.ipc.debug("Read from socket 0x{:x}: {!r}".format(
id(socket), data))
self._handle_data(data)
- self._timer.start()
+
+ if self._socket is not None:
+ self._timer.start()
@pyqtSlot()
def on_timeout(self):
"""Cancel the current connection if it was idle for too long."""
- if self._socket is None: # pragma: no cover
- log.ipc.debug("on_timeout got called with None socket!")
- return
+ assert self._socket is not None
log.ipc.error("IPC connection timed out "
"(socket 0x{:x}).".format(id(self._socket)))
self._socket.disconnectFromServer()
diff --git a/qutebrowser/misc/miscwidgets.py b/qutebrowser/misc/miscwidgets.py
index a38607390..58bdf374d 100644
--- a/qutebrowser/misc/miscwidgets.py
+++ b/qutebrowser/misc/miscwidgets.py
@@ -284,47 +284,6 @@ class WrapperLayout(QLayout):
self._container.setFocusProxy(None) # type: ignore[arg-type]
-class PseudoLayout(QLayout):
-
- """A layout which isn't actually a real layout.
-
- This is used to replace QWebEngineView's internal layout, as a WORKAROUND
- for https://bugreports.qt.io/browse/QTBUG-68224 and other related issues.
-
- This is partly inspired by https://codereview.qt-project.org/#/c/230894/
- which does something similar as part of Qt.
- """
-
- def addItem(self, item):
- assert self.parent() is not None
- item.widget().setParent(self.parent())
-
- def removeItem(self, item):
- item.widget().setParent(None)
-
- def count(self):
- return 0
-
- def itemAt(self, _pos):
- return None
-
- def widget(self):
- return self.parent().render_widget()
-
- def setGeometry(self, rect):
- """Resize the render widget when the view is resized."""
- widget = self.widget()
- if widget is not None:
- widget.setGeometry(rect)
-
- def sizeHint(self):
- """Make sure the view has the sizeHint of the render widget."""
- widget = self.widget()
- if widget is not None:
- return widget.sizeHint()
- return QSize()
-
-
class FullscreenNotification(QLabel):
"""A label telling the user this page is now fullscreen."""
diff --git a/qutebrowser/misc/sessions.py b/qutebrowser/misc/sessions.py
index eecc1964e..b4aa72f32 100644
--- a/qutebrowser/misc/sessions.py
+++ b/qutebrowser/misc/sessions.py
@@ -83,7 +83,7 @@ def init(parent=None):
def shutdown(session: Optional[ArgType], last_window: bool) -> None:
"""Handle a shutdown by saving sessions and removing the autosave file."""
if session_manager is None:
- return # type: ignore
+ return # type: ignore[unreachable]
try:
if session is not None:
diff --git a/qutebrowser/misc/sql.py b/qutebrowser/misc/sql.py
index 8f9265419..2af95ac15 100644
--- a/qutebrowser/misc/sql.py
+++ b/qutebrowser/misc/sql.py
@@ -35,7 +35,6 @@ class SqliteErrorCode:
in qutebrowser here.
"""
- UNKNOWN = '-1'
ERROR = '1' # generic error code
BUSY = '5' # database is locked
READONLY = '8' # attempt to write a readonly database
@@ -108,13 +107,6 @@ def raise_sqlite_error(msg, error):
SqliteErrorCode.NOTADB,
]
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-70506
- # We don't know what the actual error was, but let's assume it's not us to
- # blame... Usually this is something like an unreadable database file.
- qtbug_70506 = (error_code == SqliteErrorCode.UNKNOWN and
- driver_text == "Error opening database" and
- database_text == "out of memory")
-
# https://github.com/qutebrowser/qutebrowser/issues/4681
# If the query we built was too long
too_long_err = (
@@ -123,7 +115,7 @@ def raise_sqlite_error(msg, error):
database_text in ["too many SQL variables",
"LIKE or GLOB pattern too complex"]))
- if error_code in known_errors or qtbug_70506 or too_long_err:
+ if error_code in known_errors or too_long_err:
raise KnownError(msg, error)
raise BugError(msg, error)
diff --git a/qutebrowser/qt.py b/qutebrowser/qt.py
index 5b44530bb..a9cd8ed90 100644
--- a/qutebrowser/qt.py
+++ b/qutebrowser/qt.py
@@ -20,9 +20,4 @@
"""Wrappers around Qt/PyQt code."""
# pylint: disable=unused-import
-# PyQt 5.11 comes with a bundled sip,
-# for older PyQt versions it's a separate module.
-try:
- from PyQt5 import sip
-except ImportError:
- import sip # type: ignore[import, no-redef]
+from PyQt5 import sip
diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py
index fb2776376..bca1df020 100644
--- a/qutebrowser/qutebrowser.py
+++ b/qutebrowser/qutebrowser.py
@@ -82,14 +82,6 @@ def get_argparser():
"qutebrowser instance running.")
parser.add_argument('--backend', choices=['webkit', 'webengine'],
help="Which backend to use.")
- parser.add_argument('--enable-webengine-inspector', action='store_true',
- help="Enable the web inspector / devtools for "
- "QtWebEngine. Note that this is a SECURITY RISK and "
- "you should not visit untrusted websites with the "
- "inspector turned on. See "
- "https://bugreports.qt.io/browse/QTBUG-50725 for more "
- "details. This is not needed anymore since Qt 5.11 "
- "where the inspector is always enabled and secure.")
parser.add_argument('--json-args', help=argparse.SUPPRESS)
parser.add_argument('--temp-basedir-restarted', help=argparse.SUPPRESS)
@@ -176,7 +168,7 @@ def debug_flag_error(flag):
"""
valid_flags = ['debug-exit', 'pdb-postmortem', 'no-sql-history',
'no-scroll-filtering', 'log-requests', 'log-cookies',
- 'lost-focusproxy', 'log-scroll-pos', 'stack', 'chromium',
+ 'log-scroll-pos', 'stack', 'chromium',
'wait-renderer-process', 'avoid-chromium-init', 'werror']
if flag in valid_flags:
diff --git a/qutebrowser/utils/debug.py b/qutebrowser/utils/debug.py
index cd2edc39a..229a26ead 100644
--- a/qutebrowser/utils/debug.py
+++ b/qutebrowser/utils/debug.py
@@ -190,9 +190,8 @@ def qflags_key(base: Type,
def signal_name(sig: pyqtBoundSignal) -> str:
"""Get a cleaned up name of a signal.
- Unfortunately, the way to get the name of a signal differs based on:
- - PyQt versions (5.11 added .signatures for unbound signals)
- - Bound vs. unbound signals
+ Unfortunately, the way to get the name of a signal differs based on
+ bound vs. unbound signals.
Here, we try to get the name from .signal or .signatures, or if all else
fails, extract it from the repr().
@@ -209,28 +208,13 @@ def signal_name(sig: pyqtBoundSignal) -> str:
# sig.signal == '2signal1'
# sig.signal == '2signal2(QString,QString)'
m = re.fullmatch(r'[0-9]+(?P<name>.*)\(.*\)', sig.signal)
- elif hasattr(sig, 'signatures'):
+ else:
# Unbound signal, PyQt >= 5.11
# Examples:
# sig.signatures == ('signal1()',)
# sig.signatures == ('signal2(QString,QString)',)
m = re.fullmatch(r'(?P<name>.*)\(.*\)',
sig.signatures[0]) # type: ignore[attr-defined]
- else: # pragma: no cover
- # Unbound signal, PyQt < 5.11
- # Examples:
- # repr(sig) == "<unbound PYQT_SIGNAL SignalObject.signal1[]>"
- # repr(sig) == "<unbound PYQT_SIGNAL SignalObject.signal2[str, str]>"
- # repr(sig) == "<unbound PYQT_SIGNAL timeout()>"
- # repr(sig) == "<unbound PYQT_SIGNAL valueChanged(int)>"
- patterns = [
- r'<unbound PYQT_SIGNAL [^.]*\.(?P<name>[^[]*)\[.*>',
- r'<unbound PYQT_SIGNAL (?P<name>[^(]*)\(.*>',
- ]
- for pattern in patterns:
- m = re.fullmatch(pattern, repr(sig))
- if m is not None:
- break
assert m is not None, sig
return m.group('name')
diff --git a/qutebrowser/utils/docutils.py b/qutebrowser/utils/docutils.py
index 5a3a0d263..f1ee11f84 100644
--- a/qutebrowser/utils/docutils.py
+++ b/qutebrowser/utils/docutils.py
@@ -25,7 +25,7 @@ import inspect
import os.path
import collections
import enum
-from typing import Callable, Dict, Optional, List, Union
+from typing import Callable, MutableMapping, Optional, List, Union
import qutebrowser
from qutebrowser.utils import log, utils
@@ -98,7 +98,8 @@ class DocstringParser:
self._cur_arg_name: Optional[str] = None
self._short_desc_parts: List[str] = []
self._long_desc_parts: List[str] = []
- self.arg_descs: Dict[str, Union[str, List[str]]] = collections.OrderedDict()
+ self.arg_descs: MutableMapping[
+ str, Union[str, List[str]]] = collections.OrderedDict()
doc = inspect.getdoc(func)
handlers = {
self.State.short: self._parse_short,
diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py
index d8378788c..9aedb419f 100644
--- a/qutebrowser/utils/log.py
+++ b/qutebrowser/utils/log.py
@@ -234,16 +234,6 @@ def _init_py_warnings() -> None:
@contextlib.contextmanager
-def disable_qt_msghandler() -> Iterator[None]:
- """Contextmanager which temporarily disables the Qt message handler."""
- old_handler = QtCore.qInstallMessageHandler(None)
- try:
- yield
- finally:
- QtCore.qInstallMessageHandler(old_handler)
-
-
-@contextlib.contextmanager
def py_warning_filter(action: str = 'ignore', **kwargs: Any) -> Iterator[None]:
"""Contextmanager to temporarily disable certain Python warnings."""
warnings.filterwarnings(action, **kwargs)
@@ -394,7 +384,9 @@ def qt_message_handler(msg_type: QtCore.QtMsgType,
try:
qt_to_logging[QtCore.QtInfoMsg] = logging.INFO
except AttributeError:
- # While we don't support Qt < 5.5 anymore, logging still needs to work
+ # Added in Qt 5.5.
+ # While we don't support Qt < 5.5 anymore, logging still needs to work so that
+ # the Qt version warning in earlyinit.py does.
pass
# Change levels of some well-known messages to debug so they don't get
diff --git a/qutebrowser/utils/objreg.py b/qutebrowser/utils/objreg.py
index 90b70be17..c74cb9873 100644
--- a/qutebrowser/utils/objreg.py
+++ b/qutebrowser/utils/objreg.py
@@ -350,6 +350,8 @@ def _window_by_index(idx: int) -> 'mainwindow.MainWindow':
def last_opened_window() -> 'mainwindow.MainWindow':
"""Get the last opened window object."""
+ if not window_registry:
+ raise NoWindow()
for idx in range(-1, -(len(window_registry)+1), -1):
window = _window_by_index(idx)
if not window.tabbed_browser.is_shutting_down:
@@ -359,6 +361,8 @@ def last_opened_window() -> 'mainwindow.MainWindow':
def first_opened_window() -> 'mainwindow.MainWindow':
"""Get the first opened window object."""
+ if not window_registry:
+ raise NoWindow()
for idx in range(0, len(window_registry)+1):
window = _window_by_index(idx)
if not window.tabbed_browser.is_shutting_down:
diff --git a/qutebrowser/utils/qtutils.py b/qutebrowser/utils/qtutils.py
index c92827f99..cd6ea2b32 100644
--- a/qutebrowser/utils/qtutils.py
+++ b/qutebrowser/utils/qtutils.py
@@ -24,16 +24,15 @@ Module attributes:
value.
MINVALS: A dictionary of C/Qt types (as string) mapped to their minimum
value.
- MAX_WORLD_ID: The highest world ID allowed in this version of QtWebEngine.
+ MAX_WORLD_ID: The highest world ID allowed by QtWebEngine.
"""
import io
import operator
import contextlib
-from typing import TYPE_CHECKING, BinaryIO, IO, Iterator, Optional, Union, cast
+from typing import TYPE_CHECKING, BinaryIO, IO, Iterator, Optional, Union, Tuple, cast
-import pkg_resources
from PyQt5.QtCore import (qVersion, QEventLoop, QDataStream, QByteArray,
QIODevice, QFileDevice, QSaveFile, QT_VERSION_STR,
PYQT_VERSION_STR, QObject, QUrl)
@@ -48,7 +47,7 @@ if TYPE_CHECKING:
from PyQt5.QtWebEngineWidgets import QWebEngineHistory
from qutebrowser.misc import objects
-from qutebrowser.utils import usertypes
+from qutebrowser.utils import usertypes, utils
MAXVALS = {
@@ -100,27 +99,26 @@ def version_check(version: str,
if compiled and exact:
raise ValueError("Can't use compiled=True with exact=True!")
- parsed = pkg_resources.parse_version(version)
+ parsed = utils.parse_version(version)
op = operator.eq if exact else operator.ge
- result = op(pkg_resources.parse_version(qVersion()), parsed)
+ result = op(utils.parse_version(qVersion()), parsed)
if compiled and result:
# qVersion() ==/>= parsed, now check if QT_VERSION_STR ==/>= parsed.
- result = op(pkg_resources.parse_version(QT_VERSION_STR), parsed)
+ result = op(utils.parse_version(QT_VERSION_STR), parsed)
if compiled and result:
# Finally, check PYQT_VERSION_STR as well.
- result = op(pkg_resources.parse_version(PYQT_VERSION_STR), parsed)
+ result = op(utils.parse_version(PYQT_VERSION_STR), parsed)
return result
-# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-69904
-MAX_WORLD_ID = 256 if version_check('5.11.2') else 11
+MAX_WORLD_ID = 256
def is_new_qtwebkit() -> bool:
"""Check if the given version is a new QtWebKit."""
assert qWebKitVersion is not None
- return (pkg_resources.parse_version(qWebKitVersion()) >
- pkg_resources.parse_version('538.1'))
+ return (utils.parse_version(qWebKitVersion()) >
+ utils.parse_version('538.1'))
def is_single_process() -> bool:
@@ -158,19 +156,15 @@ def check_overflow(arg: int, ctype: str, fatal: bool = True) -> int:
return arg
-if TYPE_CHECKING:
- # Protocol was added in Python 3.8
- from typing import Protocol
-
- class Validatable(Protocol):
+class Validatable(utils.Protocol):
- """An object with an isValid() method (e.g. QUrl)."""
+ """An object with an isValid() method (e.g. QUrl)."""
- def isValid(self) -> bool:
- ...
+ def isValid(self) -> bool:
+ ...
-def ensure_valid(obj: 'Validatable') -> None:
+def ensure_valid(obj: Validatable) -> None:
"""Ensure a Qt object with an .isValid() method is valid."""
if not obj.isValid():
raise QtValueError(obj)
@@ -441,7 +435,7 @@ class QtValueError(ValueError):
"""Exception which gets raised by ensure_valid."""
- def __init__(self, obj: 'Validatable') -> None:
+ def __init__(self, obj: Validatable) -> None:
try:
self.reason = obj.errorString() # type: ignore[attr-defined]
except AttributeError:
@@ -475,3 +469,78 @@ class EventLoop(QEventLoop):
status = super().exec_(flags)
self._executing = False
return status
+
+
+def _get_color_percentage(x1: int, y1: int, z1: int, a1: int,
+ x2: int, y2: int, z2: int, a2: int,
+ percent: int) -> Tuple[int, int, int, int]:
+ """Get a color which is percent% interpolated between start and end.
+
+ Args:
+ x1, y1, z1, a1 : Start color components (R, G, B, A / H, S, V, A / H, S, L, A)
+ x2, y2, z2, a2 : End color components (R, G, B, A / H, S, V, A / H, S, L, A)
+ percent: Percentage to interpolate, 0-100.
+ 0: Start color will be returned.
+ 100: End color will be returned.
+
+ Return:
+ A (x, y, z, alpha) tuple with the interpolated color components.
+ """
+ if not 0 <= percent <= 100:
+ raise ValueError("percent needs to be between 0 and 100!")
+ x = round(x1 + (x2 - x1) * percent / 100)
+ y = round(y1 + (y2 - y1) * percent / 100)
+ z = round(z1 + (z2 - z1) * percent / 100)
+ a = round(a1 + (a2 - a1) * percent / 100)
+ return (x, y, z, a)
+
+
+def interpolate_color(
+ start: QColor,
+ end: QColor,
+ percent: int,
+ colorspace: Optional[QColor.Spec] = QColor.Rgb
+) -> QColor:
+ """Get an interpolated color value.
+
+ Args:
+ start: The start color.
+ end: The end color.
+ percent: Which value to get (0 - 100)
+ colorspace: The desired interpolation color system,
+ QColor::{Rgb,Hsv,Hsl} (from QColor::Spec enum)
+ If None, start is used except when percent is 100.
+
+ Return:
+ The interpolated QColor, with the same spec as the given start color.
+ """
+ ensure_valid(start)
+ ensure_valid(end)
+
+ if colorspace is None:
+ if percent == 100:
+ return QColor(*end.getRgb())
+ else:
+ return QColor(*start.getRgb())
+
+ out = QColor()
+ if colorspace == QColor.Rgb:
+ r1, g1, b1, a1 = start.getRgb()
+ r2, g2, b2, a2 = end.getRgb()
+ components = _get_color_percentage(r1, g1, b1, a1, r2, g2, b2, a2, percent)
+ out.setRgb(*components)
+ elif colorspace == QColor.Hsv:
+ h1, s1, v1, a1 = start.getHsv()
+ h2, s2, v2, a2 = end.getHsv()
+ components = _get_color_percentage(h1, s1, v1, a1, h2, s2, v2, a2, percent)
+ out.setHsv(*components)
+ elif colorspace == QColor.Hsl:
+ h1, s1, l1, a1 = start.getHsl()
+ h2, s2, l2, a2 = end.getHsl()
+ components = _get_color_percentage(h1, s1, l1, a1, h2, s2, l2, a2, percent)
+ out.setHsl(*components)
+ else:
+ raise ValueError("Invalid colorspace!")
+ out = out.convertTo(start.spec())
+ ensure_valid(out)
+ return out
diff --git a/qutebrowser/utils/standarddir.py b/qutebrowser/utils/standarddir.py
index a86fd9bdc..ff4afc83c 100644
--- a/qutebrowser/utils/standarddir.py
+++ b/qutebrowser/utils/standarddir.py
@@ -22,7 +22,6 @@
import os
import os.path
import sys
-import shutil
import contextlib
import enum
import argparse
@@ -31,7 +30,7 @@ from typing import Iterator, Optional
from PyQt5.QtCore import QStandardPaths
from PyQt5.QtWidgets import QApplication
-from qutebrowser.utils import log, debug, message, utils
+from qutebrowser.utils import log, debug, utils
# The cached locations
_locations = {}
@@ -129,11 +128,11 @@ def config_py() -> str:
def _init_data(args: Optional[argparse.Namespace]) -> None:
"""Initialize the location for data."""
- typ = QStandardPaths.DataLocation
+ typ = QStandardPaths.AppDataLocation
path = _from_args(typ, args)
if path is None:
if utils.is_windows:
- app_data_path = _writable_location(QStandardPaths.AppDataLocation)
+ app_data_path = _writable_location(typ) # same location as config
path = os.path.join(app_data_path, 'data')
elif sys.platform.startswith('haiku'):
# HaikuOS returns an empty value for AppDataLocation
@@ -174,7 +173,7 @@ def _init_cache(args: Optional[argparse.Namespace]) -> None:
if path is None:
if utils.is_windows:
# Local, not Roaming!
- data_path = _writable_location(QStandardPaths.DataLocation)
+ data_path = _writable_location(QStandardPaths.AppLocalDataLocation)
path = os.path.join(data_path, 'cache')
else:
path = _writable_location(typ)
@@ -251,11 +250,10 @@ def _writable_location(typ: QStandardPaths.StandardLocation) -> str:
# Types we are sure we handle correctly below.
assert typ in [
- QStandardPaths.ConfigLocation, QStandardPaths.DataLocation,
+ QStandardPaths.ConfigLocation, QStandardPaths.AppLocalDataLocation,
QStandardPaths.CacheLocation, QStandardPaths.DownloadLocation,
QStandardPaths.RuntimeLocation, QStandardPaths.TempLocation,
- # FIXME old Qt
- getattr(QStandardPaths, 'AppDataLocation', object())], typ_str
+ QStandardPaths.AppDataLocation], typ_str
with _unset_organization():
path = QStandardPaths.writableLocation(typ)
@@ -288,7 +286,8 @@ def _from_args(
"""
basedir_suffix = {
QStandardPaths.ConfigLocation: 'config',
- QStandardPaths.DataLocation: 'data',
+ QStandardPaths.AppDataLocation: 'data',
+ QStandardPaths.AppLocalDataLocation: 'data',
QStandardPaths.CacheLocation: 'cache',
QStandardPaths.DownloadLocation: 'download',
QStandardPaths.RuntimeLocation: 'runtime',
@@ -340,44 +339,6 @@ def init(args: Optional[argparse.Namespace]) -> None:
_init_dirs(args)
_init_cachedir_tag()
- if args is not None and getattr(args, 'basedir', None) is None:
- if utils.is_mac: # pragma: no cover
- _move_macos()
- elif utils.is_windows: # pragma: no cover
- _move_windows()
-
-
-def _move_macos() -> None:
- """Move most config files to new location on macOS."""
- old_config = config(auto=True) # ~/Library/Preferences/qutebrowser
- new_config = config() # ~/.qutebrowser
- for f in os.listdir(old_config):
- if f not in ['qsettings', 'autoconfig.yml']:
- _move_data(os.path.join(old_config, f),
- os.path.join(new_config, f))
-
-
-def _move_windows() -> None:
- """Move the whole qutebrowser directory from Local to Roaming AppData."""
- # %APPDATA%\Local\qutebrowser
- old_appdata_dir = _writable_location(QStandardPaths.DataLocation)
- # %APPDATA%\Roaming\qutebrowser
- new_appdata_dir = _writable_location(QStandardPaths.AppDataLocation)
-
- # data subfolder
- old_data = os.path.join(old_appdata_dir, 'data')
- new_data = os.path.join(new_appdata_dir, 'data')
- ok = _move_data(old_data, new_data)
- if not ok: # pragma: no cover
- return
-
- # config files
- new_config_dir = os.path.join(new_appdata_dir, 'config')
- _create(new_config_dir)
- for f in os.listdir(old_appdata_dir):
- if f != 'cache':
- _move_data(os.path.join(old_appdata_dir, f),
- os.path.join(new_config_dir, f))
def _init_cachedir_tag() -> None:
@@ -397,33 +358,3 @@ def _init_cachedir_tag() -> None:
"cachedir/\n")
except OSError:
log.init.exception("Failed to create CACHEDIR.TAG")
-
-
-def _move_data(old: str, new: str) -> bool:
- """Migrate data from an old to a new directory.
-
- If the old directory does not exist, the migration is skipped.
- If the new directory already exists, an error is shown.
-
- Return: True if moving succeeded, False otherwise.
- """
- if not os.path.exists(old):
- return False
-
- log.init.debug("Migrating data from {} to {}".format(old, new))
-
- if os.path.exists(new):
- if not os.path.isdir(new) or os.listdir(new):
- message.error("Failed to move data from {} as {} is non-empty!"
- .format(old, new))
- return False
- os.rmdir(new)
-
- try:
- shutil.move(old, new)
- except OSError as e:
- message.error("Failed to move data from {} to {}: {}".format(
- old, new, e))
- return False
-
- return True
diff --git a/qutebrowser/utils/urlutils.py b/qutebrowser/utils/urlutils.py
index 598210010..41d20e734 100644
--- a/qutebrowser/utils/urlutils.py
+++ b/qutebrowser/utils/urlutils.py
@@ -27,7 +27,7 @@ import posixpath
import urllib.parse
from typing import Optional, Tuple, Union
-from PyQt5.QtCore import QUrl, QUrlQuery
+from PyQt5.QtCore import QUrl
from PyQt5.QtNetwork import QHostInfo, QHostAddress, QNetworkProxy
from qutebrowser.api import cmdutils
@@ -126,9 +126,9 @@ def _get_search_url(txt: str) -> QUrl:
unquoted=term,
quoted=quoted_term,
semiquoted=semiquoted_term)
- url = qurl_from_user_input(evaluated)
+ url = QUrl.fromUserInput(evaluated)
else:
- url = qurl_from_user_input(config.val.url.searchengines[engine])
+ url = QUrl.fromUserInput(config.val.url.searchengines[engine])
url.setPath(None) # type: ignore[arg-type]
url.setFragment(None) # type: ignore[arg-type]
url.setQuery(None) # type: ignore[call-overload]
@@ -145,7 +145,7 @@ def _is_url_naive(urlstr: str) -> bool:
Return:
True if the URL really is a URL, False otherwise.
"""
- url = qurl_from_user_input(urlstr)
+ url = QUrl.fromUserInput(urlstr)
assert url.isValid()
host = url.host()
@@ -170,7 +170,7 @@ def _is_url_dns(urlstr: str) -> bool:
Return:
True if the URL really is a URL, False otherwise.
"""
- url = qurl_from_user_input(urlstr)
+ url = QUrl.fromUserInput(urlstr)
assert url.isValid()
if (utils.raises(ValueError, ipaddress.ip_address, urlstr) and
@@ -219,10 +219,10 @@ def fuzzy_url(urlstr: str,
try:
url = _get_search_url(urlstr)
except ValueError: # invalid search engine
- url = qurl_from_user_input(urlstr)
+ url = QUrl.fromUserInput(urlstr)
else: # probably an address
log.url.debug("URL is a fuzzy address")
- url = qurl_from_user_input(urlstr)
+ url = QUrl.fromUserInput(urlstr)
log.url.debug("Converting fuzzy term {!r} to URL -> {}".format(
urlstr, url.toDisplayString()))
ensure_valid(url)
@@ -272,7 +272,7 @@ def is_url(urlstr: str) -> bool:
urlstr = urlstr.strip()
qurl = QUrl(urlstr)
- qurl_userinput = qurl_from_user_input(urlstr)
+ qurl_userinput = QUrl.fromUserInput(urlstr)
if autosearch == 'never':
# no autosearch, so everything is a URL unless it has an explicit
@@ -306,7 +306,7 @@ def is_url(urlstr: str) -> bool:
url = True
elif autosearch == 'dns':
log.url.debug("Checking via DNS check")
- # We want to use qurl_from_user_input here, as the user might enter
+ # We want to use QUrl.fromUserInput here, as the user might enter
# "foo.de" and that should be treated as URL here.
url = ' ' not in qurl_userinput.userName() and _is_url_dns(urlstr)
elif autosearch == 'naive':
@@ -318,42 +318,6 @@ def is_url(urlstr: str) -> bool:
return url
-def qurl_from_user_input(urlstr: str) -> QUrl:
- """Get a QUrl based on a user input. Additionally handles IPv6 addresses.
-
- QUrl.fromUserInput handles something like '::1' as a file URL instead of an
- IPv6, so we first try to handle it as a valid IPv6, and if that fails we
- use QUrl.fromUserInput.
-
- WORKAROUND - https://bugreports.qt.io/browse/QTBUG-41089
- FIXME - Maybe https://codereview.qt-project.org/#/c/93851/ has a better way
- to solve this?
- https://github.com/qutebrowser/qutebrowser/issues/109
-
- Args:
- urlstr: The URL as string.
-
- Return:
- The converted QUrl.
- """
- # First we try very liberally to separate something like an IPv6 from the
- # rest (e.g. path info or parameters)
- match = re.fullmatch(r'\[?([0-9a-fA-F:.]+)\]?(.*)', urlstr.strip())
- if match:
- ipstr, rest = match.groups()
- else:
- ipstr = urlstr.strip()
- rest = ''
- # Then we try to parse it as an IPv6, and if we fail use
- # QUrl.fromUserInput.
- try:
- ipaddress.IPv6Address(ipstr)
- except ipaddress.AddressValueError:
- return QUrl.fromUserInput(urlstr)
- else:
- return QUrl('http://[{}]{}'.format(ipstr, rest))
-
-
def ensure_valid(url: QUrl) -> None:
if not url.isValid():
raise InvalidUrlError(url)
@@ -503,12 +467,19 @@ def same_domain(url1: QUrl, url2: QUrl) -> bool:
For example example.com and www.example.com are considered the same. but
example.co.uk and test.co.uk are not.
+ If the URL's schemes or ports are different, they are always treated as not equal.
+
Return:
True if the domains are the same, False otherwise.
"""
ensure_valid(url1)
ensure_valid(url2)
+ if url1.scheme() != url2.scheme():
+ return False
+ if url1.port() != url2.port():
+ return False
+
suffix1 = url1.topLevelDomain()
suffix2 = url2.topLevelDomain()
if not suffix1:
@@ -561,9 +532,7 @@ def safe_display_string(qurl: QUrl) -> str:
ensure_valid(qurl)
host = qurl.host(QUrl.FullyEncoded)
- if '..' in host: # pragma: no cover
- # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-60364
- return '(unparseable URL!) {}'.format(qurl.toDisplayString())
+ assert '..' not in host, qurl # https://bugreports.qt.io/browse/QTBUG-60364
for part in host.split('.'):
url_host = qurl.host(QUrl.FullyDecoded)
@@ -573,18 +542,6 @@ def safe_display_string(qurl: QUrl) -> str:
return qurl.toDisplayString()
-def query_string(qurl: QUrl) -> str:
- """Get a query string for the given URL.
-
- This is a WORKAROUND for:
- https://www.riverbankcomputing.com/pipermail/pyqt/2017-November/039702.html
- """
- try:
- return qurl.query()
- except AttributeError: # pragma: no cover
- return QUrlQuery(qurl).query()
-
-
class InvalidProxyTypeError(Exception):
"""Error raised when proxy_from_url gets an unknown proxy type."""
diff --git a/qutebrowser/utils/usertypes.py b/qutebrowser/utils/usertypes.py
index 9ecae9e92..893dae877 100644
--- a/qutebrowser/utils/usertypes.py
+++ b/qutebrowser/utils/usertypes.py
@@ -21,7 +21,7 @@
import operator
import enum
-from typing import TYPE_CHECKING, Any, Optional, Sequence, TypeVar, Union
+from typing import Any, Optional, Sequence, TypeVar, Union
import attr
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, QTimer
@@ -30,19 +30,7 @@ from PyQt5.QtCore import QUrl
from qutebrowser.utils import log, qtutils, utils
-if TYPE_CHECKING:
- # Protocol was added in Python 3.8
- from typing import Protocol
-
- class SupportsLessThan(Protocol):
-
- """Protocol for the _T TypeVar below."""
-
- def __lt__(self, other: Any) -> bool:
- ...
-
-
-_T = TypeVar('_T', bound='SupportsLessThan')
+_T = TypeVar('_T', bound=utils.SupportsLessThan)
class Unset:
diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py
index 6952acf97..31ff5bf50 100644
--- a/qutebrowser/utils/utils.py
+++ b/qutebrowser/utils/utils.py
@@ -31,16 +31,16 @@ import traceback
import functools
import contextlib
import posixpath
-import socket
import shlex
import glob
import mimetypes
import ctypes
import ctypes.util
-from typing import Any, Callable, IO, Iterator, Optional, Sequence, Tuple, Type, Union
+from typing import (Any, Callable, IO, Iterator, Optional, Sequence, Tuple, Type, Union,
+ TYPE_CHECKING, cast)
-from PyQt5.QtCore import QUrl
-from PyQt5.QtGui import QColor, QClipboard, QDesktopServices
+from PyQt5.QtCore import QUrl, QVersionNumber
+from PyQt5.QtGui import QClipboard, QDesktopServices
from PyQt5.QtWidgets import QApplication
import pkg_resources
import yaml
@@ -54,7 +54,7 @@ except ImportError: # pragma: no cover
YAML_C_EXT = False
import qutebrowser
-from qutebrowser.utils import qtutils, log
+from qutebrowser.utils import log
fake_clipboard = None
@@ -67,6 +67,34 @@ is_windows = sys.platform.startswith('win')
is_posix = os.name == 'posix'
+try:
+ # Protocol was added in Python 3.8
+ from typing import Protocol
+except ImportError: # pragma: no cover
+ if not TYPE_CHECKING:
+ class Protocol:
+
+ """Empty stub at runtime."""
+
+
+class SupportsLessThan(Protocol):
+
+ """Protocol for a "comparable" object."""
+
+ def __lt__(self, other: Any) -> bool:
+ ...
+
+
+if TYPE_CHECKING:
+ class VersionNumber(SupportsLessThan, QVersionNumber):
+
+ """WORKAROUND for incorrect PyQt stubs."""
+else:
+ class VersionNumber:
+
+ """We can't inherit from Protocol and QVersionNumber at runtime."""
+
+
class Unreachable(Exception):
"""Raised when there was unreachable code."""
@@ -181,7 +209,8 @@ def read_file(filename: str, binary: bool = False) -> Any:
# https://github.com/pyinstaller/pyinstaller/wiki/FAQ#misc
fn = os.path.join(os.path.dirname(sys.executable), filename)
if binary:
- with open(fn, 'rb') as f: # type: IO
+ f: IO
+ with open(fn, 'rb') as f:
return f.read()
else:
with open(fn, 'r', encoding='utf-8') as f:
@@ -210,81 +239,10 @@ def resource_filename(filename: str) -> str:
return pkg_resources.resource_filename(qutebrowser.__name__, filename)
-def _get_color_percentage(a_c1: int, a_c2: int, a_c3:
- int, b_c1: int, b_c2: int, b_c3: int,
- percent: int) -> Tuple[int, int, int]:
- """Get a color which is percent% interpolated between start and end.
-
- Args:
- a_c1, a_c2, a_c3: Start color components (R, G, B / H, S, V / H, S, L)
- b_c1, b_c2, b_c3: End color components (R, G, B / H, S, V / H, S, L)
- percent: Percentage to interpolate, 0-100.
- 0: Start color will be returned.
- 100: End color will be returned.
-
- Return:
- A (c1, c2, c3) tuple with the interpolated color components.
- """
- if not 0 <= percent <= 100:
- raise ValueError("percent needs to be between 0 and 100!")
- out_c1 = round(a_c1 + (b_c1 - a_c1) * percent / 100)
- out_c2 = round(a_c2 + (b_c2 - a_c2) * percent / 100)
- out_c3 = round(a_c3 + (b_c3 - a_c3) * percent / 100)
- return (out_c1, out_c2, out_c3)
-
-
-def interpolate_color(
- start: QColor,
- end: QColor,
- percent: int,
- colorspace: Optional[QColor.Spec] = QColor.Rgb
-) -> QColor:
- """Get an interpolated color value.
-
- Args:
- start: The start color.
- end: The end color.
- percent: Which value to get (0 - 100)
- colorspace: The desired interpolation color system,
- QColor::{Rgb,Hsv,Hsl} (from QColor::Spec enum)
- If None, start is used except when percent is 100.
-
- Return:
- The interpolated QColor, with the same spec as the given start color.
- """
- qtutils.ensure_valid(start)
- qtutils.ensure_valid(end)
-
- if colorspace is None:
- if percent == 100:
- return QColor(*end.getRgb())
- else:
- return QColor(*start.getRgb())
-
- out = QColor()
- if colorspace == QColor.Rgb:
- a_c1, a_c2, a_c3, _alpha = start.getRgb()
- b_c1, b_c2, b_c3, _alpha = end.getRgb()
- components = _get_color_percentage(a_c1, a_c2, a_c3, b_c1, b_c2, b_c3,
- percent)
- out.setRgb(*components)
- elif colorspace == QColor.Hsv:
- a_c1, a_c2, a_c3, _alpha = start.getHsv()
- b_c1, b_c2, b_c3, _alpha = end.getHsv()
- components = _get_color_percentage(a_c1, a_c2, a_c3, b_c1, b_c2, b_c3,
- percent)
- out.setHsv(*components)
- elif colorspace == QColor.Hsl:
- a_c1, a_c2, a_c3, _alpha = start.getHsl()
- b_c1, b_c2, b_c3, _alpha = end.getHsl()
- components = _get_color_percentage(a_c1, a_c2, a_c3, b_c1, b_c2, b_c3,
- percent)
- out.setHsl(*components)
- else:
- raise ValueError("Invalid colorspace!")
- out = out.convertTo(start.spec())
- qtutils.ensure_valid(out)
- return out
+def parse_version(version: str) -> VersionNumber:
+ """Parse a version string."""
+ v_q, _suffix = QVersionNumber.fromString(version)
+ return cast(VersionNumber, v_q.normalized())
def format_seconds(total_seconds: int) -> str:
@@ -633,15 +591,6 @@ def supports_selection() -> bool:
return QApplication.clipboard().supportsSelection()
-def random_port() -> int:
- """Get a random free port."""
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- sock.bind(('localhost', 0))
- port = sock.getsockname()[1]
- sock.close()
- return port
-
-
def open_file(filename: str, cmdline: str = None) -> None:
"""Open the given file.
diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py
index 0f22a0bce..53e5287bd 100644
--- a/qutebrowser/utils/version.py
+++ b/qutebrowser/utils/version.py
@@ -34,7 +34,6 @@ import functools
from typing import Mapping, Optional, Sequence, Tuple, cast
import attr
-import pkg_resources
from PyQt5.QtCore import PYQT_VERSION_STR, QLibraryInfo
from PyQt5.QtNetwork import QSslSocket
from PyQt5.QtGui import (QOpenGLContext, QOpenGLVersionProfile,
@@ -84,7 +83,7 @@ class DistributionInfo:
id: Optional[str] = attr.ib()
parsed: 'Distribution' = attr.ib()
- version: Optional[Tuple[str, ...]] = attr.ib()
+ version: Optional[utils.VersionNumber] = attr.ib()
pretty: str = attr.ib()
@@ -139,8 +138,8 @@ def distribution() -> Optional[DistributionInfo]:
assert pretty is not None
if 'VERSION_ID' in info:
- dist_version: Optional[Tuple[str, ...]] = pkg_resources.parse_version(
- info['VERSION_ID'])
+ version_id = info['VERSION_ID']
+ dist_version: Optional[utils.VersionNumber] = utils.parse_version(version_id)
else:
dist_version = None
@@ -360,7 +359,6 @@ MODULE_INFO: Mapping[str, ModuleInfo] = collections.OrderedDict([
('pygments', ['__version__']),
('yaml', ['__version__']),
('adblock', ['__version__'], "0.3.2"),
- ('cssutils', ['__version__']),
('attr', ['__version__']),
('PyQt5.QtWebEngineWidgets', []),
('PyQt5.QtWebEngine', ['PYQT_WEBENGINE_VERSION_STR']),
@@ -460,41 +458,6 @@ def _chromium_version() -> str:
Quick reference:
- Qt 5.7: Chromium 49
- 49.0.2623.111 (2016-03-31)
- 5.7.0: Security fixes from Chromium 50 and 51
- 5.7.1: Security fixes up to 54.0.2840.87 (2016-11-01)
-
- Qt 5.8: Chromium 53
- 53.0.2785.148 (2016-08-31)
- 5.8.0: Security fixes up to 55.0.2883.75 (2016-12-01)
-
- Qt 5.9: Chromium 56
- (LTS) 56.0.2924.122 (2017-01-25)
- 5.9.0: Security fixes up to 56.0.2924.122 (?)
- 5.9.1: Security fixes up to 59.0.3071.104 (2017-06-15)
- 5.9.2: Security fixes up to 61.0.3163.79 (2017-09-05)
- 5.9.3: Security fixes up to 62.0.3202.89 (2017-11-06)
- 5.9.4: Security fixes up to 63.0.3239.132 (~2017-12-14)
- 5.9.5: Security fixes up to 65.0.3325.146 (~2018-03-13)
- 5.9.6: Security fixes up to 66.0.3359.170 (2018-05-10)
- 5.9.7: Security fixes up to 69.0.3497.113 (~2018-09-11)
- 5.9.8: Security fixes up to 72.0.3626.121 (2019-03-01)
- 5.9.9: Security fixes up to 78.0.3904.108 (2019-11-18)
-
- Qt 5.10: Chromium 61
- 61.0.3163.140 (2017-09-05)
- 5.10.0: Security fixes up to 62.0.3202.94 (2017-11-13)
- 5.10.1: Security fixes up to 64.0.3282.140 (2018-02-01)
-
- Qt 5.11: Chromium 65
- 65.0.3325.151 (2018-03-06)
- 5.11.0: Security fixes up to 66.0.3359.139 (2018-04-26)
- 5.11.1: Updated to 65.0.3325.15.230
- Security fixes up to 67.0.3396.87 (2018-06-12)
- 5.11.2: Security fixes up to 68.0.3440.75 (~2018-07-31)
- 5.11.3: Security fixes up to 70.0.3538.102 (2018-11-09)
-
Qt 5.12: Chromium 69
(LTS) 69.0.3497.128 (~2018-09-11)
5.12.0: Security fixes up to 70.0.3538.102 (~2018-10-24)
@@ -527,7 +490,7 @@ def _chromium_version() -> str:
5.15.1: Security fixes up to 85.0.4183.83 (2020-08-25)
5.15.2: Updated to 83.0.4103.122 (~2020-06-24)
- Security fixes up to 86.0.4240.111 (2020-10-20)
+ Security fixes up to 86.0.4240.183 (2020-11-02)
Also see:
diff --git a/requirements.txt b/requirements.txt
index dad7a8f50..6524bb5fc 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,7 +3,6 @@
adblock==0.3.2
attrs==20.2.0
colorama==0.4.4
-cssutils==1.0.2
Jinja2==2.11.2
MarkupSafe==1.1.1
Pygments==2.7.2
diff --git a/scripts/asciidoc2html.py b/scripts/asciidoc2html.py
index 17c3fb367..109e61625 100755
--- a/scripts/asciidoc2html.py
+++ b/scripts/asciidoc2html.py
@@ -49,13 +49,13 @@ class AsciiDoc:
asciidoc: Optional[str],
asciidoc_python: Optional[str],
website: Optional[str]) -> None:
- self._cmd = None # type: Optional[List[str]]
+ self._cmd: Optional[List[str]] = None
self._asciidoc = asciidoc
self._asciidoc_python = asciidoc_python
self._website = website
- self._homedir = None # type: Optional[pathlib.Path]
- self._themedir = None # type: Optional[pathlib.Path]
- self._tempdir = None # type: Optional[pathlib.Path]
+ self._homedir: Optional[pathlib.Path] = None
+ self._themedir: Optional[pathlib.Path] = None
+ self._tempdir: Optional[pathlib.Path] = None
self._failed = False
def prepare(self) -> None:
diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py
index 8030d61a1..6044a1e18 100755
--- a/scripts/dev/build_release.py
+++ b/scripts/dev/build_release.py
@@ -252,7 +252,7 @@ def _get_windows_python_path(x64):
return fallback
-def build_windows():
+def build_windows(*, skip_packaging):
"""Build windows executables/setups."""
utils.print_title("Updating 3rdparty content")
update_3rdparty.run(nsis=True, ace=False, pdfjs=True, fancy_dmg=False)
@@ -289,6 +289,14 @@ def build_windows():
utils.print_title("Running 64bit smoke test")
smoke_test(os.path.join(out_64, 'qutebrowser.exe'))
+ if not skip_packaging:
+ artifacts += _package_windows(out_32, out_64)
+
+ return artifacts
+
+
+def _package_windows(out_32, out_64):
+ """Build installers/zips for Windows."""
utils.print_title("Building installers")
subprocess.run(['makensis.exe',
'/DVERSION={}'.format(qutebrowser.__version__),
@@ -301,7 +309,7 @@ def build_windows():
name_32 = 'qutebrowser-{}-win32.exe'.format(qutebrowser.__version__)
name_64 = 'qutebrowser-{}-amd64.exe'.format(qutebrowser.__version__)
- artifacts += [
+ artifacts = [
(os.path.join('dist', name_32),
'application/vnd.microsoft.portable-executable',
'Windows 32bit installer'),
@@ -465,7 +473,9 @@ def main():
"If not given, the current Python interpreter is used.",
nargs='?')
parser.add_argument('--upload', action='store_true', required=False,
- help="Toggle to upload the release to GitHub")
+ help="Toggle to upload the release to GitHub.")
+ parser.add_argument('--skip-packaging', action='store_true', required=False,
+ help="Skip Windows installer/zip generation.")
args = parser.parse_args()
utils.change_cwd()
@@ -487,7 +497,7 @@ def main():
run_asciidoc2html(args)
if os.name == 'nt':
- artifacts = build_windows()
+ artifacts = build_windows(skip_packaging=args.skip_packaging)
elif sys.platform == 'darwin':
artifacts = build_mac()
else:
diff --git a/scripts/dev/check_coverage.py b/scripts/dev/check_coverage.py
index f4e4ac07f..728a36873 100644
--- a/scripts/dev/check_coverage.py
+++ b/scripts/dev/check_coverage.py
@@ -78,6 +78,8 @@ PERFECT_FILES = [
'qutebrowser/api/message.py'),
(None,
'qutebrowser/api/qtutils.py'),
+ (None,
+ 'qutebrowser/qt.py'),
('tests/unit/browser/webkit/test_cache.py',
'qutebrowser/browser/webkit/cache.py'),
@@ -331,8 +333,9 @@ def main_check():
subprocess.run([sys.executable, '-m', 'coverage', 'report',
'--show-missing', '--include', filters], check=True)
print()
- print("To debug this, run 'tox -e py36-pyqt59-cov' "
- "(or py35-pyqt59-cov) locally and check htmlcov/index.html")
+ print("To debug this, run 'tox -e py36-pyqt515-cov' "
+ "(replace Python/Qt versions based on your system) locally and check "
+ "htmlcov/index.html")
print("or check https://codecov.io/github/qutebrowser/qutebrowser")
print()
diff --git a/scripts/dev/ci/docker/Dockerfile.j2 b/scripts/dev/ci/docker/Dockerfile.j2
new file mode 100644
index 000000000..412c42cf2
--- /dev/null
+++ b/scripts/dev/ci/docker/Dockerfile.j2
@@ -0,0 +1,27 @@
+FROM thecompiler/archlinux
+MAINTAINER Florian Bruhin <me@the-compiler.org>
+
+{% if unstable %}
+RUN sed -i '/^# after the header/a[kde-unstable]\nInclude = /etc/pacman.d/mirrorlist\n\n[testing]\nInclude = /etc/pacman.d/mirrorlist' /etc/pacman.conf
+{% endif %}
+RUN pacman -Suyy --noconfirm \
+ git \
+ python-tox \
+ python-distlib \
+ qt5-base \
+ qt5-declarative \
+ {% if webengine %}qt5-webengine python-pyqtwebengine{% else %}qt5-webkit{% endif %} \
+ python-pyqt5 \
+ xorg-xinit \
+ xorg-server-xvfb \
+ ttf-bitstream-vera \
+ gcc \
+ libyaml \
+ xorg-xdpyinfo
+
+USER user
+WORKDIR /home/user
+
+CMD git clone /outside qutebrowser.git && \
+ cd qutebrowser.git && \
+ tox -e py38
diff --git a/scripts/dev/ci/docker/README.md b/scripts/dev/ci/docker/README.md
new file mode 100644
index 000000000..eb2b8db91
--- /dev/null
+++ b/scripts/dev/ci/docker/README.md
@@ -0,0 +1,9 @@
+This directory contains a Dockerfile template for containers used to test
+qutebrowser on CI.
+
+The `generate.py` script uses that template to generate various image
+configuration.
+
+The images are rebuilt via Github Actions in this directory, and qutebrowser
+then downloads them during the CI run. Note that means that it'll take a while
+until builds will use the newer image if you make a change to this directory.
diff --git a/scripts/dev/ci/docker/generate.py b/scripts/dev/ci/docker/generate.py
new file mode 100644
index 000000000..7d09fdb20
--- /dev/null
+++ b/scripts/dev/ci/docker/generate.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python3
+# vim: ft=sh fileencoding=utf-8 sts=4 sw=4 et:
+
+# Copyright 2019-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/>.
+
+"""Generate Dockerfiles for qutebrowser's CI."""
+
+import sys
+
+import jinja2
+
+
+def main():
+ with open('Dockerfile.j2') as f:
+ template = jinja2.Template(f.read())
+
+ image = sys.argv[1]
+ config = {
+ 'archlinux-webkit': {'webengine': False, 'unstable': False},
+ 'archlinux-webengine': {'webengine': True, 'unstable': False},
+ 'archlinux-webengine-unstable': {'webengine': True, 'unstable': True},
+ }[image]
+
+ with open('Dockerfile', 'w') as f:
+ f.write(template.render(**config))
+ f.write('\n')
+
+
+if __name__ == '__main__':
+ main()
diff --git a/scripts/dev/ci/problemmatchers.py b/scripts/dev/ci/problemmatchers.py
index 320d0deeb..3e804af05 100644
--- a/scripts/dev/ci/problemmatchers.py
+++ b/scripts/dev/ci/problemmatchers.py
@@ -182,6 +182,20 @@ MATCHERS = {
],
},
],
+
+ "misc": [
+ {
+ "severity": "error",
+ "pattern": [
+ {
+ "regexp": r'^([^:]+):(\d+): (Found .*)',
+ "file": 1,
+ "line": 2,
+ "message": 3,
+ }
+ ]
+ }
+ ]
}
diff --git a/scripts/dev/misc_checks.py b/scripts/dev/misc_checks.py
index df2845405..14373f94f 100644
--- a/scripts/dev/misc_checks.py
+++ b/scripts/dev/misc_checks.py
@@ -28,14 +28,14 @@ import argparse
import subprocess
import tokenize
import traceback
-import collections
import pathlib
from typing import List, Iterator, Optional
-sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir,
- os.pardir))
+REPO_ROOT = pathlib.Path(__file__).resolve().parents[2]
+sys.path.insert(0, str(REPO_ROOT))
from scripts import utils
+from scripts.dev import recompile_requirements
BINARY_EXTS = {'.png', '.icns', '.ico', '.bmp', '.gz', '.bin', '.pdf',
'.sqlite', '.woff2', '.whl'}
@@ -78,8 +78,46 @@ def _get_files(
yield path
+def check_changelog_urls(_args: argparse.Namespace = None) -> bool:
+ """Ensure we have changelog URLs for all requirements."""
+ ok = True
+ all_requirements = set()
+
+ for name in recompile_requirements.get_all_names():
+ outfile = recompile_requirements.get_outfile(name)
+ missing = set()
+ with open(outfile, 'r', encoding='utf-8') as f:
+ for line in f:
+ line = line.strip()
+ if line.startswith('#') or not line:
+ continue
+ req, _version = recompile_requirements.parse_versioned_line(line)
+ if req.startswith('./'):
+ continue
+ all_requirements.add(req)
+ if req not in recompile_requirements.CHANGELOG_URLS:
+ missing.add(req)
+
+ if missing:
+ ok = False
+ req_str = ', '.join(sorted(missing))
+ utils.print_col(
+ f"Missing changelog URLs in {name} requirements: {req_str}", 'red')
+
+ extra = set(recompile_requirements.CHANGELOG_URLS) - all_requirements
+ if extra:
+ ok = False
+ req_str = ', '.join(sorted(extra))
+ utils.print_col(f"Extra changelog URLs: {req_str}", 'red')
+
+ if not ok:
+ print("Hint: Changelog URLs are in scripts/dev/recompile_requirements.py")
+
+ return ok
+
+
def check_git(_args: argparse.Namespace = None) -> bool:
- """Check for uncommitted git files.."""
+ """Check for uncommitted git files."""
if not os.path.isdir(".git"):
print("No .git dir, ignoring")
print()
@@ -101,6 +139,17 @@ def check_git(_args: argparse.Namespace = None) -> bool:
return status
+def _check_spelling_file(path, fobj, patterns):
+ ok = True
+ for num, line in enumerate(fobj, start=1):
+ for pattern, explanation in patterns:
+ if pattern.search(line):
+ ok = False
+ print(f'{path}:{num}: Found "{pattern.pattern}" - ', end='')
+ utils.print_col(explanation, 'blue')
+ return ok
+
+
def check_spelling(args: argparse.Namespace) -> Optional[bool]:
"""Check commonly misspelled words."""
# Words which I often misspell
@@ -119,6 +168,37 @@ def check_spelling(args: argparse.Namespace) -> Optional[bool]:
'eventloops', 'sizehint', 'statemachine', 'metaobject',
'logrecord'}
+ patterns = [
+ (
+ re.compile(r'[{}{}]{}'.format(w[0], w[0].upper(), w[1:])),
+ "Common misspelling or non-US spelling"
+ ) for w in words
+ ]
+ patterns += [
+ (
+ re.compile(r'(?i)# noqa(?!: )'),
+ "Don't use a blanket 'noqa', use something like 'noqa: X123' instead.",
+ ),
+ (
+ re.compile(r'# type: ignore[^\[]'),
+ ("Don't use a blanket 'type: ignore', use something like "
+ "'type: ignore[error-code]' instead."),
+ ),
+ (
+ re.compile(r'# type: (?!ignore\[)'),
+ "Don't use type comments, use type annotations instead.",
+ ),
+ (
+ re.compile(r': typing\.'),
+ "Don't use typing.SomeType, do 'from typing import SomeType' instead.",
+ ),
+ (
+ re.compile(r"""monkeypatch\.setattr\(['"]"""),
+ "Don't use monkeypatch.setattr('obj.attr', value), use "
+ "setattr(obj, 'attr', value) instead.",
+ ),
+ ]
+
# Files which should be ignored, e.g. because they come from another
# package
hint_data = pathlib.Path('tests', 'end2end', 'data', 'hints')
@@ -129,20 +209,12 @@ def check_spelling(args: argparse.Namespace) -> Optional[bool]:
hint_data / 'bootstrap' / 'bootstrap.css',
]
- seen = collections.defaultdict(list)
try:
ok = True
for path in _get_files(verbose=args.verbose, ignored=ignored):
with tokenize.open(str(path)) as f:
- for line in f:
- for w in words:
- pattern = '[{}{}]{}'.format(w[0], w[0].upper(), w[1:])
- if (re.search(pattern, line) and
- path not in seen[w] and
- '# pragma: no spellcheck' not in line):
- print('Found "{}" in {}!'.format(w, path))
- seen[w].append(path)
- ok = False
+ if not _check_spelling_file(path, f, patterns):
+ ok = False
print()
return ok
except Exception:
@@ -203,20 +275,30 @@ def check_userscripts_descriptions(_args: argparse.Namespace = None) -> bool:
def main() -> int:
+ checkers = {
+ 'git': check_git,
+ 'vcs': check_vcs_conflict,
+ 'spelling': check_spelling,
+ 'userscripts': check_userscripts_descriptions,
+ 'changelog-urls': check_changelog_urls,
+ }
+
parser = argparse.ArgumentParser()
parser.add_argument('--verbose', action='store_true', help='Show checked filenames')
parser.add_argument('checker',
- choices=('git', 'vcs', 'spelling', 'userscripts'),
+ choices=list(checkers) + ['all'],
help="Which checker to run.")
args = parser.parse_args()
- if args.checker == 'git':
- ok = check_git(args)
- elif args.checker == 'vcs':
- ok = check_vcs_conflict(args)
- elif args.checker == 'spelling':
- ok = check_spelling(args)
- elif args.checker == 'userscripts':
- ok = check_userscripts_descriptions(args)
+
+ if args.checker == 'all':
+ retvals = []
+ for name, checker in checkers.items():
+ utils.print_title(name)
+ retvals.append(checker(args))
+ return 0 if all(retvals) else 1
+
+ checker = checkers[args.checker]
+ ok = checker(args)
return 0 if ok else 1
diff --git a/scripts/dev/recompile_requirements.py b/scripts/dev/recompile_requirements.py
index 5b79b801d..094a69ebe 100644
--- a/scripts/dev/recompile_requirements.py
+++ b/scripts/dev/recompile_requirements.py
@@ -39,55 +39,88 @@ REQ_DIR = os.path.join(REPO_DIR, 'misc', 'requirements')
CHANGELOG_URLS = {
'pyparsing': 'https://github.com/pyparsing/pyparsing/blob/master/CHANGES',
- 'cherrypy': 'https://github.com/cherrypy/cherrypy/blob/master/CHANGES.rst',
'pylint': 'http://pylint.pycqa.org/en/latest/whatsnew/changelog.html',
- 'setuptools': 'https://github.com/pypa/setuptools/blob/master/CHANGES.rst',
+ 'isort': 'https://pycqa.github.io/isort/CHANGELOG/',
+ 'lazy-object-proxy': 'https://github.com/ionelmc/python-lazy-object-proxy/blob/master/CHANGELOG.rst',
+ 'mccabe': 'https://github.com/PyCQA/mccabe#changes',
'pytest-cov': 'https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst',
'pytest-xdist': 'https://github.com/pytest-dev/pytest-xdist/blob/master/CHANGELOG.rst',
'pytest-forked': 'https://github.com/pytest-dev/pytest-forked/blob/master/CHANGELOG',
+ 'pytest-xvfb': 'https://github.com/The-Compiler/pytest-xvfb/blob/master/CHANGELOG.rst',
+ 'EasyProcess': 'https://github.com/ponty/EasyProcess/commits/master',
+ 'PyVirtualDisplay': 'https://github.com/ponty/PyVirtualDisplay/commits/master',
'execnet': 'https://execnet.readthedocs.io/en/latest/changelog.html',
'apipkg': 'https://github.com/pytest-dev/apipkg/blob/master/CHANGELOG',
'pytest-rerunfailures': 'https://github.com/pytest-dev/pytest-rerunfailures/blob/master/CHANGES.rst',
+ 'pytest-repeat': 'https://github.com/pytest-dev/pytest-repeat/blob/master/CHANGES.rst',
'requests': 'https://github.com/psf/requests/blob/master/HISTORY.md',
'requests-file': 'https://github.com/dashea/requests-file/blob/master/CHANGES.rst',
- 'werkzeug': 'https://github.com/pallets/werkzeug/blob/master/CHANGES.rst',
+ 'Werkzeug': 'https://github.com/pallets/werkzeug/blob/master/CHANGES.rst',
+ 'click': 'https://click.palletsprojects.com/en/7.x/changelog/',
+ 'itsdangerous': 'https://itsdangerous.palletsprojects.com/en/1.1.x/changes/',
+ 'parse-type': 'https://github.com/jenisys/parse_type/blob/master/CHANGES.txt',
+ 'sortedcontainers': 'https://github.com/grantjenks/python-sortedcontainers/blob/master/HISTORY.rst',
+ 'soupsieve': 'https://facelessuser.github.io/soupsieve/about/changelog/',
+ 'Flask': 'https://flask.palletsprojects.com/en/1.1.x/changelog/',
+ 'Mako': 'https://docs.makotemplates.org/en/latest/changelog.html',
+ 'glob2': 'https://github.com/miracle2k/python-glob2/blob/master/CHANGES',
'hypothesis': 'https://hypothesis.readthedocs.io/en/latest/changes.html',
'mypy': 'https://mypy-lang.blogspot.com/',
'pytest': 'https://docs.pytest.org/en/latest/changelog.html',
'iniconfig': 'https://github.com/RonnyPfannschmidt/iniconfig/blob/master/CHANGELOG',
'tox': 'https://tox.readthedocs.io/en/latest/changelog.html',
- 'pyyaml': 'https://github.com/yaml/pyyaml/blob/master/CHANGES',
+ 'PyYAML': 'https://github.com/yaml/pyyaml/blob/master/CHANGES',
'pytest-bdd': 'https://github.com/pytest-dev/pytest-bdd/blob/master/CHANGES.rst',
'snowballstemmer': 'https://github.com/snowballstem/snowball/blob/master/NEWS',
'virtualenv': 'https://virtualenv.pypa.io/en/latest/changelog.html',
- 'pip': 'https://pip.pypa.io/en/stable/news/',
'packaging': 'https://pypi.org/project/packaging/',
- 'flake8-docstrings': 'https://pypi.org/project/flake8-docstrings/',
+ 'build': 'https://github.com/pypa/build/commits/master',
'attrs': 'http://www.attrs.org/en/stable/changelog.html',
- 'jinja2': 'https://github.com/pallets/jinja/blob/master/CHANGES.rst',
+ 'Jinja2': 'https://github.com/pallets/jinja/blob/master/CHANGES.rst',
+ 'MarkupSafe': 'https://markupsafe.palletsprojects.com/en/1.1.x/changes/',
'flake8': 'https://gitlab.com/pycqa/flake8/tree/master/docs/source/release-notes',
- 'cffi': 'https://cffi.readthedocs.io/en/latest/whatsnew.html',
+ 'flake8-docstrings': 'https://pypi.org/project/flake8-docstrings/',
'flake8-debugger': 'https://github.com/JBKahn/flake8-debugger/',
+ 'flake8-builtins': 'https://github.com/gforcada/flake8-builtins/blob/master/CHANGES.rst',
+ 'flake8-bugbear': 'https://github.com/PyCQA/flake8-bugbear#change-log',
+ 'flake8-tidy-imports': 'https://github.com/adamchainz/flake8-tidy-imports/blob/master/HISTORY.rst',
+ 'flake8-tuple': 'https://github.com/ar4s/flake8_tuple/blob/master/HISTORY.rst',
+ 'flake8-comprehensions': 'https://github.com/adamchainz/flake8-comprehensions/blob/master/HISTORY.rst',
+ 'flake8-copyright': 'https://github.com/savoirfairelinux/flake8-copyright/blob/master/CHANGELOG.rst',
+ 'flake8-deprecated': 'https://github.com/gforcada/flake8-deprecated/blob/master/CHANGES.rst',
+ 'flake8-future-import': 'https://github.com/xZise/flake8-future-import#changes',
+ 'flake8-mock': 'https://github.com/aleGpereira/flake8-mock#changes',
+ 'flake8-polyfill': 'https://gitlab.com/pycqa/flake8-polyfill/-/blob/master/CHANGELOG.rst',
+ 'flake8-string-format': 'https://github.com/xZise/flake8-string-format#changes',
+ 'pep8-naming': 'https://github.com/PyCQA/pep8-naming/blob/master/CHANGELOG.rst',
+ 'pycodestyle': 'https://github.com/PyCQA/pycodestyle/blob/master/CHANGES.txt',
+ 'pyflakes': 'https://github.com/PyCQA/pyflakes/blob/master/NEWS.rst',
+ 'cffi': 'https://cffi.readthedocs.io/en/latest/whatsnew.html',
'astroid': 'https://github.com/PyCQA/astroid/blob/2.4/ChangeLog',
'pytest-instafail': 'https://github.com/pytest-dev/pytest-instafail/blob/master/CHANGES.rst',
'coverage': 'https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst',
'colorama': 'https://github.com/tartley/colorama/blob/master/CHANGELOG.rst',
'hunter': 'https://github.com/ionelmc/python-hunter/blob/master/CHANGELOG.rst',
- 'uritemplate': 'https://pypi.org/project/uritemplate/',
- 'flake8-builtins': 'https://github.com/gforcada/flake8-builtins/blob/master/CHANGES.rst',
- 'flake8-bugbear': 'https://github.com/PyCQA/flake8-bugbear',
- 'flake8-tidy-imports': 'https://github.com/adamchainz/flake8-tidy-imports/blob/master/HISTORY.rst',
- 'flake8-tuple': 'https://github.com/ar4s/flake8_tuple/blob/master/HISTORY.rst',
+ 'uritemplate': 'https://github.com/python-hyper/uritemplate/blob/master/HISTORY.rst',
'more-itertools': 'https://github.com/erikrose/more-itertools/blob/master/docs/versions.rst',
'pydocstyle': 'http://www.pydocstyle.org/en/latest/release_notes.html',
- 'sphinx': 'https://www.sphinx-doc.org/en/master/changes.html',
+ 'Sphinx': 'https://www.sphinx-doc.org/en/master/changes.html',
+ 'Babel': 'https://github.com/python-babel/babel/blob/master/CHANGES',
+ 'alabaster': 'https://alabaster.readthedocs.io/en/latest/changelog.html',
+ 'imagesize': 'https://github.com/shibukawa/imagesize_py/commits/master',
+ 'pytz': 'https://mm.icann.org/pipermail/tz-announce/',
+ 'sphinxcontrib-applehelp': 'https://www.sphinx-doc.org/en/master/changes.html',
+ 'sphinxcontrib-devhelp': 'https://www.sphinx-doc.org/en/master/changes.html',
+ 'sphinxcontrib-htmlhelp': 'https://www.sphinx-doc.org/en/master/changes.html',
+ 'sphinxcontrib-jsmath': 'https://www.sphinx-doc.org/en/master/changes.html',
+ 'sphinxcontrib-qthelp': 'https://www.sphinx-doc.org/en/master/changes.html',
+ 'sphinxcontrib-serializinghtml': 'https://www.sphinx-doc.org/en/master/changes.html',
'jaraco.functools': 'https://github.com/jaraco/jaraco.functools/blob/master/CHANGES.rst',
'parse': 'https://github.com/r1chardj0n3s/parse#potential-gotchas',
'py': 'https://py.readthedocs.io/en/latest/changelog.html#changelog',
'Pympler': 'https://github.com/pympler/pympler/blob/master/CHANGELOG.md',
'pytest-mock': 'https://github.com/pytest-dev/pytest-mock/blob/master/CHANGELOG.rst',
'pytest-qt': 'https://github.com/pytest-dev/pytest-qt/blob/master/CHANGELOG.rst',
- 'wcwidth': 'https://github.com/jquast/wcwidth#history',
'pyinstaller': 'https://pyinstaller.readthedocs.io/en/stable/CHANGES.html',
'pyinstaller-hooks-contrib': 'https://github.com/pyinstaller/pyinstaller-hooks-contrib/blob/master/CHANGELOG.rst',
'pytest-benchmark': 'https://pytest-benchmark.readthedocs.io/en/stable/changelog.html',
@@ -95,14 +128,10 @@ CHANGELOG_URLS = {
'docutils': 'https://docutils.sourceforge.io/RELEASE-NOTES.html',
'bump2version': 'https://github.com/c4urself/bump2version/blob/master/CHANGELOG.md',
'six': 'https://github.com/benjaminp/six/blob/master/CHANGES',
- 'flake8-comprehensions': 'https://github.com/adamchainz/flake8-comprehensions/blob/master/HISTORY.rst',
'altgraph': 'https://github.com/ronaldoussoren/altgraph/blob/master/doc/changelog.rst',
'urllib3': 'https://github.com/urllib3/urllib3/blob/master/CHANGES.rst',
- 'wheel': 'https://github.com/pypa/wheel/blob/master/docs/news.rst',
- 'mako': 'https://docs.makotemplates.org/en/latest/changelog.html',
'lxml': 'https://lxml.de/4.6/changes-4.6.0.html',
'jwcrypto': 'https://github.com/latchset/jwcrypto/commits/master',
- 'tox-pip-version': 'https://github.com/pglass/tox-pip-version/commits/master',
'wrapt': 'https://github.com/GrahamDumpleton/wrapt/blob/develop/docs/changes.rst',
'pep517': 'https://github.com/pypa/pep517/blob/master/doc/changelog.rst',
'cryptography': 'https://cryptography.io/en/latest/changelog.html',
@@ -122,8 +151,8 @@ CHANGELOG_URLS = {
'chardet': 'https://github.com/chardet/chardet/releases',
'idna': 'https://github.com/kjd/idna/blob/master/HISTORY.rst',
'tldextract': 'https://github.com/john-kurkowski/tldextract/blob/master/CHANGELOG.md',
- 'typing_extensions': 'https://github.com/python/typing/commits/master/typing_extensions',
- 'diff_cover': 'https://github.com/Bachmann1234/diff_cover/blob/master/CHANGELOG',
+ 'typing-extensions': 'https://github.com/python/typing/commits/master/typing_extensions',
+ 'diff-cover': 'https://github.com/Bachmann1234/diff_cover/blob/master/CHANGELOG',
'pytest-clarity': 'https://github.com/darrenburns/pytest-clarity/commits/master',
'pytest-icdiff': 'https://github.com/hjwp/pytest-icdiff/blob/master/HISTORY.rst',
'icdiff': 'https://github.com/jeffkaufman/icdiff/blob/master/ChangeLog',
@@ -132,12 +161,21 @@ CHANGELOG_URLS = {
'beautifulsoup4': 'https://bazaar.launchpad.net/~leonardr/beautifulsoup/bs4/view/head:/CHANGELOG',
'check-manifest': 'https://github.com/mgedmin/check-manifest/blob/master/CHANGES.rst',
'yamllint': 'https://github.com/adrienverge/yamllint/blob/master/CHANGELOG.rst',
+ 'pathspec': 'https://github.com/cpburnz/python-path-specification/blob/master/CHANGES.rst',
'filelock': 'https://github.com/benediktschmitt/py-filelock/commits/master',
+ 'github3.py': 'https://github3py.readthedocs.io/en/master/release-notes/index.html',
+ 'manhole': 'https://github3py.readthedocs.io/en/master/release-notes/index.html',
+ 'pycparser': 'https://github.com/eliben/pycparser/blob/master/CHANGES',
+ 'python-dateutil': 'https://dateutil.readthedocs.io/en/stable/changelog.html',
+ 'appdirs': 'https://github.com/ActiveState/appdirs/blob/master/CHANGES.rst',
+ 'pluggy': 'https://github.com/pytest-dev/pluggy/blob/master/CHANGELOG.rst',
+ 'inflect': 'https://github.com/jazzband/inflect/blob/master/CHANGES.rst',
+ 'jinja2-pluralize': 'https://github.com/audreyfeldroy/jinja2_pluralize/blob/master/HISTORY.rst',
+ 'mypy-extensions': 'https://github.com/python/mypy_extensions/commits/master',
+ 'pyroma': 'https://github.com/regebro/pyroma/blob/master/HISTORY.txt',
+ 'pyPEG2': None,
}
-# PyQt versions which need SIP v4
-OLD_PYQT = {'pyqt-5.7', 'pyqt-5.9', 'pyqt-5.10', 'pyqt-5.11'}
-
def convert_line(line, comments):
"""Convert the given requirement line to place into the output."""
@@ -223,14 +261,6 @@ def get_all_names():
yield basename[len('requirements-'):-len('.txt-raw')]
-def filter_names(names, old_pyqt=False):
- """Filter requirement names."""
- if old_pyqt:
- return sorted(names)
- else:
- return sorted(set(names) - OLD_PYQT)
-
-
def run_pip(venv_dir, *args, **kwargs):
"""Run pip inside the virtualenv."""
arg_str = ' '.join(str(arg) for arg in args)
@@ -261,9 +291,6 @@ def init_venv(host_python, venv_dir, requirements, pre=False):
def parse_args():
"""Parse commandline arguments via argparse."""
parser = argparse.ArgumentParser()
- parser.add_argument('--old-pyqt',
- action='store_true',
- help='Also include old PyQt requirements.')
parser.add_argument('names', nargs='*')
return parser.parse_args()
@@ -287,7 +314,7 @@ class Change:
self.name = name
self.old = None
self.new = None
- if name in CHANGELOG_URLS:
+ if CHANGELOG_URLS.get(name):
self.url = CHANGELOG_URLS[name]
self.link = '[{}]({})'.format(self.name, self.url)
else:
@@ -327,6 +354,25 @@ def _get_changed_files():
return sorted(changed_files)
+def parse_versioned_line(line):
+ """Parse a requirements.txt line into name/version."""
+ if '==' in line:
+ name, version = line.split('==')
+ if ';' in version: # pip environment markers
+ version = version.split(';')[0].strip()
+ elif line.startswith('-e'):
+ rest, name = line.split('#egg=')
+ version = rest.split('@')[1][:7]
+ else:
+ name = line
+ version = '?'
+
+ if name.startswith('#'): # duplicate requirements
+ name = name[1:].strip()
+
+ return name, version
+
+
def _get_changes():
"""Get a list of changed versions from git."""
changes_dict = {}
@@ -337,19 +383,7 @@ def _get_changes():
if line.startswith('+++ ') or line.startswith('--- '):
continue
- if '==' in line:
- name, version = line[1:].split('==')
- if ';' in version: # pip environment markers
- version = version.split(';')[0].strip()
- elif line[1:].startswith('-e'):
- rest, name = line.split('#egg=')
- version = rest.split('@')[1][:7]
- else:
- name = line[1:]
- version = '?'
-
- if name.startswith('#'): # duplicate requirements
- name = name[1:].strip()
+ name, version = parse_versioned_line(line[1:])
if name not in changes_dict:
changes_dict[name] = Change(name)
@@ -393,15 +427,21 @@ def print_changed_files():
def get_host_python(name):
"""Get the Python to use for a given requirement name.
- Old PyQt versions need sip v4 which doesn't work on Python 3.8
- ylint installs typed_ast on < 3.8 only
+ pylint installs typed_ast on < 3.8 only
"""
- if name in OLD_PYQT or name == 'pylint':
+ if name == 'pylint':
return 'python3.7'
else:
return sys.executable
+def get_outfile(name):
+ """Get the path to the output requirements.txt file."""
+ if name == 'qutebrowser':
+ return os.path.join(REPO_DIR, 'requirements.txt')
+ return os.path.join(REQ_DIR, 'requirements-{}.txt'.format(name))
+
+
def build_requirements(name):
"""Build a requirements file."""
utils.print_subtitle("Building")
@@ -422,10 +462,7 @@ def build_requirements(name):
if utils.ON_CI:
print(reqs.strip())
- if name == 'qutebrowser':
- outfile = os.path.join(REPO_DIR, 'requirements.txt')
- else:
- outfile = os.path.join(REQ_DIR, 'requirements-{}.txt'.format(name))
+ outfile = get_outfile(name)
with open(outfile, 'w', encoding='utf-8') as f:
f.write("# This file is automatically generated by "
@@ -484,7 +521,7 @@ def main():
if args.names:
names = args.names
else:
- names = filter_names(get_all_names(), old_pyqt=args.old_pyqt)
+ names = sorted(get_all_names())
utils.print_col('Rebuilding requirements: ' + ', '.join(names), 'green')
for name in names:
diff --git a/scripts/dev/run_vulture.py b/scripts/dev/run_vulture.py
index 1d024c6e5..194381421 100755
--- a/scripts/dev/run_vulture.py
+++ b/scripts/dev/run_vulture.py
@@ -42,7 +42,7 @@ from qutebrowser.browser import qutescheme
from qutebrowser.config import configtypes
-def whitelist_generator(): # noqa
+def whitelist_generator(): # noqa: C901
"""Generator which yields lines to add to a vulture whitelist."""
loader.load_components(skip_hooks=True)
diff --git a/scripts/dictcli.py b/scripts/dictcli.py
index ebe4e285c..4e38727dd 100755
--- a/scripts/dictcli.py
+++ b/scripts/dictcli.py
@@ -37,8 +37,7 @@ import attr
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
from qutebrowser.browser.webengine import spell
from qutebrowser.config import configdata
-from qutebrowser.utils import standarddir, utils
-from scripts import utils as scriptutils
+from qutebrowser.utils import standarddir
API_URL = 'https://chromium.googlesource.com/chromium/deps/hunspell_dictionaries.git/+/master/'
@@ -216,17 +215,8 @@ def install_lang(lang):
def install(languages):
"""Install languages."""
for lang in languages:
- try:
- print('Installing {}: {}'.format(lang.code, lang.name))
- install_lang(lang)
- except PermissionError as e:
- msg = ("\n{}\n\nWith Qt < 5.10, you will need to run this script "
- "as root, as dictionaries need to be installed "
- "system-wide. If your qutebrowser uses a newer Qt version "
- "via a virtualenv, make sure you start this script with "
- "the virtualenv's Python.".format(e))
- scriptutils.print_error(msg)
- sys.exit(1)
+ print('Installing {}: {}'.format(lang.code, lang.name))
+ install_lang(lang)
def update(languages):
@@ -250,24 +240,7 @@ def remove_old(languages):
os.remove(os.path.join(spell.dictionary_dir(), old_file))
-def check_root():
- """Ask for confirmation if running as root when unnecessary."""
- if not utils.is_posix:
- return
-
- if spell.can_use_data_path() and os.geteuid() == 0:
- print("You're running Qt >= 5.10 which means qutebrowser will "
- "load dictionaries from a path in your home-directory. "
- "Unless you run qutebrowser as root (bad idea!), you "
- "most likely want to run this script as your user. ")
- answer = input("Do you want to continue anyways? [y/N] ")
- if answer not in ['y', 'Y']:
- sys.exit(0)
-
-
def main():
- check_root()
-
if configdata.DATA is None:
configdata.init()
standarddir.init(None)
diff --git a/scripts/mkvenv.py b/scripts/mkvenv.py
index 5eeb90640..ad5f2073e 100644
--- a/scripts/mkvenv.py
+++ b/scripts/mkvenv.py
@@ -24,12 +24,13 @@
import argparse
import pathlib
import sys
+import re
import os
import os.path
-import typing
import shutil
-import venv
+import venv as pyvenv
import subprocess
+from typing import List, Optional, Tuple, Dict, Union
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
from scripts import utils, link_pyqt
@@ -38,7 +39,22 @@ from scripts import utils, link_pyqt
REPO_ROOT = pathlib.Path(__file__).parent.parent
-def parse_args() -> argparse.Namespace:
+class Error(Exception):
+
+ """Exception for errors in this script."""
+
+ def __init__(self, msg, code=1):
+ super().__init__(msg)
+ self.code = code
+
+
+def print_command(*cmd: Union[str, pathlib.Path], venv: bool) -> None:
+ """Print a command being run."""
+ prefix = 'venv$ ' if venv else '$ '
+ utils.print_col(prefix + ' '.join([str(e) for e in cmd]), 'blue')
+
+
+def parse_args(argv: List[str] = None) -> argparse.Namespace:
"""Parse commandline arguments."""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--keep',
@@ -74,10 +90,10 @@ def parse_args() -> argparse.Namespace:
parser.add_argument('--tox-error',
action='store_true',
help=argparse.SUPPRESS)
- return parser.parse_args()
+ return parser.parse_args(argv)
-def pyqt_versions() -> typing.List[str]:
+def pyqt_versions() -> List[str]:
"""Get a list of all available PyQt versions.
The list is based on the filenames of misc/requirements/ files.
@@ -93,22 +109,40 @@ def pyqt_versions() -> typing.List[str]:
return versions + ['auto']
-def run_venv(venv_dir: pathlib.Path, executable, *args: str) -> None:
+def run_venv(
+ venv_dir: pathlib.Path,
+ executable,
+ *args: str,
+ capture_output=False,
+ capture_error=False,
+ env=None,
+) -> subprocess.CompletedProcess:
"""Run the given command inside the virtualenv."""
subdir = 'Scripts' if os.name == 'nt' else 'bin'
+ if env is None:
+ proc_env = None
+ else:
+ proc_env = os.environ.copy()
+ proc_env.update(env)
+
try:
- subprocess.run([str(venv_dir / subdir / executable)] +
- [str(arg) for arg in args], check=True)
+ return subprocess.run(
+ [str(venv_dir / subdir / executable)] + [str(arg) for arg in args],
+ check=True,
+ universal_newlines=capture_output or capture_error,
+ stdout=subprocess.PIPE if capture_output else None,
+ stderr=subprocess.PIPE if capture_error else None,
+ env=proc_env,
+ )
except subprocess.CalledProcessError as e:
- utils.print_error("Subprocess failed, exiting")
- sys.exit(e.returncode)
+ raise Error("Subprocess failed, exiting") from e
def pip_install(venv_dir: pathlib.Path, *args: str) -> None:
"""Run a pip install command inside the virtualenv."""
arg_str = ' '.join(str(arg) for arg in args)
- utils.print_col('venv$ pip install {}'.format(arg_str), 'blue')
+ print_command('pip install', arg_str, venv=True)
run_venv(venv_dir, 'python', '-m', 'pip', 'install', *args)
@@ -125,27 +159,25 @@ def delete_old_venv(venv_dir: pathlib.Path) -> None:
]
if not any(m.exists() for m in markers):
- utils.print_error('{} does not look like a virtualenv, '
- 'cowardly refusing to remove it.'.format(venv_dir))
- sys.exit(1)
+ raise Error('{} does not look like a virtualenv, cowardly refusing to '
+ 'remove it.'.format(venv_dir))
- utils.print_col('$ rm -r {}'.format(venv_dir), 'blue')
+ print_command('rm -r', venv_dir, venv=False)
shutil.rmtree(str(venv_dir))
def create_venv(venv_dir: pathlib.Path, use_virtualenv: bool = False) -> None:
"""Create a new virtualenv."""
if use_virtualenv:
- utils.print_col('$ python3 -m virtualenv {}'.format(venv_dir), 'blue')
+ print_command('python3 -m virtualenv', venv_dir, venv=False)
try:
subprocess.run([sys.executable, '-m', 'virtualenv', venv_dir],
check=True)
except subprocess.CalledProcessError as e:
- utils.print_error("virtualenv failed, exiting")
- sys.exit(e.returncode)
+ raise Error("virtualenv failed, exiting", e.returncode)
else:
- utils.print_col('$ python3 -m venv {}'.format(venv_dir), 'blue')
- venv.create(str(venv_dir), with_pip=True)
+ print_command('python3 -m venv', venv_dir, venv=False)
+ pyvenv.create(str(venv_dir), with_pip=True)
def upgrade_seed_pkgs(venv_dir: pathlib.Path) -> None:
@@ -202,6 +234,122 @@ def install_pyqt_wheels(venv_dir: pathlib.Path,
pip_install(venv_dir, *wheels)
+def apply_xcb_util_workaround(
+ venv_dir: pathlib.Path,
+ pyqt_type: str,
+ pyqt_version: str,
+) -> None:
+ """If needed (Debian Stable), symlink libxcb-util.so.0 -> .1.
+
+ WORKAROUND for https://bugreports.qt.io/browse/QTBUG-88688
+ """
+ utils.print_title("Running xcb-util workaround")
+
+ if not sys.platform.startswith('linux'):
+ print("Workaround not needed: Not on Linux.")
+ return
+ if pyqt_type != 'binary':
+ print("Workaround not needed: Not installing from PyQt binaries.")
+ return
+ if pyqt_version not in ['auto', '5.15']:
+ print("Workaround not needed: Not installing Qt 5.15.")
+ return
+
+ libs = _find_libs()
+ abi_type = 'libc6,x86-64' # the only one PyQt wheels are available for
+
+ if ('libxcb-util.so.1', abi_type) in libs:
+ print("Workaround not needed: libxcb-util.so.1 found.")
+ return
+
+ try:
+ libxcb_util_libs = libs['libxcb-util.so.0', abi_type]
+ except KeyError:
+ utils.print_error('Workaround failed: libxcb-util.so.0 not found.')
+ return
+
+ if len(libxcb_util_libs) > 1:
+ utils.print_error(
+ f'Workaround failed: Multiple matching libxcb-util found: '
+ f'{libxcb_util_libs}')
+ return
+
+ libxcb_util_path = pathlib.Path(libxcb_util_libs[0])
+
+ code = [
+ 'from PyQt5.QtCore import QLibraryInfo',
+ 'print(QLibraryInfo.location(QLibraryInfo.LibrariesPath))',
+ ]
+ proc = run_venv(venv_dir, 'python', '-c', '; '.join(code), capture_output=True)
+ venv_lib_path = pathlib.Path(proc.stdout.strip())
+
+ link_path = venv_lib_path / libxcb_util_path.with_suffix('.1').name
+
+ # This gives us a nicer path to print, and also conveniently makes sure we
+ # didn't accidentally end up with a path outside the venv.
+ rel_link_path = venv_dir / link_path.relative_to(venv_dir.resolve())
+ print_command('ln -s', libxcb_util_path, rel_link_path, venv=False)
+
+ link_path.symlink_to(libxcb_util_path)
+
+
+def _find_libs() -> Dict[Tuple[str, str], List[str]]:
+ """Find all system-wide .so libraries."""
+ all_libs: Dict[Tuple[str, str], List[str]] = {}
+ ldconfig_proc = subprocess.run(
+ ['ldconfig', '-p'],
+ check=True,
+ stdout=subprocess.PIPE,
+ encoding=sys.getfilesystemencoding(),
+ )
+ pattern = re.compile(r'(?P<name>\S+) \((?P<abi_type>[^)]+)\) => (?P<path>.*)')
+ for line in ldconfig_proc.stdout.splitlines():
+ match = pattern.fullmatch(line.strip())
+ if match is None:
+ if 'libs found in cache' not in line:
+ utils.print_col(f'Failed to match ldconfig output: {line}', 'yellow')
+ continue
+
+ key = match.group('name'), match.group('abi_type')
+ path = match.group('path')
+
+ libs = all_libs.setdefault(key, [])
+ libs.append(path)
+
+ return all_libs
+
+
+def run_qt_smoke_test(venv_dir: pathlib.Path) -> None:
+ """Make sure the Qt installation works."""
+ utils.print_title("Running Qt smoke test")
+ code = [
+ 'import sys',
+ 'from PyQt5.QtWidgets import QApplication',
+ 'from PyQt5.QtCore import qVersion, QT_VERSION_STR, PYQT_VERSION_STR',
+ 'print(f"Python: {sys.version}")',
+ 'print(f"qVersion: {qVersion()}")',
+ 'print(f"QT_VERSION_STR: {QT_VERSION_STR}")',
+ 'print(f"PYQT_VERSION_STR: {PYQT_VERSION_STR}")',
+ 'QApplication([])',
+ 'print("Qt seems to work properly!")',
+ 'print()',
+ ]
+ try:
+ run_venv(
+ venv_dir,
+ 'python', '-c', '; '.join(code),
+ env={'QT_DEBUG_PLUGINS': '1'},
+ capture_error=True
+ )
+ except Error as e:
+ proc_e = e.__cause__
+ assert isinstance(proc_e, subprocess.CalledProcessError), proc_e
+ print(proc_e.stderr)
+ raise Error(
+ f"Smoke test failed with status {proc_e.returncode}. "
+ "You might find additional information in the debug output above.")
+
+
def install_requirements(venv_dir: pathlib.Path) -> None:
"""Install qutebrowser's requirement.txt."""
utils.print_title("Installing other qutebrowser dependencies")
@@ -224,7 +372,7 @@ def install_qutebrowser(venv_dir: pathlib.Path) -> None:
def regenerate_docs(venv_dir: pathlib.Path,
- asciidoc: typing.Optional[typing.Tuple[str, str]]):
+ asciidoc: Optional[Tuple[str, str]]):
"""Regenerate docs using asciidoc."""
utils.print_title("Generating documentation")
if asciidoc is not None:
@@ -233,27 +381,24 @@ def regenerate_docs(venv_dir: pathlib.Path,
a2h_args = []
script_path = pathlib.Path(__file__).parent / 'asciidoc2html.py'
- utils.print_col('venv$ python3 scripts/asciidoc2html.py {}'
- .format(' '.join(a2h_args)), 'blue')
+ print_command('python3 scripts/asciidoc2html.py', *a2h_args, venv=True)
run_venv(venv_dir, 'python', str(script_path), *a2h_args)
-def main() -> None:
+def run(args) -> None:
"""Install qutebrowser in a virtualenv.."""
- args = parse_args()
venv_dir = pathlib.Path(args.venv_dir)
wheels_dir = pathlib.Path(args.pyqt_wheels_dir)
utils.change_cwd()
if (args.pyqt_version != 'auto' and
args.pyqt_type not in ['binary', 'source']):
- utils.print_error('The --pyqt-version option is only available when '
- 'installing PyQt from binary or source')
- sys.exit(1)
- elif args.pyqt_wheels_dir != 'wheels' and args.pyqt_type != 'wheels':
- utils.print_error('The --pyqt-wheels-dir option is only available '
- 'when installing PyQt from wheels')
- sys.exit(1)
+ raise Error('The --pyqt-version option is only available when installing PyQt '
+ 'from binary or source')
+
+ if args.pyqt_wheels_dir != 'wheels' and args.pyqt_type != 'wheels':
+ raise Error('The --pyqt-wheels-dir option is only available when installing '
+ 'PyQt from wheels')
if not args.keep:
utils.print_title("Creating virtual environment")
@@ -275,6 +420,10 @@ def main() -> None:
else:
raise AssertionError
+ apply_xcb_util_workaround(venv_dir, args.pyqt_type, args.pyqt_version)
+ if args.pyqt_type != 'skip':
+ run_qt_smoke_test(venv_dir)
+
install_requirements(venv_dir)
install_qutebrowser(venv_dir)
if args.dev:
@@ -284,5 +433,14 @@ def main() -> None:
regenerate_docs(venv_dir, args.asciidoc)
+def main():
+ args = parse_args()
+ try:
+ run(args)
+ except Error as e:
+ utils.print_error(str(e))
+ sys.exit(e.code)
+
+
if __name__ == '__main__':
main()
diff --git a/tests/conftest.py b/tests/conftest.py
index ef169be4f..017c11ba8 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -101,13 +101,6 @@ def _apply_platform_markers(config, item):
sys.getfilesystemencoding() == 'ascii',
"Skipped because of ASCII locale"),
- ('qtbug60673',
- pytest.mark.xfail,
- qtutils.version_check('5.8') and
- not qtutils.version_check('5.10') and
- config.webengine,
- "Broken on webengine due to "
- "https://bugreports.qt.io/browse/QTBUG-60673"),
('qtwebkit6021_xfail',
pytest.mark.xfail,
version.qWebKitVersion and # type: ignore[unreachable]
@@ -175,11 +168,6 @@ def pytest_collection_modifyitems(config, items):
_apply_platform_markers(config, item)
if list(item.iter_markers('xfail_norun')):
item.add_marker(pytest.mark.xfail(run=False))
- if list(item.iter_markers('js_prompt')):
- if config.webengine:
- item.add_marker(pytest.mark.skipif(
- PYQT_VERSION <= 0x050700,
- reason='JS prompts are not supported with PyQt 5.7'))
if deselected:
deselected_items.append(item)
@@ -281,10 +269,10 @@ def apply_fake_os(monkeypatch, request):
else:
raise ValueError("Invalid fake_os {}".format(name))
- monkeypatch.setattr('qutebrowser.utils.utils.is_mac', mac)
- monkeypatch.setattr('qutebrowser.utils.utils.is_linux', linux)
- monkeypatch.setattr('qutebrowser.utils.utils.is_windows', windows)
- monkeypatch.setattr('qutebrowser.utils.utils.is_posix', posix)
+ monkeypatch.setattr(utils, 'is_mac', mac)
+ monkeypatch.setattr(utils, 'is_linux', linux)
+ monkeypatch.setattr(utils, 'is_windows', windows)
+ monkeypatch.setattr(utils, 'is_posix', posix)
@pytest.fixture(scope='session', autouse=True)
diff --git a/tests/end2end/conftest.py b/tests/end2end/conftest.py
index 43105d6cb..17b457521 100644
--- a/tests/end2end/conftest.py
+++ b/tests/end2end/conftest.py
@@ -35,7 +35,7 @@ from PyQt5.QtCore import PYQT_VERSION, QCoreApplication
pytest.register_assert_rewrite('end2end.fixtures')
-from end2end.fixtures.webserver import server, server_per_test, ssl_server
+from end2end.fixtures.webserver import server, server_per_test, server2, ssl_server
from end2end.fixtures.quteprocess import (quteproc_process, quteproc,
quteproc_new)
from end2end.fixtures.testprocess import pytest_runtest_makereport
@@ -140,8 +140,7 @@ def pytest_collection_modifyitems(config, items):
"""Apply @qtwebengine_* markers; skip unittests with QUTE_BDD_WEBENGINE."""
# 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))
+ header_bug_fixed = qtutils.version_check('5.15', compiled=False)
lib_path = pathlib.Path(QCoreApplication.libraryPaths()[0])
qpdf_image_plugin = lib_path / 'imageformats' / 'libqpdf.so'
diff --git a/tests/end2end/features/downloads.feature b/tests/end2end/features/downloads.feature
index a440590b8..df2e10b46 100644
--- a/tests/end2end/features/downloads.feature
+++ b/tests/end2end/features/downloads.feature
@@ -101,18 +101,6 @@ Feature: Downloading things from a website.
And I run :leave-mode
Then no crash should happen
- # https://github.com/qutebrowser/qutebrowser/issues/4240
- @qt<5.11.2
- Scenario: Downloading with SSL errors (issue 1413)
- When SSL is supported
- And I clear SSL errors
- And I set content.ssl_strict to ask
- And I set downloads.location.prompt to false
- And I download an SSL page
- And I wait for "Entering mode KeyMode.* (reason: question asked)" in the log
- And I run :prompt-accept
- Then the error "Download error: SSL handshake failed" should be shown
-
Scenario: Closing window with downloads.remove_finished timeout (issue 1242)
When I set downloads.remove_finished to 500
And I open data/downloads/download.bin in a new window without waiting
@@ -148,16 +136,16 @@ Feature: Downloading things from a website.
And I wait until the download is finished
Then the downloaded file download with spaces.bin should exist
- @qtwebkit_skip @qt<5.9 @qt>=5.13
- Scenario: Downloading a file with evil content-disposition header (Qt 5.8 or older and 5.13 and newer)
+ @qtwebkit_skip @qt>=5.13
+ Scenario: Downloading a file with evil content-disposition header (Qt 5.13 and newer)
# Content-Disposition: download; filename=..%2Ffoo
When I open response-headers?Content-Disposition=download;%20filename%3D..%252Ffoo without waiting
And I wait until the download is finished
Then the downloaded file ../foo should not exist
And the downloaded file foo should exist
- @qtwebkit_skip @qt<5.13 @qt>=5.9
- Scenario: Downloading a file with evil content-disposition header (Qt 5.9 to 5.12)
+ @qtwebkit_skip @qt<5.13
+ Scenario: Downloading a file with evil content-disposition header (Qt 5.12)
# Content-Disposition: download; filename=..%2Ffoo
When I open response-headers?Content-Disposition=download;%20filename%3D..%252Ffoo without waiting
And I wait until the download is finished
@@ -211,24 +199,6 @@ Feature: Downloading things from a website.
does-not-exist
does-not-exist
- @qtwebkit_skip @qt<5.10
- Scenario: Retrying a failed download with QtWebEngine (Qt < 5.10)
- When I open data/downloads/issue2298.html
- And I run :click-element id download
- And I wait for "Download error: *" in the log
- And I run :download-retry
- Then the error "Retrying downloads is unsupported *" should be shown
-
- @qtwebkit_skip @qt==5.10.1
- Scenario: Retrying a failed download with QtWebEngine (Qt 5.10)
- When I open data/downloads/issue2298.html
- And I run :click-element id download
- And I wait for "Download error: *" in the log
- And I run :download-retry
- # For some reason it doesn't actually try again here, but let's hope it
- # works e.g. on a connection loss, which we can't test automatically.
- Then "Retrying downloads is unsupported *" should not be logged
-
@flaky
Scenario: Retrying with count
When I run :download http://localhost:(port)/data/downloads/download.bin
diff --git a/tests/end2end/features/hints.feature b/tests/end2end/features/hints.feature
index 35e48c483..271450d90 100644
--- a/tests/end2end/features/hints.feature
+++ b/tests/end2end/features/hints.feature
@@ -179,18 +179,6 @@ Feature: Using hints
And I hint with args "all run message-info {hint-url}" and follow a
Then the message "http://localhost:(port)/data/hello.txt" should be shown
- @qt<5.11
- Scenario: Clicking an invalid link
- When I open data/invalid_link.html
- And I hint with args "all" and follow a
- Then the error "Invalid link clicked - *" should be shown
-
- @qt<5.11
- Scenario: Clicking an invalid link opening in a new tab
- When I open data/invalid_link.html
- And I hint with args "all tab" and follow a
- Then the error "Invalid link clicked - *" should be shown
-
Scenario: Hinting inputs without type
When I open data/hints/input.html
And I hint with args "inputs" and follow a
diff --git a/tests/end2end/features/javascript.feature b/tests/end2end/features/javascript.feature
index a4c3d1338..6238e8b7b 100644
--- a/tests/end2end/features/javascript.feature
+++ b/tests/end2end/features/javascript.feature
@@ -124,33 +124,11 @@ Feature: Javascript stuff
# https://github.com/qutebrowser/qutebrowser/issues/1190
# https://github.com/qutebrowser/qutebrowser/issues/2495
- # Currently broken on Windows and on Qt 5.12
- # https://github.com/qutebrowser/qutebrowser/issues/4230
- @posix @qt<5.12
- Scenario: Checking visible/invisible window size
- When I run :tab-only
- And I open data/javascript/windowsize.html in a new background tab
- And I wait for "[*/data/javascript/windowsize.html:*] loaded" in the log
- And I run :tab-next
- Then the window sizes should be the same
-
- @flaky @qt<5.12
- Scenario: Checking visible/invisible window size with vertical tabbar
- When I run :tab-only
- And I set tabs.position to left
- And I open data/javascript/windowsize.html in a new background tab
- And I wait for "[*/data/javascript/windowsize.html:*] loaded" in the log
- And I run :tab-next
- Then the window sizes should be the same
-
@flaky
Scenario: Have a GreaseMonkey script run at page start
When I have a GreaseMonkey file saved for document-start with noframes unset
And I run :greasemonkey-reload
And I open data/hints/iframe.html
- # This second reload is required in webengine < 5.8 for scripts
- # registered to run at document-start, some sort of timing issue.
- And I run :reload
Then the javascript message "Script is running on /data/hints/iframe.html" should be logged
Scenario: Have a GreaseMonkey script running on frames
diff --git a/tests/end2end/features/keyinput.feature b/tests/end2end/features/keyinput.feature
index 2769e3dc3..aa9009f7c 100644
--- a/tests/end2end/features/keyinput.feature
+++ b/tests/end2end/features/keyinput.feature
@@ -18,31 +18,6 @@ Feature: Keyboard input
# input.forward_unbound_keys
- @qt<5.11.1
- Scenario: Forwarding all keys
- When I open data/keyinput/log.html
- And I set input.forward_unbound_keys to all
- And I press the key ","
- And I press the key "<F1>"
- # ,
- Then the javascript message "key press: 188" should be logged
- And the javascript message "key release: 188" should be logged
- # <F1>
- And the javascript message "key press: 112" should be logged
- And the javascript message "key release: 112" should be logged
-
- @qt<5.11.1
- Scenario: Forwarding special keys
- When I open data/keyinput/log.html
- And I set input.forward_unbound_keys to auto
- And I press the keys ",<F1>"
- # <F1>
- Then the javascript message "key press: 112" should be logged
- And the javascript message "key release: 112" should be logged
- # ,
- And the javascript message "key press: 188" should not be logged
- And the javascript message "key release: 188" should not be logged
-
Scenario: Forwarding no keys
When I open data/keyinput/log.html
And I set input.forward_unbound_keys to none
@@ -66,10 +41,10 @@ Feature: Keyboard input
@no_xvfb @posix @qtwebengine_skip
Scenario: :fake-key sending key to the website with other window focused
When I open data/keyinput/log.html
- And I run :inspector
+ And I run :devtools
And I wait for "Focus object changed: <PyQt5.QtWebKitWidgets.QWebView object at *>" in the log
And I run :fake-key x
- And I run :inspector
+ And I run :devtools
And I wait for "Focus object changed: <qutebrowser.browser.webkit.webview.WebView *>" in the log
Then the error "No focused webview!" should be shown
diff --git a/tests/end2end/features/misc.feature b/tests/end2end/features/misc.feature
index f66f09768..c5a74d081 100644
--- a/tests/end2end/features/misc.feature
+++ b/tests/end2end/features/misc.feature
@@ -171,25 +171,20 @@ Feature: Various utility commands.
# :inspect
- @qtwebkit_skip @qt<5.11
- Scenario: Inspector without --enable-webengine-inspector
- When I run :devtools
- Then the error "QtWebEngine inspector is not enabled. See 'qutebrowser --help' for details." should be shown
-
@no_xvfb @posix @qtwebengine_skip
Scenario: Inspector smoke test
- When I run :inspector
+ When I run :devtools
And I wait for "Focus object changed: <PyQt5.QtWebKitWidgets.QWebView object at *>" in the log
- And I run :inspector
+ And I run :devtools
And I wait for "Focus object changed: *" in the log
Then no crash should happen
# Different code path as an inspector got created now
@no_xvfb @posix @qtwebengine_skip
Scenario: Inspector smoke test 2
- When I run :inspector
+ When I run :devtools
And I wait for "Focus object changed: <PyQt5.QtWebKitWidgets.QWebView object at *>" in the log
- And I run :inspector
+ And I run :devtools
And I wait for "Focus object changed: *" in the log
Then no crash should happen
@@ -314,7 +309,6 @@ Feature: Various utility commands.
And I press the key "<Ctrl-C>"
Then no crash should happen
- @js_prompt
Scenario: Focusing download widget via Tab (original issue)
When I open data/prompt/jsprompt.html
And I run :click-element id button
@@ -506,25 +500,14 @@ Feature: Various utility commands.
## Renderer crashes
# Skipped on Windows as "... has stopped working" hangs.
- @qtwebkit_skip @no_invalid_lines @posix @qt<5.9
+ @qtwebkit_skip @no_invalid_lines @posix
Scenario: Renderer crash
When I run :open -t chrome://crash
- Then the error "Renderer process crashed" should be shown
-
- @qtwebkit_skip @no_invalid_lines @qt<5.9
- Scenario: Renderer kill
- When I run :open -t chrome://kill
- Then the error "Renderer process was killed" should be shown
-
- # Skipped on Windows as "... has stopped working" hangs.
- @qtwebkit_skip @no_invalid_lines @posix @qt>=5.9
- Scenario: Renderer crash (5.9)
- When I run :open -t chrome://crash
Then "Renderer process crashed" should be logged
And "* 'Error loading chrome://crash/'" should be logged
- @qtwebkit_skip @no_invalid_lines @qt>=5.9 @flaky
- Scenario: Renderer kill (5.9)
+ @qtwebkit_skip @no_invalid_lines @flaky
+ Scenario: Renderer kill
When I run :open -t chrome://kill
Then "Renderer process was killed" should be logged
And "* 'Error loading chrome://kill/'" should be logged
diff --git a/tests/end2end/features/prompts.feature b/tests/end2end/features/prompts.feature
index 96532dc8c..a0b550054 100644
--- a/tests/end2end/features/prompts.feature
+++ b/tests/end2end/features/prompts.feature
@@ -39,7 +39,6 @@ Feature: Prompts
And I run :leave-mode
Then the javascript message "confirm reply: false" should be logged
- @js_prompt
Scenario: Javascript prompt
When I open data/prompt/jsprompt.html
And I run :click-element id button
@@ -48,7 +47,6 @@ Feature: Prompts
And I run :prompt-accept
Then the javascript message "Prompt reply: prompt test" should be logged
- @js_prompt
Scenario: Javascript prompt with default
When I open data/prompt/jsprompt.html
And I run :click-element id button-default
@@ -56,7 +54,6 @@ Feature: Prompts
And I run :prompt-accept
Then the javascript message "Prompt reply: default" should be logged
- @js_prompt
Scenario: Rejected javascript prompt
When I open data/prompt/jsprompt.html
And I run :click-element id button
@@ -137,7 +134,6 @@ Feature: Prompts
# Shift-Insert with prompt (issue 1299)
- @js_prompt
Scenario: Pasting via shift-insert in prompt mode
When selection is supported
And I put "insert test" into the primary selection
@@ -148,7 +144,6 @@ Feature: Prompts
And I run :prompt-accept
Then the javascript message "Prompt reply: insert test" should be logged
- @js_prompt
Scenario: Pasting via shift-insert without it being supported
When selection is not supported
And I put "insert test" into the primary selection
@@ -160,7 +155,6 @@ Feature: Prompts
And I run :prompt-accept
Then the javascript message "Prompt reply: clipboard test" should be logged
- @js_prompt
Scenario: Using content.javascript.prompt
When I set content.javascript.prompt to false
And I open data/prompt/jsprompt.html
@@ -396,7 +390,6 @@ Feature: Prompts
Then the javascript message "Alert done" should be logged
And the error "No value is permitted with alert prompts!" should be shown
- @js_prompt
Scenario: Javascript prompt with value
When I set content.javascript.prompt to true
And I open data/prompt/jsprompt.html
diff --git a/tests/end2end/features/qutescheme.feature b/tests/end2end/features/qutescheme.feature
index 84e1b04e8..4c283710a 100644
--- a/tests/end2end/features/qutescheme.feature
+++ b/tests/end2end/features/qutescheme.feature
@@ -185,7 +185,6 @@ Feature: Special qute:// pages
And I open data/misc/test.pdf without waiting
Then "Download test.pdf finished" should be logged
- @qtwebengine_skip: Might work with Qt 5.12
Scenario: Downloading a pdf via pdf.js button (issue 1214)
Given pdfjs is available
When I set content.pdfjs to true
@@ -193,7 +192,7 @@ Feature: Special qute:// pages
And I open data/misc/test.pdf without waiting
And I wait for "[qute://pdfjs/*] PDF * (PDF.js: *)" in the log
And I run :jseval document.getElementById("download").click()
- And I wait for "Asking question <qutebrowser.utils.usertypes.Question default=* mode=<PromptMode.download: 5> text=* title='Save file to:'>, *" in the log
+ And I wait for "Asking question <qutebrowser.utils.usertypes.Question default=* mode=<PromptMode.download: 5> option=None text=* title='Save file to:'>, *" in the log
And I run :leave-mode
Then no crash should happen
@@ -283,7 +282,6 @@ Feature: Special qute:// pages
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
diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature
index 2d3dfe1d1..75051ad44 100644
--- a/tests/end2end/features/tabs.feature
+++ b/tests/end2end/features/tabs.feature
@@ -737,15 +737,8 @@ Feature: Tab management
# https://github.com/qutebrowser/qutebrowser/issues/2289
- @qtwebkit_skip @qt<5.9
- Scenario: Cloning a tab with a view-source URL
- When I open /
- And I open view-source:http://localhost:(port)
- And I run :tab-clone
- Then the error "Can't serialize special URL!" should be shown
-
- @qtwebkit_skip @qt>=5.9
- Scenario: Cloning a tab with a special URL (Qt 5.9)
+ @qtwebkit_skip
+ Scenario: Cloning a tab with a special URL
When I open chrome://gpu
And I run :tab-clone
Then no crash should happen
diff --git a/tests/end2end/features/test_downloads_bdd.py b/tests/end2end/features/test_downloads_bdd.py
index 951ebcfea..1f27d2794 100644
--- a/tests/end2end/features/test_downloads_bdd.py
+++ b/tests/end2end/features/test_downloads_bdd.py
@@ -96,12 +96,6 @@ def wait_for_download_prompt(tmpdir, quteproc, path):
"(reason: question asked)")
-@bdd.when("I download an SSL page")
-def download_ssl_page(quteproc, ssl_server):
- quteproc.send_cmd(':download https://localhost:{}/'
- .format(ssl_server.port))
-
-
@bdd.then(bdd.parsers.parse("The downloaded file {filename} should not exist"))
def download_should_not_exist(filename, tmpdir):
path = tmpdir / 'downloads' / filename
diff --git a/tests/end2end/features/test_prompts_bdd.py b/tests/end2end/features/test_prompts_bdd.py
index 98f2febbb..61cfcd8f3 100644
--- a/tests/end2end/features/test_prompts_bdd.py
+++ b/tests/end2end/features/test_prompts_bdd.py
@@ -22,8 +22,6 @@ import logging
import pytest_bdd as bdd
bdd.scenarios('prompts.feature')
-from qutebrowser.utils import qtutils
-
@bdd.when("I load an SSL page")
def load_ssl_page(quteproc, ssl_server):
@@ -51,24 +49,17 @@ def no_prompt_shown(quteproc):
@bdd.then("a SSL error page should be shown")
def ssl_error_page(request, quteproc):
- if request.config.webengine and qtutils.version_check('5.9'):
+ if request.config.webengine:
quteproc.wait_for(message="Certificate error: *")
msg = quteproc.wait_for(message="Load error: *")
msg.expected = True
- expected_messages = [
- 'Load error: ERR_INSECURE_RESPONSE', # Qt <= 5.10
- 'Load error: ERR_CERT_AUTHORITY_INVALID', # Qt 5.11
- ]
- assert msg.message in expected_messages
+ assert msg.message == 'Load error: ERR_CERT_AUTHORITY_INVALID'
else:
- if not request.config.webengine:
- line = quteproc.wait_for(message='Error while loading *: SSL '
- 'handshake failed')
- line.expected = True
- quteproc.wait_for(message="Changing title for idx * to 'Error "
- "loading page: *'")
+ line = quteproc.wait_for(message='Error while loading *: SSL handshake failed')
+ line.expected = True
+ quteproc.wait_for(message="Changing title for idx * to 'Error loading page: *'")
content = quteproc.get_content().strip()
assert "Unable to load page" in content
diff --git a/tests/end2end/features/test_qutescheme_bdd.py b/tests/end2end/features/test_qutescheme_bdd.py
index 587aadc41..1be913ac9 100644
--- a/tests/end2end/features/test_qutescheme_bdd.py
+++ b/tests/end2end/features/test_qutescheme_bdd.py
@@ -47,7 +47,7 @@ def request_blocked(request, quteproc, kind):
webkit_error_unsupported = (
"Error while loading qute://settings/set?*: Unsupported request type")
- if request.config.webengine and qtutils.version_check('5.12'):
+ if request.config.webengine:
# On Qt 5.12, we mark qute:// as a local scheme, causing most requests
# being blocked by Chromium internally (logging to the JS console).
expected_messages = {
@@ -60,13 +60,6 @@ def request_blocked(request, quteproc, kind):
# On Qt 5.15, Chromium blocks the redirect as ERR_UNSAFE_REDIRECT
# instead.
expected_messages['redirect'] = [unsafe_redirect_msg]
- elif request.config.webengine:
- expected_messages = {
- 'img': [blocking_csrf_msg],
- 'link': [blocking_set_msg, blocked_request_msg],
- 'redirect': [blocking_set_msg, blocked_request_msg],
- 'form': [blocking_set_msg, blocked_request_msg],
- }
else: # QtWebKit
expected_messages = {
'img': [blocking_csrf_msg],
diff --git a/tests/end2end/features/test_search_bdd.py b/tests/end2end/features/test_search_bdd.py
index ba3254830..3a9fb036c 100644
--- a/tests/end2end/features/test_search_bdd.py
+++ b/tests/end2end/features/test_search_bdd.py
@@ -19,11 +19,14 @@
import json
+import pytest
import pytest_bdd as bdd
-# pylint: disable=unused-import
-from end2end.features.test_yankpaste_bdd import init_fake_clipboard
-# pylint: enable=unused-import
+
+@pytest.fixture(autouse=True)
+def init_fake_clipboard(quteproc):
+ """Make sure the fake clipboard will be used."""
+ quteproc.send_cmd(':debug-set-fake-clipboard')
@bdd.then(bdd.parsers.parse('"{text}" should be found'))
@@ -34,6 +37,7 @@ def check_found_text(request, quteproc, text):
# https://codereview.qt-project.org/#/c/192920/
# https://codereview.qt-project.org/#/c/192921/
# https://bugreports.qt.io/browse/QTBUG-53134
+ # FIXME: Doesn't actually work, investigate why.
return
quteproc.send_cmd(':yank selection')
quteproc.wait_for(message='Setting fake clipboard: {}'.format(
diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py
index f5cc2bb19..7ad739997 100644
--- a/tests/end2end/fixtures/quteprocess.py
+++ b/tests/end2end/fixtures/quteprocess.py
@@ -36,7 +36,7 @@ import pytest
from PyQt5.QtCore import pyqtSignal, QUrl
from qutebrowser.misc import ipc
-from qutebrowser.utils import log, utils, javascript, qtutils
+from qutebrowser.utils import log, utils, javascript
from helpers import utils as testutils
from end2end.fixtures import testprocess
@@ -421,8 +421,6 @@ class QuteProc(testprocess.Process):
_webengine: Whether to use QtWebEngine
basedir: The base directory for this instance.
request: The request object for the current test.
- _focus_ready: Whether the main window got focused.
- _load_ready: Whether the about:blank page got loaded.
_instance_id: A unique ID for this QuteProc instance
_run_counter: A counter to get a unique ID for each run.
@@ -439,75 +437,23 @@ class QuteProc(testprocess.Process):
super().__init__(request, parent)
self._ipc_socket = None
self.basedir = None
- self._focus_ready = False
- self._load_ready = False
self._instance_id = next(instance_counter)
self._run_counter = itertools.count()
- def _is_ready(self, what):
- """Called by _parse_line if loading/focusing is done.
-
- When both are done, emits the 'ready' signal.
- """
- if what == 'load':
- self._load_ready = True
- elif what == 'focus':
- self._focus_ready = True
- else:
- raise ValueError("Invalid value {!r} for 'what'.".format(what))
-
- is_qt_5_12 = qtutils.version_check('5.12', compiled=False)
- if ((self._load_ready and self._focus_ready) or
- (self._load_ready and is_qt_5_12)):
- self._load_ready = False
- self._focus_ready = False
- self.ready.emit()
-
def _process_line(self, log_line):
"""Check if the line matches any initial lines we're interested in."""
- start_okay_message_load = (
+ start_okay_message = (
"load status for <qutebrowser.browser.* tab_id=0 "
"url='about:blank'>: LoadStatus.success")
- start_okay_messages_focus = [
- ## QtWebKit
- "Focus object changed: "
- "<qutebrowser.browser.* tab_id=0 url='about:blank'>",
- # when calling QApplication::sync
- "Focus object changed: "
- "<qutebrowser.browser.webkit.webview.WebView tab_id=0 url=''>",
-
- ## QtWebEngine
- "Focus object changed: "
- "<PyQt5.QtWidgets.QOpenGLWidget object at *>",
- # with Qt >= 5.8
- "Focus object changed: "
- "<PyQt5.QtGui.QWindow object at *>",
- # when calling QApplication::sync
- "Focus object changed: "
- "<PyQt5.QtWidgets.QWidget object at *>",
- # Qt >= 5.11
- "Focus object changed: "
- "<qutebrowser.browser.webengine.webview.WebEngineView object "
- "at *>",
- # Qt >= 5.11 with workarounds
- "Focus object changed: "
- "<PyQt5.QtQuickWidgets.QQuickWidget object at *>",
- ]
if (log_line.category == 'ipc' and
log_line.message.startswith("Listening as ")):
self._ipc_socket = log_line.message.split(' ', maxsplit=2)[2]
elif (log_line.category == 'webview' and
- testutils.pattern_match(pattern=start_okay_message_load,
+ testutils.pattern_match(pattern=start_okay_message,
value=log_line.message)):
- if not self._load_ready:
- log_line.waited_for = True
- self._is_ready('load')
- elif (log_line.category == 'misc' and any(
- testutils.pattern_match(pattern=pattern,
- value=log_line.message)
- for pattern in start_okay_messages_focus)):
- self._is_ready('focus')
+ log_line.waited_for = True
+ self.ready.emit()
elif (log_line.category == 'init' and
log_line.module == 'standarddir' and
log_line.function == 'init' and
@@ -738,11 +684,7 @@ class QuteProc(testprocess.Process):
target_arg)
self._wait_for_ipc()
- def start(self, *args, wait_focus=True,
- **kwargs): # pylint: disable=arguments-differ
- if not wait_focus:
- self._focus_ready = True
-
+ def start(self, *args, **kwargs): # pylint: disable=arguments-differ
try:
super().start(*args, **kwargs)
except testprocess.ProcessExited:
@@ -877,24 +819,16 @@ class QuteProc(testprocess.Process):
raise ValueError("Invalid URL {}: {}".format(url,
qurl.errorString()))
- if (qurl == QUrl('about:blank') and
- not qtutils.version_check('5.10', compiled=False)):
- # For some reason, we don't get a LoadStatus.success for
- # about:blank sometimes.
- # However, if we do this for Qt 5.10, we get general testsuite
- # instability as site loads get reported with about:blank...
- pattern = "Changing title for idx * to 'about:blank'"
- else:
- # We really need the same representation that the webview uses in
- # its __repr__
- url = utils.elide(qurl.toDisplayString(QUrl.EncodeUnicode), 100)
- assert url
-
- pattern = re.compile(
- r"(load status for <qutebrowser\.browser\..* "
- r"tab_id=\d+ url='{url}/?'>: LoadStatus\.{load_status}|fetch: "
- r"PyQt5\.QtCore\.QUrl\('{url}'\) -> .*)".format(
- load_status=re.escape(load_status), url=re.escape(url)))
+ # We really need the same representation that the webview uses in
+ # its __repr__
+ url = utils.elide(qurl.toDisplayString(QUrl.EncodeUnicode), 100)
+ assert url
+
+ pattern = re.compile(
+ r"(load status for <qutebrowser\.browser\..* "
+ r"tab_id=\d+ url='{url}/?'>: LoadStatus\.{load_status}|fetch: "
+ r"PyQt5\.QtCore\.QUrl\('{url}'\) -> .*)".format(
+ load_status=re.escape(load_status), url=re.escape(url)))
try:
self.wait_for(message=pattern, timeout=timeout, after=after)
diff --git a/tests/end2end/fixtures/testprocess.py b/tests/end2end/fixtures/testprocess.py
index 814d16806..51352c539 100644
--- a/tests/end2end/fixtures/testprocess.py
+++ b/tests/end2end/fixtures/testprocess.py
@@ -22,6 +22,7 @@
import re
import os
import time
+import warnings
import attr
import pytest
@@ -100,7 +101,7 @@ def pytest_runtest_makereport(item, call):
return
quteproc_log = getattr(item, '_quteproc_log', None)
- server_log = getattr(item, '_server_log', None)
+ server_logs = getattr(item, '_server_logs', [])
if not hasattr(report.longrepr, 'addsection'):
# In some conditions (on macOS and Windows it seems), report.longrepr
@@ -113,11 +114,11 @@ def pytest_runtest_makereport(item, call):
verbose = item.config.getoption('--verbose')
if quteproc_log is not None:
- report.longrepr.addsection("qutebrowser output",
- _render_log(quteproc_log, verbose=verbose))
- if server_log is not None:
- report.longrepr.addsection("server output",
- _render_log(server_log, verbose=verbose))
+ report.longrepr.addsection(
+ "qutebrowser output", _render_log(quteproc_log, verbose=verbose))
+ for name, content in server_logs:
+ report.longrepr.addsection(
+ f"{name} output", _render_log(content, verbose=verbose))
class Process(QObject):
@@ -316,8 +317,11 @@ class Process(QObject):
else:
self.proc.terminate()
- ok = self.proc.waitForFinished()
+ ok = self.proc.waitForFinished(5000)
if not ok:
+ cmdline = ' '.join([self.proc.program()] + self.proc.arguments())
+ warnings.warn(f"Test process {cmdline} with PID {self.proc.processId()} "
+ "failed to terminate!")
self.proc.kill()
self.proc.waitForFinished()
diff --git a/tests/end2end/fixtures/webserver.py b/tests/end2end/fixtures/webserver.py
index 839355664..d40739724 100644
--- a/tests/end2end/fixtures/webserver.py
+++ b/tests/end2end/fixtures/webserver.py
@@ -23,6 +23,7 @@ import re
import sys
import json
import os.path
+import socket
from http import HTTPStatus
import attr
@@ -31,8 +32,6 @@ from PyQt5.QtCore import pyqtSignal, QUrl
from end2end.fixtures import testprocess
-from qutebrowser.utils import utils
-
class Request(testprocess.Line):
@@ -140,9 +139,17 @@ class WebserverProcess(testprocess.Process):
def __init__(self, request, script, parent=None):
super().__init__(request, parent)
self._script = script
- self.port = utils.random_port()
+ self.port = self._random_port()
self.new_data.connect(self.new_request)
+ def _random_port(self) -> int:
+ """Get a random free port."""
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.bind(('localhost', 0))
+ port = sock.getsockname()[1]
+ sock.close()
+ return port
+
def get_requests(self):
"""Get the requests to the server during this test."""
requests = self._get_data()
@@ -185,21 +192,41 @@ def server(qapp, request):
@pytest.fixture(autouse=True)
def server_per_test(server, request):
"""Fixture to clean server request list after each test."""
- request.node._server_log = server.captured_log
+ if not hasattr(request.node, '_server_logs'):
+ request.node._server_logs = []
+ request.node._server_logs.append(('server', server.captured_log))
+
server.before_test()
yield
server.after_test()
@pytest.fixture
+def server2(qapp, request):
+ """Fixture for a second server object for cross-origin tests."""
+ server = WebserverProcess(request, 'webserver_sub')
+
+ if not hasattr(request.node, '_server_logs'):
+ request.node._server_logs = []
+ request.node._server_logs.append(('secondary server', server.captured_log))
+
+ server.start()
+ yield server
+ server.terminate()
+
+
+@pytest.fixture
def ssl_server(request, qapp):
"""Fixture for a webserver with a self-signed SSL certificate.
- This needs to be explicitly used in a test, and overwrites the server log
- used in that test.
+ This needs to be explicitly used in a test.
"""
server = WebserverProcess(request, 'webserver_sub_ssl')
- request.node._server_log = server.captured_log
+
+ if not hasattr(request.node, '_server_logs'):
+ request.node._server_logs = []
+ request.node._server_logs.append(('SSL server', server.captured_log))
+
server.start()
yield server
server.after_test()
diff --git a/tests/end2end/fixtures/webserver_sub.py b/tests/end2end/fixtures/webserver_sub.py
index 9902ab125..e38d64bb8 100644
--- a/tests/end2end/fixtures/webserver_sub.py
+++ b/tests/end2end/fixtures/webserver_sub.py
@@ -29,9 +29,8 @@ parameters or headers with the same name properly.
import sys
import json
import time
-import signal
-import os
import threading
+import pathlib
from http import HTTPStatus
import cheroot.wsgi
@@ -41,6 +40,9 @@ app = flask.Flask(__name__)
_redirect_later_event = None
+END2END_DIR = pathlib.Path(__file__).resolve().parents[1]
+
+
@app.route('/')
def root():
"""Show simple text."""
@@ -55,15 +57,8 @@ def send_data(path):
If a directory is requested, its index.html is sent.
"""
- if hasattr(sys, 'frozen'):
- basedir = os.path.realpath(os.path.dirname(sys.executable))
- data_dir = os.path.join(basedir, 'end2end', 'data')
- else:
- basedir = os.path.join(os.path.realpath(os.path.dirname(__file__)),
- '..')
- data_dir = os.path.join(basedir, 'data')
- print(basedir)
- if os.path.isdir(os.path.join(data_dir, path)):
+ data_dir = END2END_DIR / 'data'
+ if (data_dir / path).is_dir():
path += '/index.html'
return flask.send_from_directory(data_dir, path)
@@ -249,6 +244,12 @@ def view_headers():
return flask.jsonify(headers=dict(flask.request.headers))
+@app.route('/headers-link/<int:port>')
+def headers_link(port):
+ """Get a (possibly cross-origin) link to /headers."""
+ return flask.render_template('headers-link.html', port=port)
+
+
@app.route('/response-headers')
def response_headers():
"""Return a set of response headers from the query string."""
@@ -274,11 +275,9 @@ def view_user_agent():
@app.route('/favicon.ico')
def favicon():
- basedir = os.path.join(os.path.realpath(os.path.dirname(__file__)),
- '..', '..', '..')
- return flask.send_from_directory(os.path.join(basedir, 'icons'),
- 'qutebrowser.ico',
- mimetype='image/vnd.microsoft.icon')
+ icon_dir = END2END_DIR.parents[1] / 'icons'
+ return flask.send_from_directory(
+ icon_dir, 'qutebrowser.ico', mimetype='image/vnd.microsoft.icon')
@app.after_request
@@ -322,18 +321,12 @@ class WSGIServer(cheroot.wsgi.Server):
def main():
- if hasattr(sys, 'frozen'):
- basedir = os.path.realpath(os.path.dirname(sys.executable))
- app.template_folder = os.path.join(basedir, 'end2end', 'templates')
+ app.template_folder = END2END_DIR / 'templates'
+ assert app.template_folder.is_dir(), app.template_folder
+
port = int(sys.argv[1])
server = WSGIServer(('127.0.0.1', port), app)
-
- signal.signal(signal.SIGTERM, lambda *args: server.stop())
-
- try:
- server.start()
- except KeyboardInterrupt:
- server.stop()
+ server.start()
if __name__ == '__main__':
diff --git a/tests/end2end/templates/headers-link.html b/tests/end2end/templates/headers-link.html
new file mode 100644
index 000000000..fece530b1
--- /dev/null
+++ b/tests/end2end/templates/headers-link.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Link to header page</title>
+ </head>
+ <body>
+ <a href="http://localhost:{{ port }}/headers" id="link">headers</a>
+ </body>
+</html>
diff --git a/tests/end2end/test_invocations.py b/tests/end2end/test_invocations.py
index 3e8731fad..e34bd912d 100644
--- a/tests/end2end/test_invocations.py
+++ b/tests/end2end/test_invocations.py
@@ -20,16 +20,15 @@
"""Test starting qutebrowser with special arguments/environments."""
import subprocess
-import socket
import sys
import logging
import re
+import json
import pytest
from PyQt5.QtCore import QProcess
from helpers import utils
-from qutebrowser.utils import qtutils
ascii_locale = pytest.mark.skipif(sys.hexversion >= 0x03070000,
@@ -71,7 +70,6 @@ def temp_basedir_env(tmpdir, short_tmpdir):
'[general]',
'quickstart-done = 1',
'backend-warning-shown = 1',
- 'old-qt-warning-shown = 1',
'webkit-warning-shown = 1',
]
@@ -162,7 +160,7 @@ def test_open_command_line_with_ascii_locale(request, server, tmpdir,
# all be called. No exception thrown means test success.
args = (['--temp-basedir'] + _base_args(request.config) +
['/home/user/föö.html'])
- quteproc_new.start(args, env={'LC_ALL': 'C'}, wait_focus=False)
+ quteproc_new.start(args, env={'LC_ALL': 'C'})
if not request.config.webengine:
line = quteproc_new.wait_for(message="Error while loading *: Error "
@@ -252,10 +250,7 @@ def test_version(request):
print(stderr)
assert ok
-
- if qtutils.version_check('5.9'):
- # Segfaults on exit with Qt 5.7
- assert proc.exitStatus() == QProcess.NormalExit
+ assert proc.exitStatus() == QProcess.NormalExit
match = re.search(r'^qutebrowser\s+v\d+(\.\d+)', stdout, re.MULTILINE)
assert match is not None
@@ -275,23 +270,6 @@ def test_qt_arg(request, quteproc_new, tmpdir):
quteproc_new.wait_for_quit()
-@utils.skip_qt511
-def test_webengine_inspector(request, quteproc_new):
- if not request.config.webengine:
- pytest.skip()
- args = (['--temp-basedir', '--enable-webengine-inspector'] +
- _base_args(request.config))
- quteproc_new.start(args)
- line = quteproc_new.wait_for(
- message='Remote debugging server started successfully. Try pointing a '
- 'Chromium-based browser to http://127.0.0.1:*')
- port = int(line.message.split(':')[-1])
-
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.connect(('127.0.0.1', port))
- s.close()
-
-
@pytest.mark.linux
def test_webengine_download_suffix(request, quteproc_new, tmpdir):
"""Make sure QtWebEngine does not add a suffix to downloads."""
@@ -406,3 +384,36 @@ def test_qute_settings_persistence(short_tmpdir, request, quteproc_new):
quteproc_new.send_cmd(':quit')
quteproc_new.wait_for_quit()
+
+
+@pytest.mark.parametrize('value, expected', [
+ ('always', 'http://localhost:(port2)/headers-link/(port)'),
+ ('never', None),
+ ('same-domain', 'http://localhost:(port2)/'), # None with QtWebKit
+])
+def test_referrer(quteproc_new, server, server2, request, value, expected):
+ """Check referrer settings."""
+ args = _base_args(request.config) + [
+ '--temp-basedir',
+ '-s', 'content.headers.referer', value,
+ ]
+ quteproc_new.start(args)
+
+ quteproc_new.open_path(f'headers-link/{server.port}', port=server2.port)
+ quteproc_new.send_cmd(':click-element id link')
+ quteproc_new.wait_for_load_finished('headers')
+
+ content = quteproc_new.get_content()
+ data = json.loads(content)
+ print(data)
+ headers = data['headers']
+
+ if not request.config.webengine and value == 'same-domain':
+ # With QtWebKit and same-domain, we don't send a referer at all.
+ expected = None
+
+ if expected is not None:
+ for key, val in [('(port)', server.port), ('(port2)', server2.port)]:
+ expected = expected.replace(key, str(val))
+
+ assert headers.get('Referer') == expected
diff --git a/tests/end2end/test_mkvenv.py b/tests/end2end/test_mkvenv.py
new file mode 100644
index 000000000..430be0279
--- /dev/null
+++ b/tests/end2end/test_mkvenv.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
+
+# Copyright 2020 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
+
+# This file is part of qutebrowser.
+#
+# qutebrowser is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# qutebrowser is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
+
+
+from scripts import mkvenv
+
+
+def test_smoke(tmp_path):
+ """Simple smoke test of mkvenv.py."""
+ args = mkvenv.parse_args(['--venv-dir', str(tmp_path / 'venv'), '--skip-docs'])
+ mkvenv.run(args)
diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py
index 2183ac1d1..3c0623dfb 100644
--- a/tests/helpers/fixtures.py
+++ b/tests/helpers/fixtures.py
@@ -45,7 +45,7 @@ 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, qtutils
+from qutebrowser.utils import objreg, standarddir, utils, usertypes
from qutebrowser.browser import greasemonkey, history, qutescheme
from qutebrowser.browser.webkit import cookies, cache
from qutebrowser.misc import savemanager, sql, objects, sessions
@@ -258,11 +258,7 @@ def webengine_tab(web_tab_setup, qtbot, redirect_webengine_data,
# 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)
+ sip.delete(tab._widget)
@pytest.fixture(params=['webkit', 'webengine'])
diff --git a/tests/helpers/stubs.py b/tests/helpers/stubs.py
index f9223c3ca..725df8fe8 100644
--- a/tests/helpers/stubs.py
+++ b/tests/helpers/stubs.py
@@ -670,8 +670,8 @@ class FakeWebEngineProfile:
class FakeCookieStore:
- def __init__(self, has_cookie_filter):
+ def __init__(self):
self.cookie_filter = None
- if has_cookie_filter:
- self.setCookieFilter = (
- lambda func: setattr(self, 'cookie_filter', func)) # noqa
+
+ def setCookieFilter(self, func):
+ self.cookie_filter = func
diff --git a/tests/helpers/utils.py b/tests/helpers/utils.py
index a437e047c..5f7297719 100644
--- a/tests/helpers/utils.py
+++ b/tests/helpers/utils.py
@@ -41,16 +41,8 @@ from qutebrowser.utils import qtutils, log
ON_CI = 'CI' in os.environ
-qt58 = pytest.mark.skipif(
- qtutils.version_check('5.9'), reason="Needs Qt 5.8 or earlier")
-qt59 = pytest.mark.skipif(
- not qtutils.version_check('5.9'), reason="Needs Qt 5.9 or newer")
-qt510 = pytest.mark.skipif(
- not qtutils.version_check('5.10'), reason="Needs Qt 5.10 or newer")
qt514 = pytest.mark.skipif(
not qtutils.version_check('5.14'), reason="Needs Qt 5.14 or newer")
-skip_qt511 = pytest.mark.skipif(
- qtutils.version_check('5.11'), reason="Needs Qt 5.10 or earlier")
class PartialCompareOutcome:
@@ -273,15 +265,6 @@ def seccomp_args(qt_flag):
"""
affected_versions = set()
for base, patch_range in [
- ## seccomp-bpf failure in syscall 0281
- ## https://github.com/qutebrowser/qutebrowser/issues/3163
- # 5.7.1
- ('5.7', [1]),
-
- ## seccomp-bpf failure in syscall 0281 (clock_nanosleep)
- ## https://bugreports.qt.io/browse/QTBUG-81313
- # 5.11.0 to 5.11.3 (inclusive)
- ('5.11', range(0, 4)),
# 5.12.0 to 5.12.7 (inclusive)
('5.12', range(0, 8)),
# 5.13.0 to 5.13.2 (inclusive)
diff --git a/tests/unit/api/test_cmdutils.py b/tests/unit/api/test_cmdutils.py
index 3ee486303..811ba2659 100644
--- a/tests/unit/api/test_cmdutils.py
+++ b/tests/unit/api/test_cmdutils.py
@@ -24,8 +24,8 @@
import sys
import logging
import types
-import typing
import enum
+from typing import Union
import pytest
@@ -301,17 +301,17 @@ class TestRegister:
(int, 'x', None, cmdexc.ArgumentTypeError),
(str, 'foo', None, 'foo'),
- (typing.Union[str, int], 'foo', None, 'foo'),
- (typing.Union[str, int], '42', None, 42),
+ (Union[str, int], 'foo', None, 'foo'),
+ (Union[str, int], '42', None, 42),
# Choices
(str, 'foo', ['foo'], 'foo'),
(str, 'bar', ['foo'], cmdexc.ArgumentTypeError),
# Choices with Union: only checked when it's a str
- (typing.Union[str, int], 'foo', ['foo'], 'foo'),
- (typing.Union[str, int], 'bar', ['foo'], cmdexc.ArgumentTypeError),
- (typing.Union[str, int], '42', ['foo'], 42),
+ (Union[str, int], 'foo', ['foo'], 'foo'),
+ (Union[str, int], 'bar', ['foo'], cmdexc.ArgumentTypeError),
+ (Union[str, int], '42', ['foo'], 42),
(Enum, 'x', None, Enum.x),
(Enum, 'z', None, cmdexc.ArgumentTypeError),
diff --git a/tests/unit/browser/test_caret.py b/tests/unit/browser/test_caret.py
index 75d9fee09..bfa718315 100644
--- a/tests/unit/browser/test_caret.py
+++ b/tests/unit/browser/test_caret.py
@@ -324,9 +324,6 @@ def test_drop_selection(caret, selection):
class TestSearch:
- # https://bugreports.qt.io/browse/QTBUG-60673
-
- @pytest.mark.qtbug60673
@pytest.mark.no_xvfb
def test_yanking_a_searched_line(self, caret, selection, mode_manager, web_tab, qtbot):
mode_manager.leave(usertypes.KeyMode.caret)
@@ -339,7 +336,6 @@ class TestSearch:
caret.move_to_end_of_line()
selection.check('five six')
- @pytest.mark.qtbug60673
@pytest.mark.no_xvfb
def test_yanking_a_searched_line_with_multiple_matches(self, caret, selection, mode_manager, web_tab, qtbot):
mode_manager.leave(usertypes.KeyMode.caret)
diff --git a/tests/unit/browser/test_hints.py b/tests/unit/browser/test_hints.py
index 382c322fb..3b09ed0fd 100644
--- a/tests/unit/browser/test_hints.py
+++ b/tests/unit/browser/test_hints.py
@@ -30,10 +30,8 @@ import qutebrowser.browser.hints
@pytest.fixture(autouse=True)
-def setup(benchmark, win_registry, mode_manager):
- yield
- # WORKAROUND for https://github.com/ionelmc/pytest-benchmark/issues/125
- benchmark._mode = 'WORKAROUND' # pylint: disable=protected-access
+def setup(win_registry, mode_manager):
+ pass
@pytest.fixture
diff --git a/tests/unit/browser/test_history.py b/tests/unit/browser/test_history.py
index c70b858f5..c1990de0d 100644
--- a/tests/unit/browser/test_history.py
+++ b/tests/unit/browser/test_history.py
@@ -464,7 +464,8 @@ class TestCompletionMetaInfo:
def test_contains_keyerror(self, metainfo):
with pytest.raises(KeyError):
- 'does_not_exist' in metainfo # pylint: disable=pointless-statement
+ # pylint: disable=pointless-statement
+ 'does_not_exist' in metainfo # noqa: B015
def test_getitem_keyerror(self, metainfo):
with pytest.raises(KeyError):
diff --git a/tests/unit/browser/test_navigate.py b/tests/unit/browser/test_navigate.py
index 5fe0acbf6..5a93a517c 100644
--- a/tests/unit/browser/test_navigate.py
+++ b/tests/unit/browser/test_navigate.py
@@ -187,6 +187,8 @@ class TestUp:
('/one/two/three', 1, '/one/two'),
('/one/two/three?foo=bar', 1, '/one/two'),
('/one/two/three', 2, '/one'),
+ ('/one/two%2Fthree', 1, '/one'),
+ ('/one/two%2Fthree/four', 1, '/one/two%2Fthree'),
])
def test_up(self, url_suffix, count, expected_suffix):
url_base = 'https://example.com'
diff --git a/tests/unit/browser/test_pdfjs.py b/tests/unit/browser/test_pdfjs.py
index d05ff1fc0..465244819 100644
--- a/tests/unit/browser/test_pdfjs.py
+++ b/tests/unit/browser/test_pdfjs.py
@@ -24,7 +24,7 @@ import pytest
from PyQt5.QtCore import QUrl
from qutebrowser.browser import pdfjs
-from qutebrowser.utils import usertypes, utils, urlmatch
+from qutebrowser.utils import urlmatch
pytestmark = [pytest.mark.usefixtures('data_tmpdir')]
@@ -52,15 +52,6 @@ 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.
@@ -78,36 +69,6 @@ def test_generate_pdfjs_script(filename, expected):
assert 'PDFView' in actual
-@pytest.mark.parametrize('qt, backend, expected', [
- ('new', usertypes.Backend.QtWebEngine, False),
- ('new', usertypes.Backend.QtWebKit, False),
- ('old', usertypes.Backend.QtWebEngine, True),
- ('old', usertypes.Backend.QtWebKit, False),
- ('5.7', usertypes.Backend.QtWebEngine, False),
- ('5.7', usertypes.Backend.QtWebKit, False),
-])
-def test_generate_pdfjs_script_disable_object_url(monkeypatch,
- qt, backend, expected):
- if qt == 'new':
- monkeypatch.setattr(pdfjs.qtutils, 'version_check',
- lambda version, exact=False, compiled=True:
- version != '5.7.1')
- elif qt == 'old':
- monkeypatch.setattr(pdfjs.qtutils, 'version_check',
- lambda version, exact=False, compiled=True: False)
- elif qt == '5.7':
- monkeypatch.setattr(pdfjs.qtutils, 'version_check',
- lambda version, exact=False, compiled=True:
- version == '5.7.1')
- else:
- raise utils.Unreachable
-
- monkeypatch.setattr(pdfjs.objects, 'backend', backend)
-
- script = pdfjs._generate_pdfjs_script('testfile')
- assert ('PDFJS.disableCreateObjectURL' in script) == expected
-
-
class TestResources:
@pytest.fixture
@@ -166,6 +127,19 @@ class TestResources:
expected = 'OSError while reading PDF.js file: Message'
assert caplog.messages == [expected]
+ def test_broken_installation(self, data_tmpdir, tmpdir, monkeypatch,
+ read_file_mock):
+ """Make sure we don't crash with a broken local installation."""
+ monkeypatch.setattr(pdfjs, '_SYSTEM_PATHS', [])
+ monkeypatch.setattr(pdfjs.os.path, 'expanduser',
+ lambda _in: tmpdir / 'fallback')
+ read_file_mock.side_effect = FileNotFoundError
+
+ (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
+
@pytest.mark.parametrize('path, expected', [
('web/viewer.js', 'viewer.js'),
diff --git a/tests/unit/browser/test_qutescheme.py b/tests/unit/browser/test_qutescheme.py
index d4a87c4f9..0d813df02 100644
--- a/tests/unit/browser/test_qutescheme.py
+++ b/tests/unit/browser/test_qutescheme.py
@@ -28,6 +28,7 @@ from PyQt5.QtCore import QUrl, QUrlQuery
import pytest
from qutebrowser.browser import qutescheme, pdfjs, downloads
+from qutebrowser.utils import utils
class TestJavascriptHandler:
@@ -51,7 +52,7 @@ class TestJavascriptHandler:
return content
raise OSError("File not found {}!".format(path))
- monkeypatch.setattr('qutebrowser.utils.utils.read_file', _read_file)
+ monkeypatch.setattr(utils, 'read_file', _read_file)
@pytest.mark.parametrize("filename, content", js_files)
def test_qutejavascript(self, filename, content):
diff --git a/tests/unit/browser/webengine/test_darkmode.py b/tests/unit/browser/webengine/test_darkmode.py
index b2ca6a20a..3e62000d2 100644
--- a/tests/unit/browser/webengine/test_darkmode.py
+++ b/tests/unit/browser/webengine/test_darkmode.py
@@ -27,9 +27,6 @@ from qutebrowser.misc import objects
from helpers import utils
-pytestmark = utils.qt510
-
-
@pytest.fixture(autouse=True)
def patch_backend(monkeypatch):
monkeypatch.setattr(objects, 'backend', usertypes.Backend.QtWebEngine)
@@ -156,9 +153,6 @@ def test_customization(config_stub, monkeypatch, setting, value, exp_key, exp_va
@pytest.mark.parametrize('qversion, webengine_version, expected', [
# Without PYQT_WEBENGINE_VERSION
- ('5.9.9', None, darkmode.Variant.unavailable),
- ('5.10.1', None, darkmode.Variant.qt_510),
- ('5.11.3', None, darkmode.Variant.qt_511_to_513),
('5.12.9', None, darkmode.Variant.qt_511_to_513),
# With PYQT_WEBENGINE_VERSION
@@ -175,6 +169,22 @@ def test_variant(monkeypatch, qversion, webengine_version, expected):
assert darkmode._variant() == expected
+@pytest.mark.parametrize('value, is_valid, expected', [
+ ('invalid_value', False, darkmode.Variant.qt_515_0),
+ ('qt_515_2', True, darkmode.Variant.qt_515_2),
+])
+def test_variant_override(monkeypatch, caplog, value, is_valid, expected):
+ monkeypatch.setattr(darkmode.qtutils, 'qVersion', lambda: None)
+ monkeypatch.setattr(darkmode, 'PYQT_WEBENGINE_VERSION', 0x050f00)
+ monkeypatch.setenv('QUTE_DARKMODE_VARIANT', value)
+
+ with caplog.at_level(logging.WARNING):
+ assert darkmode._variant() == expected
+
+ log_msg = 'Ignoring invalid QUTE_DARKMODE_VARIANT=invalid_value'
+ assert (log_msg in caplog.messages) != is_valid
+
+
def test_broken_smart_images_policy(config_stub, monkeypatch, caplog):
config_stub.val.colors.webpage.darkmode.enabled = True
config_stub.val.colors.webpage.darkmode.policy.images = 'smart'
@@ -194,7 +204,6 @@ def test_broken_smart_images_policy(config_stub, monkeypatch, caplog):
assert settings in expected
-@utils.qt510
def test_new_chromium():
"""Fail if we encounter an unknown Chromium version.
@@ -224,5 +233,11 @@ def test_options(configdata_init):
assert not opt.supports_pattern, name
assert opt.restart, name
- assert not opt.raw_backends['QtWebKit'], name
- assert opt.raw_backends['QtWebEngine'] in ['Qt 5.10', 'Qt 5.14'], name
+
+ if opt.backends:
+ # On older Qt versions, this is an empty list.
+ assert opt.backends == [usertypes.Backend.QtWebEngine], name
+
+ if opt.raw_backends is not None:
+ assert not opt.raw_backends['QtWebKit'], name
+ assert opt.raw_backends['QtWebEngine'] == 'Qt 5.14', name
diff --git a/tests/unit/browser/webengine/test_spell.py b/tests/unit/browser/webengine/test_spell.py
index ab437a37d..f9f092605 100644
--- a/tests/unit/browser/webengine/test_spell.py
+++ b/tests/unit/browser/webengine/test_spell.py
@@ -22,10 +22,9 @@ import logging
import os
import pytest
-from PyQt5.QtCore import QLibraryInfo
from qutebrowser.browser.webengine import spell
-from qutebrowser.utils import usertypes, qtutils, standarddir
+from qutebrowser.utils import usertypes
def test_version(message_mock, caplog):
@@ -39,21 +38,6 @@ def test_version(message_mock, caplog):
assert msg.text == expected
-@pytest.mark.parametrize('qt_version, old, subdir', [
- ('5.9', True, 'global_datapath'),
- ('5.9', False, 'global_datapath'),
- ('5.10', True, 'global_datapath'),
- ('5.10', False, 'user_datapath'),
-])
-def test_dictionary_dir(monkeypatch, qt_version, old, subdir):
- monkeypatch.setattr(qtutils, 'qVersion', lambda: qt_version)
- monkeypatch.setattr(QLibraryInfo, 'location', lambda _: 'global_datapath')
- monkeypatch.setattr(standarddir, 'data', lambda: 'user_datapath')
-
- expected = os.path.join(subdir, 'qtwebengine_dictionaries')
- assert spell.dictionary_dir(old=old) == expected
-
-
def test_local_filename_dictionary_does_not_exist(monkeypatch):
"""Tests retrieving local filename when the dir doesn't exits."""
monkeypatch.setattr(
@@ -104,48 +88,9 @@ class TestInit:
monkeypatch.delenv(self.ENV, raising=False)
@pytest.fixture
- def patch_new_qt(self, monkeypatch):
- monkeypatch.setattr(spell.qtutils, 'version_check',
- lambda _ver, compiled: True)
-
- @pytest.fixture
def dict_dir(self, data_tmpdir):
return data_tmpdir / 'qtwebengine_dictionaries'
- @pytest.fixture
- def old_dict_dir(self, monkeypatch, tmpdir):
- data_dir = tmpdir / 'old'
- dict_dir = data_dir / 'qtwebengine_dictionaries'
- (dict_dir / 'somedict').ensure()
- monkeypatch.setattr(spell.QLibraryInfo, 'location',
- lambda _arg: str(data_dir))
- return dict_dir
-
- def test_old_qt(self, monkeypatch):
- monkeypatch.setattr(spell.qtutils, 'version_check',
- lambda _ver, compiled: False)
- spell.init()
- assert self.ENV not in os.environ
-
- def test_new_qt(self, dict_dir, patch_new_qt):
+ def test_init(self, dict_dir):
spell.init()
assert os.environ[self.ENV] == str(dict_dir)
-
- def test_moving(self, old_dict_dir, dict_dir, patch_new_qt):
- spell.init()
- assert (dict_dir / 'somedict').exists()
-
- def test_moving_oserror(self, mocker, caplog,
- old_dict_dir, dict_dir, patch_new_qt):
- mocker.patch('shutil.copytree', side_effect=OSError)
-
- with caplog.at_level(logging.ERROR):
- spell.init()
-
- assert caplog.messages[0] == 'Failed to copy old dictionaries'
-
- def test_moving_existing_destdir(self, old_dict_dir, dict_dir,
- patch_new_qt):
- dict_dir.ensure(dir=True)
- spell.init()
- assert not (dict_dir / 'somedict').exists()
diff --git a/tests/unit/browser/webengine/test_webengine_cookies.py b/tests/unit/browser/webengine/test_webengine_cookies.py
index 0933fa1c6..1ac9c5d1a 100644
--- a/tests/unit/browser/webengine/test_webengine_cookies.py
+++ b/tests/unit/browser/webengine/test_webengine_cookies.py
@@ -29,12 +29,9 @@ from qutebrowser.utils import urlmatch
@pytest.fixture
def filter_request():
- try:
- request = QWebEngineCookieStore.FilterRequest()
- request.firstPartyUrl = QUrl('https://example.com')
- return request
- except AttributeError:
- pytest.skip("FilterRequest not available")
+ request = QWebEngineCookieStore.FilterRequest()
+ request.firstPartyUrl = QUrl('https://example.com')
+ return request
@pytest.fixture(autouse=True)
@@ -85,15 +82,6 @@ def test_invalid_url(config_stub, filter_request, global_value):
assert cookies._accept_cookie(filter_request) == accepted
-def test_third_party_workaround(monkeypatch, config_stub, filter_request):
- monkeypatch.setattr(cookies.qtutils, 'version_check',
- lambda ver, compiled: False)
- config_stub.val.content.cookies.accept = 'no-3rdparty'
- filter_request.thirdParty = True
- filter_request.firstPartyUrl = QUrl()
- assert cookies._accept_cookie(filter_request)
-
-
@pytest.mark.parametrize('enabled', [True, False])
def test_logging(monkeypatch, config_stub, filter_request, caplog, enabled):
monkeypatch.setattr(cookies.objects, 'debug_flags',
@@ -117,12 +105,10 @@ class TestInstall:
profile = QWebEngineProfile()
cookies.install_filter(profile)
- @pytest.mark.parametrize('has_cookie_filter', [True, False])
- def test_fake_profile(self, stubs, has_cookie_filter):
- store = stubs.FakeCookieStore(has_cookie_filter=has_cookie_filter)
+ def test_fake_profile(self, stubs):
+ store = stubs.FakeCookieStore()
profile = stubs.FakeWebEngineProfile(cookie_store=store)
cookies.install_filter(profile)
- if has_cookie_filter:
- assert store.cookie_filter is cookies._accept_cookie
+ assert store.cookie_filter is cookies._accept_cookie
diff --git a/tests/unit/browser/webengine/test_webenginedownloads.py b/tests/unit/browser/webengine/test_webenginedownloads.py
index 3a830bd58..3749b01f5 100644
--- a/tests/unit/browser/webengine/test_webenginedownloads.py
+++ b/tests/unit/browser/webengine/test_webenginedownloads.py
@@ -24,7 +24,6 @@ import pytest
pytest.importorskip('PyQt5.QtWebEngineWidgets')
from qutebrowser.browser.webengine import webenginedownloads
-from helpers import utils
@pytest.mark.parametrize('path, expected', [
@@ -34,10 +33,8 @@ from helpers import utils
('foo - 1970-01-01T00:00:00.000Z', 'foo'),
('foo(a)', 'foo(a)'),
('foo1', 'foo1'),
- pytest.param('foo%20bar', 'foo bar', marks=utils.qt58),
- pytest.param('foo%2Fbar', 'bar', marks=utils.qt58),
- pytest.param('foo%20bar', 'foo%20bar', marks=utils.qt59),
- pytest.param('foo%2Fbar', 'foo%2Fbar', marks=utils.qt59),
+ ('foo%20bar', 'foo%20bar'),
+ ('foo%2Fbar', 'foo%2Fbar'),
])
def test_get_suggested_filename(path, expected):
assert webenginedownloads._get_suggested_filename(path) == expected
diff --git a/tests/unit/browser/webengine/test_webengineinterceptor.py b/tests/unit/browser/webengine/test_webengineinterceptor.py
index 2c352a6a8..7a4fd918a 100644
--- a/tests/unit/browser/webengine/test_webengineinterceptor.py
+++ b/tests/unit/browser/webengine/test_webengineinterceptor.py
@@ -27,8 +27,6 @@ pytest.importorskip('PyQt5.QtWebEngineWidgets')
from PyQt5.QtWebEngineCore import QWebEngineUrlRequestInfo
from qutebrowser.browser.webengine import interceptor
-from qutebrowser.extensions import interceptors
-from qutebrowser.utils import qtutils
def test_no_missing_resource_types():
@@ -42,8 +40,4 @@ def test_no_missing_resource_types():
def test_resource_type_values():
request_interceptor = interceptor.RequestInterceptor()
for qt_value, qb_item in request_interceptor._resource_types.items():
- if (qtutils.version_check('5.7.1', exact=True, compiled=False) and
- qb_item == interceptors.ResourceType.unknown):
- # Qt 5.7 has ResourceTypeUnknown = 18 instead of 255
- continue
assert qt_value == qb_item.value
diff --git a/tests/unit/browser/webengine/test_webenginesettings.py b/tests/unit/browser/webengine/test_webenginesettings.py
index ec61df7c6..53f3e21b2 100644
--- a/tests/unit/browser/webengine/test_webenginesettings.py
+++ b/tests/unit/browser/webengine/test_webenginesettings.py
@@ -17,7 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
-import types
import logging
import pytest
@@ -25,7 +24,7 @@ import pytest
pytest.importorskip('PyQt5.QtWebEngineWidgets')
from qutebrowser.browser.webengine import webenginesettings
-from qutebrowser.utils import usertypes, qtutils
+from qutebrowser.utils import usertypes
from qutebrowser.misc import objects
@@ -34,8 +33,7 @@ def init(qapp, config_stub, cache_tmpdir, data_tmpdir, monkeypatch):
monkeypatch.setattr(webenginesettings.webenginequtescheme, 'init',
lambda: None)
monkeypatch.setattr(objects, 'backend', usertypes.Backend.QtWebEngine)
- init_args = types.SimpleNamespace(enable_webengine_inspector=False)
- webenginesettings.init(init_args)
+ webenginesettings.init()
config_stub.changed.disconnect(webenginesettings._update_settings)
@@ -47,8 +45,6 @@ def test_big_cache_size(config_stub):
assert profile.httpCacheMaximumSize() == 2 ** 31 - 1
-@pytest.mark.skipif(
- not qtutils.version_check('5.8'), reason="Needs Qt 5.8 or newer")
def test_non_existing_dict(config_stub, monkeypatch, message_mock, caplog):
monkeypatch.setattr(webenginesettings.spell, 'local_filename',
lambda _code: None)
@@ -63,8 +59,6 @@ def test_non_existing_dict(config_stub, monkeypatch, message_mock, caplog):
assert msg.text == expected
-@pytest.mark.skipif(
- not qtutils.version_check('5.8'), reason="Needs Qt 5.8 or newer")
def test_existing_dict(config_stub, monkeypatch):
monkeypatch.setattr(webenginesettings.spell, 'local_filename',
lambda _code: 'en-US-8-0')
@@ -76,8 +70,6 @@ def test_existing_dict(config_stub, monkeypatch):
assert profile.spellCheckLanguages() == ['en-US-8-0']
-@pytest.mark.skipif(
- not qtutils.version_check('5.8'), reason="Needs Qt 5.8 or newer")
def test_spell_check_disabled(config_stub, monkeypatch):
config_stub.val.spellcheck.languages = []
webenginesettings._update_settings('spellcheck.languages')
diff --git a/tests/unit/browser/webengine/test_webenginetab.py b/tests/unit/browser/webengine/test_webenginetab.py
index 4684921c6..02a034331 100644
--- a/tests/unit/browser/webengine/test_webenginetab.py
+++ b/tests/unit/browser/webengine/test_webenginetab.py
@@ -101,9 +101,6 @@ class TestWebengineScripts:
"""Make sure document-end is forced when needed."""
monkeypatch.setattr(greasemonkey.objects, 'backend',
usertypes.Backend.QtWebEngine)
- monkeypatch.setattr(greasemonkey.qtutils, 'version_check',
- lambda version, exact=False, compiled=True:
- True)
scripts = [
greasemonkey.GreasemonkeyScript([
diff --git a/tests/unit/browser/webkit/network/test_networkreply.py b/tests/unit/browser/webkit/network/test_networkreply.py
index 0aa3943e7..e1c9d04f8 100644
--- a/tests/unit/browser/webkit/network/test_networkreply.py
+++ b/tests/unit/browser/webkit/network/test_networkreply.py
@@ -52,9 +52,8 @@ class TestFixedDataNetworkReply:
b'Hello World! This is a test.'])
def test_data(self, qtbot, req, data):
reply = networkreply.FixedDataNetworkReply(req, data, 'test/foo')
- with qtbot.waitSignal(reply.metaDataChanged), \
- qtbot.waitSignal(reply.readyRead), \
- qtbot.waitSignal(reply.finished):
+ with qtbot.waitSignals([reply.metaDataChanged, reply.readyRead,
+ reply.finished], order='strict'):
pass
assert reply.bytesAvailable() == len(data)
@@ -79,7 +78,7 @@ def test_error_network_reply(qtbot, req):
reply = networkreply.ErrorNetworkReply(
req, "This is an error", QNetworkReply.UnknownNetworkError)
- with qtbot.waitSignal(reply.error), qtbot.waitSignal(reply.finished):
+ with qtbot.waitSignals([reply.error, reply.finished], order='strict'):
pass
reply.abort() # shouldn't do anything
diff --git a/tests/unit/browser/webkit/test_cache.py b/tests/unit/browser/webkit/test_cache.py
index f0aaf226e..9cd8eab9b 100644
--- a/tests/unit/browser/webkit/test_cache.py
+++ b/tests/unit/browser/webkit/test_cache.py
@@ -23,13 +23,6 @@ from PyQt5.QtCore import QUrl, QDateTime
from PyQt5.QtNetwork import QNetworkDiskCache, QNetworkCacheMetaData
from qutebrowser.browser.webkit import cache
-from qutebrowser.utils import qtutils
-
-
-pytestmark = pytest.mark.skipif(
- qtutils.version_check('5.7.1', compiled=False) and
- not qtutils.version_check('5.9', compiled=False),
- reason="QNetworkDiskCache is broken on Qt 5.7.1 and 5.8")
@pytest.fixture
diff --git a/tests/unit/browser/webkit/test_mhtml.py b/tests/unit/browser/webkit/test_mhtml.py
index 58e5602b3..a30bfe786 100644
--- a/tests/unit/browser/webkit/test_mhtml.py
+++ b/tests/unit/browser/webkit/test_mhtml.py
@@ -21,21 +21,16 @@
import io
import textwrap
import re
+import uuid
import pytest
mhtml = pytest.importorskip('qutebrowser.browser.webkit.mhtml')
-try:
- import cssutils
-except ImportError:
- cssutils = None
-
-
@pytest.fixture(autouse=True)
def patch_uuid(monkeypatch):
- monkeypatch.setattr("uuid.uuid4", lambda: "UUID")
+ monkeypatch.setattr(uuid, "uuid4", lambda: "UUID")
class Checker:
@@ -254,34 +249,25 @@ def test_empty_content_type(checker):
""")
-@pytest.mark.parametrize('has_cssutils', [
- pytest.param(True, marks=pytest.mark.skipif(
- cssutils is None, reason="requires cssutils"), id='with_cssutils'),
- pytest.param(False, id='no_cssutils'),
-])
-@pytest.mark.parametrize('inline, style, expected_urls', [
- pytest.param(False, "@import 'default.css'", ['default.css'],
+@pytest.mark.parametrize('style, expected_urls', [
+ pytest.param("@import 'default.css'", ['default.css'],
id='import with apostrophe'),
- pytest.param(False, '@import "default.css"', ['default.css'],
+ pytest.param('@import "default.css"', ['default.css'],
id='import with quote'),
- pytest.param(False, "@import \t 'tabbed.css'", ['tabbed.css'],
+ pytest.param("@import \t 'tabbed.css'", ['tabbed.css'],
id='import with tab'),
- pytest.param(False, "@import url('default.css')", ['default.css'],
+ pytest.param("@import url('default.css')", ['default.css'],
id='import with url()'),
- pytest.param(False, """body {
+ pytest.param("""body {
background: url("/bg-img.png")
}""", ['/bg-img.png'], id='background with body'),
- pytest.param(True, 'background: url(folder/file.png) no-repeat',
+ pytest.param('background: url(folder/file.png) no-repeat',
['folder/file.png'], id='background'),
- pytest.param(True, 'content: url()', [], id='content'),
+ pytest.param('content: url()', [], id='content'),
])
-def test_css_url_scanner(monkeypatch, has_cssutils, inline, style,
- expected_urls):
- if not has_cssutils:
- monkeypatch.setattr(mhtml, '_get_css_imports_cssutils',
- lambda data, inline=False: None)
+def test_css_url_scanner(monkeypatch, style, expected_urls):
expected_urls.sort()
- urls = mhtml._get_css_imports(style, inline=inline)
+ urls = mhtml._get_css_imports(style)
urls.sort()
assert urls == expected_urls
diff --git a/tests/unit/browser/webkit/test_tabhistory.py b/tests/unit/browser/webkit/test_tabhistory.py
index 9325cb7d0..48e0c98fc 100644
--- a/tests/unit/browser/webkit/test_tabhistory.py
+++ b/tests/unit/browser/webkit/test_tabhistory.py
@@ -33,7 +33,8 @@ pytestmark = pytest.mark.qt_log_ignore('QIODevice::read.*: device not open')
ITEMS = [
Item(QUrl('https://www.heise.de/'), 'heise'),
- Item(QUrl('http://example.com/%E2%80%A6'), 'percent', active=True),
+ Item(QUrl('about:blank'), 'blank', active=True),
+ Item(QUrl('http://example.com/%E2%80%A6'), 'percent'),
Item(QUrl('http://example.com/?foo=bar'), 'arg',
original_url=QUrl('http://original.url.example.com/'),
user_data={'foo': 23, 'bar': 42}),
diff --git a/tests/unit/completion/test_completiondelegate.py b/tests/unit/completion/test_completiondelegate.py
index 739b8b773..4732837a1 100644
--- a/tests/unit/completion/test_completiondelegate.py
+++ b/tests/unit/completion/test_completiondelegate.py
@@ -18,6 +18,8 @@
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
from unittest import mock
+import hypothesis
+import hypothesis.strategies
import pytest
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QTextDocument, QColor
@@ -69,10 +71,17 @@ def test_benchmark_highlight(benchmark):
benchmark(bench)
+@hypothesis.given(text=hypothesis.strategies.text())
+def test_pattern_hypothesis(text):
+ """Make sure we can't produce invalid patterns."""
+ doc = QTextDocument()
+ completiondelegate._Highlighter(doc, text, Qt.red)
+
+
def test_highlighted(qtbot):
"""Make sure highlighting works.
- Note that with Qt 5.11.3 and > 5.12.1 we need to call setPlainText *after*
+ Note that with Qt > 5.12.1 we need to call setPlainText *after*
creating the highlighter for highlighting to work. Ideally, we'd test
whether CompletionItemDelegate._get_textdoc() works properly, but testing
that is kind of hard, so we just test it in isolation here.
diff --git a/tests/unit/completion/test_completionmodel.py b/tests/unit/completion/test_completionmodel.py
index 1fc0b4d73..98e70dc01 100644
--- a/tests/unit/completion/test_completionmodel.py
+++ b/tests/unit/completion/test_completionmodel.py
@@ -77,8 +77,8 @@ def test_set_pattern(pat, qtbot):
for c in cats:
c.set_pattern = mock.Mock(spec=[])
model.add_category(c)
- with qtbot.waitSignal(model.layoutAboutToBeChanged), \
- qtbot.waitSignal(model.layoutChanged):
+ with qtbot.waitSignals([model.layoutAboutToBeChanged, model.layoutChanged],
+ order='strict'):
model.set_pattern(pat)
for c in cats:
c.set_pattern.assert_called_with(pat)
diff --git a/tests/unit/completion/test_completionwidget.py b/tests/unit/completion/test_completionwidget.py
index 356b854c5..c0ef4b47f 100644
--- a/tests/unit/completion/test_completionwidget.py
+++ b/tests/unit/completion/test_completionwidget.py
@@ -161,6 +161,7 @@ def test_completion_item_focus_no_model(which, completionview, model, qtbot):
completionview.completion_item_focus(which)
+@pytest.mark.skip("Seems to disagree with reality, see #5897")
def test_completion_item_focus_fetch(completionview, model, qtbot):
"""Test that on_next_prev_item moves the selection properly.
diff --git a/tests/unit/completion/test_models.py b/tests/unit/completion/test_models.py
index 2ac7084dd..8b4653b58 100644
--- a/tests/unit/completion/test_models.py
+++ b/tests/unit/completion/test_models.py
@@ -26,6 +26,8 @@ import time
from datetime import datetime
from unittest import mock
+import hypothesis
+import hypothesis.strategies
import pytest
from PyQt5.QtCore import QUrl, QDateTime
try:
@@ -37,7 +39,8 @@ except ImportError:
from qutebrowser.misc import objects
from qutebrowser.completion import completer
-from qutebrowser.completion.models import miscmodels, urlmodel, configmodel
+from qutebrowser.completion.models import (
+ miscmodels, urlmodel, configmodel, listcategory)
from qutebrowser.config import configdata, configtypes
from qutebrowser.utils import usertypes
from qutebrowser.mainwindow import tabbedbrowser
@@ -1324,3 +1327,10 @@ def test_undo_completion(tabbed_browser_stubs, info):
"2020-01-01 00:00"),
],
})
+
+
+@hypothesis.given(text=hypothesis.strategies.text())
+def test_listcategory_hypothesis(text):
+ """Make sure we can't produce invalid patterns."""
+ cat = listcategory.ListCategory("test", [])
+ cat.set_pattern(text)
diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py
index 588e4a5cf..b30ab4bee 100644
--- a/tests/unit/config/test_config.py
+++ b/tests/unit/config/test_config.py
@@ -432,12 +432,11 @@ class TestConfig:
assert conf.get_obj(name1) == 'never'
assert conf.get_obj(name2) is True
- with qtbot.waitSignal(conf.changed), qtbot.waitSignal(conf.changed):
+ with qtbot.waitSignals([conf.changed, conf.changed]) as blocker:
conf.clear(save_yaml=save_yaml)
- # Doesn't work with PyQt 5.15.1 workaround
- # options = {blocker1.args[0], blocker2.args[0]}
- # assert options == {name1, name2}
+ options = {e.args[0] for e in blocker.all_signals_and_args}
+ assert options == {name1, name2}
if save_yaml:
assert yaml_value(name1) is usertypes.UNSET
diff --git a/tests/unit/config/test_configcommands.py b/tests/unit/config/test_configcommands.py
index 331d214b1..dc62717e5 100644
--- a/tests/unit/config/test_configcommands.py
+++ b/tests/unit/config/test_configcommands.py
@@ -212,14 +212,12 @@ class TestSet:
commands.set(win_id=0, option='foo?')
-@pytest.mark.parametrize('old', [True, False])
-def test_diff(commands, tabbed_browser_stubs, old):
+def test_diff(commands, tabbed_browser_stubs):
"""Run ':config-diff'.
Should open qute://configdiff."""
- commands.config_diff(win_id=0, old=old)
- url = QUrl('qute://configdiff/old') if old else QUrl('qute://configdiff')
- assert tabbed_browser_stubs[0].loaded_url == url
+ commands.config_diff(win_id=0)
+ assert tabbed_browser_stubs[0].loaded_url == QUrl('qute://configdiff')
class TestCycle:
diff --git a/tests/unit/config/test_configdata.py b/tests/unit/config/test_configdata.py
index 4ea5ffe6d..ae17cd51b 100644
--- a/tests/unit/config/test_configdata.py
+++ b/tests/unit/config/test_configdata.py
@@ -289,7 +289,7 @@ class TestParseYamlBackend:
data = self._yaml("""
backend:
QtWebKit: {}
- QtWebEngine: Qt 5.8
+ QtWebEngine: Qt 5.15
""".format('true' if webkit else 'false'))
monkeypatch.setattr(configdata.qtutils, 'version_check',
lambda v: has_new_version)
diff --git a/tests/unit/config/test_configinit.py b/tests/unit/config/test_configinit.py
index 6b44196b6..23cc890e4 100644
--- a/tests/unit/config/test_configinit.py
+++ b/tests/unit/config/test_configinit.py
@@ -18,6 +18,7 @@
"""Tests for qutebrowser.config.configinit."""
+import builtins
import logging
import unittest.mock
@@ -110,7 +111,7 @@ class TestEarlyInit:
expected = '<Default configuration>'
assert config.instance.dump_userconfig() == expected
- @pytest.mark.parametrize('load_autoconfig', [True, False]) # noqa
+ @pytest.mark.parametrize('load_autoconfig', [True, False])
@pytest.mark.parametrize('config_py', [True, 'error', False])
@pytest.mark.parametrize('invalid_yaml', ['42', 'list', 'unknown',
'wrong-type', False])
@@ -390,6 +391,6 @@ def test_get_backend(monkeypatch, args, config_stub,
args.backend = arg
config_stub.val.backend = confval
- monkeypatch.setattr('builtins.__import__', fake_import)
+ monkeypatch.setattr(builtins, '__import__', fake_import)
assert configinit.get_backend(args) == used
diff --git a/tests/unit/config/test_configtypes.py b/tests/unit/config/test_configtypes.py
index b637ec13c..710018604 100644
--- a/tests/unit/config/test_configtypes.py
+++ b/tests/unit/config/test_configtypes.py
@@ -138,10 +138,16 @@ class TestValidValues:
def test_descriptions(self, klass):
"""Test descriptions."""
- vv = klass(('foo', "foo desc"), ('bar', "bar desc"), 'baz')
- assert vv.descriptions['foo'] == "foo desc"
- assert vv.descriptions['bar'] == "bar desc"
- assert 'baz' not in vv.descriptions
+ vv = klass(
+ ('one-with', "desc 1"),
+ ('two-with', "desc 2"),
+ 'three-without',
+ ('four-without', None)
+ )
+ assert vv.descriptions['one-with'] == "desc 1"
+ assert vv.descriptions['two-with'] == "desc 2"
+ assert 'three-without' not in vv.descriptions
+ assert 'four-without' not in vv.descriptions
@pytest.mark.parametrize('args, expected', [
(['a', 'b'], "<qutebrowser.config.configtypes.ValidValues "
@@ -249,10 +255,11 @@ class TestAll:
configtypes.PercOrInt, # ditto
]:
return
- elif (isinstance(klass, functools.partial) and
- klass.func in [configtypes.ListOrValue, configtypes.List]):
+ elif (isinstance(klass, functools.partial) and klass.func in [
+ configtypes.ListOrValue, configtypes.List, configtypes.Dict]):
# ListOrValue: "- /" -> "/"
# List: "- /" -> ["/"]
+ # Dict: '{":": "A"}' -> ':: A'
return
assert converted == s
@@ -395,14 +402,11 @@ class MappingSubclass(configtypes.MappingType):
"""A MappingType we use in TestMappingType which is valid/good."""
MAPPING = {
- 'one': 1,
- 'two': 2,
+ 'one': (1, 'one doc'),
+ 'two': (2, 'two doc'),
+ 'three': (3, None),
}
- def __init__(self, none_ok=False):
- super().__init__(none_ok)
- self.valid_values = configtypes.ValidValues('one', 'two')
-
class TestMappingType:
@@ -428,11 +432,12 @@ class TestMappingType:
def test_to_str(self, klass):
assert klass().to_str('one') == 'one'
- @pytest.mark.parametrize('typ', [configtypes.ColorSystem(),
- configtypes.Position(),
- configtypes.SelectOnRemove()])
- def test_mapping_type_matches_valid_values(self, typ):
- assert sorted(typ.MAPPING) == sorted(typ.valid_values)
+ def test_valid_values(self, klass):
+ assert klass().valid_values == configtypes.ValidValues(
+ ('one', 'one doc'),
+ ('two', 'two doc'),
+ ('three', None),
+ )
class TestString:
@@ -1948,7 +1953,7 @@ class TestFuzzyUrl:
assert klass().to_py(val) == expected
@pytest.mark.parametrize('val', [
- '::foo', # invalid URL
+ '', # invalid URL
'foo bar', # invalid search term
])
def test_to_py_invalid(self, klass, val):
diff --git a/tests/unit/config/test_configutils.py b/tests/unit/config/test_configutils.py
index 7e1a7c744..4830340cf 100644
--- a/tests/unit/config/test_configutils.py
+++ b/tests/unit/config/test_configutils.py
@@ -21,6 +21,7 @@ import hypothesis
from hypothesis import strategies
import pytest
from PyQt5.QtCore import QUrl
+from PyQt5.QtWidgets import QLabel
from qutebrowser.config import configutils, configdata, configtypes, configexc
from qutebrowser.utils import urlmatch, usertypes, qtutils
@@ -364,3 +365,45 @@ class TestFontFamilies:
assert family
str(families)
+
+ def test_system_default_basics(self, qapp):
+ families = configutils.FontFamilies.from_system_default()
+ assert len(families) == 1
+ assert str(families)
+
+ def test_system_default_rendering(self, qtbot):
+ families = configutils.FontFamilies.from_system_default()
+
+ label = QLabel()
+ qtbot.add_widget(label)
+ label.setText("Hello World")
+
+ stylesheet = f'font-family: {families.to_str(quote=True)}'
+ print(stylesheet)
+ label.setStyleSheet(stylesheet)
+
+ with qtbot.waitExposed(label):
+ # Needed so the font gets calculated
+ label.show()
+ info = label.fontInfo()
+
+ # Check the requested font to make sure CSS parsing worked
+ assert label.font().family() == families.family
+
+ # Try to find out whether the monospace font did a fallback on a non-monospace
+ # font...
+ fallback_label = QLabel()
+ qtbot.add_widget(label)
+ fallback_label.setText("fallback")
+
+ with qtbot.waitExposed(fallback_label):
+ # Needed so the font gets calculated
+ fallback_label.show()
+
+ fallback_family = fallback_label.fontInfo().family()
+ print(f'fallback: {fallback_family}')
+ if info.family() == fallback_family:
+ return
+
+ # If we didn't fall back, we should've gotten a fixed-pitch font.
+ assert info.fixedPitch(), info.family()
diff --git a/tests/unit/config/test_qtargs.py b/tests/unit/config/test_qtargs.py
index a3a7f910d..051956a00 100644
--- a/tests/unit/config/test_qtargs.py
+++ b/tests/unit/config/test_qtargs.py
@@ -42,8 +42,7 @@ class TestQtArgs:
@pytest.fixture(autouse=True)
def reduce_args(self, monkeypatch, config_stub):
"""Make sure no --disable-shared-workers/referer argument get added."""
- monkeypatch.setattr(qtargs.qtutils, 'version_check',
- lambda version, compiled=False: True)
+ monkeypatch.setattr(qtargs.qtutils, 'qVersion', lambda: '5.15.0')
config_stub.val.content.headers.referer = 'always'
@pytest.mark.parametrize('args, expected', [
@@ -95,8 +94,7 @@ class TestQtArgs:
])
def test_shared_workers(self, config_stub, monkeypatch, parser,
backend, expected):
- monkeypatch.setattr(qtargs.qtutils, 'version_check',
- lambda version, compiled=False: False)
+ monkeypatch.setattr(qtargs.qtutils, 'qVersion', lambda: '5.14.0')
monkeypatch.setattr(qtargs.objects, 'backend', backend)
parsed = parser.parse_args([])
args = qtargs.qt_args(parsed)
@@ -118,7 +116,7 @@ class TestQtArgs:
def test_in_process_stack_traces(self, monkeypatch, parser, backend,
version_check, debug_flag, expected):
monkeypatch.setattr(qtargs.qtutils, 'version_check',
- lambda version, compiled=False: version_check)
+ lambda version, compiled=False, exact=False: version_check)
monkeypatch.setattr(qtargs.objects, 'backend', backend)
parsed = parser.parse_args(['--debug-flag', 'stack'] if debug_flag
else [])
@@ -168,25 +166,6 @@ class TestQtArgs:
args = qtargs.qt_args(parsed)
assert ('--disable-gpu' in args) == added
- @utils.qt510
- @pytest.mark.parametrize('new_version, autoplay, added', [
- (True, False, False), # new enough to not need it
- (False, True, False), # autoplay enabled
- (False, False, True),
- ])
- def test_autoplay(self, config_stub, monkeypatch, parser,
- new_version, autoplay, added):
- monkeypatch.setattr(qtargs.objects, 'backend',
- usertypes.Backend.QtWebEngine)
- config_stub.val.content.autoplay = autoplay
- monkeypatch.setattr(qtargs.qtutils, 'version_check',
- lambda version, compiled=False: new_version)
-
- parsed = parser.parse_args([])
- args = qtargs.qt_args(parsed)
- assert ('--autoplay-policy=user-gesture-required' in args) == added
-
- @utils.qt59
@pytest.mark.parametrize('policy, arg', [
('all-interfaces', None),
@@ -273,14 +252,31 @@ class TestQtArgs:
else:
assert arg in args
- @pytest.mark.parametrize('referer, arg', [
- ('always', None),
- ('never', '--no-referrers'),
- ('same-domain', '--reduced-referrer-granularity'),
+ @pytest.mark.parametrize('qt_version, referer, arg', [
+ # 'always' -> no arguments
+ ('5.15.0', 'always', None),
+
+ # 'never' is handled via interceptor for most Qt versions
+ ('5.12.3', 'never', '--no-referrers'),
+ ('5.12.4', 'never', None),
+ ('5.13.0', 'never', '--no-referrers'),
+ ('5.13.1', 'never', None),
+ ('5.14.0', 'never', None),
+ ('5.15.0', 'never', None),
+
+ # 'same-domain' - arguments depend on Qt versions
+ ('5.13.0', 'same-domain', '--reduced-referrer-granularity'),
+ ('5.14.0', 'same-domain', '--enable-features=ReducedReferrerGranularity'),
+ ('5.15.0', 'same-domain', '--enable-features=ReducedReferrerGranularity'),
])
- def test_referer(self, config_stub, monkeypatch, parser, referer, arg):
- monkeypatch.setattr(qtargs.objects, 'backend',
- usertypes.Backend.QtWebEngine)
+ def test_referer(self, config_stub, monkeypatch, parser, qt_version, referer, arg):
+ monkeypatch.setattr(qtargs.objects, 'backend', usertypes.Backend.QtWebEngine)
+ monkeypatch.setattr(qtargs.qtutils, 'qVersion', lambda: qt_version)
+
+ # Avoid WebRTC pipewire feature
+ monkeypatch.setattr(qtargs.utils, 'is_linux', False)
+ # Avoid overlay scrollbar feature
+ config_stub.val.scrolling.bar = 'never'
config_stub.val.content.headers.referer = referer
parsed = parser.parse_args([])
@@ -289,6 +285,7 @@ class TestQtArgs:
if arg is None:
assert '--no-referrers' not in args
assert '--reduced-referrer-granularity' not in args
+ assert '--enable-features=ReducedReferrerGranularity' not in args
else:
assert arg in args
@@ -314,26 +311,20 @@ class TestQtArgs:
assert ('--force-dark-mode' in args) == added
- @pytest.mark.parametrize('bar, new_qt, is_mac, added', [
+ @pytest.mark.parametrize('bar, is_mac, added', [
# Overlay bar enabled
- ('overlay', True, False, True),
+ ('overlay', False, True),
# No overlay on mac
- ('overlay', True, True, False),
- ('overlay', False, True, False),
- # No overlay on old Qt
- ('overlay', False, False, False),
+ ('overlay', True, False),
# Overlay disabled
- ('when-searching', True, False, False),
- ('always', True, False, False),
- ('never', True, False, False),
+ ('when-searching', False, False),
+ ('always', False, False),
+ ('never', False, False),
])
def test_overlay_scrollbar(self, config_stub, monkeypatch, parser,
- bar, new_qt, is_mac, added):
+ bar, is_mac, added):
monkeypatch.setattr(qtargs.objects, 'backend',
usertypes.Backend.QtWebEngine)
- monkeypatch.setattr(qtargs.qtutils, 'version_check',
- lambda version, exact=False, compiled=True:
- new_qt)
monkeypatch.setattr(qtargs.utils, 'is_mac', is_mac)
# Avoid WebRTC pipewire feature
monkeypatch.setattr(qtargs.utils, 'is_linux', False)
@@ -387,7 +378,6 @@ class TestQtArgs:
assert combined_flag in args
assert overlay_flag not in args
- @utils.qt510
def test_blink_settings(self, config_stub, monkeypatch, parser):
from qutebrowser.browser.webengine import darkmode
monkeypatch.setattr(qtargs.objects, 'backend',
diff --git a/tests/unit/config/test_websettings.py b/tests/unit/config/test_websettings.py
index 651c14aba..e1445efbb 100644
--- a/tests/unit/config/test_websettings.py
+++ b/tests/unit/config/test_websettings.py
@@ -95,10 +95,10 @@ def test_user_agent(monkeypatch, config_stub, qapp):
def test_config_init(request, monkeypatch, config_stub):
if request.config.webengine:
from qutebrowser.browser.webengine import webenginesettings
- monkeypatch.setattr(webenginesettings, 'init', lambda _args: None)
+ monkeypatch.setattr(webenginesettings, 'init', lambda: None)
else:
from qutebrowser.browser.webkit import webkitsettings
- monkeypatch.setattr(webkitsettings, 'init', lambda _args: None)
+ monkeypatch.setattr(webkitsettings, 'init', lambda: None)
websettings.init(args=None)
assert config_stub.dump_userconfig() == '<Default configuration>'
diff --git a/tests/unit/javascript/test_greasemonkey.py b/tests/unit/javascript/test_greasemonkey.py
index c066ab479..5d549ca68 100644
--- a/tests/unit/javascript/test_greasemonkey.py
+++ b/tests/unit/javascript/test_greasemonkey.py
@@ -27,6 +27,7 @@ from PyQt5.QtCore import QUrl
from qutebrowser.utils import usertypes
from qutebrowser.browser import greasemonkey
+from qutebrowser.misc import objects
test_gm_script = r"""
// ==UserScript==
@@ -168,15 +169,6 @@ def test_utf8_bom():
class TestForceDocumentEnd:
- @pytest.fixture
- def patch(self, monkeypatch):
- def _patch(*, backend, qt_512):
- monkeypatch.setattr(greasemonkey.objects, 'backend', backend)
- monkeypatch.setattr(greasemonkey.qtutils, 'version_check',
- lambda version, exact=False, compiled=True:
- qt_512)
- return _patch
-
def _get_script(self, *, namespace, name):
source = textwrap.dedent("""
// ==UserScript==
@@ -192,26 +184,15 @@ class TestForceDocumentEnd:
assert len(scripts) == 1
return scripts[0]
- @pytest.mark.parametrize('backend, qt_512', [
- (usertypes.Backend.QtWebKit, True),
- (usertypes.Backend.QtWebEngine, False),
- ])
- def test_not_applicable(self, patch, backend, qt_512):
- """Test backend/Qt version combinations which don't need a fix."""
- patch(backend=backend, qt_512=qt_512)
- script = self._get_script(namespace='https://github.com/ParticleCore',
- name='Iridium')
- assert not script.needs_document_end_workaround()
-
@pytest.mark.parametrize('namespace, name, force', [
('http://userstyles.org', 'foobar', True),
('https://github.com/ParticleCore', 'Iridium', True),
('https://github.com/ParticleCore', 'Foo', False),
('https://example.org', 'Iridium', False),
])
- def test_matching(self, patch, namespace, name, force):
+ def test_matching(self, monkeypatch, namespace, name, force):
"""Test matching based on namespace/name."""
- patch(backend=usertypes.Backend.QtWebEngine, qt_512=True)
+ monkeypatch.setattr(objects, 'backend', usertypes.Backend.QtWebEngine)
script = self._get_script(namespace=namespace, name=name)
assert script.needs_document_end_workaround() == force
diff --git a/tests/unit/keyinput/test_basekeyparser.py b/tests/unit/keyinput/test_basekeyparser.py
index 4e474b4f3..cd57d33cb 100644
--- a/tests/unit/keyinput/test_basekeyparser.py
+++ b/tests/unit/keyinput/test_basekeyparser.py
@@ -21,11 +21,11 @@
from unittest import mock
-from PyQt5.QtCore import Qt, PYQT_VERSION
+from PyQt5.QtCore import Qt
import pytest
from qutebrowser.keyinput import basekeyparser, keyutils
-from qutebrowser.utils import utils, usertypes
+from qutebrowser.utils import usertypes
# Alias because we need this a lot in here.
@@ -119,11 +119,9 @@ def test_read_config(keyparser, key_config_stub, changed_mode, expected):
class TestHandle:
def test_valid_key(self, prompt_keyparser, handle_text):
- modifier = Qt.MetaModifier if utils.is_mac else Qt.ControlModifier
-
infos = [
- keyutils.KeyInfo(Qt.Key_A, modifier),
- keyutils.KeyInfo(Qt.Key_X, modifier),
+ keyutils.KeyInfo(Qt.Key_A, Qt.ControlModifier),
+ keyutils.KeyInfo(Qt.Key_X, Qt.ControlModifier),
]
for info in infos:
prompt_keyparser.handle(info.to_event())
@@ -133,11 +131,9 @@ class TestHandle:
assert not prompt_keyparser._sequence
def test_valid_key_count(self, prompt_keyparser):
- modifier = Qt.MetaModifier if utils.is_mac else Qt.ControlModifier
-
infos = [
keyutils.KeyInfo(Qt.Key_5, Qt.NoModifier),
- keyutils.KeyInfo(Qt.Key_A, modifier),
+ keyutils.KeyInfo(Qt.Key_A, Qt.ControlModifier),
]
for info in infos:
prompt_keyparser.handle(info.to_event())
@@ -309,8 +305,6 @@ class TestCount:
# https://github.com/qutebrowser/qutebrowser/issues/3743
handle_text(prompt_keyparser, Qt.Key_twosuperior, Qt.Key_B, Qt.Key_A)
- @pytest.mark.skipif(PYQT_VERSION == 0x050F01,
- reason='waitSignals is broken in PyQt 5.15.1')
def test_count_keystring_update(self, qtbot,
handle_text, prompt_keyparser):
"""Make sure the keystring is updated correctly when entering count."""
diff --git a/tests/unit/keyinput/test_keyutils.py b/tests/unit/keyinput/test_keyutils.py
index 0df721c68..4c297ef7e 100644
--- a/tests/unit/keyinput/test_keyutils.py
+++ b/tests/unit/keyinput/test_keyutils.py
@@ -28,7 +28,6 @@ from PyQt5.QtWidgets import QWidget
from unit.keyinput import key_data
from qutebrowser.keyinput import keyutils
-from qutebrowser.utils import utils
@pytest.fixture(params=key_data.KEYS, ids=lambda k: k.attribute)
@@ -421,13 +420,10 @@ class TestKeySequence:
('', Qt.Key_Colon, Qt.AltModifier | Qt.ShiftModifier, ':',
'<Alt+Shift+:>'),
- # Swapping Control/Meta on macOS
- ('', Qt.Key_A, Qt.ControlModifier, '',
- '<Meta+A>' if utils.is_mac else '<Ctrl+A>'),
- ('', Qt.Key_A, Qt.ControlModifier | Qt.ShiftModifier, '',
- '<Meta+Shift+A>' if utils.is_mac else '<Ctrl+Shift+A>'),
- ('', Qt.Key_A, Qt.MetaModifier, '',
- '<Ctrl+A>' if utils.is_mac else '<Meta+A>'),
+ # Modifiers
+ ('', Qt.Key_A, Qt.ControlModifier, '', '<Ctrl+A>'),
+ ('', Qt.Key_A, Qt.ControlModifier | Qt.ShiftModifier, '', '<Ctrl+Shift+A>'),
+ ('', Qt.Key_A, Qt.MetaModifier, '', '<Meta+A>'),
# Handling of Backtab
('', Qt.Key_Backtab, Qt.NoModifier, '', '<Backtab>'),
@@ -444,27 +440,6 @@ class TestKeySequence:
new = seq.append_event(event)
assert new == keyutils.KeySequence.parse(expected)
- @pytest.mark.fake_os('mac')
- @pytest.mark.parametrize('modifiers, expected', [
- (Qt.ControlModifier,
- Qt.MetaModifier),
- (Qt.MetaModifier,
- Qt.ControlModifier),
- (Qt.ControlModifier | Qt.MetaModifier,
- Qt.ControlModifier | Qt.MetaModifier),
- (Qt.ControlModifier | Qt.ShiftModifier,
- Qt.MetaModifier | Qt.ShiftModifier),
- (Qt.MetaModifier | Qt.ShiftModifier,
- Qt.ControlModifier | Qt.ShiftModifier),
- (Qt.ShiftModifier, Qt.ShiftModifier),
- ])
- def test_fake_mac(self, modifiers, expected):
- """Make sure Control/Meta are swapped with a simulated Mac."""
- seq = keyutils.KeySequence()
- 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])
def test_append_event_invalid(self, key):
seq = keyutils.KeySequence()
diff --git a/tests/unit/mainwindow/statusbar/test_url.py b/tests/unit/mainwindow/statusbar/test_url.py
index 8bf71aff4..bd37fd2dc 100644
--- a/tests/unit/mainwindow/statusbar/test_url.py
+++ b/tests/unit/mainwindow/statusbar/test_url.py
@@ -26,7 +26,6 @@ from PyQt5.QtCore import QUrl
from qutebrowser.utils import usertypes, urlutils
from qutebrowser.mainwindow.statusbar import url
-from helpers import utils
@pytest.fixture
@@ -47,10 +46,7 @@ def url_widget(qtbot, monkeypatch, config_stub):
('http://username:secret%20password@test.com', 'http://username@test.com'),
('http://example.com%5b/', '(invalid URL!) http://example.com%5b/'),
# https://bugreports.qt.io/browse/QTBUG-60364
- pytest.param('http://www.xn--80ak6aa92e.com',
- '(unparseable URL!) http://www.аррӏе.com', marks=utils.qt58),
- pytest.param('http://www.xn--80ak6aa92e.com',
- 'http://www.xn--80ak6aa92e.com', marks=utils.qt59),
+ ('http://www.xn--80ak6aa92e.com', 'http://www.xn--80ak6aa92e.com'),
# IDN URL
('http://www.ä.com', '(www.xn--4ca.com) http://www.ä.com'),
(None, ''),
diff --git a/tests/unit/misc/test_earlyinit.py b/tests/unit/misc/test_earlyinit.py
index 728b4eb26..af229a40a 100644
--- a/tests/unit/misc/test_earlyinit.py
+++ b/tests/unit/misc/test_earlyinit.py
@@ -31,3 +31,20 @@ def test_init_faulthandler_stderr_none(monkeypatch, attr):
"""Make sure init_faulthandler works when sys.stderr/__stderr__ is None."""
monkeypatch.setattr(sys, attr, None)
earlyinit.init_faulthandler()
+
+
+@pytest.mark.parametrize('same', [True, False])
+def test_qt_version(same):
+ if same:
+ qt_version_str = '5.14.0'
+ expected = '5.14.0'
+ else:
+ qt_version_str = '5.13.0'
+ expected = '5.14.0 (compiled 5.13.0)'
+ actual = earlyinit.qt_version(qversion='5.14.0', qt_version_str=qt_version_str)
+ assert actual == expected
+
+
+def test_qt_version_no_args():
+ """Make sure qt_version without arguments at least works."""
+ earlyinit.qt_version()
diff --git a/tests/unit/misc/test_guiprocess.py b/tests/unit/misc/test_guiprocess.py
index 7e71478ce..4ed19f64e 100644
--- a/tests/unit/misc/test_guiprocess.py
+++ b/tests/unit/misc/test_guiprocess.py
@@ -54,8 +54,8 @@ def fake_proc(monkeypatch, stubs):
def test_start(proc, qtbot, message_mock, py_proc):
"""Test simply starting a process."""
- with qtbot.waitSignal(proc.started, timeout=10000), \
- qtbot.waitSignal(proc.finished, timeout=10000):
+ with qtbot.waitSignals([proc.started, proc.finished], timeout=10000,
+ order='strict'):
argv = py_proc("import sys; print('test'); sys.exit(0)")
proc.start(*argv)
@@ -70,8 +70,8 @@ def test_start_verbose(proc, qtbot, message_mock, py_proc):
"""Test starting a process verbosely."""
proc.verbose = True
- with qtbot.waitSignal(proc.started, timeout=10000), \
- qtbot.waitSignal(proc.finished, timeout=10000):
+ with qtbot.waitSignals([proc.started, proc.finished], timeout=10000,
+ order='strict'):
argv = py_proc("import sys; print('test'); sys.exit(0)")
proc.start(*argv)
@@ -99,8 +99,9 @@ def test_start_output_message(proc, qtbot, caplog, message_mock, py_proc,
code.append("sys.exit(0)")
with caplog.at_level(logging.ERROR, 'message'):
- with qtbot.waitSignal(proc.started, timeout=10000), \
- qtbot.waitSignal(proc.finished, timeout=10000):
+ with qtbot.waitSignals([proc.started, proc.finished],
+ timeout=10000,
+ order='strict'):
argv = py_proc(';'.join(code))
proc.start(*argv)
@@ -146,8 +147,8 @@ def test_start_env(monkeypatch, qtbot, py_proc):
sys.exit(0)
""")
- with qtbot.waitSignal(proc.started, timeout=10000), \
- qtbot.waitSignal(proc.finished, timeout=10000):
+ with qtbot.waitSignals([proc.started, proc.finished], timeout=10000,
+ order='strict'):
proc.start(*argv)
data = qutescheme.spawn_output
@@ -186,12 +187,12 @@ def test_double_start(qtbot, proc, py_proc):
def test_double_start_finished(qtbot, proc, py_proc):
"""Test starting a GUIProcess twice (with the first call finished)."""
- with qtbot.waitSignal(proc.started, timeout=10000), \
- qtbot.waitSignal(proc.finished, timeout=10000):
+ with qtbot.waitSignals([proc.started, proc.finished], timeout=10000,
+ order='strict'):
argv = py_proc("import sys; sys.exit(0)")
proc.start(*argv)
- with qtbot.waitSignal(proc.started, timeout=10000), \
- qtbot.waitSignal(proc.finished, timeout=10000):
+ with qtbot.waitSignals([proc.started, proc.finished], timeout=10000,
+ order='strict'):
argv = py_proc("import sys; sys.exit(0)")
proc.start(*argv)
@@ -266,8 +267,8 @@ def test_exit_successful_output(qtbot, proc, py_proc, stream):
def test_stdout_not_decodable(proc, qtbot, message_mock, py_proc):
"""Test handling malformed utf-8 in stdout."""
- with qtbot.waitSignal(proc.started, timeout=10000), \
- qtbot.waitSignal(proc.finished, timeout=10000):
+ with qtbot.waitSignals([proc.started, proc.finished], timeout=10000,
+ order='strict'):
argv = py_proc(r"""
import sys
# Using \x81 because it's invalid in UTF-8 and CP1252
diff --git a/tests/unit/misc/test_ipc.py b/tests/unit/misc/test_ipc.py
index 28c570586..3f53ca238 100644
--- a/tests/unit/misc/test_ipc.py
+++ b/tests/unit/misc/test_ipc.py
@@ -493,10 +493,10 @@ NEW_VERSION = str(ipc.PROTOCOL_VERSION + 1).encode('utf-8')
(b'{"args": [], "target_arg": null}\n', 'invalid version'),
])
def test_invalid_data(qtbot, ipc_server, connected_socket, caplog, data, msg):
+ signals = [ipc_server.got_invalid_data, connected_socket.disconnected]
with caplog.at_level(logging.ERROR):
with qtbot.assertNotEmitted(ipc_server.got_args):
- with qtbot.waitSignal(ipc_server.got_invalid_data), \
- qtbot.waitSignal(connected_socket.disconnected):
+ with qtbot.waitSignals(signals, order='strict'):
connected_socket.write(data)
invalid_msg = 'Ignoring invalid IPC data from socket '
@@ -514,8 +514,8 @@ def test_multiline(qtbot, ipc_server, connected_socket):
version=ipc.PROTOCOL_VERSION))
with qtbot.assertNotEmitted(ipc_server.got_invalid_data):
- with qtbot.waitSignal(ipc_server.got_args), \
- qtbot.waitSignal(ipc_server.got_args):
+ with qtbot.waitSignals([ipc_server.got_args, ipc_server.got_args],
+ order='strict'):
connected_socket.write(data.encode('utf-8'))
assert len(spy) == 2
@@ -767,7 +767,7 @@ def test_long_username(monkeypatch):
"""See https://github.com/qutebrowser/qutebrowser/issues/888."""
username = 'alexandercogneau'
basedir = '/this_is_a_long_basedir'
- monkeypatch.setattr('getpass.getuser', lambda: username)
+ monkeypatch.setattr(getpass, 'getuser', lambda: username)
name = ipc._get_socketname(basedir=basedir)
server = ipc.IPCServer(name)
expected_md5 = md5('{}-{}'.format(username, basedir))
diff --git a/tests/unit/misc/test_sql.py b/tests/unit/misc/test_sql.py
index 2cb55b891..c8efe6ef6 100644
--- a/tests/unit/misc/test_sql.py
+++ b/tests/unit/misc/test_sql.py
@@ -49,22 +49,8 @@ class TestSqlError:
with pytest.raises(exception):
sql.raise_sqlite_error("Message", sql_err)
- def test_qtbug_70506(self):
- """Test Qt's wrong handling of errors while opening the database.
-
- Due to https://bugreports.qt.io/browse/QTBUG-70506 we get an error with
- "out of memory" as string and -1 as error code.
- """
- sql_err = QSqlError("Error opening database",
- "out of memory",
- QSqlError.UnknownError,
- sql.SqliteErrorCode.UNKNOWN)
- with pytest.raises(sql.KnownError):
- sql.raise_sqlite_error("Message", sql_err)
-
def test_logging(self, caplog):
- sql_err = QSqlError("driver text", "db text", QSqlError.UnknownError,
- '23')
+ sql_err = QSqlError("driver text", "db text", QSqlError.UnknownError, '23')
with pytest.raises(sql.BugError):
sql.raise_sqlite_error("Message", sql_err)
diff --git a/tests/unit/utils/test_qtutils.py b/tests/unit/utils/test_qtutils.py
index 81d198946..2e54fb42e 100644
--- a/tests/unit/utils/test_qtutils.py
+++ b/tests/unit/utils/test_qtutils.py
@@ -26,6 +26,7 @@ import os.path
import unittest
import unittest.mock
+import attr
import pytest
from PyQt5.QtCore import (QDataStream, QPoint, QUrl, QByteArray, QIODevice,
QTimer, QBuffer, QFile, QProcess, QFileDevice)
@@ -53,23 +54,25 @@ else:
@pytest.mark.parametrize(['qversion', 'compiled', 'pyqt', 'version', 'exact',
'expected'], [
# equal versions
- ('5.4.0', None, None, '5.4.0', False, True),
- ('5.4.0', None, None, '5.4.0', True, True), # exact=True
- ('5.4.0', None, None, '5.4', True, True), # without trailing 0
+ ('5.14.0', None, None, '5.14.0', False, True),
+ ('5.14.0', None, None, '5.14.0', True, True), # exact=True
+ ('5.14.0', None, None, '5.14', True, True), # without trailing 0
# newer version installed
- ('5.4.1', None, None, '5.4', False, True),
- ('5.4.1', None, None, '5.4', True, False), # exact=True
+ ('5.14.1', None, None, '5.14', False, True),
+ ('5.14.1', None, None, '5.14', True, False), # exact=True
# older version installed
- ('5.3.2', None, None, '5.4', False, False),
- ('5.3.0', None, None, '5.3.2', False, False),
- ('5.3.0', None, None, '5.3.2', True, False), # exact=True
+ ('5.13.2', None, None, '5.14', False, False),
+ ('5.13.0', None, None, '5.13.2', False, False),
+ ('5.13.0', None, None, '5.13.2', True, False), # exact=True
# compiled=True
# new Qt runtime, but compiled against older version
- ('5.4.0', '5.3.0', '5.4.0', '5.4.0', False, False),
+ ('5.14.0', '5.13.0', '5.14.0', '5.14.0', False, False),
# new Qt runtime, compiled against new version, but old PyQt
- ('5.4.0', '5.4.0', '5.3.0', '5.4.0', False, False),
+ ('5.14.0', '5.14.0', '5.13.0', '5.14.0', False, False),
# all up-to-date
- ('5.4.0', '5.4.0', '5.4.0', '5.4.0', False, True),
+ ('5.14.0', '5.14.0', '5.14.0', '5.14.0', False, True),
+ # dev suffix
+ ('5.15.1', '5.15.1', '5.15.2.dev2009281246', '5.15.0', False, True),
])
# pylint: enable=bad-continuation
def test_version_check(monkeypatch, qversion, compiled, pyqt, version, exact,
@@ -936,3 +939,107 @@ class TestEventLoop:
QTimer.singleShot(400, self.loop.quit)
self.loop.exec_()
assert not self.loop._executing
+
+
+class Color(QColor):
+
+ """A QColor with a nicer repr()."""
+
+ def __repr__(self):
+ return utils.get_repr(self, constructor=True, red=self.red(),
+ green=self.green(), blue=self.blue(),
+ alpha=self.alpha())
+
+
+class TestInterpolateColor:
+
+ @attr.s
+ class Colors:
+
+ white = attr.ib()
+ black = attr.ib()
+
+ @pytest.fixture
+ def colors(self):
+ """Example colors to be used."""
+ return self.Colors(Color('white'), Color('black'))
+
+ def test_invalid_start(self, colors):
+ """Test an invalid start color."""
+ with pytest.raises(qtutils.QtValueError):
+ qtutils.interpolate_color(Color(), colors.white, 0)
+
+ def test_invalid_end(self, colors):
+ """Test an invalid end color."""
+ with pytest.raises(qtutils.QtValueError):
+ qtutils.interpolate_color(colors.white, Color(), 0)
+
+ @pytest.mark.parametrize('perc', [-1, 101])
+ def test_invalid_percentage(self, colors, perc):
+ """Test an invalid percentage."""
+ with pytest.raises(ValueError):
+ qtutils.interpolate_color(colors.white, colors.white, perc)
+
+ def test_invalid_colorspace(self, colors):
+ """Test an invalid colorspace."""
+ with pytest.raises(ValueError):
+ qtutils.interpolate_color(colors.white, colors.black, 10, QColor.Cmyk)
+
+ @pytest.mark.parametrize('colorspace', [QColor.Rgb, QColor.Hsv,
+ QColor.Hsl])
+ def test_0_100(self, colors, colorspace):
+ """Test 0% and 100% in different colorspaces."""
+ white = qtutils.interpolate_color(colors.white, colors.black, 0, colorspace)
+ black = qtutils.interpolate_color(colors.white, colors.black, 100, colorspace)
+ assert Color(white) == colors.white
+ assert Color(black) == colors.black
+
+ def test_interpolation_rgb(self):
+ """Test an interpolation in the RGB colorspace."""
+ color = qtutils.interpolate_color(
+ Color(0, 40, 100), Color(0, 20, 200), 50, QColor.Rgb)
+ assert Color(color) == Color(0, 30, 150)
+
+ def test_interpolation_hsv(self):
+ """Test an interpolation in the HSV colorspace."""
+ start = Color()
+ stop = Color()
+ start.setHsv(0, 40, 100)
+ stop.setHsv(0, 20, 200)
+ color = qtutils.interpolate_color(start, stop, 50, QColor.Hsv)
+ expected = Color()
+ expected.setHsv(0, 30, 150)
+ assert Color(color) == expected
+
+ def test_interpolation_hsl(self):
+ """Test an interpolation in the HSL colorspace."""
+ start = Color()
+ stop = Color()
+ start.setHsl(0, 40, 100)
+ stop.setHsl(0, 20, 200)
+ color = qtutils.interpolate_color(start, stop, 50, QColor.Hsl)
+ expected = Color()
+ expected.setHsl(0, 30, 150)
+ assert Color(color) == expected
+
+ @pytest.mark.parametrize('colorspace', [QColor.Rgb, QColor.Hsv,
+ QColor.Hsl])
+ def test_interpolation_alpha(self, colorspace):
+ """Test interpolation of colorspace's alpha."""
+ start = Color(0, 0, 0, 30)
+ stop = Color(0, 0, 0, 100)
+ color = qtutils.interpolate_color(start, stop, 50, colorspace)
+ expected = Color(0, 0, 0, 65)
+ assert Color(color) == expected
+
+ @pytest.mark.parametrize('percentage, expected', [
+ (0, (0, 0, 0)),
+ (99, (0, 0, 0)),
+ (100, (255, 255, 255)),
+ ])
+ def test_interpolation_none(self, percentage, expected):
+ """Test an interpolation with a gradient turned off."""
+ color = qtutils.interpolate_color(
+ Color(0, 0, 0), Color(255, 255, 255), percentage, None)
+ assert isinstance(color, QColor)
+ assert Color(color) == Color(*expected)
diff --git a/tests/unit/utils/test_standarddir.py b/tests/unit/utils/test_standarddir.py
index ea65b7cc4..dbc8831f6 100644
--- a/tests/unit/utils/test_standarddir.py
+++ b/tests/unit/utils/test_standarddir.py
@@ -28,7 +28,6 @@ import textwrap
import logging
import subprocess
-import attr
from PyQt5.QtCore import QStandardPaths
import pytest
@@ -108,7 +107,7 @@ def test_fake_windows(tmpdir, monkeypatch, what):
def test_fake_haiku(tmpdir, monkeypatch):
"""Test getting data dir on HaikuOS."""
locations = {
- QStandardPaths.DataLocation: '',
+ QStandardPaths.AppDataLocation: '',
QStandardPaths.ConfigLocation: str(tmpdir / 'config' / APPNAME),
}
monkeypatch.setattr(standarddir.QStandardPaths, 'writableLocation',
@@ -129,14 +128,14 @@ class TestWritableLocation:
'qutebrowser.utils.standarddir.QStandardPaths.writableLocation',
lambda typ: '')
with pytest.raises(standarddir.EmptyValueError):
- standarddir._writable_location(QStandardPaths.DataLocation)
+ standarddir._writable_location(QStandardPaths.AppDataLocation)
def test_sep(self, monkeypatch):
"""Make sure the right kind of separator is used."""
monkeypatch.setattr(standarddir.os, 'sep', '\\')
monkeypatch.setattr(standarddir.os.path, 'join',
lambda *parts: '\\'.join(parts))
- loc = standarddir._writable_location(QStandardPaths.DataLocation)
+ loc = standarddir._writable_location(QStandardPaths.AppDataLocation)
assert '/' not in loc
assert '\\' in loc
@@ -392,133 +391,13 @@ class TestSystemData:
fake_args):
"""Test that system-wide path is not used on non-Linux OS."""
fake_args.basedir = str(tmpdir)
- monkeypatch.setattr('sys.platform', "potato")
+ monkeypatch.setattr(sys, 'platform', 'potato')
standarddir._init_data(args=fake_args)
assert standarddir.data(system=True) == standarddir.data()
-class TestMoveWindowsAndMacOS:
-
- """Test other invocations of _move_data."""
-
- @pytest.fixture(autouse=True)
- def patch_standardpaths(self, files, monkeypatch):
- locations = {
- QStandardPaths.DataLocation: str(files.local_data_dir),
- QStandardPaths.AppDataLocation: str(files.roaming_data_dir),
- }
- monkeypatch.setattr(standarddir.QStandardPaths, 'writableLocation',
- locations.get)
- monkeypatch.setattr(
- standarddir, 'config', lambda auto=False:
- str(files.auto_config_dir if auto else files.config_dir))
-
- @pytest.fixture
- def files(self, tmpdir):
-
- @attr.s
- class Files:
-
- auto_config_dir = attr.ib()
- config_dir = attr.ib()
- local_data_dir = attr.ib()
- roaming_data_dir = attr.ib()
-
- return Files(
- auto_config_dir=tmpdir / 'auto_config' / APPNAME,
- config_dir=tmpdir / 'config' / APPNAME,
- local_data_dir=tmpdir / 'data' / APPNAME,
- roaming_data_dir=tmpdir / 'roaming-data' / APPNAME,
- )
-
- def test_move_macos(self, files):
- """Test moving configs on macOS."""
- (files.auto_config_dir / 'autoconfig.yml').ensure()
- (files.auto_config_dir / 'quickmarks').ensure()
- files.config_dir.ensure(dir=True)
-
- standarddir._move_macos()
-
- assert (files.auto_config_dir / 'autoconfig.yml').exists()
- assert not (files.config_dir / 'autoconfig.yml').exists()
- assert not (files.auto_config_dir / 'quickmarks').exists()
- assert (files.config_dir / 'quickmarks').exists()
-
- def test_move_windows(self, files):
- """Test moving configs on Windows."""
- (files.local_data_dir / 'data' / 'blocked-hosts').ensure()
- (files.local_data_dir / 'qutebrowser.conf').ensure()
- (files.local_data_dir / 'cache' / 'cachefile').ensure()
-
- standarddir._move_windows()
-
- assert (files.roaming_data_dir / 'data' / 'blocked-hosts').exists()
- assert (files.roaming_data_dir / 'config' /
- 'qutebrowser.conf').exists()
- assert not (files.roaming_data_dir / 'cache').exists()
- assert (files.local_data_dir / 'cache' / 'cachefile').exists()
-
-
-class TestMove:
-
- @pytest.fixture
- def dirs(self, tmpdir):
- @attr.s
- class Dirs:
-
- old = attr.ib()
- new = attr.ib()
- old_file = attr.ib()
- new_file = attr.ib()
-
- old_dir = tmpdir / 'old'
- new_dir = tmpdir / 'new'
- return Dirs(old=old_dir, new=new_dir,
- old_file=old_dir / 'file', new_file=new_dir / 'file')
-
- def test_no_old_dir(self, dirs, caplog):
- """Nothing should happen without any old directory."""
- standarddir._move_data(str(dirs.old), str(dirs.new))
- assert not any(message.startswith('Migrating data from')
- for message in caplog.messages)
-
- @pytest.mark.parametrize('empty_dest', [True, False])
- def test_moving_data(self, dirs, empty_dest):
- dirs.old_file.ensure()
- if empty_dest:
- dirs.new.ensure(dir=True)
-
- standarddir._move_data(str(dirs.old), str(dirs.new))
- assert not dirs.old_file.exists()
- assert dirs.new_file.exists()
-
- def test_already_existing(self, dirs, caplog):
- dirs.old_file.ensure()
- dirs.new_file.ensure()
-
- with caplog.at_level(logging.ERROR):
- standarddir._move_data(str(dirs.old), str(dirs.new))
-
- expected = "Failed to move data from {} as {} is non-empty!".format(
- dirs.old, dirs.new)
- assert caplog.messages[-1] == expected
-
- def test_deleting_error(self, dirs, monkeypatch, mocker, caplog):
- """When there was an error it should be logged."""
- mock = mocker.Mock(side_effect=OSError('error'))
- monkeypatch.setattr(standarddir.shutil, 'move', mock)
- dirs.old_file.ensure()
-
- with caplog.at_level(logging.ERROR):
- standarddir._move_data(str(dirs.old), str(dirs.new))
-
- expected = "Failed to move data from {} to {}: error".format(
- dirs.old, dirs.new)
- assert caplog.messages[-1] == expected
-
-
@pytest.mark.parametrize('args_kind', ['basedir', 'normal', 'none'])
-def test_init(mocker, tmpdir, monkeypatch, args_kind):
+def test_init(tmpdir, monkeypatch, args_kind):
"""Do some sanity checks for standarddir.init().
Things like _init_cachedir_tag() are tested in more detail in other tests.
@@ -527,8 +406,6 @@ def test_init(mocker, tmpdir, monkeypatch, args_kind):
monkeypatch.setenv('HOME', str(tmpdir))
- m_windows = mocker.patch('qutebrowser.utils.standarddir._move_windows')
- m_mac = mocker.patch('qutebrowser.utils.standarddir._move_macos')
if args_kind == 'normal':
args = types.SimpleNamespace(basedir=None)
elif args_kind == 'basedir':
@@ -540,19 +417,6 @@ def test_init(mocker, tmpdir, monkeypatch, args_kind):
standarddir.init(args)
assert standarddir._locations != {}
- if args_kind == 'normal':
- if utils.is_mac:
- m_windows.assert_not_called()
- assert m_mac.called
- elif utils.is_windows:
- assert m_windows.called
- m_mac.assert_not_called()
- else:
- m_windows.assert_not_called()
- m_mac.assert_not_called()
- else:
- m_windows.assert_not_called()
- m_mac.assert_not_called()
@pytest.mark.linux
diff --git a/tests/unit/utils/test_urlutils.py b/tests/unit/utils/test_urlutils.py
index df9d8b510..0167f6cee 100644
--- a/tests/unit/utils/test_urlutils.py
+++ b/tests/unit/utils/test_urlutils.py
@@ -33,7 +33,6 @@ import hypothesis.strategies
from qutebrowser.api import cmdutils
from qutebrowser.browser.network import pac
from qutebrowser.utils import utils, urlutils, usertypes
-from helpers import utils as testutils
class FakeDNS:
@@ -216,15 +215,11 @@ class TestFuzzyUrl:
assert url == QUrl('http://foo')
@pytest.mark.parametrize('do_search', [True, False])
- def test_invalid_url(self, do_search, is_url_mock, monkeypatch,
- caplog):
+ def test_invalid_url(self, do_search, caplog):
"""Test with an invalid URL."""
- is_url_mock.return_value = True
- monkeypatch.setattr(urlutils, 'qurl_from_user_input',
- lambda url: QUrl())
with pytest.raises(urlutils.InvalidUrlError):
with caplog.at_level(logging.ERROR):
- urlutils.fuzzy_url('foo', do_search=do_search)
+ urlutils.fuzzy_url('', do_search=do_search)
@pytest.mark.parametrize('url', ['', ' '])
def test_empty(self, url):
@@ -490,29 +485,6 @@ def test_searchengine_is_url(config_stub, auto_search, open_base_url, is_url):
assert urlutils.is_url('test') == is_url
-@pytest.mark.parametrize('user_input, output', [
- ('qutebrowser.org', 'http://qutebrowser.org'),
- ('http://qutebrowser.org', 'http://qutebrowser.org'),
- ('::1/foo', 'http://[::1]/foo'),
- ('[::1]/foo', 'http://[::1]/foo'),
- ('http://[::1]', 'http://[::1]'),
- ('qutebrowser.org', 'http://qutebrowser.org'),
- ('http://qutebrowser.org', 'http://qutebrowser.org'),
- ('::1/foo', 'http://[::1]/foo'),
- ('[::1]/foo', 'http://[::1]/foo'),
- ('http://[::1]', 'http://[::1]'),
-])
-def test_qurl_from_user_input(user_input, output):
- """Test qurl_from_user_input.
-
- Args:
- user_input: The string to pass to qurl_from_user_input.
- output: The expected QUrl string.
- """
- url = urlutils.qurl_from_user_input(user_input)
- assert url.toString() == output
-
-
@pytest.mark.parametrize('url, valid, has_err_string', [
('http://www.example.com/', True, False),
('', False, False),
@@ -643,7 +615,7 @@ class TestInvalidUrlError:
@pytest.mark.parametrize('are_same, url1, url2', [
(True, 'http://example.com', 'http://www.example.com'),
- (True, 'http://bbc.co.uk', 'https://www.bbc.co.uk'),
+ (True, 'http://bbc.co.uk', 'http://www.bbc.co.uk'),
(True, 'http://many.levels.of.domains.example.com', 'http://www.example.com'),
(True, 'http://idn.иком.museum', 'http://idn2.иком.museum'),
(True, 'http://one.not_a_valid_tld', 'http://one.not_a_valid_tld'),
@@ -652,6 +624,9 @@ class TestInvalidUrlError:
(False, 'https://example.kids.museum', 'http://example.kunst.museum'),
(False, 'http://idn.иком.museum', 'http://idn.ירושלים.museum'),
(False, 'http://one.not_a_valid_tld', 'http://two.not_a_valid_tld'),
+
+ (False, 'http://example.org', 'https://example.org'), # different scheme
+ (False, 'http://example.org:80', 'http://example.org:8080'), # different port
])
def test_same_domain(are_same, url1, url2):
"""Test same_domain."""
@@ -702,12 +677,8 @@ def test_data_url():
(QUrl('http://www.example.xn--p1ai'),
'(www.example.xn--p1ai) http://www.example.рф'),
# https://bugreports.qt.io/browse/QTBUG-60364
- pytest.param(QUrl('http://www.xn--80ak6aa92e.com'),
- '(unparseable URL!) http://www.аррӏе.com',
- marks=testutils.qt58),
- pytest.param(QUrl('http://www.xn--80ak6aa92e.com'),
- 'http://www.xn--80ak6aa92e.com',
- marks=testutils.qt59),
+ (QUrl('http://www.xn--80ak6aa92e.com'),
+ 'http://www.xn--80ak6aa92e.com'),
])
def test_safe_display_string(url, expected):
assert urlutils.safe_display_string(url) == expected
@@ -718,11 +689,6 @@ def test_safe_display_string_invalid():
urlutils.safe_display_string(QUrl())
-def test_query_string():
- url = QUrl('https://www.example.com/?foo=bar')
- assert urlutils.query_string(url) == 'foo=bar'
-
-
class TestProxyFromUrl:
@pytest.mark.parametrize('url, expected', [
diff --git a/tests/unit/utils/test_utils.py b/tests/unit/utils/test_utils.py
index 8a07e3411..ac7ed5ce7 100644
--- a/tests/unit/utils/test_utils.py
+++ b/tests/unit/utils/test_utils.py
@@ -25,15 +25,12 @@ import os.path
import io
import logging
import functools
-import socket
import re
import shlex
import math
-import pkg_resources
-import attr
from PyQt5.QtCore import QUrl
-from PyQt5.QtGui import QColor, QClipboard
+from PyQt5.QtGui import QClipboard
import pytest
import hypothesis
from hypothesis import strategies
@@ -41,22 +38,12 @@ import yaml
import qutebrowser
import qutebrowser.utils # for test_qualname
-from qutebrowser.utils import utils, qtutils, version, usertypes
+from qutebrowser.utils import utils, version, usertypes
ELLIPSIS = '\u2026'
-class Color(QColor):
-
- """A QColor with a nicer repr()."""
-
- def __repr__(self):
- return utils.get_repr(self, constructor=True, red=self.red(),
- green=self.green(), blue=self.blue(),
- alpha=self.alpha())
-
-
class TestCompactText:
"""Test compact_text."""
@@ -161,100 +148,6 @@ def test_resource_filename():
assert f.read().splitlines()[0] == "Hello World!"
-class TestInterpolateColor:
-
- """Tests for interpolate_color.
-
- Attributes:
- white: The Color white as a valid Color for tests.
- white: The Color black as a valid Color for tests.
- """
-
- @attr.s
- class Colors:
-
- white = attr.ib()
- black = attr.ib()
-
- @pytest.fixture
- def colors(self):
- """Example colors to be used."""
- return self.Colors(Color('white'), Color('black'))
-
- def test_invalid_start(self, colors):
- """Test an invalid start color."""
- with pytest.raises(qtutils.QtValueError):
- utils.interpolate_color(Color(), colors.white, 0)
-
- def test_invalid_end(self, colors):
- """Test an invalid end color."""
- with pytest.raises(qtutils.QtValueError):
- utils.interpolate_color(colors.white, Color(), 0)
-
- @pytest.mark.parametrize('perc', [-1, 101])
- def test_invalid_percentage(self, colors, perc):
- """Test an invalid percentage."""
- with pytest.raises(ValueError):
- utils.interpolate_color(colors.white, colors.white, perc)
-
- def test_invalid_colorspace(self, colors):
- """Test an invalid colorspace."""
- with pytest.raises(ValueError):
- utils.interpolate_color(colors.white, colors.black, 10,
- QColor.Cmyk)
-
- @pytest.mark.parametrize('colorspace', [QColor.Rgb, QColor.Hsv,
- QColor.Hsl])
- def test_0_100(self, colors, colorspace):
- """Test 0% and 100% in different colorspaces."""
- white = utils.interpolate_color(colors.white, colors.black, 0,
- colorspace)
- black = utils.interpolate_color(colors.white, colors.black, 100,
- colorspace)
- assert Color(white) == colors.white
- assert Color(black) == colors.black
-
- def test_interpolation_rgb(self):
- """Test an interpolation in the RGB colorspace."""
- color = utils.interpolate_color(Color(0, 40, 100), Color(0, 20, 200),
- 50, QColor.Rgb)
- assert Color(color) == Color(0, 30, 150)
-
- def test_interpolation_hsv(self):
- """Test an interpolation in the HSV colorspace."""
- start = Color()
- stop = Color()
- start.setHsv(0, 40, 100)
- stop.setHsv(0, 20, 200)
- color = utils.interpolate_color(start, stop, 50, QColor.Hsv)
- expected = Color()
- expected.setHsv(0, 30, 150)
- assert Color(color) == expected
-
- def test_interpolation_hsl(self):
- """Test an interpolation in the HSL colorspace."""
- start = Color()
- stop = Color()
- start.setHsl(0, 40, 100)
- stop.setHsl(0, 20, 200)
- color = utils.interpolate_color(start, stop, 50, QColor.Hsl)
- expected = Color()
- expected.setHsl(0, 30, 150)
- assert Color(color) == expected
-
- @pytest.mark.parametrize('percentage, expected', [
- (0, (0, 0, 0)),
- (99, (0, 0, 0)),
- (100, (255, 255, 255)),
- ])
- def test_interpolation_none(self, percentage, expected):
- """Test an interpolation with a gradient turned off."""
- color = utils.interpolate_color(Color(0, 0, 0), Color(255, 255, 255),
- percentage, None)
- assert isinstance(color, QColor)
- assert Color(color) == Color(*expected)
-
-
@pytest.mark.parametrize('seconds, out', [
(-1, '-0:01'),
(0, '0:00'),
@@ -750,13 +643,6 @@ class TestGetSetClipboard:
utils.get_clipboard(fallback=True)
-def test_random_port():
- port = utils.random_port()
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- sock.bind(('localhost', port))
- sock.close()
-
-
class TestOpenFile:
@pytest.mark.not_frozen
@@ -805,7 +691,7 @@ class TestOpenFile:
info = version.DistributionInfo(
id='org.kde.Platform',
parsed=version.Distribution.kde_flatpak,
- version=pkg_resources.parse_version('5.12'),
+ version=utils.parse_version('5.12'),
pretty='Unknown')
monkeypatch.setattr(version, 'distribution',
lambda: info)
diff --git a/tests/unit/utils/test_version.py b/tests/unit/utils/test_version.py
index d54899bb1..b4875635e 100644
--- a/tests/unit/utils/test_version.py
+++ b/tests/unit/utils/test_version.py
@@ -25,7 +25,7 @@ import collections
import os.path
import subprocess
import contextlib
-import builtins # noqa https://github.com/JBKahn/flake8-debugger/issues/20
+import builtins
import types
import importlib
import logging
@@ -33,7 +33,6 @@ import textwrap
import datetime
import attr
-import pkg_resources
import pytest
import hypothesis
import hypothesis.strategies
@@ -77,7 +76,7 @@ from qutebrowser.browser import pdfjs
""",
version.DistributionInfo(
id='ubuntu', parsed=version.Distribution.ubuntu,
- version=pkg_resources.parse_version('14.4'),
+ version=utils.parse_version('14.4'),
pretty='Ubuntu 14.04.5 LTS')),
# Ubuntu 17.04
("""
@@ -90,7 +89,7 @@ from qutebrowser.browser import pdfjs
""",
version.DistributionInfo(
id='ubuntu', parsed=version.Distribution.ubuntu,
- version=pkg_resources.parse_version('17.4'),
+ version=utils.parse_version('17.4'),
pretty='Ubuntu 17.04')),
# Debian Jessie
("""
@@ -102,7 +101,7 @@ from qutebrowser.browser import pdfjs
""",
version.DistributionInfo(
id='debian', parsed=version.Distribution.debian,
- version=pkg_resources.parse_version('8'),
+ version=utils.parse_version('8'),
pretty='Debian GNU/Linux 8 (jessie)')),
# Void Linux
("""
@@ -133,7 +132,7 @@ from qutebrowser.browser import pdfjs
""",
version.DistributionInfo(
id='fedora', parsed=version.Distribution.fedora,
- version=pkg_resources.parse_version('25'),
+ version=utils.parse_version('25'),
pretty='Fedora 25 (Twenty Five)')),
# OpenSUSE
("""
@@ -146,7 +145,7 @@ from qutebrowser.browser import pdfjs
""",
version.DistributionInfo(
id='opensuse', parsed=version.Distribution.opensuse,
- version=pkg_resources.parse_version('42.2'),
+ version=utils.parse_version('42.2'),
pretty='openSUSE Leap 42.2')),
# Linux Mint
("""
@@ -159,7 +158,7 @@ from qutebrowser.browser import pdfjs
""",
version.DistributionInfo(
id='linuxmint', parsed=version.Distribution.linuxmint,
- version=pkg_resources.parse_version('18.1'),
+ version=utils.parse_version('18.1'),
pretty='Linux Mint 18.1')),
# Manjaro
("""
@@ -188,7 +187,7 @@ from qutebrowser.browser import pdfjs
""",
version.DistributionInfo(
id='org.kde.Platform', parsed=version.Distribution.kde_flatpak,
- version=pkg_resources.parse_version('5.12'),
+ version=utils.parse_version('5.12'),
pretty='KDE')),
# No PRETTY_NAME
("""
@@ -221,7 +220,7 @@ def test_distribution(tmpdir, monkeypatch, os_release, expected):
(None, False),
(version.DistributionInfo(
id='org.kde.Platform', parsed=version.Distribution.kde_flatpak,
- version=pkg_resources.parse_version('5.12'),
+ version=utils.parse_version('5.12'),
pretty='Unknown'), True),
(version.DistributionInfo(
id='arch', parsed=version.Distribution.arch, version=None,
@@ -562,7 +561,6 @@ class ImportFake:
('pygments', True),
('yaml', True),
('adblock', True),
- ('cssutils', True),
('attr', True),
('PyQt5.QtWebEngineWidgets', True),
('PyQt5.QtWebEngine', True),
@@ -616,7 +614,7 @@ class ImportFake:
def import_fake(monkeypatch):
"""Fixture to patch imports using ImportFake."""
fake = ImportFake()
- monkeypatch.setattr('builtins.__import__', fake.fake_import)
+ monkeypatch.setattr(builtins, '__import__', fake.fake_import)
monkeypatch.setattr(version.importlib, 'import_module',
fake.fake_importlib_import)
return fake
@@ -639,7 +637,6 @@ class TestModuleVersions:
@pytest.mark.parametrize('module, idx, expected', [
('colorama', 1, 'colorama: no'),
('adblock', 6, 'adblock: no'),
- ('cssutils', 7, 'cssutils: no'),
])
def test_missing_module(self, module, idx, expected, import_fake):
"""Test with a module missing.
@@ -690,7 +687,6 @@ class TestModuleVersions:
('pygments', True),
('yaml', True),
('adblock', True),
- ('cssutils', True),
('attr', True),
])
def test_existing_attributes(self, name, has_version):
@@ -703,8 +699,6 @@ class TestModuleVersions:
name: The name of the module to check.
has_version: Whether a __version__ attribute is expected.
"""
- if name == 'cssutils':
- pytest.importorskip(name)
module = importlib.import_module(name)
assert hasattr(module, '__version__') == has_version
@@ -1032,7 +1026,7 @@ def test_version_info(params, stubs, monkeypatch, config_stub):
substitutions['ssl'] = 'SSL VERSION' if params.ssl_support else 'no'
for name, val in patches.items():
- monkeypatch.setattr('qutebrowser.utils.version.' + name, val)
+ monkeypatch.setattr(f'qutebrowser.utils.version.{name}', val)
if params.frozen:
monkeypatch.setattr(sys, 'frozen', True, raising=False)
@@ -1147,9 +1141,8 @@ 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_info',
- lambda: "dummy")
- monkeypatch.setattr('qutebrowser.utils.utils.log_clipboard', True)
+ monkeypatch.setattr(version, 'version_info', lambda: 'dummy')
+ monkeypatch.setattr(utils, 'log_clipboard', True)
version.pastebin_version(pbclient)
pbclient.success.emit("https://www.example.com/\n")
@@ -1162,8 +1155,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_info',
- lambda: "dummy")
+ monkeypatch.setattr(version, 'version_info', lambda: 'dummy')
version.pastebin_version(pbclient)
pbclient.success.emit("https://www.example.com/\n")
@@ -1180,8 +1172,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_info',
- lambda: "dummy")
+ monkeypatch.setattr(version, 'version_info', lambda: 'dummy')
version.pastebin_url = None
with caplog.at_level(logging.ERROR):
@@ -1201,7 +1192,7 @@ def test_uptime(monkeypatch, qapp):
class FakeDateTime(datetime.datetime):
now = lambda x=datetime.datetime(1, 1, 1, 1, 1, 1, 2): x
- monkeypatch.setattr('datetime.datetime', FakeDateTime)
+ monkeypatch.setattr(datetime, 'datetime', FakeDateTime)
uptime_delta = version._uptime()
assert uptime_delta == datetime.timedelta(0)
diff --git a/tests/unit/utils/usertypes/test_question.py b/tests/unit/utils/usertypes/test_question.py
index 014ef7f0c..59c3f7d43 100644
--- a/tests/unit/utils/usertypes/test_question.py
+++ b/tests/unit/utils/usertypes/test_question.py
@@ -53,25 +53,23 @@ def test_done(mode, answer, signal_names, question, qtbot):
question.mode = mode
question.answer = answer
signals = [getattr(question, name) for name in signal_names]
- blockers = [qtbot.waitSignal(signal) for signal in signals]
-
- question.done()
- for blocker in blockers:
- blocker.wait()
-
+ with qtbot.waitSignals(signals, order='strict'):
+ question.done()
assert not question.is_aborted
def test_cancel(question, qtbot):
"""Test Question.cancel()."""
- with qtbot.waitSignal(question.cancelled), qtbot.waitSignal(question.completed):
+ with qtbot.waitSignals([question.cancelled, question.completed],
+ order='strict'):
question.cancel()
assert not question.is_aborted
def test_abort(question, qtbot):
"""Test Question.abort()."""
- with qtbot.waitSignal(question.aborted), qtbot.waitSignal(question.completed):
+ with qtbot.waitSignals([question.aborted, question.completed],
+ order='strict'):
question.abort()
assert question.is_aborted
diff --git a/tox.ini b/tox.ini
index bfc1f2b49..73baf89d7 100644
--- a/tox.ini
+++ b/tox.ini
@@ -12,8 +12,8 @@ minversion = 3.15
[testenv]
setenv =
PYTEST_QT_API=pyqt5
- 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
+ pyqt{,512,513,514,515}: LINK_PYQT_SKIP=true
+ pyqt{,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 XDG_* QUTE_* DOCKER QT_QUICK_BACKEND PY_COLORS
basepython =
@@ -22,15 +22,10 @@ basepython =
py37: {env:PYTHON:python3.7}
py38: {env:PYTHON:python3.8}
py39: {env:PYTHON:python3.9}
-pip_version = pip
deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/misc/requirements/requirements-tests.txt
pyqt: -r{toxinidir}/misc/requirements/requirements-pyqt.txt
- pyqt57: -r{toxinidir}/misc/requirements/requirements-pyqt-5.7.txt
- pyqt59: -r{toxinidir}/misc/requirements/requirements-pyqt-5.9.txt
- pyqt510: -r{toxinidir}/misc/requirements/requirements-pyqt-5.10.txt
- pyqt511: -r{toxinidir}/misc/requirements/requirements-pyqt-5.11.txt
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
@@ -45,19 +40,14 @@ commands =
[testenv:misc]
ignore_errors = true
basepython = {env:PYTHON:python3}
-pip_version = pip
# For global .gitignore files
passenv = HOME
deps =
commands =
- {envpython} scripts/dev/misc_checks.py git
- {envpython} scripts/dev/misc_checks.py vcs
- {envpython} scripts/dev/misc_checks.py spelling
- {envpython} scripts/dev/misc_checks.py userscripts
+ {envpython} scripts/dev/misc_checks.py all
[testenv:vulture]
basepython = {env:PYTHON:python3}
-pip_version = pip
deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/misc/requirements/requirements-vulture.txt
@@ -68,7 +58,6 @@ commands =
[testenv:vulture-pyqtlink]
basepython = {env:PYTHON:python3}
-pip_version = pip
deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/misc/requirements/requirements-vulture.txt
@@ -79,7 +68,6 @@ commands =
[testenv:pylint]
basepython = {env:PYTHON:python3}
-pip_version = pip
ignore_errors = true
passenv =
deps =
@@ -93,7 +81,6 @@ commands =
[testenv:pylint-pyqtlink]
basepython = {env:PYTHON:python3}
-pip_version = pip
ignore_errors = true
passenv =
deps =
@@ -107,7 +94,6 @@ commands =
[testenv:pylint-master]
basepython = {env:PYTHON:python3}
-pip_version = pip
passenv = {[testenv:pylint]passenv}
deps =
-r{toxinidir}/requirements.txt
@@ -120,7 +106,6 @@ commands =
[testenv:flake8]
basepython = {env:PYTHON:python3}
-pip_version = pip
passenv =
deps =
-r{toxinidir}/requirements.txt
@@ -130,7 +115,6 @@ commands =
[testenv:pyroma]
basepython = {env:PYTHON:python3}
-pip_version = pip
passenv =
deps =
-r{toxinidir}/misc/requirements/requirements-pyroma.txt
@@ -139,7 +123,6 @@ commands =
[testenv:check-manifest]
basepython = {env:PYTHON:python3}
-pip_version = pip
passenv =
deps =
-r{toxinidir}/misc/requirements/requirements-check-manifest.txt
@@ -148,7 +131,6 @@ commands =
[testenv:docs]
basepython = {env:PYTHON:python3}
-pip_version = pip
whitelist_externals = git
passenv = CI GITHUB_REF
deps =
@@ -161,7 +143,6 @@ commands =
[testenv:pyinstaller-{64,32}]
basepython = {env:PYTHON:python3}
-pip_version = pip
passenv = APPDATA HOME PYINSTALLER_DEBUG
deps =
-r{toxinidir}/requirements.txt
@@ -186,7 +167,6 @@ commands = bash scripts/dev/run_shellcheck.sh {posargs}
[testenv:mypy]
basepython = {env:PYTHON:python3}
-pip_version = pip
passenv = TERM MYPY_FORCE_TERMINAL_WIDTH
deps =
-r{toxinidir}/requirements.txt
@@ -198,14 +178,12 @@ commands =
[testenv:yamllint]
basepython = {env:PYTHON:python3}
-pip_version = pip
deps = -r{toxinidir}/misc/requirements/requirements-yamllint.txt
commands =
{envpython} -m yamllint -f colored --strict . {posargs}
[testenv:mypy-diff]
basepython = {env:PYTHON:python3}
-pip_version = pip
passenv = {[testenv:mypy]passenv}
deps = {[testenv:mypy]deps}
commands =
@@ -214,7 +192,6 @@ commands =
[testenv:sphinx]
basepython = {env:PYTHON:python3}
-pip_version = pip
passenv =
usedevelop = true
deps =
@@ -226,7 +203,6 @@ commands =
[testenv:build-release]
basepython = {env:PYTHON:python3}
-pip_version = pip
passenv = *
usedevelop = true
deps =