Add test around remembering permissions across restart

Qt 6.8 has its own permission grant persistence features. This means
that if you accept a permission prompt in qutebrowser, and don't save
it, it will be remembered by webengine anyway and you won't be
re-prompted again.

This test demonstrates that behaviour by temporarily granting a
permission, restarting the browser in the same basedir, then seeing if
we get prompted for the permission again or not. If not it fails on the
"Asking question" line.

We can't do much about re-prompting for a permission in the same browser
instance (Qt saves the permission grant in memory too) but we can clean
up the persisted permission files on browser starts so it doesn't
remember it forever. At that point the skip mark can be removed from
this test.
This commit is contained in:
toofar 2024-10-13 17:59:00 +13:00
parent 7475d385ac
commit dfd4fffaac
1 changed files with 28 additions and 0 deletions

View File

@ -636,6 +636,34 @@ def test_cookies_store(quteproc_new, request, short_tmpdir, store):
quteproc_new.wait_for_quit()
@pytest.mark.qt68_beta4_skip
def test_permission_prompt_across_restart(quteproc_new, request, short_tmpdir):
# Start test process
args = _base_args(request.config) + [
'--basedir', str(short_tmpdir),
'-s', 'content.notifications.enabled', 'ask',
]
quteproc_new.start(args)
def notification_prompt(answer):
quteproc_new.open_path('data/prompt/notifications.html')
quteproc_new.send_cmd(':click-element id button')
quteproc_new.wait_for(message='Asking question *')
quteproc_new.send_cmd(f':prompt-accept {answer}')
# Make sure we are prompted the first time we are opened in this basedir
notification_prompt('yes')
quteproc_new.wait_for_js('notification permission granted')
# Restart with same basedir
quteproc_new.send_cmd(':quit')
quteproc_new.wait_for_quit()
quteproc_new.start(args)
# We should be re-prompted in the new instance
notification_prompt('no')
# The 'colors' dictionaries in the parametrize decorator below have (QtWebEngine
# version, CPU architecture) as keys. Either of those (or both) can be None to
# say "on all other Qt versions" or "on all other CPU architectures".