Merge branch 'pdfjs-1.6.210' of https://github.com/Kingdread/qutebrowser into Kingdread-pdfjs-1.6.210

This commit is contained in:
Florian Bruhin 2016-10-06 22:52:44 +02:00
commit c40539c7e9
2 changed files with 7 additions and 5 deletions

View File

@ -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)))

View File

@ -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():