diff --git a/qutebrowser/browser/pdfjs.py b/qutebrowser/browser/pdfjs.py index db849cb04..da6dcbfe6 100644 --- a/qutebrowser/browser/pdfjs.py +++ b/qutebrowser/browser/pdfjs.py @@ -89,6 +89,7 @@ def _generate_pdfjs_script(filename): # 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)) diff --git a/tests/unit/browser/test_pdfjs.py b/tests/unit/browser/test_pdfjs.py index 43bb2c38e..ff62545bd 100644 --- a/tests/unit/browser/test_pdfjs.py +++ b/tests/unit/browser/test_pdfjs.py @@ -21,7 +21,7 @@ import pytest from PyQt5.QtCore import QUrl from qutebrowser.browser import pdfjs -from qutebrowser.utils import usertypes +from qutebrowser.utils import usertypes, utils @pytest.mark.parametrize('available, snippet', [ @@ -61,15 +61,30 @@ def test_generate_pdfjs_script(filename, expected): assert 'PDFView' in actual -@pytest.mark.parametrize('new_qt, backend, expected', [ - (True, usertypes.Backend.QtWebEngine, False), - (True, usertypes.Backend.QtWebKit, False), - (False, usertypes.Backend.QtWebEngine, True), - (False, usertypes.Backend.QtWebKit, False), +@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, - new_qt, backend, expected): - monkeypatch.setattr(pdfjs.qtutils, 'version_check', lambda _v: new_qt) + qt, backend, expected): + if qt == 'new': + monkeypatch.setattr(pdfjs.qtutils, 'version_check', + lambda version, exact=False, compiled=True: + False if version == '5.7.1' else True) + 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: + True if version == '5.7.1' else False) + else: + raise utils.Unreachable + monkeypatch.setattr(pdfjs.objects, 'backend', backend) script = pdfjs._generate_pdfjs_script('testfile')