diff options
Diffstat (limited to 'tests/auto')
| -rw-r--r-- | tests/auto/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | tests/auto/core/certificateerror/tst_certificateerror.cpp | 1 | ||||
| -rw-r--r-- | tests/auto/httpserver/httpserver.cpp | 3 | ||||
| -rw-r--r-- | tests/auto/httpserver/httpsserver.h | 71 | ||||
| -rw-r--r-- | tests/auto/quick/qmltests/tst_qmltests.cpp | 2 | ||||
| -rw-r--r-- | tests/auto/widgets/accessibility/tst_accessibility.cpp | 53 |
6 files changed, 89 insertions, 43 deletions
diff --git a/tests/auto/core/CMakeLists.txt b/tests/auto/core/CMakeLists.txt index 5615d6b2d..4e8d5f128 100644 --- a/tests/auto/core/CMakeLists.txt +++ b/tests/auto/core/CMakeLists.txt @@ -7,7 +7,7 @@ add_subdirectory(qwebengineurlrequestinterceptor) add_subdirectory(origins) add_subdirectory(devtools) -if(QT_FEATURE_ssl) +if(QT_FEATURE_ssl AND QT_VERSION VERSION_GREATER_EQUAL "6.4") add_subdirectory(qwebengineclientcertificatestore) add_subdirectory(certificateerror) endif() diff --git a/tests/auto/core/certificateerror/tst_certificateerror.cpp b/tests/auto/core/certificateerror/tst_certificateerror.cpp index 67e2d8ae4..fd22f5d63 100644 --- a/tests/auto/core/certificateerror/tst_certificateerror.cpp +++ b/tests/auto/core/certificateerror/tst_certificateerror.cpp @@ -105,7 +105,6 @@ void tst_CertificateError::handleError() QTRY_COMPARE_WITH_TIMEOUT(page.loadSpy.size(), 1, 30000); QCOMPARE(page.loadSpy.takeFirst().value(0).toBool(), acceptCertificate); QCOMPARE(toPlainTextSync(&page), expectedContent); - QVERIFY(server.stop()); } void tst_CertificateError::fatalError() diff --git a/tests/auto/httpserver/httpserver.cpp b/tests/auto/httpserver/httpserver.cpp index e08af77e7..c65d68ce7 100644 --- a/tests/auto/httpserver/httpserver.cpp +++ b/tests/auto/httpserver/httpserver.cpp @@ -24,8 +24,7 @@ HttpServer::HttpServer(QTcpServer *tcpServer, const QString &protocol, { m_url.setHost(hostAddress.toString()); m_url.setScheme(protocol); - connect(tcpServer, &QTcpServer::pendingConnectionAvailable, this, - &HttpServer::handleNewConnection); + connect(tcpServer, &QTcpServer::newConnection, this, &HttpServer::handleNewConnection); } HttpServer::~HttpServer() diff --git a/tests/auto/httpserver/httpsserver.h b/tests/auto/httpserver/httpsserver.h index 10deeb322..d064c1416 100644 --- a/tests/auto/httpserver/httpsserver.h +++ b/tests/auto/httpserver/httpsserver.h @@ -7,56 +7,51 @@ #include "httpserver.h" #include <QDebug> -#include <QtCore/qfile.h> -#include <QtNetwork/qsslkey.h> -#include <QtNetwork/qsslsocket.h> -#include <QtNetwork/qsslconfiguration.h> -#include <QtNetwork/qsslserver.h> +#include <QFile> +#include <QSslKey> +#include <QSslSocket> +#include <QSslConfiguration> +#include <QTcpServer> -static QSslServer *createServer(const QString &certificateFileName, const QString &keyFileName, - const QString &ca) +struct SslTcpServer : QTcpServer { - QSslConfiguration configuration(QSslConfiguration::defaultConfiguration()); + SslTcpServer(const QString &certPath, const QString &keyPath) { + sslconf.setLocalCertificateChain(QSslCertificate::fromPath(certPath)); + sslconf.setPrivateKey(readKey(keyPath)); + } + + void incomingConnection(qintptr d) override { + auto socket = new QSslSocket(this); + socket->setSslConfiguration(sslconf); - QFile keyFile(keyFileName); - if (keyFile.open(QIODevice::ReadOnly)) { - QSslKey key(keyFile.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey); - if (!key.isNull()) { - configuration.setPrivateKey(key); - } else { - qCritical() << "Could not parse key: " << keyFileName; + if (!socket->setSocketDescriptor(d)) { + qWarning() << "Failed to setup ssl socket!"; + delete socket; + return; } - } else { - qCritical() << "Could not find key: " << keyFileName; - } - QList<QSslCertificate> localCerts = QSslCertificate::fromPath(certificateFileName); - if (!localCerts.isEmpty()) { - configuration.setLocalCertificateChain(localCerts); - } else { - qCritical() << "Could not find certificate: " << certificateFileName; + connect(socket, QOverload<QSslSocket::SocketError>::of(&QSslSocket::errorOccurred), + [] (QSslSocket::SocketError e) { qWarning() << "! Socket Error:" << e; }); + connect(socket, QOverload<const QList<QSslError> &>::of(&QSslSocket::sslErrors), + [] (const QList<QSslError> &le) { qWarning() << "! SSL Errors:\n" << le; }); + + addPendingConnection(socket); + socket->startServerEncryption(); } - if (!ca.isEmpty()) { - QList<QSslCertificate> caCerts = QSslCertificate::fromPath(ca); - if (!caCerts.isEmpty()) { - configuration.addCaCertificates(caCerts); - configuration.setPeerVerifyMode(QSslSocket::VerifyPeer); - } else { - qCritical() << "Could not find certificate: " << certificateFileName; - } + QSslKey readKey(const QString &path) const { + QFile file(path); + file.open(QIODevice::ReadOnly); + return QSslKey(file.readAll(), QSsl::Rsa, QSsl::Pem); } - QSslServer *server = new QSslServer(); - server->setSslConfiguration(configuration); - return server; -} + QSslConfiguration sslconf; +}; struct HttpsServer : HttpServer { - HttpsServer(const QString &certPath, const QString &keyPath, const QString &ca, - QObject *parent = nullptr) - : HttpServer(createServer(certPath, keyPath, ca), "https", QHostAddress::LocalHost, 0, + HttpsServer(const QString &certPath, const QString &keyPath, QObject *parent = nullptr) + : HttpServer(new SslTcpServer(certPath, keyPath), "https", QHostAddress::LocalHost, 0, parent) { } diff --git a/tests/auto/quick/qmltests/tst_qmltests.cpp b/tests/auto/quick/qmltests/tst_qmltests.cpp index 9e928157e..d27ef269d 100644 --- a/tests/auto/quick/qmltests/tst_qmltests.cpp +++ b/tests/auto/quick/qmltests/tst_qmltests.cpp @@ -263,7 +263,7 @@ int main(int argc, char **argv) #if QT_CONFIG(ssl) qmlRegisterSingletonType<HttpsServer>( "Test.Shared", 1, 0, "HttpsServer", [&](QQmlEngine *, QJSEngine *) { - return new HttpsServer(":/resources/server.pem", ":/resources/server.key", ""); + return new HttpsServer(":/resources/server.pem", ":/resources/server.key"); }); #endif Setup setup; diff --git a/tests/auto/widgets/accessibility/tst_accessibility.cpp b/tests/auto/widgets/accessibility/tst_accessibility.cpp index 68566c082..f2cd4d05d 100644 --- a/tests/auto/widgets/accessibility/tst_accessibility.cpp +++ b/tests/auto/widgets/accessibility/tst_accessibility.cpp @@ -50,6 +50,7 @@ private Q_SLOTS: void roles(); void objectName(); void crossTreeParent(); + void tableCellInterface(); }; // This will be called before the first test function is executed. @@ -605,6 +606,58 @@ void tst_Accessibility::crossTreeParent() QCOMPARE(p->object()->objectName(), QStringLiteral("my_id")); } +void tst_Accessibility::tableCellInterface() +{ + QWebEngineView webView; + webView.resize(400, 400); + webView.show(); + QVERIFY(QTest::qWaitForWindowExposed(&webView)); + + QSignalSpy spyFinished(&webView, &QWebEngineView::loadFinished); + webView.setHtml(QLatin1String( + "<html><body>" + " <ul>" + " <li><a href='#link1' id='link1'>Link in ListItem</a></li>" + " </ul>" + "" + " <div role='rowgroup'>" + " <div role='row'>" + " <span role='cell'><a href='#link2' id='link2'>Link in Cell</a></span>" + " </div>" + " </div>" + "</body></html>")); + QTRY_COMPARE(spyFinished.size(), 1); + + QAccessibleInterface *view = QAccessible::queryAccessibleInterface(&webView); + QAccessibleInterface *document = view->child(0); + QTRY_COMPARE(document->childCount(), 2); + + // ListItem without Table parent. + { + QAccessibleInterface *list = document->child(0); + QAccessibleInterface *listItem = list->child(0); + QVERIFY(!listItem->tableCellInterface()); + + // Should not crash. + QPoint linkCenter = elementCenter(webView.page(), QLatin1String("link1")); + QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, {}, linkCenter); + QTRY_COMPARE(webView.url().fragment(), QLatin1String("link1")); + } + + // Cell without Table parent. + { + QAccessibleInterface *rowgroup = document->child(1); + QAccessibleInterface *row = rowgroup->child(0); + QAccessibleInterface *cell = row->child(0); + QVERIFY(!cell->tableCellInterface()); + + // Should not crash. + QPoint linkCenter = elementCenter(webView.page(), QLatin1String("link2")); + QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, {}, linkCenter); + QTRY_COMPARE(webView.url().fragment(), QLatin1String("link2")); + } +} + static QByteArrayList params = QByteArrayList() << "--force-renderer-accessibility" << "--enable-features=AccessibilityExposeARIAAnnotations"; |
