Make prompt tests run

This commit is contained in:
Florian Bruhin 2016-11-10 10:26:27 +01:00
parent 6697d692e1
commit d93bc8b26b
4 changed files with 35 additions and 15 deletions

View File

@ -130,12 +130,12 @@ class WebEnginePage(QWebEnginePage):
self.certificate_error.emit()
url = error.url()
error = webenginetab.CertificateErrorWrapper(error)
log.webview.debug("Certificate error: {}".format(error))
# FIXME
error_page = jinja.render('error.html',
title="Error while loading page",
url=url.toDisplayString(), error=str(error),
icon='', qutescheme=False)
url_string = url.toDisplayString()
error_page = jinja.render(
'error.html', title="Error loading page: {}".format(url_string),
url=url_string, error=str(error), icon='')
if not error.is_overridable():
log.webview.error("Non-overridable certificate error: "
@ -147,7 +147,6 @@ class WebEnginePage(QWebEnginePage):
url, [error], abort_on=[self.loadStarted, self.shutting_down])
if not ignore:
log.webview.error("Certificate error: {}".format(error))
self.setHtml(error_page)
return ignore

View File

@ -234,7 +234,8 @@ class NetworkManager(QNetworkAccessManager):
errors: A list of errors.
"""
errors = [webkittab.CertificateErrorWrapper(e) for e in errors]
log.webview.debug("Certificate errors {!r}".format(errors))
log.webview.debug("Certificate errors: {!r}".format(
' / '.join(str(err) for err in errors)))
try:
host_tpl = urlutils.host_tuple(reply.url())
except ValueError:

View File

@ -167,7 +167,7 @@ Feature: Prompts
# SSL
Scenario: SSL error with ssl-strict = false
When I run :debug-clear-ssl-errors
When I clear SSL errors
And I set network -> ssl-strict to false
And I load an SSL page
And I wait until the SSL page finished loading
@ -175,14 +175,13 @@ Feature: Prompts
And the page should contain the plaintext "Hello World via SSL!"
Scenario: SSL error with ssl-strict = true
When I run :debug-clear-ssl-errors
When I clear SSL errors
And I set network -> ssl-strict to true
And I load an SSL page
Then "Error while loading *: SSL handshake failed" should be logged
And the page should contain the plaintext "Unable to load page"
Then a SSL error page should be shown
Scenario: SSL error with ssl-strict = ask -> yes
When I run :debug-clear-ssl-errors
When I clear SSL errors
And I set network -> ssl-strict to ask
And I load an SSL page
And I wait for a prompt
@ -191,13 +190,12 @@ Feature: Prompts
Then the page should contain the plaintext "Hello World via SSL!"
Scenario: SSL error with ssl-strict = ask -> no
When I run :debug-clear-ssl-errors
When I clear SSL errors
And I set network -> ssl-strict to ask
And I load an SSL page
And I wait for a prompt
And I run :prompt-accept no
Then "Error while loading *: SSL handshake failed" should be logged
And the page should contain the plaintext "Unable to load page"
Then a SSL error page should be shown
# Geolocation
@ -469,6 +467,7 @@ Feature: Prompts
# https://github.com/The-Compiler/qutebrowser/issues/1249#issuecomment-175205531
# https://github.com/The-Compiler/qutebrowser/pull/2054#issuecomment-258285544
@qtwebengine_todo: Permissions are not implemented yet
Scenario: Interrupting SSL prompt during a notification prompt
When I set content -> notifications to ask
And I set network -> ssl-strict to ask

View File

@ -22,6 +22,15 @@ import pytest_bdd as bdd
bdd.scenarios('prompts.feature')
@bdd.when("I clear SSL errors")
def clear_ssl_errors(request, quteproc):
if request.config.webengine:
quteproc.terminate()
quteproc.start()
else:
quteproc.send_cmd(':debug-clear-ssl-errors')
@bdd.when("I load an SSL page")
def load_ssl_page(quteproc, ssl_server):
# We don't wait here as we can get an SSL question.
@ -43,3 +52,15 @@ def wait_for_prompt(quteproc):
def no_prompt_shown(quteproc):
quteproc.ensure_not_logged(message='Entering mode KeyMode.* (reason: '
'question asked)')
@bdd.then("a SSL error page should be shown")
def ssl_error_page(request, quteproc):
if not request.config.webengine:
line = quteproc.wait_for(message='Error while loading *: SSL '
'handshake failed')
line.expected = True
quteproc.wait_for(message="Changing title for idx * to 'Error "
"loading page: *'")
content = quteproc.get_content().strip()
assert "Unable to load page" in content