From ffa276a1826a95bf1f80b15f48cfbf2b9cfe6dad Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Thu, 6 Oct 2016 14:43:16 +0200 Subject: [PATCH 1/3] pdfjs: compatibility for v1.6.210 They renamed PDFView to PDFViewerApplication, which we need to account for in our pdfjs scripts. Also, it seems like the actual viewer is now only created when the DOM has been loaded. This means that at the time when our script is executed, the viewer does not yet exist. Thus we need to delay the open request too by registering a DOMContentLoaded handler. --- qutebrowser/browser/pdfjs.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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))) From a9ac123bfa034c5c36ac0528d74b61a2dd492a0a Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Thu, 6 Oct 2016 16:18:21 +0200 Subject: [PATCH 2/3] tests: relax pdfjs tests Updating the whole snippet in two places is bad, so we relax the testing code. --- tests/unit/browser/test_pdfjs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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(): From 9ad4d46599f3a576462643fb0ec326cbd12bc3e1 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 6 Oct 2016 22:58:45 +0200 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.asciidoc | 1 + 1 file changed, 1 insertion(+) 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) -------------------