Move new permission API check from pytest markers to BDD step
For tests that do the same prompt in the same session, they are failing on Qt6.8 and PyQWebEnginet6.7 because we can't disable the new WebEngine behaviour. We can work around this by getting a fresh instance for each test, but I don't want to make more tests slower if I don't have to. So move that logic into a custom "fresh instance" prompt that will only create one when needed.
This commit is contained in:
parent
0192b58a6a
commit
f551bbbb76
|
|
@ -41,7 +41,6 @@ markers =
|
|||
qt6_only: Tests which should only run with Qt 6
|
||||
qt5_xfail: Tests which fail with Qt 5
|
||||
qt6_xfail: Tests which fail with Qt 6
|
||||
qt68_no_permission_api: Fails on Qt 6.8 with PyQt<6.8
|
||||
qt_log_level_fail = WARNING
|
||||
qt_log_ignore =
|
||||
# GitHub Actions
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import pstats
|
|||
import operator
|
||||
|
||||
import pytest
|
||||
from qutebrowser.qt import machinery
|
||||
from qutebrowser.qt.core import PYQT_VERSION, QCoreApplication
|
||||
|
||||
pytest.register_assert_rewrite('end2end.fixtures')
|
||||
|
|
@ -29,7 +28,7 @@ from end2end.fixtures.quteprocess import (
|
|||
)
|
||||
from end2end.fixtures.testprocess import pytest_runtest_makereport
|
||||
# pylint: enable=unused-import
|
||||
from qutebrowser.utils import qtutils, utils, version
|
||||
from qutebrowser.utils import qtutils, utils
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
|
|
@ -192,12 +191,6 @@ def pytest_collection_modifyitems(config, items):
|
|||
'Skipped on Windows',
|
||||
pytest.mark.skipif,
|
||||
utils.is_windows),
|
||||
('qt68_no_permission_api', # WORKAROUND: https://github.com/qutebrowser/qutebrowser/issues/8242#issuecomment-2184542226
|
||||
"Fails on Qt 6.8 with PyQt<6.8",
|
||||
pytest.mark.xfail,
|
||||
machinery.IS_QT6 and version.qtwebengine_versions(
|
||||
avoid_init=True
|
||||
).webengine == utils.VersionNumber(6, 8) and version.PYQT_WEBENGINE_VERSION_STR < '6.8.0'),
|
||||
]
|
||||
|
||||
for item in items:
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ Feature: Prompts
|
|||
|
||||
@qt>=6.8
|
||||
Scenario: Clipboard - ask allow - copy
|
||||
Given I have a fresh instance
|
||||
Given I may need a fresh instance
|
||||
When I set content.javascript.clipboard to ask
|
||||
And I open data/prompt/clipboard.html
|
||||
And I run :click-element id copy
|
||||
|
|
@ -216,7 +216,7 @@ Feature: Prompts
|
|||
|
||||
@qt>=6.8
|
||||
Scenario: Clipboard - ask allow - paste
|
||||
Given I have a fresh instance
|
||||
Given I may need a fresh instance
|
||||
When I set content.javascript.clipboard to ask
|
||||
And I open data/prompt/clipboard.html
|
||||
And I run :click-element id paste
|
||||
|
|
@ -226,7 +226,7 @@ Feature: Prompts
|
|||
|
||||
@qt>=6.8
|
||||
Scenario: Clipboard - ask deny - copy
|
||||
Given I have a fresh instance
|
||||
Given I may need a fresh instance
|
||||
When I set content.javascript.clipboard to ask
|
||||
And I open data/prompt/clipboard.html
|
||||
And I run :click-element id copy
|
||||
|
|
@ -236,7 +236,7 @@ Feature: Prompts
|
|||
|
||||
@qt>=6.8
|
||||
Scenario: Clipboard - ask deny - paste
|
||||
Given I have a fresh instance
|
||||
Given I may need a fresh instance
|
||||
When I set content.javascript.clipboard to ask
|
||||
And I open data/prompt/clipboard.html
|
||||
And I run :click-element id paste
|
||||
|
|
@ -358,8 +358,8 @@ Feature: Prompts
|
|||
And I run :click-element id button
|
||||
Then the javascript message "geolocation permission denied" should be logged
|
||||
|
||||
@qt68_no_permission_api
|
||||
Scenario: geolocation with ask -> false
|
||||
Given I may need a fresh instance
|
||||
When I set content.geolocation to ask
|
||||
And I open data/prompt/geolocation.html in a new tab
|
||||
And I run :click-element id button
|
||||
|
|
@ -367,8 +367,8 @@ Feature: Prompts
|
|||
And I run :prompt-accept no
|
||||
Then the javascript message "geolocation permission denied" should be logged
|
||||
|
||||
@qt68_no_permission_api
|
||||
Scenario: geolocation with ask -> false and save
|
||||
Given I may need a fresh instance
|
||||
When I set content.geolocation to ask
|
||||
And I open data/prompt/geolocation.html in a new tab
|
||||
And I run :click-element id button
|
||||
|
|
@ -377,8 +377,8 @@ Feature: Prompts
|
|||
Then the javascript message "geolocation permission denied" should be logged
|
||||
And the per-domain option content.geolocation should be set to false for http://localhost:(port)
|
||||
|
||||
@qt68_no_permission_api
|
||||
Scenario: geolocation with ask -> abort
|
||||
Given I may need a fresh instance
|
||||
When I set content.geolocation to ask
|
||||
And I open data/prompt/geolocation.html in a new tab
|
||||
And I run :click-element id button
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import logging
|
|||
import pytest_bdd as bdd
|
||||
bdd.scenarios('prompts.feature')
|
||||
|
||||
from qutebrowser.utils import qtutils, version
|
||||
|
||||
|
||||
@bdd.when("I load an SSL page")
|
||||
def load_ssl_page(quteproc, ssl_server):
|
||||
|
|
@ -37,6 +39,20 @@ def wait_for_prompt(quteproc):
|
|||
quteproc.wait_for(message='Asking question *')
|
||||
|
||||
|
||||
@bdd.given("I may need a fresh instance")
|
||||
def fresh_instance(quteproc):
|
||||
"""Restart qutebrowser to bypass webengine's permission persistance."""
|
||||
# Qt6.8 by default will remember feature grants or denies. When we are
|
||||
# on PyQt6.8 we disable that with the new API, otherwise restart the
|
||||
# browser to make it forget previous prompts.
|
||||
if (
|
||||
qtutils.version_check("6.8", compiled=False)
|
||||
and version.PYQT_WEBENGINE_VERSION_STR < "6.8.0"
|
||||
):
|
||||
quteproc.terminate()
|
||||
quteproc.start()
|
||||
|
||||
|
||||
@bdd.then("no prompt should be shown")
|
||||
def no_prompt_shown(quteproc):
|
||||
quteproc.ensure_not_logged(message='Entering mode KeyMode.* (reason: '
|
||||
|
|
|
|||
Loading…
Reference in New Issue