diff --git a/qutebrowser/browser/pdfjs.py b/qutebrowser/browser/pdfjs.py index b0cff11d3..83b89330c 100644 --- a/qutebrowser/browser/pdfjs.py +++ b/qutebrowser/browser/pdfjs.py @@ -163,3 +163,13 @@ def _read_from_system(system_path, names): except OSError: continue return None + + +def is_available(): + """Return true if a pdfjs installation is available.""" + try: + get_pdfjs_res('build/pdf.js') + except PDFJSNotFound: + return False + else: + return True diff --git a/tests/integration/data/misc/test.pdf b/tests/integration/data/misc/test.pdf new file mode 100644 index 000000000..6bd5f16be Binary files /dev/null and b/tests/integration/data/misc/test.pdf differ diff --git a/tests/integration/features/misc.feature b/tests/integration/features/misc.feature index ea033405d..78c565d26 100644 --- a/tests/integration/features/misc.feature +++ b/tests/integration/features/misc.feature @@ -243,3 +243,17 @@ Feature: Various utility commands. When I set general -> startpage to http://localhost:(port)/data/numbers/1.txt,http://localhost:(port)/data/numbers/2.txt And I run :home Then data/numbers/1.txt should be loaded + + # pdfjs support + + Scenario: pdfjs is used for pdf files + Given pdfjs is available + When I set content -> enable-pdfjs to true + And I open data/misc/test.pdf + Then the javascript message "PDF * [*] (PDF.js: *)" should be logged + + Scenario: pdfjs is not used when disabled + When I set content -> enable-pdfjs to false + And I set storage -> prompt-download-directory to false + And I open data/misc/test.pdf + Then "Download finished" should be logged diff --git a/tests/integration/features/test_misc.py b/tests/integration/features/test_misc.py index f92d3fc47..4700be8a6 100644 --- a/tests/integration/features/test_misc.py +++ b/tests/integration/features/test_misc.py @@ -17,5 +17,16 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +import pytest import pytest_bdd as bdd + +from qutebrowser.browser import pdfjs + + bdd.scenarios('misc.feature') + + +@bdd.given('pdfjs is available') +def pdfjs_available(): + if not pdfjs.is_available(): + pytest.skip("No pdfjs installation found.")