summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorKirill Burtsev <kirill.burtsev@qt.io>2021-06-09 12:20:42 +0000
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-08-10 21:03:27 +0000
commit513c5435536c041eb89136fbc322a68e38caf845 (patch)
treed0eb7504e526169b2d6075ca7652af76a0828c60 /tests/auto
parentf21f37496501199d0e50b3b4375add235a05a3ec (diff)
Revert "Remove certificate fatal error test"
This reverts commit 3cdf6827de796b49fb49f94a18906303732bb93f. Reason for revert: The test didn't work and was skipped due to real regression Change-Id: I6f3c87a0d1561a32465da61a811edc753e69c24b Reviewed-by: Michal Klocek <michal.klocek@qt.io> (cherry picked from commit 8427a3e370291598ccd7f6f3a843cc1ba90109ae) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/core/certificateerror/tst_certificateerror.cpp17
-rw-r--r--tests/auto/quick/qmltests/data/tst_certificateError.qml17
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/core/certificateerror/tst_certificateerror.cpp b/tests/auto/core/certificateerror/tst_certificateerror.cpp
index a2b15a1ae..da679fa8a 100644
--- a/tests/auto/core/certificateerror/tst_certificateerror.cpp
+++ b/tests/auto/core/certificateerror/tst_certificateerror.cpp
@@ -43,6 +43,7 @@ public:
private Q_SLOTS:
void handleError_data();
void handleError();
+ void fatalError();
};
struct PageWithCertificateErrorHandler : QWebEnginePage
@@ -131,5 +132,21 @@ void tst_CertificateError::handleError()
QCOMPARE(toPlainTextSync(&page), expectedContent);
}
+void tst_CertificateError::fatalError()
+{
+ PageWithCertificateErrorHandler page(false, false);
+ page.settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false);
+ QSignalSpy loadFinishedSpy(&page, &QWebEnginePage::loadFinished);
+
+ page.setUrl(QUrl("https://revoked.badssl.com"));
+ if (!loadFinishedSpy.wait(10000))
+ QSKIP("Couldn't load page from network, skipping test.");
+ QTRY_VERIFY(page.error);
+ QVERIFY(!page.error->isOverridable());
+
+ // Fatal certificate errors are implicitly rejected. This should not cause crash.
+ page.error->rejectCertificate();
+}
+
QTEST_MAIN(tst_CertificateError)
#include <tst_certificateerror.moc>
diff --git a/tests/auto/quick/qmltests/data/tst_certificateError.qml b/tests/auto/quick/qmltests/data/tst_certificateError.qml
index a707f4a74..bad24bf0f 100644
--- a/tests/auto/quick/qmltests/data/tst_certificateError.qml
+++ b/tests/auto/quick/qmltests/data/tst_certificateError.qml
@@ -121,5 +121,22 @@ TestWebEngineView {
verify(error.overridable)
compare(error.type, WebEngineCertificateError.CertificateAuthorityInvalid)
}
+
+ function test_fatalError() {
+ var handleCertificateError = function(error) {
+ verify(!error.overrideable);
+ // QQuickWebEngineViewPrivate::allowCertificateError() will implicitly reject
+ // fatal errors and it should not crash if already rejected in handler.
+ error.rejectCertificate();
+ }
+ view.certificateError.connect(handleCertificateError);
+
+ view.url = Qt.resolvedUrl('https://revoked.badssl.com');
+ if (!view.waitForLoadFailed(10000))
+ skip("Couldn't load page from network, skipping test.");
+ compare(spyError.count, 1);
+
+ view.certificateError.disconnect(handleCertificateError);
+ }
}
}