summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2022-05-09 20:06:35 +0200
committerFlorian Bruhin <me@the-compiler.org>2022-06-22 17:41:11 +0200
commit99b937b4eb515d87eaa817c1421b8d0e42837f4e (patch)
treee9e3392591a20c02147a3f13789d5b92778bf32e
parent5cef34e0d6aac9ab4cd8cf1c78065ae26f6670f0 (diff)
downloadqutebrowser-99b937b4eb515d87eaa817c1421b8d0e42837f4e.tar.gz
qutebrowser-99b937b4eb515d87eaa817c1421b8d0e42837f4e.zip
tests: Skip broken PDF.js installations
See #7135 TODO: cherry-pick to master?
-rw-r--r--tests/end2end/features/conftest.py17
-rw-r--r--tests/end2end/features/downloads.feature2
-rw-r--r--tests/end2end/features/qutescheme.feature5
3 files changed, 20 insertions, 4 deletions
diff --git a/tests/end2end/features/conftest.py b/tests/end2end/features/conftest.py
index 4504b4f20..5ae4f5d41 100644
--- a/tests/end2end/features/conftest.py
+++ b/tests/end2end/features/conftest.py
@@ -35,8 +35,9 @@ import pytest
import pytest_bdd as bdd
import qutebrowser
-from qutebrowser.utils import log, utils, docutils
+from qutebrowser.utils import log, utils, docutils, version
from qutebrowser.browser import pdfjs
+from end2end.fixtures import testprocess
from helpers import testutils
@@ -436,6 +437,20 @@ def update_documentation():
subprocess.run([sys.executable, update_script], check=True)
+@bdd.when("I wait until PDF.js is loaded")
+def wait_pdfjs(quteproc):
+ quteproc.wait_for(message="load status for <qutebrowser.browser.* "
+ "tab_id=* url='qute://pdfjs/web/viewer.html?*'>: LoadStatus.success")
+ try:
+ quteproc.wait_for(message="[qute://pdfjs/web/viewer.html?*] Uncaught TypeError: Cannot read property 'set' of undefined", timeout=100)
+ except testprocess.WaitForTimeout:
+ pass
+ else:
+ pytest.skip(f"Non-legacy PDF.js installation: {version._pdfjs_version()}")
+
+ quteproc.wait_for(message="[qute://pdfjs/*] PDF * (PDF.js: *)")
+
+
## Then
diff --git a/tests/end2end/features/downloads.feature b/tests/end2end/features/downloads.feature
index af59838cd..9ed77f317 100644
--- a/tests/end2end/features/downloads.feature
+++ b/tests/end2end/features/downloads.feature
@@ -646,7 +646,7 @@ Feature: Downloading things from a website.
When I set downloads.location.prompt to false
And I set content.pdfjs to true
And I open data/misc/test.pdf without waiting
- And I wait for the javascript message "PDF * [*] (PDF.js: *)"
+ And I wait until PDF.js is loaded
And I run :click-element id download
And I wait until the download is finished
# We get viewer.html as name on QtWebKit...
diff --git a/tests/end2end/features/qutescheme.feature b/tests/end2end/features/qutescheme.feature
index 039434f1c..1753aa264 100644
--- a/tests/end2end/features/qutescheme.feature
+++ b/tests/end2end/features/qutescheme.feature
@@ -176,7 +176,8 @@ Feature: Special qute:// pages
Given pdfjs is available
When I set content.pdfjs to true
And I open data/misc/test.pdf without waiting
- Then the javascript message "PDF * [*] (PDF.js: *)" should be logged
+ And I wait until PDF.js is loaded
+ # No "Then"
@qtwebkit_pdf_imageformat_skip
Scenario: pdfjs is not used when disabled
@@ -190,7 +191,7 @@ Feature: Special qute:// pages
When I set content.pdfjs to true
And I set downloads.location.prompt to true
And I open data/misc/test.pdf without waiting
- And I wait for "[qute://pdfjs/*] PDF * (PDF.js: *)" in the log
+ And I wait until PDF.js is loaded
And I run :jseval document.getElementById("download").click()
And I wait for "Asking question <qutebrowser.utils.usertypes.Question default=* mode=<PromptMode.download: 5> option=None text=* title='Save file to:'>, *" in the log
And I run :mode-leave