summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/auto.pro8
-rw-r--r--tests/auto/quick/dialogs/BLACKLIST6
-rw-r--r--tests/auto/quick/publicapi/tst_publicapi.cpp5
-rw-r--r--tests/auto/quick/qmltests/data/tst_download.qml21
-rw-r--r--tests/auto/quick/qmltests/data/tst_findText.qml84
-rw-r--r--tests/auto/shared/https.pri4
-rw-r--r--tests/auto/shared/httpserver.cpp31
-rw-r--r--tests/auto/shared/httpserver.h13
-rw-r--r--tests/auto/shared/httpsserver.h81
-rw-r--r--tests/auto/shared/httpsserver.qrc6
-rw-r--r--tests/auto/shared/resources/cert.pem64
-rw-r--r--tests/auto/shared/resources/key.pem27
-rw-r--r--tests/auto/widgets/certificateerror/certificateerror.pro3
-rw-r--r--tests/auto/widgets/certificateerror/tst_certificateerror.cpp126
-rw-r--r--tests/auto/widgets/qwebenginepage/BLACKLIST3
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp136
-rw-r--r--tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp17
-rw-r--r--tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp83
-rw-r--r--tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp2
-rw-r--r--tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp25
-rw-r--r--tests/auto/widgets/widgets.pro1
-rw-r--r--tests/manual/widgets/webgl/main.cpp6
-rw-r--r--tests/tests.pro6
23 files changed, 672 insertions, 86 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 06430cf8e..59bcd5aef 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -1,9 +1,9 @@
TEMPLATE = subdirs
-SUBDIRS = quick
+qtHaveModule(webengine) {
+ SUBDIRS += quick
+}
qtHaveModule(webenginewidgets) {
- SUBDIRS += widgets
-# core tests depend on widgets for now
- SUBDIRS += core
+ SUBDIRS += core widgets
}
diff --git a/tests/auto/quick/dialogs/BLACKLIST b/tests/auto/quick/dialogs/BLACKLIST
index 6d7e2a2fc..10b7391a0 100644
--- a/tests/auto/quick/dialogs/BLACKLIST
+++ b/tests/auto/quick/dialogs/BLACKLIST
@@ -1,2 +1,8 @@
[contextMenuRequested]
osx-10.13
+[javaScriptDialogRequested]
+osx-10.13
+[colorDialogRequested]
+osx-10.13
+[fileDialogRequested]
+osx-10.13
diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp
index f464d58d0..9f7dfa8ad 100644
--- a/tests/auto/quick/publicapi/tst_publicapi.cpp
+++ b/tests/auto/quick/publicapi/tst_publicapi.cpp
@@ -35,6 +35,7 @@
#include <QtTest/QtTest>
#include <QtWebEngine/QQuickWebEngineProfile>
#include <QtWebEngine/QQuickWebEngineScript>
+#include <QtWebEngineCore/QWebEngineFindTextResult>
#include <QtWebEngineCore/QWebEngineNotification>
#include <QtWebEngineCore/QWebEngineQuotaRequest>
#include <QtWebEngineCore/QWebEngineRegisterProtocolHandlerRequest>
@@ -85,6 +86,7 @@ static const QList<const QMetaObject *> typesToCheck = QList<const QMetaObject *
<< &QWebEngineQuotaRequest::staticMetaObject
<< &QWebEngineRegisterProtocolHandlerRequest::staticMetaObject
<< &QWebEngineNotification::staticMetaObject
+ << &QWebEngineFindTextResult::staticMetaObject
;
static QList<const char *> knownEnumNames = QList<const char *>();
@@ -276,6 +278,8 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineFileDialogRequest.dialogAccept(QStringList) --> void"
<< "QQuickWebEngineFileDialogRequest.dialogReject() --> void"
<< "QQuickWebEngineFileDialogRequest.mode --> FileMode"
+ << "QWebEngineFindTextResult.numberOfMatches --> int"
+ << "QWebEngineFindTextResult.activeMatchOrdinal --> int"
<< "QQuickWebEngineFormValidationMessageRequest.Hide --> RequestType"
<< "QQuickWebEngineFormValidationMessageRequest.Move --> RequestType"
<< "QQuickWebEngineFormValidationMessageRequest.Show --> RequestType"
@@ -694,6 +698,7 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.findText(QString) --> void"
<< "QQuickWebEngineView.findText(QString,FindFlags) --> void"
<< "QQuickWebEngineView.findText(QString,FindFlags,QJSValue) --> void"
+ << "QQuickWebEngineView.findTextFinished(QWebEngineFindTextResult) --> void"
<< "QQuickWebEngineView.formValidationMessageRequested(QQuickWebEngineFormValidationMessageRequest*) --> void"
<< "QQuickWebEngineView.fullScreenCancelled() --> void"
<< "QQuickWebEngineView.fullScreenRequested(QQuickWebEngineFullScreenRequest) --> void"
diff --git a/tests/auto/quick/qmltests/data/tst_download.qml b/tests/auto/quick/qmltests/data/tst_download.qml
index ff57c76c7..c38018ffd 100644
--- a/tests/auto/quick/qmltests/data/tst_download.qml
+++ b/tests/auto/quick/qmltests/data/tst_download.qml
@@ -53,7 +53,10 @@ TestWebEngineView {
function urlToPath(url) {
var path = url.toString()
- path = path.replace(/^(file:\/{2})/,"")
+ if (Qt.platform.os !== "windows")
+ path = path.replace(/^(file:\/{2})/, "")
+ else
+ path = path.replace(/^(file:\/{3})/, "")
return path
}
@@ -90,14 +93,9 @@ TestWebEngineView {
download.cancel()
} else {
totalBytes = download.totalBytes
- download.downloadDirectory = testDownloadProfile.downloadPath
- download.downloadFileName = "testfile.zip"
- if (downloadDirectory.length != 0)
- download.downloadDirectory = testDownloadProfile.downloadPath + downloadDirectory
-
- if (downloadFileName.length != 0)
- download.downloadFileName = downloadFileName
+ download.downloadDirectory = downloadDirectory.length != 0 ? testDownloadProfile.downloadPath + downloadDirectory : testDownloadProfile.downloadPath
+ download.downloadFileName = downloadFileName.length != 0 ? downloadFileName : "testfile.zip"
download.accept()
}
@@ -125,6 +123,9 @@ TestWebEngineView {
downloadDirectoryChanged = 0
downloadFileNameChanged = 0
downloadPathChanged = 0
+ downloadDirectory = ""
+ downloadFileName = ""
+ downloadedPath = ""
}
function test_downloadRequest() {
@@ -203,8 +204,8 @@ TestWebEngineView {
tryCompare(downloadState, "1", WebEngineDownloadItem.DownloadInProgress);
compare(downloadedPath, testDownloadProfile.downloadPath + downloadDirectory + downloadFileName);
compare(downloadDirectoryChanged, 1);
- compare(downloadFileNameChanged, 3);
- compare(downloadPathChanged, 4);
+ compare(downloadFileNameChanged, 1);
+ compare(downloadPathChanged, 2);
downloadFinishedSpy.wait();
compare(totalBytes, receivedBytes);
tryCompare(downloadState, "2", WebEngineDownloadItem.DownloadCompleted);
diff --git a/tests/auto/quick/qmltests/data/tst_findText.qml b/tests/auto/quick/qmltests/data/tst_findText.qml
index 14053a675..040d324e6 100644
--- a/tests/auto/quick/qmltests/data/tst_findText.qml
+++ b/tests/auto/quick/qmltests/data/tst_findText.qml
@@ -38,9 +38,16 @@ TestWebEngineView {
property int matchCount: 0
property bool findFailed: false
+ SignalSpy {
+ id: findTextSpy
+ target: webEngineView
+ signalName: "findTextFinished"
+ }
+
function clear() {
findFailed = false
matchCount = -1
+ findTextSpy.clear()
}
function findCallbackCalled() { return matchCount != -1 }
@@ -104,6 +111,9 @@ TestWebEngineView {
webEngineView.findText("Hello", findFlags, webEngineView.findTextCallback)
tryCompare(webEngineView, "matchCount", 1)
verify(!findFailed)
+ tryCompare(findTextSpy, "count", 1)
+ compare(findTextSpy.signalArguments[0][0].numberOfMatches, 1)
+ compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1)
}
function test_findTextCaseInsensitive() {
@@ -115,6 +125,9 @@ TestWebEngineView {
webEngineView.findText("heLLo", findFlags, webEngineView.findTextCallback)
tryCompare(webEngineView, "matchCount", 1)
verify(!findFailed)
+ tryCompare(findTextSpy, "count", 1)
+ compare(findTextSpy.signalArguments[0][0].numberOfMatches, 1)
+ compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1)
}
function test_findTextManyMatches() {
@@ -126,6 +139,9 @@ TestWebEngineView {
webEngineView.findText("bla", findFlags, webEngineView.findTextCallback)
tryCompare(webEngineView, "matchCount", 100, 20000)
verify(!findFailed)
+ tryCompare(findTextSpy, "count", 1)
+ compare(findTextSpy.signalArguments[0][0].numberOfMatches, 100)
+ compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1)
}
@@ -138,6 +154,9 @@ TestWebEngineView {
webEngineView.findText("heLLo", findFlags, webEngineView.findTextCallback)
tryCompare(webEngineView, "matchCount", 0)
verify(findFailed)
+ tryCompare(findTextSpy, "count", 1)
+ compare(findTextSpy.signalArguments[0][0].numberOfMatches, 0)
+ compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 0)
}
function test_findTextNotFound() {
@@ -149,6 +168,9 @@ TestWebEngineView {
webEngineView.findText("string-that-is-not-threre", findFlags, webEngineView.findTextCallback)
tryCompare(webEngineView, "matchCount", 0)
verify(findFailed)
+ tryCompare(findTextSpy, "count", 1)
+ compare(findTextSpy.signalArguments[0][0].numberOfMatches, 0)
+ compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 0)
}
function test_findTextAfterNotFound() {
@@ -160,6 +182,9 @@ TestWebEngineView {
webEngineView.findText("hello", findFlags, webEngineView.findTextCallback)
tryCompare(webEngineView, "matchCount", 0)
verify(findFailed)
+ tryCompare(findTextSpy, "count", 1)
+ compare(findTextSpy.signalArguments[0][0].numberOfMatches, 0)
+ compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 0)
webEngineView.url = Qt.resolvedUrl("test1.html")
verify(webEngineView.waitForLoadSucceeded())
@@ -168,6 +193,9 @@ TestWebEngineView {
webEngineView.findText("hello", findFlags, webEngineView.findTextCallback)
tryCompare(webEngineView, "matchCount", 1)
verify(!findFailed)
+ tryCompare(findTextSpy, "count", 1)
+ compare(findTextSpy.signalArguments[0][0].numberOfMatches, 1)
+ compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1)
}
function test_findTextInModifiedDOMAfterNotFound() {
@@ -182,6 +210,9 @@ TestWebEngineView {
webEngineView.findText("hello", findFlags, webEngineView.findTextCallback)
tryCompare(webEngineView, "matchCount", 0, 20000)
verify(findFailed)
+ tryCompare(findTextSpy, "count", 1)
+ compare(findTextSpy.signalArguments[0][0].numberOfMatches, 0)
+ compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 0)
runJavaScript("document.body.innerHTML = 'blahellobla'");
tryVerify(function() { return getBodyInnerHTML() == "blahellobla"; }, 20000);
@@ -190,6 +221,9 @@ TestWebEngineView {
webEngineView.findText("hello", findFlags, webEngineView.findTextCallback)
tryCompare(webEngineView, "matchCount", 1)
verify(!findFailed)
+ tryCompare(findTextSpy, "count", 1)
+ compare(findTextSpy.signalArguments[0][0].numberOfMatches, 1)
+ compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1)
}
function test_findTextInterruptedByLoad() {
@@ -227,5 +261,55 @@ TestWebEngineView {
webEngineView.findText('New page', findFlags, webEngineView.findTextCallback)
tryCompare(webEngineView, 'matchCount', 1)
}
+
+ function test_findTextActiveMatchOrdinal() {
+ webEngineView.loadHtml(
+ "<html><body>" +
+ "foo bar foo bar foo" +
+ "</body></html>");
+ verify(webEngineView.waitForLoadSucceeded());
+
+ // Iterate over all "foo" matches.
+ webEngineView.clear();
+ for (var i = 1; i <= 3; ++i) {
+ webEngineView.findText("foo");
+ findTextSpy.wait();
+ compare(findTextSpy.count, i);
+ compare(findTextSpy.signalArguments[i-1][0].numberOfMatches, 3);
+ compare(findTextSpy.signalArguments[i-1][0].activeMatchOrdinal, i);
+ }
+
+ // The last match is followed by the fist one.
+ webEngineView.clear();
+ webEngineView.findText("foo");
+ findTextSpy.wait();
+ compare(findTextSpy.count, 1);
+ compare(findTextSpy.signalArguments[0][0].numberOfMatches, 3);
+ compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1);
+
+ // The first match is preceded by the last one.
+ webEngineView.clear();
+ webEngineView.findText("foo", WebEngineView.FindBackward);
+ findTextSpy.wait();
+ compare(findTextSpy.count, 1);
+ compare(findTextSpy.signalArguments[0][0].numberOfMatches, 3);
+ compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 3);
+
+ // Finding another word resets the activeMatchOrdinal.
+ webEngineView.clear();
+ webEngineView.findText("bar");
+ findTextSpy.wait();
+ compare(findTextSpy.count, 1);
+ compare(findTextSpy.signalArguments[0][0].numberOfMatches, 2);
+ compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1);
+
+ // If no match activeMatchOrdinal is 0.
+ webEngineView.clear();
+ webEngineView.findText("bla");
+ findTextSpy.wait();
+ compare(findTextSpy.count, 1);
+ compare(findTextSpy.signalArguments[0][0].numberOfMatches, 0);
+ compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 0);
+ }
}
}
diff --git a/tests/auto/shared/https.pri b/tests/auto/shared/https.pri
new file mode 100644
index 000000000..ce4c147f7
--- /dev/null
+++ b/tests/auto/shared/https.pri
@@ -0,0 +1,4 @@
+include($$PWD/http.pri)
+
+HEADERS += $$PWD/httpsserver.h
+RESOURCES += $$PWD/httpsserver.qrc
diff --git a/tests/auto/shared/httpserver.cpp b/tests/auto/shared/httpserver.cpp
index b85af9901..e282fc8b8 100644
--- a/tests/auto/shared/httpserver.cpp
+++ b/tests/auto/shared/httpserver.cpp
@@ -31,9 +31,21 @@
Q_LOGGING_CATEGORY(gHttpServerLog, "HttpServer")
-HttpServer::HttpServer(QObject *parent) : QObject(parent)
+HttpServer::HttpServer(QObject *parent) : HttpServer(new QTcpServer, "http", parent)
{
- connect(&m_tcpServer, &QTcpServer::newConnection, this, &HttpServer::handleNewConnection);
+}
+
+HttpServer::HttpServer(QTcpServer *tcpServer, const QString &protocol, QObject *parent)
+ : QObject(parent), m_tcpServer(tcpServer)
+{
+ m_url.setHost(QStringLiteral("127.0.0.1"));
+ m_url.setScheme(protocol);
+ connect(tcpServer, &QTcpServer::newConnection, this, &HttpServer::handleNewConnection);
+}
+
+HttpServer::~HttpServer()
+{
+ delete m_tcpServer;
}
bool HttpServer::start()
@@ -41,21 +53,18 @@ bool HttpServer::start()
m_error = false;
m_expectingError = false;
- if (!m_tcpServer.listen()) {
- qCWarning(gHttpServerLog).noquote() << m_tcpServer.errorString();
+ if (!m_tcpServer->listen()) {
+ qCWarning(gHttpServerLog).noquote() << m_tcpServer->errorString();
return false;
}
- m_url.setScheme(QStringLiteral("http"));
- m_url.setHost(QStringLiteral("127.0.0.1"));
- m_url.setPort(m_tcpServer.serverPort());
-
+ m_url.setPort(m_tcpServer->serverPort());
return true;
}
bool HttpServer::stop()
{
- m_tcpServer.close();
+ m_tcpServer->close();
return m_error == m_expectingError;
}
@@ -73,12 +82,12 @@ QUrl HttpServer::url(const QString &path) const
void HttpServer::handleNewConnection()
{
- auto rr = new HttpReqRep(m_tcpServer.nextPendingConnection(), this);
+ auto rr = new HttpReqRep(m_tcpServer->nextPendingConnection(), this);
connect(rr, &HttpReqRep::requestReceived, [this, rr]() {
Q_EMIT newRequest(rr);
rr->close();
});
- connect(rr, &HttpReqRep::responseSent, [this, rr]() {
+ connect(rr, &HttpReqRep::responseSent, [rr]() {
qCInfo(gHttpServerLog).noquote() << rr->requestMethod() << rr->requestPath()
<< rr->responseStatus() << rr->responseBody().size();
});
diff --git a/tests/auto/shared/httpserver.h b/tests/auto/shared/httpserver.h
index b4649244e..57f824bb5 100644
--- a/tests/auto/shared/httpserver.h
+++ b/tests/auto/shared/httpserver.h
@@ -59,19 +59,22 @@ class HttpServer : public QObject
Q_OBJECT
public:
explicit HttpServer(QObject *parent = nullptr);
+ explicit HttpServer(QTcpServer *server, const QString &protocol, QObject *parent = nullptr);
+
+ ~HttpServer() override;
// Must be called to start listening.
//
// Returns true if a TCP port has been successfully bound.
- Q_REQUIRED_RESULT bool start();
+ Q_INVOKABLE Q_REQUIRED_RESULT bool start();
// Stops listening and performs final error checks.
- Q_REQUIRED_RESULT bool stop();
+ Q_INVOKABLE Q_REQUIRED_RESULT bool stop();
- void setExpectError(bool b);
+ Q_INVOKABLE void setExpectError(bool b);
// Full URL for given relative path
- QUrl url(const QString &path = QStringLiteral("/")) const;
+ Q_INVOKABLE QUrl url(const QString &path = QStringLiteral("/")) const;
Q_SIGNALS:
// Emitted after a HTTP request has been successfully parsed.
@@ -81,7 +84,7 @@ private Q_SLOTS:
void handleNewConnection();
private:
- QTcpServer m_tcpServer;
+ QTcpServer *m_tcpServer;
QUrl m_url;
bool m_error = false;
bool m_expectingError = false;
diff --git a/tests/auto/shared/httpsserver.h b/tests/auto/shared/httpsserver.h
new file mode 100644
index 000000000..32c8e8345
--- /dev/null
+++ b/tests/auto/shared/httpsserver.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef HTTPSSERVER_H
+#define HTTPSSERVER_H
+
+#include "httpreqrep.h"
+#include "httpserver.h"
+
+#include <QDebug>
+#include <QFile>
+#include <QSslKey>
+#include <QSslSocket>
+#include <QSslConfiguration>
+#include <QTcpServer>
+
+struct SslTcpServer : QTcpServer
+{
+ SslTcpServer() {
+ sslconf.setLocalCertificateChain(QSslCertificate::fromPath(":/resources/cert.pem"));
+ sslconf.setPrivateKey(readKey(":/resources/key.pem"));
+ }
+
+ void incomingConnection(qintptr d) override {
+ auto socket = new QSslSocket(this);
+ socket->setSslConfiguration(sslconf);
+
+ if (!socket->setSocketDescriptor(d)) {
+ qWarning() << "Failed to setup ssl socket!";
+ delete socket;
+ return;
+ }
+
+ connect(socket, QOverload<QSslSocket::SocketError>::of(&QSslSocket::error),
+ [] (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();
+ }
+
+ QSslKey readKey(const QString &path) const {
+ QFile file(path);
+ file.open(QIODevice::ReadOnly);
+ return QSslKey(file.readAll(), QSsl::Rsa, QSsl::Pem);
+ }
+
+ QSslConfiguration sslconf;
+};
+
+struct HttpsServer : HttpServer
+{
+ HttpsServer(QObject *parent = nullptr) : HttpServer(new SslTcpServer, "https", parent) { }
+};
+
+#endif
diff --git a/tests/auto/shared/httpsserver.qrc b/tests/auto/shared/httpsserver.qrc
new file mode 100644
index 000000000..ec57a1983
--- /dev/null
+++ b/tests/auto/shared/httpsserver.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>resources/cert.pem</file>
+ <file>resources/key.pem</file>
+</qresource>
+</RCC>
diff --git a/tests/auto/shared/resources/cert.pem b/tests/auto/shared/resources/cert.pem
new file mode 100644
index 000000000..3aaaf289c
--- /dev/null
+++ b/tests/auto/shared/resources/cert.pem
@@ -0,0 +1,64 @@
+-----BEGIN CERTIFICATE-----
+MIIEpDCCAoygAwIBAgIUO90aty9AMjvBvzfUhr1WwdBrKkMwDQYJKoZIhvcNAQEL
+BQAwfzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcM
+DVNhbiBGcmFuY2lzY28xDzANBgNVBAoMBkJhZFNTTDEyMDAGA1UEAwwpQmFkU1NM
+IEludGVybWVkaWF0ZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwH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ABXDFxxTp902ozNnZaSk2DxAUqcsOD4
+ago0IhRdkFGe1Q7F8gOxtlUL5owNL4uhRP8BbwOja2Gopn2+kA9CNqdwPI4Ipjlr
+yo61oCqzy3RAXOUct8WAvybacADmJODAxDq9O5fAZuYZScjjj1ASowmbyDH/Wb9z
++WfiKKH4BfgOIukzK3I1M9wiSDefIodCFfEVXbdNudZj8f9Gw4RrZwkUuxDLeRWG
+ReDtzAWq7G0Diw3uX40S4jaj3MeS6oHp2Nrj/VyjSRiYTeN/pnA9N0M5VuCYYvXD
+f50rrigjQfOgb4TmnyJAjXWVkXW7Fa+ooLsbvlfr8wP8f31y1cgWPHTVIv6Kmug7
+Bg88k3x5gLTXmutDjseORonhGMRdAxHgJVf5aKfzdRpwXZTDZJXhsAz9OdlOhNZd
+UrYo680QugA0V3H5D8Egbr2AUUSMDkn133COjeOIDknFxX3qDqeTzqLZCAEBIoKn
+Adpix0jvG1Ys4Ayq6K2wQFdGFjtl6LsiGC7pWWU=
+-----END CERTIFICATE-----
diff --git a/tests/auto/shared/resources/key.pem b/tests/auto/shared/resources/key.pem
new file mode 100644
index 000000000..89922679a
--- /dev/null
+++ b/tests/auto/shared/resources/key.pem
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEowIBAAKCAQEAkybT/L4zJCqefpd+eYT6aQ0PtobQfFgP+n+z5wWoUxIAJnjb
+5ZW47IJxka/2/ggzJOfrUBur54LkTfFQ+yX85eKYCuH0GLz+Rve50LDn0ya6qSgm
+EhDG0bend2tMZY+Nl3B+5Ane1vua8hdJjv3ZO3e5UgpQwysL54eYyhEWWlbFWF11
+LhEdMYp953UGLqoV4Mlw+Li8TmFwdKQx6icgBTuloXLzk9aUU+b6NbXdadNXkmzg
+09ICsb8pnMXiF2P9Xm5rK0IoiRkSHxVnU12nQXh65Ns/2Dj5DcbHmVdvallfr4wn
+LeFPUotysZnvFmE7FLMSr/eQfkTG+Jlb7ZhoGwIDAQABAoIBADRXy3BL98U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g6b3NKuASoc/vC08njZQvWpe5xrzY2DL8epVKb1qf6+8SE
+eX34cIcSaonEZ2g67MAeIG6jtmPwxWk4EYAsO1u4XiyziABkoNyLKVH4hZg61BsV
+jL7R5UrUvBbhKLFOwkcB4Kwdwu7COB/UKa5XJBTMbuw1UTyxlUeI
+-----END RSA PRIVATE KEY-----
diff --git a/tests/auto/widgets/certificateerror/certificateerror.pro b/tests/auto/widgets/certificateerror/certificateerror.pro
new file mode 100644
index 000000000..73ba7515b
--- /dev/null
+++ b/tests/auto/widgets/certificateerror/certificateerror.pro
@@ -0,0 +1,3 @@
+include(../tests.pri)
+include(../../shared/https.pri)
+QT *= core-private
diff --git a/tests/auto/widgets/certificateerror/tst_certificateerror.cpp b/tests/auto/widgets/certificateerror/tst_certificateerror.cpp
new file mode 100644
index 000000000..5fd765ed5
--- /dev/null
+++ b/tests/auto/widgets/certificateerror/tst_certificateerror.cpp
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <httpsserver.h>
+#include <util.h>
+
+#include <QWebEngineCertificateError>
+#include <QWebEnginePage>
+#include <QWebEngineSettings>
+
+#include <QtTest/QtTest>
+
+class tst_CertificateError : public QObject
+{
+ Q_OBJECT
+public:
+ tst_CertificateError() { }
+
+private Q_SLOTS:
+ void handleError_data();
+ void handleError();
+};
+
+struct PageWithCertificateErrorHandler : QWebEnginePage
+{
+ PageWithCertificateErrorHandler(bool defer, bool accept, QObject *p = nullptr)
+ : QWebEnginePage(p), deferError(defer), acceptCertificate(accept) {
+ connect(this, &QWebEnginePage::loadFinished, [&] (bool result) { spyLoad(result); });
+ }
+
+ bool deferError, acceptCertificate;
+
+ CallbackSpy<bool> spyLoad;
+ QScopedPointer<QWebEngineCertificateError> error;
+
+ bool certificateError(const QWebEngineCertificateError &e) override {
+ error.reset(new QWebEngineCertificateError(e));
+ if (deferError)
+ error->defer();
+ return acceptCertificate;
+ }
+};
+
+void tst_CertificateError::handleError_data()
+{
+ QTest::addColumn<bool>("deferError");
+ QTest::addColumn<bool>("acceptCertificate");
+ QTest::addColumn<QString>("expectedContent");
+ QTest::addRow("Reject") << false << false << QString();
+ QTest::addRow("DeferReject") << true << false << QString();
+ QTest::addRow("DeferAccept") << true << true << "TEST";
+}
+
+void tst_CertificateError::handleError()
+{
+ HttpsServer server;
+ server.setExpectError(true);
+ QVERIFY(server.start());
+
+ connect(&server, &HttpsServer::newRequest, [&] (HttpReqRep *rr) {
+ rr->setResponseBody(QByteArrayLiteral("<html><body>TEST</body></html>"));
+ rr->sendResponse();
+ });
+
+ QFETCH(bool, deferError);
+ QFETCH(bool, acceptCertificate);
+ QFETCH(QString, expectedContent);
+
+ PageWithCertificateErrorHandler page(deferError, acceptCertificate);
+ page.settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false);
+
+ page.setUrl(server.url());
+ QTRY_VERIFY(page.error);
+ QVERIFY(page.error->isOverridable());
+ auto chain = page.error->chain();
+ QCOMPARE(chain.size(), 2);
+ QCOMPARE(chain[0].serialNumber(), "3b:dd:1a:b7:2f:40:32:3b:c1:bf:37:d4:86:bd:56:c1:d0:6b:2a:43");
+ QCOMPARE(chain[1].serialNumber(), "6d:52:fb:b4:57:3b:b2:03:c8:62:7b:7e:44:45:5c:d3:08:87:74:17");
+
+ if (deferError) {
+ QVERIFY(page.error->deferred());
+ QVERIFY(!page.error->answered());
+ QVERIFY(!page.spyLoad.wasCalled());
+ QCOMPARE(toPlainTextSync(&page), QString());
+
+ if (acceptCertificate)
+ page.error->ignoreCertificateError();
+ else
+ page.error->rejectCertificate();
+
+ QVERIFY(page.error->answered());
+ page.error.reset();
+ }
+
+ bool loadResult = page.spyLoad.waitForResult();
+ QVERIFY(page.spyLoad.wasCalled());
+ QCOMPARE(loadResult, acceptCertificate);
+ QCOMPARE(toPlainTextSync(&page), expectedContent);
+}
+
+QTEST_MAIN(tst_CertificateError)
+#include <tst_certificateerror.moc>
diff --git a/tests/auto/widgets/qwebenginepage/BLACKLIST b/tests/auto/widgets/qwebenginepage/BLACKLIST
index 4e344c936..e6fad8b20 100644
--- a/tests/auto/widgets/qwebenginepage/BLACKLIST
+++ b/tests/auto/widgets/qwebenginepage/BLACKLIST
@@ -7,3 +7,6 @@ windows
[runJavaScriptFromSlot]
osx
linux
+
+[fullScreenRequested]
+windows
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 713feca6d..dbb15ba10 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -47,6 +47,7 @@
#include <qnetworkreply.h>
#include <qnetworkrequest.h>
#include <qwebenginedownloaditem.h>
+#include <qwebenginefindtextresult.h>
#include <qwebenginefullscreenrequest.h>
#include <qwebenginehistory.h>
#include <qwebenginenotification.h>
@@ -127,6 +128,8 @@ private Q_SLOTS:
void findText();
void findTextResult();
void findTextSuccessiveShouldCallAllCallbacks();
+ void findTextCalledOnMatch();
+ void findTextActiveMatchOrdinal();
void deleteQWebEngineViewTwice();
void loadSignalsOrder_data();
void loadSignalsOrder();
@@ -941,18 +944,24 @@ void tst_QWebEnginePage::findText()
// Invoking a stopFinding operation will not change or clear the currently selected text,
// if nothing was found beforehand.
{
- CallbackSpy<bool> spy;
- m_view->findText("", 0, spy.ref());
- QVERIFY(spy.wasCalled());
+ CallbackSpy<bool> callbackSpy;
+ QSignalSpy signalSpy(m_view->page(), &QWebEnginePage::findTextFinished);
+ m_view->findText("", 0, callbackSpy.ref());
+ QVERIFY(callbackSpy.wasCalled());
+ QCOMPARE(signalSpy.count(), 1);
QTRY_COMPARE(m_view->selectedText(), QString("foo bar"));
}
// Invoking a startFinding operation with text that won't be found, will clear the current
// selection.
{
- CallbackSpy<bool> spy;
- m_view->findText("Will not be found", 0, spy.ref());
- QCOMPARE(spy.waitForResult(), false);
+ CallbackSpy<bool> callbackSpy;
+ QSignalSpy signalSpy(m_view->page(), &QWebEnginePage::findTextFinished);
+ m_view->findText("Will not be found", 0, callbackSpy.ref());
+ QCOMPARE(callbackSpy.waitForResult(), false);
+ QTRY_COMPARE(signalSpy.count(), 1);
+ auto result = signalSpy.takeFirst().value(0).value<QWebEngineFindTextResult>();
+ QCOMPARE(result.numberOfMatches(), 0);
QTRY_VERIFY(m_view->selectedText().isEmpty());
}
@@ -963,24 +972,36 @@ void tst_QWebEnginePage::findText()
// Invoking a startFinding operation with text that will be found, will clear the current
// selection as well.
{
- CallbackSpy<bool> spy;
- m_view->findText("foo", 0, spy.ref());
- QVERIFY(spy.waitForResult());
+ CallbackSpy<bool> callbackSpy;
+ QSignalSpy signalSpy(m_view->page(), &QWebEnginePage::findTextFinished);
+ m_view->findText("foo", 0, callbackSpy.ref());
+ QVERIFY(callbackSpy.waitForResult());
+ QTRY_COMPARE(signalSpy.count(), 1);
QTRY_VERIFY(m_view->selectedText().isEmpty());
}
// Invoking a stopFinding operation after text was found, will set the selected text to the
// found text.
{
- CallbackSpy<bool> spy;
- m_view->findText("", 0, spy.ref());
- QTRY_VERIFY(spy.wasCalled());
+ CallbackSpy<bool> callbackSpy;
+ QSignalSpy signalSpy(m_view->page(), &QWebEnginePage::findTextFinished);
+ m_view->findText("", 0, callbackSpy.ref());
+ QTRY_VERIFY(callbackSpy.wasCalled());
+ QTRY_COMPARE(signalSpy.count(), 1);
QTRY_COMPARE(m_view->selectedText(), QString("foo"));
}
}
void tst_QWebEnginePage::findTextResult()
{
+ QSignalSpy findTextSpy(m_view->page(), &QWebEnginePage::findTextFinished);
+ auto signalResult = [&findTextSpy]() -> QVector<int> {
+ if (findTextSpy.count() != 1)
+ return QVector<int>({-1, -1});
+ auto r = findTextSpy.takeFirst().value(0).value<QWebEngineFindTextResult>();
+ return QVector<int>({ r.numberOfMatches(), r.activeMatchOrdinal() });
+ };
+
// findText will abort in blink if the view has an empty size.
m_view->resize(800, 600);
m_view->show();
@@ -990,15 +1011,21 @@ void tst_QWebEnginePage::findTextResult()
QTRY_COMPARE(loadSpy.count(), 1);
QCOMPARE(findTextSync(m_page, ""), false);
+ QCOMPARE(signalResult(), QVector<int>({0, 0}));
const QStringList words = { "foo", "bar" };
for (const QString &subString : words) {
QCOMPARE(findTextSync(m_page, subString), true);
+ QCOMPARE(signalResult(), QVector<int>({1, 1}));
+
QCOMPARE(findTextSync(m_page, ""), false);
+ QCOMPARE(signalResult(), QVector<int>({0, 0}));
}
QCOMPARE(findTextSync(m_page, "blahhh"), false);
+ QCOMPARE(signalResult(), QVector<int>({0, 0}));
QCOMPARE(findTextSync(m_page, ""), false);
+ QCOMPARE(signalResult(), QVector<int>({0, 0}));
}
void tst_QWebEnginePage::findTextSuccessiveShouldCallAllCallbacks()
@@ -1024,6 +1051,91 @@ void tst_QWebEnginePage::findTextSuccessiveShouldCallAllCallbacks()
QVERIFY(spy5.wasCalled());
}
+void tst_QWebEnginePage::findTextCalledOnMatch()
+{
+ QSignalSpy loadSpy(m_view->page(), &QWebEnginePage::loadFinished);
+
+ // findText will abort in blink if the view has an empty size.
+ m_view->resize(800, 600);
+ m_view->show();
+ m_view->setHtml(QString("<html><head></head><body><div>foo bar</div></body></html>"));
+ QTRY_COMPARE(loadSpy.count(), 1);
+
+ // CALLBACK
+ bool callbackCalled = false;
+ m_view->page()->findText("foo", 0, [this, &callbackCalled](bool found) {
+ QVERIFY(found);
+
+ m_view->page()->findText("bar", 0, [&callbackCalled](bool found) {
+ QVERIFY(found);
+ callbackCalled = true;
+ });
+ });
+ QTRY_VERIFY(callbackCalled);
+
+ // SIGNAL
+ int findTextFinishedCount = 0;
+ connect(m_view->page(), &QWebEnginePage::findTextFinished, [this, &findTextFinishedCount](QWebEngineFindTextResult result) {
+ QCOMPARE(result.numberOfMatches(), 1);
+ if (findTextFinishedCount == 0)
+ m_view->page()->findText("bar");
+ findTextFinishedCount++;
+ });
+
+ m_view->page()->findText("foo");
+ QTRY_COMPARE(findTextFinishedCount, 2);
+}
+
+void tst_QWebEnginePage::findTextActiveMatchOrdinal()
+{
+ QSignalSpy loadSpy(m_view->page(), &QWebEnginePage::loadFinished);
+ QSignalSpy findTextSpy(m_view->page(), &QWebEnginePage::findTextFinished);
+ QWebEngineFindTextResult result;
+
+ // findText will abort in blink if the view has an empty size.
+ m_view->resize(800, 600);
+ m_view->show();
+ m_view->setHtml(QString("<html><head></head><body><div>foo bar foo bar foo</div></body></html>"));
+ QTRY_COMPARE(loadSpy.count(), 1);
+
+ // Iterate over all "foo" matches.
+ for (int i = 1; i <= 3; ++i) {
+ m_view->page()->findText("foo", 0);
+ QTRY_COMPARE(findTextSpy.count(), 1);
+ result = findTextSpy.takeFirst().value(0).value<QWebEngineFindTextResult>();
+ QCOMPARE(result.numberOfMatches(), 3);
+ QCOMPARE(result.activeMatchOrdinal(), i);
+ }
+
+ // The last match is followed by the fist one.
+ m_view->page()->findText("foo", 0);
+ QTRY_COMPARE(findTextSpy.count(), 1);
+ result = findTextSpy.takeFirst().value(0).value<QWebEngineFindTextResult>();
+ QCOMPARE(result.numberOfMatches(), 3);
+ QCOMPARE(result.activeMatchOrdinal(), 1);
+
+ // The first match is preceded by the last one.
+ m_view->page()->findText("foo", QWebEnginePage::FindBackward);
+ QTRY_COMPARE(findTextSpy.count(), 1);
+ result = findTextSpy.takeFirst().value(0).value<QWebEngineFindTextResult>();
+ QCOMPARE(result.numberOfMatches(), 3);
+ QCOMPARE(result.activeMatchOrdinal(), 3);
+
+ // Finding another word resets the activeMatchOrdinal.
+ m_view->page()->findText("bar", 0);
+ QTRY_COMPARE(findTextSpy.count(), 1);
+ result = findTextSpy.takeFirst().value(0).value<QWebEngineFindTextResult>();
+ QCOMPARE(result.numberOfMatches(), 2);
+ QCOMPARE(result.activeMatchOrdinal(), 1);
+
+ // If no match activeMatchOrdinal is 0.
+ m_view->page()->findText("bla", 0);
+ QTRY_COMPARE(findTextSpy.count(), 1);
+ result = findTextSpy.takeFirst().value(0).value<QWebEngineFindTextResult>();
+ QCOMPARE(result.numberOfMatches(), 0);
+ QCOMPARE(result.activeMatchOrdinal(), 0);
+}
+
static QWindow *findNewTopLevelWindow(const QWindowList &oldTopLevelWindows)
{
const auto tlws = QGuiApplication::topLevelWindows();
diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
index 8b75067ee..25afa5849 100644
--- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
+++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
@@ -40,6 +40,8 @@
#include <QtWebEngineWidgets/qwebengineview.h>
#include <QtWebEngineWidgets/qwebenginedownloaditem.h>
+#include <mutex>
+
class tst_QWebEngineProfile : public QObject
{
Q_OBJECT
@@ -255,18 +257,18 @@ public:
bool isSequential() const override { return true; }
qint64 bytesAvailable() const override
{
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
return m_bytesAvailable;
}
bool atEnd() const override
{
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
return (m_data.size() >= 1000 && m_bytesRead >= 1000);
}
protected:
void timerEvent(QTimerEvent *) override
{
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
m_bytesAvailable += 200;
m_data.append(200, 'c');
emit readyRead();
@@ -278,7 +280,7 @@ protected:
qint64 readData(char *data, qint64 maxlen) override
{
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
qint64 len = qMin(qint64(m_bytesAvailable), maxlen);
if (len) {
memcpy(data, m_data.constData() + m_bytesRead, len);
@@ -295,7 +297,12 @@ protected:
}
private:
+#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
mutable QMutex m_mutex{QMutex::Recursive};
+ using QRecursiveMutex = QMutex;
+#else
+ mutable QRecursiveMutex m_mutex;
+#endif
QByteArray m_data;
QBasicTimer m_timer;
int m_bytesRead;
@@ -519,7 +526,7 @@ void tst_QWebEngineProfile::urlSchemeHandlerRequestHeaders()
QWebEngineProfile profile;
profile.installUrlSchemeHandler("myscheme", &handler);
- profile.setRequestInterceptor(&interceptor);
+ profile.setUrlRequestInterceptor(&interceptor);
QWebEnginePage page(&profile);
QSignalSpy loadFinishedSpy(&page, SIGNAL(loadFinished(bool)));
diff --git a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
index 1ba9c13e8..90361f2c9 100644
--- a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
+++ b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
@@ -30,6 +30,26 @@
#include <QWebChannel>
#endif
+static bool verifyOrder(QStringList orderList)
+{
+ QStringList expected = {
+ "DocumentCreation",
+ "DOMContentLoaded",
+ "DocumentReady",
+ "load",
+ "Deferred"
+ };
+
+ if (orderList.at(4) == "load (timeout)") {
+ if (orderList.at(3) != "Deferred")
+ return false;
+ expected[3] = "Deferred";
+ expected[4] = "load (timeout)";
+ }
+
+ return orderList == expected;
+}
+
class tst_QWebEngineScript: public QObject {
Q_OBJECT
@@ -101,15 +121,28 @@ void tst_QWebEngineScript::loadEvents()
script.setRunsOnSubFrames(true);
if (injectionPoint == QWebEngineScript::DocumentCreation) {
script.setSourceCode(QStringLiteral(R"(
- var log = ["DocumentCreation"];
- for (let type of ["DOMContentLoaded", "load"]) {
- window.addEventListener(type, () => log.push(type));
+ var log = ['DocumentCreation'];
+ var timestamps = {'DocumentCreation': Date.now()};
+ for (let type of ['DOMContentLoaded', 'load']) {
+ window.addEventListener(type, () => {
+ timestamps[type] = Date.now();
+ if (type === 'load' && log.includes('Deferred') && timestamps['Deferred'] - timestamps['DOMContentLoaded'] > 500)
+ log.push(type + ' (timeout)');
+ else
+ log.push(type);
+ });
}
)"));
} else if (injectionPoint == QWebEngineScript::DocumentReady) {
- script.setSourceCode(QStringLiteral(R"(log.push("DocumentReady"))"));
+ script.setSourceCode(QStringLiteral(R"(
+ timestamps['DocumentReady'] = Date.now();
+ log.push('DocumentReady');
+ )"));
} else {
- script.setSourceCode(QStringLiteral(R"(log.push("Deferred"))"));
+ script.setSourceCode(QStringLiteral(R"(
+ timestamps['Deferred'] = Date.now();
+ log.push('Deferred');
+ )"));
}
return script;
}
@@ -144,46 +177,38 @@ void tst_QWebEngineScript::loadEvents()
profile.pages.emplace_back(profile);
Page &page = profile.pages.back();
- const QStringList expected = {
- "DocumentCreation",
- "DOMContentLoaded",
- "DocumentReady",
- "load",
- "Deferred"
- };
-
// Single frame / setHtml
page.setHtml(QStringLiteral("<!DOCTYPE html><html><head><title>mr</title></head><body></body></html>"));
QTRY_COMPARE(page.spy.count(), 1);
QCOMPARE(page.spy.takeFirst().value(0).toBool(), true);
- QCOMPARE(page.eval("window.log", QWebEngineScript::MainWorld).toStringList(), expected);
- QCOMPARE(page.eval("window.log", QWebEngineScript::ApplicationWorld).toStringList(), expected);
+ QVERIFY(verifyOrder(page.eval("window.log", QWebEngineScript::MainWorld).toStringList()));
+ QVERIFY(verifyOrder(page.eval("window.log", QWebEngineScript::ApplicationWorld).toStringList()));
// After discard
page.setLifecycleState(QWebEnginePage::LifecycleState::Discarded);
page.setLifecycleState(QWebEnginePage::LifecycleState::Active);
QTRY_COMPARE(page.spy.count(), 1);
QCOMPARE(page.spy.takeFirst().value(0).toBool(), true);
- QCOMPARE(page.eval("window.log", QWebEngineScript::MainWorld).toStringList(), expected);
- QCOMPARE(page.eval("window.log", QWebEngineScript::ApplicationWorld).toStringList(), expected);
+ QVERIFY(verifyOrder(page.eval("window.log", QWebEngineScript::MainWorld).toStringList()));
+ QVERIFY(verifyOrder(page.eval("window.log", QWebEngineScript::ApplicationWorld).toStringList()));
// Multiple frames
page.load(QUrl("qrc:/resources/test_iframe_main.html"));
QTRY_COMPARE(page.spy.count(), 1);
QCOMPARE(page.spy.takeFirst().value(0).toBool(), true);
- QCOMPARE(page.eval("window.log", QWebEngineScript::MainWorld).toStringList(), expected);
- QCOMPARE(page.eval("window.log", QWebEngineScript::ApplicationWorld).toStringList(), expected);
- QCOMPARE(page.eval("window[0].log", QWebEngineScript::MainWorld).toStringList(), expected);
- QCOMPARE(page.eval("window[0].log", QWebEngineScript::ApplicationWorld).toStringList(), expected);
- QCOMPARE(page.eval("window[0][0].log", QWebEngineScript::MainWorld).toStringList(), expected);
- QCOMPARE(page.eval("window[0][0].log", QWebEngineScript::ApplicationWorld).toStringList(), expected);
+ QVERIFY(verifyOrder(page.eval("window.log", QWebEngineScript::MainWorld).toStringList()));
+ QVERIFY(verifyOrder(page.eval("window.log", QWebEngineScript::ApplicationWorld).toStringList()));
+ QVERIFY(verifyOrder(page.eval("window[0].log", QWebEngineScript::MainWorld).toStringList()));
+ QVERIFY(verifyOrder(page.eval("window[0].log", QWebEngineScript::ApplicationWorld).toStringList()));
+ QVERIFY(verifyOrder(page.eval("window[0][0].log", QWebEngineScript::MainWorld).toStringList()));
+ QVERIFY(verifyOrder(page.eval("window[0][0].log", QWebEngineScript::ApplicationWorld).toStringList()));
// Cross-process navigation
page.load(QUrl("chrome://gpu"));
QTRY_COMPARE_WITH_TIMEOUT(page.spy.count(), 1, 20000);
QCOMPARE(page.spy.takeFirst().value(0).toBool(), true);
- QCOMPARE(page.eval("window.log", QWebEngineScript::MainWorld).toStringList(), expected);
- QCOMPARE(page.eval("window.log", QWebEngineScript::ApplicationWorld).toStringList(), expected);
+ QVERIFY(verifyOrder(page.eval("window.log", QWebEngineScript::MainWorld).toStringList()));
+ QVERIFY(verifyOrder(page.eval("window.log", QWebEngineScript::ApplicationWorld).toStringList()));
// Using window.open from JS
QVERIFY(profile.pages.size() == 1);
@@ -191,10 +216,10 @@ void tst_QWebEngineScript::loadEvents()
QTRY_VERIFY(profile.pages.size() == 2);
QTRY_COMPARE(profile.pages.front().spy.count(), 1);
QTRY_COMPARE(profile.pages.back().spy.count(), 1);
- QCOMPARE(profile.pages.front().eval("window.log", QWebEngineScript::MainWorld).toStringList(), expected);
- QCOMPARE(profile.pages.front().eval("window.log", QWebEngineScript::ApplicationWorld).toStringList(), expected);
- QCOMPARE(profile.pages.back().eval("window.log", QWebEngineScript::MainWorld).toStringList(), expected);
- QCOMPARE(profile.pages.back().eval("window.log", QWebEngineScript::ApplicationWorld).toStringList(), expected);
+ QVERIFY(verifyOrder(profile.pages.front().eval("window.log", QWebEngineScript::MainWorld).toStringList()));
+ QVERIFY(verifyOrder(profile.pages.front().eval("window.log", QWebEngineScript::ApplicationWorld).toStringList()));
+ QVERIFY(verifyOrder(profile.pages.back().eval("window.log", QWebEngineScript::MainWorld).toStringList()));
+ QVERIFY(verifyOrder(profile.pages.back().eval("window.log", QWebEngineScript::ApplicationWorld).toStringList()));
}
void tst_QWebEngineScript::scriptWorld_data()
diff --git a/tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp b/tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp
index 0704cf383..b4061b984 100644
--- a/tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp
+++ b/tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp
@@ -177,7 +177,7 @@ void tst_QWebEngineSettings::setInAcceptNavigationRequest()
{
NavigationRequestOverride page;
QSignalSpy loadFinishedSpy(&page, SIGNAL(loadFinished(bool)));
- QWebEngineSettings::globalSettings()->setAttribute(QWebEngineSettings::JavascriptEnabled, false);
+ QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::JavascriptEnabled, false);
QVERIFY(!page.settings()->testAttribute(QWebEngineSettings::JavascriptEnabled));
page.load(QUrl("about:blank"));
diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
index fa179f2f8..827ac2757 100644
--- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
+++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
@@ -237,31 +237,46 @@ void tst_QWebEngineView::renderHints()
QVERIFY(!(webView.renderHints() & QPainter::Antialiasing));
QVERIFY(webView.renderHints() & QPainter::TextAntialiasing);
QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform);
+#if QT_DEPRECATED_SINCE(5, 14)
QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing));
+#endif
+ QVERIFY(!(webView.renderHints() & QPainter::Antialiasing));
webView.setRenderHint(QPainter::Antialiasing, true);
QVERIFY(webView.renderHints() & QPainter::Antialiasing);
QVERIFY(webView.renderHints() & QPainter::TextAntialiasing);
QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform);
+#if QT_DEPRECATED_SINCE(5, 14)
QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing));
+#endif
+ QVERIFY(!(webView.renderHints() & QPainter::Antialiasing));
webView.setRenderHint(QPainter::Antialiasing, false);
QVERIFY(!(webView.renderHints() & QPainter::Antialiasing));
QVERIFY(webView.renderHints() & QPainter::TextAntialiasing);
QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform);
+#if QT_DEPRECATED_SINCE(5, 14)
QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing));
+#endif
+ QVERIFY(!(webView.renderHints() & QPainter::Antialiasing));
webView.setRenderHint(QPainter::SmoothPixmapTransform, true);
QVERIFY(!(webView.renderHints() & QPainter::Antialiasing));
QVERIFY(webView.renderHints() & QPainter::TextAntialiasing);
QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform);
+#if QT_DEPRECATED_SINCE(5, 14)
QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing));
+#endif
+ QVERIFY(!(webView.renderHints() & QPainter::Antialiasing));
webView.setRenderHint(QPainter::SmoothPixmapTransform, false);
QVERIFY(webView.renderHints() & QPainter::TextAntialiasing);
QVERIFY(!(webView.renderHints() & QPainter::SmoothPixmapTransform));
+#if QT_DEPRECATED_SINCE(5, 14)
QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing));
#endif
+ QVERIFY(!(webView.renderHints() & QPainter::Antialiasing));
+#endif
}
void tst_QWebEngineView::getWebKitVersion()
@@ -480,14 +495,14 @@ void tst_QWebEngineView::microFocusCoordinates()
evaluateJavaScriptSync(webView.page(), "document.getElementById('input1').focus()");
QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("input1"));
- QTRY_VERIFY(webView.focusProxy()->inputMethodQuery(Qt::ImMicroFocus).isValid());
- QVariant initialMicroFocus = webView.focusProxy()->inputMethodQuery(Qt::ImMicroFocus);
+ QTRY_VERIFY(webView.focusProxy()->inputMethodQuery(Qt::ImCursorRectangle).isValid());
+ QVariant initialMicroFocus = webView.focusProxy()->inputMethodQuery(Qt::ImCursorRectangle);
evaluateJavaScriptSync(webView.page(), "window.scrollBy(0, 50)");
QTRY_VERIFY(scrollSpy.count() > 0);
- QTRY_VERIFY(webView.focusProxy()->inputMethodQuery(Qt::ImMicroFocus).isValid());
- QVariant currentMicroFocus = webView.focusProxy()->inputMethodQuery(Qt::ImMicroFocus);
+ QTRY_VERIFY(webView.focusProxy()->inputMethodQuery(Qt::ImCursorRectangle).isValid());
+ QVariant currentMicroFocus = webView.focusProxy()->inputMethodQuery(Qt::ImCursorRectangle);
QCOMPARE(initialMicroFocus.toRect().translated(QPoint(0,-50)), currentMicroFocus.toRect());
}
@@ -2989,7 +3004,7 @@ void tst_QWebEngineView::mouseLeave()
QVBoxLayout *layout = new QVBoxLayout;
layout->setAlignment(Qt::AlignTop);
layout->setSpacing(0);
- layout->setMargin(0);
+ layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(label);
layout->addWidget(view);
containerWidget->setLayout(layout);
diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro
index 92159bf83..df553df55 100644
--- a/tests/auto/widgets/widgets.pro
+++ b/tests/auto/widgets/widgets.pro
@@ -4,6 +4,7 @@ QT_FOR_CONFIG += webenginecore webenginecore-private
TEMPLATE = subdirs
SUBDIRS += \
+ certificateerror \
defaultsurfaceformat \
devtools \
faviconmanager \
diff --git a/tests/manual/widgets/webgl/main.cpp b/tests/manual/widgets/webgl/main.cpp
index 364eda8b9..c18a15bac 100644
--- a/tests/manual/widgets/webgl/main.cpp
+++ b/tests/manual/widgets/webgl/main.cpp
@@ -30,9 +30,9 @@
#include <QtCore/QLoggingCategory>
#include <QtCore/QOperatingSystemVersion>
#include <QtGui/QOpenGLContext>
+#include <QtGui/QScreen>
#include <QtGui/QSurfaceFormat>
#include <QtWidgets/QApplication>
-#include <QtWidgets/QDesktopWidget>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QMainWindow>
@@ -104,7 +104,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
QSize MainWindow::sizeHint() const
{
- const QRect desktopRect = QApplication::desktop()->screenGeometry();
+ const QRect desktopRect = QGuiApplication::primaryScreen()->geometry();
const QSize size = desktopRect.size() * qreal(0.9);
return size;
}
@@ -172,7 +172,7 @@ int main(int argc, char *argv[])
MainWindow w;
// Move middle-ish.
- const QRect desktopRect = QApplication::desktop()->screenGeometry();
+ const QRect desktopRect = QGuiApplication::primaryScreen()->geometry();
const QSize pos = desktopRect.size() * qreal(0.1);
w.move(pos.width(), pos.height());
diff --git a/tests/tests.pro b/tests/tests.pro
index 2922e5076..acb223640 100644
--- a/tests/tests.pro
+++ b/tests/tests.pro
@@ -1,3 +1,7 @@
TEMPLATE = subdirs
-SUBDIRS += auto quicktestbrowser
+SUBDIRS += auto
+
+qtHaveModule(webengine) {
+ SUBDIRS += quicktestbrowser
+}