diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 051f86487..addde7ef5 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -179,6 +179,7 @@ Fixed - Fixed hang when using multiple spaces in a row with the URL completion - Fixed crash when closing a window without focusing it - Userscripts now can access QUTE_FIFO correctly on Windows +- Compatibility with pdfjs v1.6.210 v0.8.3 (unreleased) ------------------- diff --git a/qutebrowser/browser/pdfjs.py b/qutebrowser/browser/pdfjs.py index 51ed2dfbe..3bc2c2dc3 100644 --- a/qutebrowser/browser/pdfjs.py +++ b/qutebrowser/browser/pdfjs.py @@ -62,8 +62,10 @@ def _generate_pdfjs_script(url): url: The url of the pdf page as QUrl. """ return ( - 'PDFJS.verbosity = PDFJS.VERBOSITY_LEVELS.info;\n' - 'PDFView.open("{url}");\n' + 'document.addEventListener("DOMContentLoaded", function() {{\n' + ' PDFJS.verbosity = PDFJS.VERBOSITY_LEVELS.info;\n' + ' (window.PDFView || window.PDFViewerApplication).open("{url}");\n' + '}});\n' ).format(url=javascript.string_escape(url.toString(QUrl.FullyEncoded))) diff --git a/tests/unit/browser/test_pdfjs.py b/tests/unit/browser/test_pdfjs.py index ad489bc7a..a33dae5bf 100644 --- a/tests/unit/browser/test_pdfjs.py +++ b/tests/unit/browser/test_pdfjs.py @@ -36,11 +36,11 @@ from qutebrowser.browser import pdfjs 'http://foobar/%22);alert(%22attack!%22);'), ]) def test_generate_pdfjs_script(url, expected): - expected_code = ('PDFJS.verbosity = PDFJS.VERBOSITY_LEVELS.info;\n' - 'PDFView.open("{}");\n'.format(expected)) + expected_open = 'open("{}");'.format(expected) url = QUrl(url) actual = pdfjs._generate_pdfjs_script(url) - assert actual == expected_code + assert expected_open in actual + assert 'PDFView' in actual def test_fix_urls():