From 92b5d1cfe46f25189235953bde0266d79098fc06 Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Thu, 20 May 2021 17:16:00 +0200 Subject: Ensure certificate error callback call for all types Amends a2a9ea11f9. Actually reject certificate when it's considered to be fatal. Adapt tests for possible regression but checking if load really failed (due to missing internet access) or was just halted by missing callback call internaly. Change-Id: I656525c353ce410f7bda8c55227a29fcd617bfdd Reviewed-by: Michal Klocek Reviewed-by: Qt CI Bot (cherry picked from commit 3acfd3b1cd39e89fb6bc2f0da3412f07d68de7b6) Reviewed-by: Qt Cherry-pick Bot --- .../auto/core/certificateerror/tst_certificateerror.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'tests/auto/core/certificateerror') diff --git a/tests/auto/core/certificateerror/tst_certificateerror.cpp b/tests/auto/core/certificateerror/tst_certificateerror.cpp index da679fa8a..3c43d997f 100644 --- a/tests/auto/core/certificateerror/tst_certificateerror.cpp +++ b/tests/auto/core/certificateerror/tst_certificateerror.cpp @@ -139,13 +139,19 @@ void tst_CertificateError::fatalError() QSignalSpy loadFinishedSpy(&page, &QWebEnginePage::loadFinished); page.setUrl(QUrl("https://revoked.badssl.com")); - if (!loadFinishedSpy.wait(10000)) + if (!loadFinishedSpy.wait(10000)) { + QVERIFY2(!page.error, "There shouldn't be any certificate error if not loaded due to missing internet access!"); 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(); + // revoked certificate might not be reported as invalid by chromium and the load will silently succeed + bool failed = !loadFinishedSpy.first().first().toBool(), hasError = bool(page.error); + QCOMPARE(failed, hasError); + if (hasError) { + QVERIFY(!page.error->isOverridable()); + // Fatal certificate errors are implicitly rejected. But second call should not cause crash. + page.error->rejectCertificate(); + } } QTEST_MAIN(tst_CertificateError) -- cgit v1.2.1