tests: Fix JS header tests

This is a follow-up to f0eed465ab
See #4657
This commit is contained in:
Florian Bruhin 2020-06-19 16:21:03 +02:00
parent 5929bf81ce
commit a6817bd086
3 changed files with 18 additions and 3 deletions

View File

@ -30,6 +30,7 @@ markers =
fake_os: Fake utils.is_* to a fake operating system
unicode_locale: Tests which need an unicode locale to work
qtwebkit6021_xfail: Tests which would fail on WebKit version 602.1
js_headers: Sets JS headers dynamically on QtWebEngine (unsupported on some versions)
qt_log_level_fail = WARNING
qt_log_ignore =
^SpellCheck: .*

View File

@ -137,6 +137,11 @@ if not getattr(sys, 'frozen', False):
def pytest_collection_modifyitems(config, items):
"""Apply @qtwebengine_* markers; skip unittests with QUTE_BDD_WEBENGINE."""
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-75884
# (note this isn't actually fixed properly before Qt 5.15)
header_bug_fixed = (not qtutils.version_check('5.12', compiled=False) or
qtutils.version_check('5.15', compiled=False))
markers = [
('qtwebengine_todo', 'QtWebEngine TODO', pytest.mark.xfail,
config.webengine),
@ -152,6 +157,9 @@ def pytest_collection_modifyitems(config, items):
config.webengine),
('qtwebengine_mac_xfail', 'Fails on macOS with QtWebEngine',
pytest.mark.xfail, config.webengine and utils.is_mac),
('js_headers', 'Sets headers dynamically via JS',
pytest.mark.skipif,
config.webengine and not header_bug_fixed),
]
for item in items:

View File

@ -349,18 +349,24 @@ Feature: Various utility commands.
# This still doesn't set window.navigator.language
# See https://bugreports.qt.io/browse/QTBUG-61949
@qtwebkit_skip
@qtwebkit_skip @js_headers
Scenario: Accept-Language header (JS)
When I set content.headers.accept_language to it,fr
And I run :jseval console.log(window.navigator.languages)
Then the javascript message "it,fr" should be logged
Scenario: Setting a custom user-agent header
Scenario: User-agent header
When I set content.headers.user_agent to toaster
And I open headers
And I run :jseval console.log(window.navigator.userAgent)
Then the header User-Agent should be set to toaster
And the javascript message "toaster" should be logged
@js_headers
Scenario: User-agent header (JS)
When I set content.headers.user_agent to toaster
And I open about:blank
And I run :jseval console.log(window.navigator.userAgent)
Then the javascript message "toaster" should be logged
## https://github.com/qutebrowser/qutebrowser/issues/1523