summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/core/qwebengineclientcertificatestore/tst_qwebengineclientcertificatestore.cpp2
-rw-r--r--tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp4
-rw-r--r--tests/auto/core/qwebengineurlrequestinterceptor/resources/content.html3
-rw-r--r--tests/auto/core/qwebengineurlrequestinterceptor/resources/content2.html6
-rw-r--r--tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp229
-rw-r--r--tests/auto/pdf/qpdfsearchmodel/tst_qpdfsearchmodel.cpp2
-rw-r--r--tests/auto/quick/certificateerror/WebView.qml64
-rw-r--r--tests/auto/quick/certificateerror/certificateerror.pro7
-rw-r--r--tests/auto/quick/certificateerror/certificateerror.qrc5
-rw-r--r--tests/auto/quick/certificateerror/testhandler.cpp63
-rw-r--r--tests/auto/quick/certificateerror/testhandler.h59
-rw-r--r--tests/auto/quick/certificateerror/tst_certificateerror.cpp125
-rw-r--r--tests/auto/quick/dialogs/testhandler.cpp2
-rw-r--r--tests/auto/quick/dialogs/tst_dialogs.cpp81
-rw-r--r--tests/auto/quick/inspectorserver/tst_inspectorserver.cpp11
-rw-r--r--tests/auto/quick/publicapi/tst_publicapi.cpp344
-rw-r--r--tests/auto/quick/qmltests/BLACKLIST2
-rw-r--r--tests/auto/quick/qmltests/data/TestWebEngineView.qml6
-rw-r--r--tests/auto/quick/qmltests/data/accepttypes.html (renamed from tests/auto/quick/qmltests2/data/accepttypes.html)0
-rw-r--r--tests/auto/quick/qmltests/data/alert.html (renamed from tests/auto/quick/qmltests2/data/alert.html)0
-rw-r--r--tests/auto/quick/qmltests/data/confirm.html (renamed from tests/auto/quick/qmltests2/data/confirm.html)0
-rw-r--r--tests/auto/quick/qmltests/data/confirmclose.html (renamed from tests/auto/quick/qmltests2/data/confirmclose.html)0
-rw-r--r--tests/auto/quick/qmltests/data/directoryupload.html (renamed from tests/auto/quick/qmltests2/data/directoryupload.html)0
-rw-r--r--tests/auto/quick/qmltests/data/favicon-candidates-gray.html (renamed from tests/auto/quick/qmltests2/data/favicon-candidates-gray.html)0
-rw-r--r--tests/auto/quick/qmltests/data/favicon-misc.html (renamed from tests/auto/quick/qmltests2/data/favicon-misc.html)0
-rw-r--r--tests/auto/quick/qmltests/data/favicon-multi-gray.html (renamed from tests/auto/quick/qmltests2/data/favicon-multi-gray.html)0
-rw-r--r--tests/auto/quick/qmltests/data/favicon-multi.html (renamed from tests/auto/quick/qmltests2/data/favicon-multi.html)0
-rw-r--r--tests/auto/quick/qmltests/data/favicon-shortcut.html (renamed from tests/auto/quick/qmltests2/data/favicon-shortcut.html)0
-rw-r--r--tests/auto/quick/qmltests/data/favicon-single.html (renamed from tests/auto/quick/qmltests2/data/favicon-single.html)0
-rw-r--r--tests/auto/quick/qmltests/data/favicon-touch.html (renamed from tests/auto/quick/qmltests2/data/favicon-touch.html)0
-rw-r--r--tests/auto/quick/qmltests/data/favicon-unavailable.html (renamed from tests/auto/quick/qmltests2/data/favicon-unavailable.html)0
-rw-r--r--tests/auto/quick/qmltests/data/favicon2.html (renamed from tests/auto/quick/qmltests2/data/favicon2.html)0
-rw-r--r--tests/auto/quick/qmltests/data/icons/gray128.png (renamed from tests/auto/quick/qmltests2/data/icons/gray128.png)bin146 -> 146 bytes
-rw-r--r--tests/auto/quick/qmltests/data/icons/gray16.png (renamed from tests/auto/quick/qmltests2/data/icons/gray16.png)bin72 -> 72 bytes
-rw-r--r--tests/auto/quick/qmltests/data/icons/gray255.png (renamed from tests/auto/quick/qmltests2/data/icons/gray255.png)bin335 -> 335 bytes
-rw-r--r--tests/auto/quick/qmltests/data/icons/gray32.png (renamed from tests/auto/quick/qmltests2/data/icons/gray32.png)bin79 -> 79 bytes
-rw-r--r--tests/auto/quick/qmltests/data/icons/gray64.png (renamed from tests/auto/quick/qmltests2/data/icons/gray64.png)bin99 -> 99 bytes
-rw-r--r--tests/auto/quick/qmltests/data/icons/grayicons.ico (renamed from tests/auto/quick/qmltests2/data/icons/grayicons.ico)bin22150 -> 22150 bytes
-rw-r--r--tests/auto/quick/qmltests/data/icons/qt144.png (renamed from tests/auto/quick/qmltests2/data/icons/qt144.png)bin8315 -> 8315 bytes
-rw-r--r--tests/auto/quick/qmltests/data/icons/qt32.ico (renamed from tests/auto/quick/qmltests2/data/icons/qt32.ico)bin4286 -> 4286 bytes
-rw-r--r--tests/auto/quick/qmltests/data/icons/qtmulti.ico (renamed from tests/auto/quick/qmltests2/data/icons/qtmulti.ico)bin22382 -> 22382 bytes
-rw-r--r--tests/auto/quick/qmltests/data/icons/small-favicon.png (renamed from tests/auto/quick/qmltests2/data/icons/small-favicon.png)bin878 -> 878 bytes
-rw-r--r--tests/auto/quick/qmltests/data/multifileupload.html (renamed from tests/auto/quick/qmltests2/data/multifileupload.html)0
-rw-r--r--tests/auto/quick/qmltests/data/prompt.html (renamed from tests/auto/quick/qmltests2/data/prompt.html)0
-rw-r--r--tests/auto/quick/qmltests/data/singlefileupload.html (renamed from tests/auto/quick/qmltests2/data/singlefileupload.html)0
-rw-r--r--tests/auto/quick/qmltests/data/test2.html2
-rw-r--r--tests/auto/quick/qmltests/data/titleupdate.js (renamed from tests/auto/quick/qmltests2/data/titleupdate.js)0
-rw-r--r--tests/auto/quick/qmltests/data/tst_certificateError.qml (renamed from tests/auto/quick/qmltests_ssl/data/tst_certificateError.qml)4
-rw-r--r--tests/auto/quick/qmltests/data/tst_download.qml42
-rw-r--r--tests/auto/quick/qmltests/data/tst_favicon.qml (renamed from tests/auto/quick/qmltests2/data/tst_favicon.qml)0
-rw-r--r--tests/auto/quick/qmltests/data/tst_faviconDownload.qml (renamed from tests/auto/quick/qmltests2/data/tst_faviconDownload.qml)0
-rw-r--r--tests/auto/quick/qmltests/data/tst_filePicker.qml (renamed from tests/auto/quick/qmltests2/data/tst_filePicker.qml)0
-rw-r--r--tests/auto/quick/qmltests/data/tst_inputMethod.qml (renamed from tests/auto/quick/qmltests2/data/tst_inputMethod.qml)0
-rw-r--r--tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml (renamed from tests/auto/quick/qmltests2/data/tst_javaScriptDialogs.qml)15
-rw-r--r--tests/auto/quick/qmltests/data/tst_linkHovered.qml (renamed from tests/auto/quick/qmltests2/data/tst_linkHovered.qml)0
-rw-r--r--tests/auto/quick/qmltests/data/tst_loadFail.qml (renamed from tests/auto/quick/qmltests2/data/tst_loadFail.qml)0
-rw-r--r--tests/auto/quick/qmltests/data/tst_loadUrl.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_mouseClick.qml (renamed from tests/auto/quick/qmltests2/data/tst_mouseClick.qml)0
-rw-r--r--tests/auto/quick/qmltests/data/tst_newViewRequest.qml25
-rw-r--r--tests/auto/quick/qmltests/data/tst_userScripts.qml85
-rw-r--r--tests/auto/quick/qmltests/data/tst_viewSource.qml30
-rw-r--r--tests/auto/quick/qmltests/data/tst_viewSoure.qml133
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/AlertDialog.qml (renamed from tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/AlertDialog.qml)0
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/ConfirmDialog.qml (renamed from tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/ConfirmDialog.qml)0
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/FilePicker.qml (renamed from tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/FilePicker.qml)0
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/Menu.qml (renamed from tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/Menu.qml)0
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/MenuItem.qml (renamed from tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/MenuItem.qml)0
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/PromptDialog.qml (renamed from tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/PromptDialog.qml)0
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/qmldir (renamed from tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/qmldir)0
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/TestParams/FilePickerParams.qml (renamed from tests/auto/quick/qmltests2/mock-delegates/TestParams/FilePickerParams.qml)0
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/TestParams/JSDialogParams.qml (renamed from tests/auto/quick/qmltests2/mock-delegates/TestParams/JSDialogParams.qml)0
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/TestParams/qmldir (renamed from tests/auto/quick/qmltests2/mock-delegates/TestParams/qmldir)0
-rw-r--r--tests/auto/quick/qmltests/qmltests.pro159
-rw-r--r--tests/auto/quick/qmltests/tst_qmltests.cpp12
-rw-r--r--tests/auto/quick/qmltests2/data/favicon.html10
-rw-r--r--tests/auto/quick/qmltests2/data/icons/favicon.pngbin3961 -> 0 bytes
-rw-r--r--tests/auto/quick/qmltests2/data/test1.html6
-rw-r--r--tests/auto/quick/qmltests2/data/test2.html6
-rw-r--r--tests/auto/quick/qmltests2/qmltests2.pro78
-rw-r--r--tests/auto/quick/qmltests2/tst_qmltests2.cpp127
-rw-r--r--tests/auto/quick/qmltests_ssl/data/TestWebEngineView.qml122
-rw-r--r--tests/auto/quick/qmltests_ssl/qmltests_ssl.pro10
-rw-r--r--tests/auto/quick/qmltests_ssl/tst_qmltests_ssl.cpp160
-rw-r--r--tests/auto/quick/qquickwebengineview/BLACKLIST2
-rw-r--r--tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp61
-rw-r--r--tests/auto/quick/quick.pro12
-rw-r--r--tests/auto/quick/shared/util.h2
-rw-r--r--tests/auto/shared/httpserver.cpp10
-rw-r--r--tests/auto/shared/httpserver.h1
-rw-r--r--tests/auto/shared/httpsserver.h2
-rw-r--r--tests/auto/widgets/accessibility/BLACKLIST2
-rw-r--r--tests/auto/widgets/accessibility/tst_accessibility.cpp13
-rw-r--r--tests/auto/widgets/certificateerror/tst_certificateerror.cpp18
-rw-r--r--tests/auto/widgets/loadsignals/tst_loadsignals.cpp50
-rw-r--r--tests/auto/widgets/origins/origins.pro1
-rw-r--r--tests/auto/widgets/origins/tst_origins.cpp41
-rw-r--r--tests/auto/widgets/proxy/proxy_server.cpp2
-rw-r--r--tests/auto/widgets/qwebenginedownloadrequest/qwebenginedownloadrequest.pro (renamed from tests/auto/widgets/qwebenginedownloaditem/qwebenginedownloaditem.pro)0
-rw-r--r--tests/auto/widgets/qwebenginedownloadrequest/tst_qwebenginedownloadrequest.cpp (renamed from tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp)387
-rw-r--r--tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp3
-rw-r--r--tests/auto/widgets/qwebenginepage/BLACKLIST6
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp123
-rw-r--r--tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp26
-rw-r--r--tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp6
-rw-r--r--tests/auto/widgets/qwebenginesettings/BLACKLIST2
-rw-r--r--tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp2
-rw-r--r--tests/auto/widgets/qwebengineview/BLACKLIST6
-rw-r--r--tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp285
-rw-r--r--tests/auto/widgets/spellchecking/tst_spellchecking.cpp24
-rw-r--r--tests/auto/widgets/touchinput/touchinput.pro2
-rw-r--r--tests/auto/widgets/touchinput/tst_touchinput.cpp349
-rw-r--r--tests/auto/widgets/util.h39
-rw-r--r--tests/auto/widgets/widgets.pro7
-rw-r--r--tests/manual/quick/quick.pro3
-rw-r--r--tests/manual/quick/touchbrowser/AddressBar.qml102
-rw-r--r--tests/manual/quick/touchbrowser/main.cpp100
-rw-r--r--tests/manual/quick/touchbrowser/main.qml65
-rw-r--r--tests/manual/quick/touchbrowser/qml.qrc6
-rw-r--r--tests/manual/quick/touchbrowser/touchbrowser.pro19
-rw-r--r--tests/manual/quick/touchbrowser/touchmockingapplication.cpp287
-rw-r--r--tests/manual/quick/touchbrowser/touchmockingapplication.h72
-rw-r--r--tests/manual/quick/touchbrowser/utils.h49
-rw-r--r--tests/manual/widgets/inputmethods/colorpicker.cpp1
123 files changed, 2586 insertions, 1645 deletions
diff --git a/tests/auto/core/qwebengineclientcertificatestore/tst_qwebengineclientcertificatestore.cpp b/tests/auto/core/qwebengineclientcertificatestore/tst_qwebengineclientcertificatestore.cpp
index 6d51bf7af..f288a2c75 100644
--- a/tests/auto/core/qwebengineclientcertificatestore/tst_qwebengineclientcertificatestore.cpp
+++ b/tests/auto/core/qwebengineclientcertificatestore/tst_qwebengineclientcertificatestore.cpp
@@ -28,7 +28,7 @@
#include <QtTest/QtTest>
#include <QtWebEngineCore/qwebengineclientcertificatestore.h>
-#include <QtWebEngineWidgets/qwebengineprofile.h>
+#include <QtWebEngineCore/qwebengineprofile.h>
class tst_QWebEngineClientCertificateStore : public QObject
{
diff --git a/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp b/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp
index 5290d5373..8416abfdb 100644
--- a/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp
+++ b/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp
@@ -30,8 +30,8 @@
#include <QtTest/QtTest>
#include <QtWebEngineCore/qwebenginecallback.h>
#include <QtWebEngineCore/qwebenginecookiestore.h>
-#include <QtWebEngineWidgets/qwebenginepage.h>
-#include <QtWebEngineWidgets/qwebengineprofile.h>
+#include <QtWebEngineCore/qwebengineprofile.h>
+#include <QtWebEngineCore/qwebenginepage.h>
#include "httpserver.h"
#include "httpreqrep.h"
diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/content.html b/tests/auto/core/qwebengineurlrequestinterceptor/resources/content.html
index 360ad65ef..84bf55036 100644
--- a/tests/auto/core/qwebengineurlrequestinterceptor/resources/content.html
+++ b/tests/auto/core/qwebengineurlrequestinterceptor/resources/content.html
@@ -1,5 +1,6 @@
<html>
+<head><link rel="icon" href="data:,"></head>
<body>
-<a>This is test content</a>
+<a>Simple test page without favicon (meaning no separate request from http server)</a>
</body>
</html>
diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/content2.html b/tests/auto/core/qwebengineurlrequestinterceptor/resources/content2.html
new file mode 100644
index 000000000..84bf55036
--- /dev/null
+++ b/tests/auto/core/qwebengineurlrequestinterceptor/resources/content2.html
@@ -0,0 +1,6 @@
+<html>
+<head><link rel="icon" href="data:,"></head>
+<body>
+<a>Simple test page without favicon (meaning no separate request from http server)</a>
+</body>
+</html>
diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp
index 20e191a4f..54546569f 100644
--- a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp
+++ b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp
@@ -30,15 +30,13 @@
#include <QtTest/QtTest>
#include <QtWebEngineCore/qwebengineurlrequestinfo.h>
#include <QtWebEngineCore/qwebengineurlrequestinterceptor.h>
-#include <QtWebEngineWidgets/qwebenginepage.h>
-#include <QtWebEngineWidgets/qwebengineprofile.h>
-#include <QtWebEngineWidgets/qwebenginesettings.h>
+#include <QtWebEngineCore/qwebenginesettings.h>
+#include <QtWebEngineCore/qwebengineprofile.h>
+#include <QtWebEngineCore/qwebenginepage.h>
#include <httpserver.h>
#include <httpreqrep.h>
-typedef void (QWebEngineProfile::*InterceptorSetter)(QWebEngineUrlRequestInterceptor *interceptor);
-Q_DECLARE_METATYPE(InterceptorSetter)
class tst_QWebEngineUrlRequestInterceptor : public QObject
{
Q_OBJECT
@@ -54,27 +52,20 @@ public Q_SLOTS:
private Q_SLOTS:
void initTestCase();
void cleanupTestCase();
- void interceptRequest_data();
void interceptRequest();
- void ipv6HostEncoding_data();
void ipv6HostEncoding();
void requestedUrl_data();
void requestedUrl();
void setUrlSameUrl_data();
void setUrlSameUrl();
- void firstPartyUrl_data();
void firstPartyUrl();
void firstPartyUrlNestedIframes_data();
void firstPartyUrlNestedIframes();
void requestInterceptorByResourceType_data();
void requestInterceptorByResourceType();
- void firstPartyUrlHttp_data();
void firstPartyUrlHttp();
- void passRefererHeader_data();
- void passRefererHeader();
- void initiator_data();
+ void customHeaders();
void initiator();
- void jsServiceWorker_data();
void jsServiceWorker();
};
@@ -116,36 +107,39 @@ struct RequestInfo {
int resourceType;
};
-static const QByteArray kHttpHeaderReferrerValue = QByteArrayLiteral("http://somereferrer.com/");
-static const QByteArray kHttpHeaderRefererName = QByteArrayLiteral("referer");
static const QUrl kRedirectUrl = QUrl("qrc:///resources/content.html");
+Q_LOGGING_CATEGORY(lc, "qt.webengine.tests")
+
class TestRequestInterceptor : public QWebEngineUrlRequestInterceptor
{
public:
QList<RequestInfo> requestInfos;
bool shouldRedirect = false;
+ QUrl redirectUrl;
QMap<QUrl, QSet<QUrl>> requestInitiatorUrls;
QMap<QByteArray, QByteArray> headers;
void interceptRequest(QWebEngineUrlRequestInfo &info) override
{
- QCOMPARE(QThread::currentThread() == QCoreApplication::instance()->thread(), !property("deprecated").toBool());
+ QVERIFY(QThread::currentThread() == QCoreApplication::instance()->thread());
+ qCDebug(lc) << this << "Type:" << info.resourceType() << info.requestMethod() << "Navigation:" << info.navigationType()
+ << info.requestUrl() << "Initiator:" << info.initiator();
// Since 63 we also intercept some unrelated blob requests..
if (info.requestUrl().scheme() == QLatin1String("blob"))
return;
bool block = info.requestMethod() != QByteArrayLiteral("GET");
- bool redirect = shouldRedirect && info.requestUrl() != kRedirectUrl;
+ bool redirect = shouldRedirect && info.requestUrl() != redirectUrl;
+
+ // set additional headers if any required by test
+ for (auto it = headers.begin(); it != headers.end(); ++it) info.setHttpHeader(it.key(), it.value());
if (block) {
info.block(true);
} else if (redirect) {
- info.redirect(kRedirectUrl);
- } else {
- // set additional headers if any required by test
- for (auto it = headers.begin(); it != headers.end(); ++it) info.setHttpHeader(it.key(), it.value());
+ info.redirect(redirectUrl);
}
requestInitiatorUrls[info.requestUrl()].insert(info.initiator());
@@ -195,8 +189,8 @@ public:
return false;
}
- TestRequestInterceptor(bool redirect)
- : shouldRedirect(redirect)
+ TestRequestInterceptor(bool redirect = false, const QUrl &url = kRedirectUrl)
+ : shouldRedirect(redirect), redirectUrl(url)
{
}
};
@@ -220,20 +214,12 @@ public:
QStringList sourceIDs;
};
-void tst_QWebEngineUrlRequestInterceptor::interceptRequest_data()
-{
- QTest::addColumn<InterceptorSetter>("setter");
- QTest::newRow("ui") << &QWebEngineProfile::setUrlRequestInterceptor;
- QTest::newRow("io") << &QWebEngineProfile::setRequestInterceptor;
-}
-
void tst_QWebEngineUrlRequestInterceptor::interceptRequest()
{
- QFETCH(InterceptorSetter, setter);
QWebEngineProfile profile;
profile.settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false);
TestRequestInterceptor interceptor(/* intercept */ false);
- (profile.*setter)(&interceptor);
+ profile.setUrlRequestInterceptor(&interceptor);
QWebEnginePage page(&profile);
QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool)));
@@ -263,7 +249,7 @@ void tst_QWebEngineUrlRequestInterceptor::interceptRequest()
// Make sure that registering an observer does not modify the request.
TestRequestInterceptor observer(/* intercept */ false);
- (profile.*setter)(&observer);
+ profile.setUrlRequestInterceptor(&observer);
page.load(QUrl("qrc:///resources/__placeholder__"));
QTRY_COMPARE(loadSpy.count(), 1);
success = loadSpy.takeFirst().takeFirst();
@@ -292,17 +278,11 @@ public:
QList<QUrl> requestedUrls;
};
-void tst_QWebEngineUrlRequestInterceptor::ipv6HostEncoding_data()
-{
- interceptRequest_data();
-}
-
void tst_QWebEngineUrlRequestInterceptor::ipv6HostEncoding()
{
- QFETCH(InterceptorSetter, setter);
QWebEngineProfile profile;
LocalhostContentProvider contentProvider;
- (profile.*setter)(&contentProvider);
+ profile.setUrlRequestInterceptor(&contentProvider);
QWebEnginePage page(&profile);
QSignalSpy spyLoadFinished(&page, SIGNAL(loadFinished(bool)));
@@ -322,23 +302,20 @@ void tst_QWebEngineUrlRequestInterceptor::ipv6HostEncoding()
void tst_QWebEngineUrlRequestInterceptor::requestedUrl_data()
{
- QTest::addColumn<InterceptorSetter>("setter");
QTest::addColumn<bool>("interceptInPage");
- QTest::newRow("ui profile intercept") << &QWebEngineProfile::setUrlRequestInterceptor << false;
- QTest::newRow("ui page intercept") << &QWebEngineProfile::setUrlRequestInterceptor << true;
- QTest::newRow("io profile intercept") << &QWebEngineProfile::setRequestInterceptor << false;
+ QTest::newRow("profile intercept") << false;
+ QTest::newRow("page intercept") << true;
}
void tst_QWebEngineUrlRequestInterceptor::requestedUrl()
{
- QFETCH(InterceptorSetter, setter);
QFETCH(bool, interceptInPage);
QWebEngineProfile profile;
profile.settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false);
TestRequestInterceptor interceptor(/* intercept */ true);
if (!interceptInPage)
- (profile.*setter)(&interceptor);
+ profile.setUrlRequestInterceptor(&interceptor);
QWebEnginePage page(&profile);
if (interceptInPage)
@@ -377,13 +354,12 @@ void tst_QWebEngineUrlRequestInterceptor::setUrlSameUrl_data()
void tst_QWebEngineUrlRequestInterceptor::setUrlSameUrl()
{
- QFETCH(InterceptorSetter, setter);
QFETCH(bool, interceptInPage);
QWebEngineProfile profile;
TestRequestInterceptor interceptor(/* intercept */ true);
if (!interceptInPage)
- (profile.*setter)(&interceptor);
+ profile.setUrlRequestInterceptor(&interceptor);
QWebEnginePage page(&profile);
if (interceptInPage)
@@ -412,17 +388,11 @@ void tst_QWebEngineUrlRequestInterceptor::setUrlSameUrl()
QCOMPARE(spy.count(), 4);
}
-void tst_QWebEngineUrlRequestInterceptor::firstPartyUrl_data()
-{
- interceptRequest_data();
-}
-
void tst_QWebEngineUrlRequestInterceptor::firstPartyUrl()
{
- QFETCH(InterceptorSetter, setter);
QWebEngineProfile profile;
TestRequestInterceptor interceptor(/* intercept */ false);
- (profile.*setter)(&interceptor);
+ profile.setUrlRequestInterceptor(&interceptor);
QWebEnginePage page(&profile);
QSignalSpy spy(&page, SIGNAL(loadFinished(bool)));
@@ -440,19 +410,13 @@ void tst_QWebEngineUrlRequestInterceptor::firstPartyUrl()
void tst_QWebEngineUrlRequestInterceptor::firstPartyUrlNestedIframes_data()
{
QUrl url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/iframe.html"));
- QTest::addColumn<InterceptorSetter>("setter");
QTest::addColumn<QUrl>("requestUrl");
- QTest::newRow("ui file") << &QWebEngineProfile::setUrlRequestInterceptor << url;
- QTest::newRow("io file") << &QWebEngineProfile::setRequestInterceptor << url;
- QTest::newRow("ui qrc") << &QWebEngineProfile::setUrlRequestInterceptor
- << QUrl("qrc:///resources/iframe.html");
- QTest::newRow("io qrc") << &QWebEngineProfile::setRequestInterceptor
- << QUrl("qrc:///resources/iframe.html");
+ QTest::newRow("ui file") << url;
+ QTest::newRow("ui qrc") << QUrl("qrc:///resources/iframe.html");
}
void tst_QWebEngineUrlRequestInterceptor::firstPartyUrlNestedIframes()
{
- QFETCH(InterceptorSetter, setter);
QFETCH(QUrl, requestUrl);
if (requestUrl.scheme() == "file" && !QDir(TESTS_SOURCE_DIR).exists())
@@ -462,7 +426,7 @@ void tst_QWebEngineUrlRequestInterceptor::firstPartyUrlNestedIframes()
QWebEngineProfile profile;
TestRequestInterceptor interceptor(/* intercept */ false);
- (profile.*setter)(&interceptor);
+ profile.setUrlRequestInterceptor(&interceptor);
QWebEnginePage page(&profile);
QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool)));
@@ -502,47 +466,40 @@ void tst_QWebEngineUrlRequestInterceptor::requestInterceptorByResourceType_data(
QUrl faviconFirstPartyUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/favicon.html"));
QUrl faviconRequestUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/icons/favicon.png"));
- QTest::addColumn<InterceptorSetter>("setter");
QTest::addColumn<QUrl>("requestUrl");
QTest::addColumn<QUrl>("firstPartyUrl");
QTest::addColumn<int>("resourceType");
- QStringList name = { "ui", "io" };
- QVector<InterceptorSetter> setters = { &QWebEngineProfile::setUrlRequestInterceptor,
- &QWebEngineProfile::setRequestInterceptor };
- for (int i = 0; i < 2; i++) {
- QTest::newRow(qPrintable(name[i] + "StyleSheet"))
- << setters[i] << styleRequestUrl << firstPartyUrl
- << static_cast<int>(QWebEngineUrlRequestInfo::ResourceTypeStylesheet);
- QTest::newRow(qPrintable(name[i] + "Script")) << setters[i] << scriptRequestUrl << firstPartyUrl
- << static_cast<int>(QWebEngineUrlRequestInfo::ResourceTypeScript);
- QTest::newRow(qPrintable(name[i] + "Image")) << setters[i] << imageRequestUrl << imageFirstPartyUrl
- << static_cast<int>(QWebEngineUrlRequestInfo::ResourceTypeImage);
- QTest::newRow(qPrintable(name[i] + "FontResource"))
- << setters[i] << fontRequestUrl << firstPartyUrl
- << static_cast<int>(QWebEngineUrlRequestInfo::ResourceTypeFontResource);
- QTest::newRow(qPrintable(name[i] + "Media")) << setters[i] << mediaRequestUrl << mediaFirstPartyUrl
- << static_cast<int>(QWebEngineUrlRequestInfo::ResourceTypeMedia);
- QTest::newRow(qPrintable(name[i] + "Favicon"))
- << setters[i] << faviconRequestUrl << faviconFirstPartyUrl
- << static_cast<int>(QWebEngineUrlRequestInfo::ResourceTypeFavicon);
- QTest::newRow(qPrintable(name[i] + "Xhr")) << setters[i] << xhrRequestUrl << firstPartyUrl
- << static_cast<int>(QWebEngineUrlRequestInfo::ResourceTypeXhr);
- }
+ QTest::newRow("StyleSheet")
+ << styleRequestUrl << firstPartyUrl
+ << static_cast<int>(QWebEngineUrlRequestInfo::ResourceTypeStylesheet);
+ QTest::newRow("Script") << scriptRequestUrl << firstPartyUrl
+ << static_cast<int>(QWebEngineUrlRequestInfo::ResourceTypeScript);
+ QTest::newRow("Image") << imageRequestUrl << imageFirstPartyUrl
+ << static_cast<int>(QWebEngineUrlRequestInfo::ResourceTypeImage);
+ QTest::newRow("FontResource")
+ << fontRequestUrl << firstPartyUrl
+ << static_cast<int>(QWebEngineUrlRequestInfo::ResourceTypeFontResource);
+ QTest::newRow(qPrintable("Media")) << mediaRequestUrl << mediaFirstPartyUrl
+ << static_cast<int>(QWebEngineUrlRequestInfo::ResourceTypeMedia);
+ QTest::newRow("Favicon")
+ << faviconRequestUrl << faviconFirstPartyUrl
+ << static_cast<int>(QWebEngineUrlRequestInfo::ResourceTypeFavicon);
+ QTest::newRow(qPrintable("Xhr")) << xhrRequestUrl << firstPartyUrl
+ << static_cast<int>(QWebEngineUrlRequestInfo::ResourceTypeXhr);
}
void tst_QWebEngineUrlRequestInterceptor::requestInterceptorByResourceType()
{
if (!QDir(TESTS_SOURCE_DIR).exists())
W_QSKIP(QString("This test requires access to resources found in '%1'").arg(TESTS_SOURCE_DIR).toLatin1().constData(), SkipAll);
- QFETCH(InterceptorSetter, setter);
QFETCH(QUrl, requestUrl);
QFETCH(QUrl, firstPartyUrl);
QFETCH(int, resourceType);
QWebEngineProfile profile;
TestRequestInterceptor interceptor(/* intercept */ false);
- (profile.*setter)(&interceptor);
+ profile.setUrlRequestInterceptor(&interceptor);
QWebEnginePage page(&profile);
QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool)));
@@ -557,17 +514,11 @@ void tst_QWebEngineUrlRequestInterceptor::requestInterceptorByResourceType()
QCOMPARE(infos.at(0).resourceType, resourceType);
}
-void tst_QWebEngineUrlRequestInterceptor::firstPartyUrlHttp_data()
-{
- interceptRequest_data();
-}
-
void tst_QWebEngineUrlRequestInterceptor::firstPartyUrlHttp()
{
- QFETCH(InterceptorSetter, setter);
QWebEngineProfile profile;
TestRequestInterceptor interceptor(/* intercept */ false);
- (profile.*setter)(&interceptor);
+ profile.setUrlRequestInterceptor(&interceptor);
QWebEnginePage page(&profile);
QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool)));
@@ -627,56 +578,70 @@ void tst_QWebEngineUrlRequestInterceptor::firstPartyUrlHttp()
QCOMPARE(info.firstPartyUrl, firstPartyUrl);
}
-void tst_QWebEngineUrlRequestInterceptor::passRefererHeader_data()
-{
- interceptRequest_data();
-}
-
-void tst_QWebEngineUrlRequestInterceptor::passRefererHeader()
+void tst_QWebEngineUrlRequestInterceptor::customHeaders()
{
- QFETCH(InterceptorSetter, setter);
// Create HTTP Server to parse the request.
HttpServer httpServer;
-
- if (!httpServer.start())
- QSKIP("Failed to start http server");
-
- bool succeeded = false;
- connect(&httpServer, &HttpServer::newRequest, [&succeeded](HttpReqRep *rr) {
- const QByteArray headerValue = rr->requestHeader(kHttpHeaderRefererName);
- QCOMPARE(headerValue, kHttpHeaderReferrerValue);
- succeeded = headerValue == kHttpHeaderReferrerValue;
- rr->sendResponse();
- });
+ httpServer.setResourceDirs({ TESTS_SOURCE_DIR "qwebengineurlrequestinterceptor/resources" });
+ QVERIFY(httpServer.start());
QWebEngineProfile profile;
TestRequestInterceptor interceptor(false);
- interceptor.headers.insert(kHttpHeaderRefererName, kHttpHeaderReferrerValue);
- (profile.*setter)(&interceptor);
+ profile.setUrlRequestInterceptor(&interceptor);
QWebEnginePage page(&profile);
QSignalSpy spy(&page, SIGNAL(loadFinished(bool)));
- QWebEngineHttpRequest httpRequest;
- QUrl requestUrl = httpServer.url();
- httpRequest.setUrl(requestUrl);
- page.load(httpRequest);
+ interceptor.headers = {
+ { "referer", "http://somereferrer.com/" },
+ { "from", "user@example.com" },
+ { "user-agent", "mozilla/5.0 (x11; linux x86_64; rv:12.0) gecko/20100101 firefox/12.0" },
+ };
+
+ QMap<QByteArray, QByteArray> actual, expected;
+ connect(&httpServer, &HttpServer::newRequest, [&] (HttpReqRep *rr) {
+ for (auto it = expected.begin(); it != expected.end(); ++it) {
+ auto headerValue = rr->requestHeader(it.key());
+ actual[it.key()] = headerValue;
+ QCOMPARE(headerValue, it.value());
+ }
+ });
+
+ auto dumpHeaders = [&] () {
+ QString s; QDebug d(&s);
+ for (auto it = expected.begin(); it != expected.end(); ++it)
+ d << "\n\tHeader:" << it.key() << "| actual:" << actual[it.key()] << "expected:" << it.value();
+ return s;
+ };
+
+ expected = interceptor.headers;
+ page.load(httpServer.url("/content.html"));
QVERIFY(spy.wait());
- (void) httpServer.stop();
- QVERIFY(succeeded);
-}
+ QVERIFY2(actual == expected, qPrintable(dumpHeaders()));
-void tst_QWebEngineUrlRequestInterceptor::initiator_data()
-{
- interceptRequest_data();
+ // test that custom headers are also applied on redirect
+ interceptor.shouldRedirect = true;
+ interceptor.redirectUrl = httpServer.url("/content2.html");
+ interceptor.headers = {
+ { "referer", "http://somereferrer2.com/" },
+ { "from", "user2@example.com" },
+ { "user-agent", "mozilla/5.0 (compatible; googlebot/2.1; +http://www.google.com/bot.html)" },
+ };
+
+ actual.clear();
+ expected = interceptor.headers;
+ page.triggerAction(QWebEnginePage::Reload);
+ QVERIFY(spy.wait());
+ QVERIFY2(actual == expected, qPrintable(dumpHeaders()));
+
+ (void) httpServer.stop();
}
void tst_QWebEngineUrlRequestInterceptor::initiator()
{
- QFETCH(InterceptorSetter, setter);
QWebEngineProfile profile;
TestRequestInterceptor interceptor(/* intercept */ false);
- (profile.*setter)(&interceptor);
+ profile.setUrlRequestInterceptor(&interceptor);
QWebEnginePage page(&profile);
QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool)));
@@ -736,14 +701,8 @@ void tst_QWebEngineUrlRequestInterceptor::initiator()
QVERIFY(interceptor.requestInitiatorUrls[info.requestUrl].contains(info.initiator));
}
-void tst_QWebEngineUrlRequestInterceptor::jsServiceWorker_data()
-{
- interceptRequest_data();
-}
-
void tst_QWebEngineUrlRequestInterceptor::jsServiceWorker()
{
- QFETCH(InterceptorSetter, setter);
HttpServer server;
server.setResourceDirs({ TESTS_SOURCE_DIR "qwebengineurlrequestinterceptor/resources" });
@@ -753,7 +712,7 @@ void tst_QWebEngineUrlRequestInterceptor::jsServiceWorker()
std::unique_ptr<ConsolePage> page;
page.reset(new ConsolePage(&profile));
TestRequestInterceptor interceptor(/* intercept */ false);
- (profile.*setter)(&interceptor);
+ profile.setUrlRequestInterceptor(&interceptor);
QVERIFY(loadSync(page.get(), server.url("/sw.html")));
// We expect only one message here, because logging of services workers is not exposed in our API.
diff --git a/tests/auto/pdf/qpdfsearchmodel/tst_qpdfsearchmodel.cpp b/tests/auto/pdf/qpdfsearchmodel/tst_qpdfsearchmodel.cpp
index e690bfc11..c0706faaf 100644
--- a/tests/auto/pdf/qpdfsearchmodel/tst_qpdfsearchmodel.cpp
+++ b/tests/auto/pdf/qpdfsearchmodel/tst_qpdfsearchmodel.cpp
@@ -58,7 +58,7 @@ void tst_QPdfSearchModel::findText()
QPdfSearchModel model;
model.setDocument(&document);
- QVector<QRectF> matches = model.matches(1, "ai");
+ QList<QRectF> matches = model.matches(1, "ai");
qDebug() << matches;
QCOMPARE(matches.count(), 3);
diff --git a/tests/auto/quick/certificateerror/WebView.qml b/tests/auto/quick/certificateerror/WebView.qml
new file mode 100644
index 000000000..97abdfb98
--- /dev/null
+++ b/tests/auto/quick/certificateerror/WebView.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtWebEngine 1.4
+import QtQuick.Window 2.0
+import QtTest 1.0
+import io.qt.tester 1.0
+
+Window {
+ width: 50
+ height: 50
+ visible: true
+
+ TestHandler {
+ id: handler
+ onLoadPage: function(url) {
+ view.url = url
+ }
+ }
+
+ WebEngineView {
+ id: view
+ anchors.fill: parent
+ onLoadingChanged: function(request) {
+ if (request.status === WebEngineView.LoadSucceededStatus) {
+ handler.loadSuccess = true
+ } else if (request.status === WebEngineView.LoadFailedStatus) {
+ handler.loadSuccess = false
+ }
+ }
+ onCertificateError: function(error) {
+ handler.certificateError = error
+ }
+ Component.onCompleted: {
+ view.settings.errorPageEnabled = false
+ }
+ }
+}
diff --git a/tests/auto/quick/certificateerror/certificateerror.pro b/tests/auto/quick/certificateerror/certificateerror.pro
new file mode 100644
index 000000000..27d5a3cc1
--- /dev/null
+++ b/tests/auto/quick/certificateerror/certificateerror.pro
@@ -0,0 +1,7 @@
+include(../tests.pri)
+include(../../shared/https.pri)
+QT *= webenginecore-private webengine webengine-private
+HEADERS += $$PWD/testhandler.h
+SOURCES += $$PWD/testhandler.cpp
+RESOURCES += certificateerror.qrc
+
diff --git a/tests/auto/quick/certificateerror/certificateerror.qrc b/tests/auto/quick/certificateerror/certificateerror.qrc
new file mode 100644
index 000000000..bfc3013e7
--- /dev/null
+++ b/tests/auto/quick/certificateerror/certificateerror.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>WebView.qml</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/quick/certificateerror/testhandler.cpp b/tests/auto/quick/certificateerror/testhandler.cpp
new file mode 100644
index 000000000..cb6710aa3
--- /dev/null
+++ b/tests/auto/quick/certificateerror/testhandler.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 "testhandler.h"
+
+TestHandler::TestHandler(QObject *parent) : QObject(parent)
+{
+ setObjectName(QStringLiteral("TestListner"));
+}
+
+void TestHandler::load(const QUrl &page)
+{
+ emit loadPage(page);
+}
+
+void TestHandler::setLoadSuccess(bool success)
+{
+ if (m_loadSuccess != success) {
+ m_loadSuccess = success;
+ emit loadSuccessChanged();
+ }
+}
+
+bool TestHandler::loadSuccess() const
+{
+ return m_loadSuccess;
+}
+
+QWebEngineCertificateError TestHandler::certificateError() const
+{
+ return *m_error;
+}
+
+void TestHandler::setCertificateError(QWebEngineCertificateError error)
+{
+ m_error = new QWebEngineCertificateError(error);
+ emit certificateErrorChanged();
+}
diff --git a/tests/auto/quick/certificateerror/testhandler.h b/tests/auto/quick/certificateerror/testhandler.h
new file mode 100644
index 000000000..a6d95d9a9
--- /dev/null
+++ b/tests/auto/quick/certificateerror/testhandler.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 TESTHANDLER_H
+#define TESTHANDLER_H
+
+#include <QWebEngineCertificateError>
+
+class TestHandler : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QWebEngineCertificateError certificateError READ certificateError WRITE
+ setCertificateError NOTIFY certificateErrorChanged)
+ Q_PROPERTY(bool loadSuccess READ loadSuccess WRITE setLoadSuccess NOTIFY loadSuccessChanged)
+public:
+ explicit TestHandler(QObject *parent = nullptr);
+ QWebEngineCertificateError certificateError() const;
+
+ void setCertificateError(QWebEngineCertificateError error);
+ void setLoadSuccess(bool success);
+ bool loadSuccess() const;
+ void load(const QUrl &page);
+
+signals:
+ void loadPage(const QUrl &page);
+ void certificateErrorChanged();
+ void loadSuccessChanged();
+
+private:
+ QWebEngineCertificateError *m_error = nullptr;
+ bool m_loadSuccess = false;
+};
+
+#endif // TESTHANDLER_H
diff --git a/tests/auto/quick/certificateerror/tst_certificateerror.cpp b/tests/auto/quick/certificateerror/tst_certificateerror.cpp
new file mode 100644
index 000000000..3e2dc85fb
--- /dev/null
+++ b/tests/auto/quick/certificateerror/tst_certificateerror.cpp
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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 "testhandler.h"
+#include <httpsserver.h>
+#include <util.h>
+#include <QWebEngineCertificateError>
+#include <QQuickWebEngineProfile>
+#include <QQmlApplicationEngine>
+#include <QQuickWindow>
+#include <QtTest/QtTest>
+
+class tst_CertificateError : public QObject
+{
+ Q_OBJECT
+public:
+ tst_CertificateError() { }
+
+private Q_SLOTS:
+ void initTestCase();
+ void handleError_data();
+ void handleError();
+
+private:
+ QScopedPointer<QQmlApplicationEngine> m_engine;
+ QQuickWindow *m_widnow = nullptr;
+ TestHandler *m_handler = nullptr;
+};
+
+void tst_CertificateError::initTestCase()
+{
+ QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true);
+ qmlRegisterType<TestHandler>("io.qt.tester", 1, 0, "TestHandler");
+ m_engine.reset(new QQmlApplicationEngine());
+ m_engine->load(QUrl(QStringLiteral("qrc:/WebView.qml")));
+ m_widnow = qobject_cast<QQuickWindow *>(m_engine->rootObjects().first());
+ Q_ASSERT(m_widnow);
+ m_handler = m_widnow->findChild<TestHandler *>(QStringLiteral("TestListner"));
+ Q_ASSERT(m_handler);
+}
+
+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);
+
+ QSignalSpy certificateErrorSpy(m_handler, &TestHandler::certificateErrorChanged);
+ m_handler->load(server.url());
+ QTRY_COMPARE(certificateErrorSpy.count(), 1);
+ QWebEngineCertificateError error = m_handler->certificateError();
+
+ if (deferError) {
+ error.defer();
+ return;
+ }
+
+ if (acceptCertificate)
+ error.acceptCertificate();
+ else
+ error.rejectCertificate();
+
+ QVERIFY(error.isOverridable());
+ auto chain = error.certificateChain();
+ 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(!m_handler->loadSuccess());
+
+ if (acceptCertificate)
+ error.acceptCertificate();
+ else
+ error.rejectCertificate();
+ }
+ QTRY_COMPARE_WITH_TIMEOUT(m_handler->loadSuccess(), acceptCertificate, 3000);
+}
+
+static QByteArrayList params;
+W_QTEST_MAIN(tst_CertificateError, params)
+#include <tst_certificateerror.moc>
diff --git a/tests/auto/quick/dialogs/testhandler.cpp b/tests/auto/quick/dialogs/testhandler.cpp
index bdd63a547..78a944cc6 100644
--- a/tests/auto/quick/dialogs/testhandler.cpp
+++ b/tests/auto/quick/dialogs/testhandler.cpp
@@ -30,7 +30,7 @@
TestHandler::TestHandler(QObject *parent) : QObject(parent)
{
- setObjectName(QStringLiteral("TestListner"));
+ setObjectName(QStringLiteral("TestListener"));
}
QObject* TestHandler::request() const
diff --git a/tests/auto/quick/dialogs/tst_dialogs.cpp b/tests/auto/quick/dialogs/tst_dialogs.cpp
index 8e802a836..8f2e79d3b 100644
--- a/tests/auto/quick/dialogs/tst_dialogs.cpp
+++ b/tests/auto/quick/dialogs/tst_dialogs.cpp
@@ -29,22 +29,23 @@
#include "testhandler.h"
#include "server.h"
#include "util.h"
+
#include <QtWebEngine/private/qquickwebenginedialogrequests_p.h>
-#include <QtWebEngine/private/qquickwebenginecontextmenurequest_p.h>
+#include <QtWebEngineCore/qwebenginecontextmenurequest.h>
#include <QQuickWebEngineProfile>
+
+#include <QNetworkProxy>
#include <QQmlApplicationEngine>
#include <QQuickWindow>
-#include <QTest>
#include <QSignalSpy>
-#include <QNetworkProxy>
-
+#include <QTest>
-class tst_Dialogs : public QObject {
+class tst_Dialogs : public QObject
+{
Q_OBJECT
public:
tst_Dialogs(){}
-
private slots:
void initTestCase();
void init();
@@ -57,11 +58,11 @@ private slots:
void authenticationDialogRequested();
private:
- void createDialog(const QLatin1String& dialog, bool &ok);
+ void createDialog(const QLatin1String &dialog, bool &ok);
private:
QScopedPointer<QQmlApplicationEngine> m_engine;
- QQuickWindow *m_widnow;
- TestHandler *m_listner;
+ QQuickWindow *m_window;
+ TestHandler *m_listener;
};
void tst_Dialogs::initTestCase()
@@ -70,10 +71,10 @@ void tst_Dialogs::initTestCase()
qmlRegisterType<TestHandler>("io.qt.tester", 1, 0, "TestHandler");
m_engine.reset(new QQmlApplicationEngine());
m_engine->load(QUrl(QStringLiteral("qrc:/WebView.qml")));
- m_widnow = qobject_cast<QQuickWindow*>(m_engine->rootObjects().first());
- Q_ASSERT(m_widnow);
- m_listner = m_widnow->findChild<TestHandler*>(QStringLiteral("TestListner"));
- Q_ASSERT(m_listner);
+ m_window = qobject_cast<QQuickWindow*>(m_engine->rootObjects().first());
+ Q_ASSERT(m_window);
+ m_listener = m_window->findChild<TestHandler*>(QStringLiteral("TestListener"));
+ Q_ASSERT(m_listener);
QNetworkProxy proxy;
proxy.setType(QNetworkProxy::HttpProxy);
@@ -84,29 +85,29 @@ void tst_Dialogs::initTestCase()
void tst_Dialogs::init()
{
- m_listner->setRequest(nullptr);
- m_listner->setReady(false);
+ m_listener->setRequest(nullptr);
+ m_listener->setReady(false);
}
-void tst_Dialogs::createDialog(const QLatin1String& dialog, bool &ok)
+void tst_Dialogs::createDialog(const QLatin1String &dialog, bool &ok)
{
QString trigger = QStringLiteral("document.getElementById('buttonOne').onclick = function() {document.getElementById('%1').click()}");
- QSignalSpy dialogSpy(m_listner, &TestHandler::requestChanged);
- m_listner->runJavaScript(trigger.arg(dialog));
- QTRY_VERIFY(m_listner->ready());
- QTest::mouseClick(m_widnow, Qt::LeftButton);
+ QSignalSpy dialogSpy(m_listener, &TestHandler::requestChanged);
+ m_listener->runJavaScript(trigger.arg(dialog));
+ QTRY_VERIFY(m_listener->ready());
+ QTest::mouseClick(m_window, Qt::LeftButton);
QTRY_COMPARE(dialogSpy.count(), 1);
ok = true;
}
void tst_Dialogs::colorDialogRequested()
{
- m_listner->load(QUrl("qrc:/index.html"));
- QTRY_VERIFY(m_listner->ready());
+ m_listener->load(QUrl("qrc:/index.html"));
+ QTRY_VERIFY(m_listener->ready());
bool ok = false;
createDialog(QLatin1String("colorpicker"), ok);
if (ok) {
- auto dialog = qobject_cast<QQuickWebEngineColorDialogRequest*>(m_listner->request());
+ auto *dialog = qobject_cast<QQuickWebEngineColorDialogRequest*>(m_listener->request());
QVERIFY2(dialog, "Incorrect dialog requested");
dialog->dialogReject();
QVERIFY2(dialog->isAccepted(), "Dialog is not accepted");
@@ -116,23 +117,23 @@ void tst_Dialogs::colorDialogRequested()
void tst_Dialogs::contextMenuRequested()
{
- m_listner->load(QUrl("qrc:/index.html"));
- QTRY_COMPARE_WITH_TIMEOUT(m_listner->ready(), true, 20000);
- QSignalSpy dialogSpy(m_listner, &TestHandler::requestChanged);
- QTest::mouseClick(m_widnow, Qt::RightButton);
+ m_listener->load(QUrl("qrc:/index.html"));
+ QTRY_COMPARE_WITH_TIMEOUT(m_listener->ready(), true, 20000);
+ QSignalSpy dialogSpy(m_listener, &TestHandler::requestChanged);
+ QTest::mouseClick(m_window, Qt::RightButton);
QTRY_COMPARE(dialogSpy.count(), 1);
- auto dialog = qobject_cast<QQuickWebEngineContextMenuRequest*>(m_listner->request());
+ auto dialog = qobject_cast<QWebEngineContextMenuRequest *>(m_listener->request());
QVERIFY2(dialog, "Incorrect dialog requested");
}
void tst_Dialogs::fileDialogRequested()
{
- m_listner->load(QUrl("qrc:/index.html"));
- QTRY_VERIFY(m_listner->ready());
+ m_listener->load(QUrl("qrc:/index.html"));
+ QTRY_VERIFY(m_listener->ready());
bool ok = false;
createDialog(QLatin1String("filepicker"), ok);
if (ok) {
- auto dialog = qobject_cast<QQuickWebEngineFileDialogRequest*>(m_listner->request());
+ auto dialog = qobject_cast<QQuickWebEngineFileDialogRequest*>(m_listener->request());
QVERIFY2(dialog, "Incorrect dialog requested");
dialog->dialogReject();
QVERIFY2(dialog->isAccepted(), "Dialog is not accepted");
@@ -173,11 +174,11 @@ void tst_Dialogs::authenticationDialogRequested()
server.run();
QTRY_VERIFY2(server.isListening(), "Could not setup authentication server");
- QSignalSpy dialogSpy(m_listner, &TestHandler::requestChanged);
- m_listner->load(url);
+ QSignalSpy dialogSpy(m_listener, &TestHandler::requestChanged);
+ m_listener->load(url);
QTRY_COMPARE(dialogSpy.count(), 1);
- auto dialog = qobject_cast<QQuickWebEngineAuthenticationDialogRequest*>(m_listner->request());
+ auto *dialog = qobject_cast<QQuickWebEngineAuthenticationDialogRequest*>(m_listener->request());
QVERIFY2(dialog, "Incorrect dialog requested");
dialog->dialogReject();
QVERIFY2(dialog->isAccepted(), "Dialog is not accepted");
@@ -214,20 +215,20 @@ void tst_Dialogs::javaScriptDialogRequested()
QFETCH(QString, message);
QFETCH(QString, defaultText);
- m_listner->load(QUrl("qrc:/index.html"));
- QTRY_VERIFY(m_listner->ready());
+ m_listener->load(QUrl("qrc:/index.html"));
+ QTRY_VERIFY(m_listener->ready());
- QSignalSpy dialogSpy(m_listner, &TestHandler::requestChanged);
- m_listner->runJavaScript(script);
+ QSignalSpy dialogSpy(m_listener, &TestHandler::requestChanged);
+ m_listener->runJavaScript(script);
QTRY_COMPARE(dialogSpy.count(), 1);
- auto dialog = qobject_cast<QQuickWebEngineJavaScriptDialogRequest*>(m_listner->request());
+ auto *dialog = qobject_cast<QQuickWebEngineJavaScriptDialogRequest*>(m_listener->request());
QVERIFY2(dialog, "Incorrect dialog requested");
dialog->dialogReject();
QVERIFY2(dialog->isAccepted(), "Dialog is not accepted");
QCOMPARE(dialog->type(), type);
QCOMPARE(dialog->message(), message);
QCOMPARE(dialog->defaultText(), defaultText);
- QTRY_VERIFY(m_listner->ready()); // make sure javascript executes no longer
+ QTRY_VERIFY(m_listener->ready()); // make sure javascript executes no longer
}
static QByteArrayList params;
diff --git a/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp b/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
index 85257fcb7..1f30fce5b 100644
--- a/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
+++ b/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
@@ -105,8 +105,15 @@ inline QQuickWebEngineView* tst_InspectorServer::webView() const
QJsonArray tst_InspectorServer::fetchPageList() const
{
QNetworkAccessManager qnam;
- QScopedPointer<QNetworkReply> reply(qnam.get(QNetworkRequest(s_inspectorServerHttpBaseUrl.resolved(QUrl("json/list")))));
- QSignalSpy(reply.data(), SIGNAL(finished())).wait();
+ QSignalSpy spy(&qnam, &QNetworkAccessManager::finished);;
+ QNetworkRequest request(s_inspectorServerHttpBaseUrl.resolved(QUrl("json/list")));
+ QScopedPointer<QNetworkReply> reply(qnam.get(request));
+ spy.wait();
+ // Work-around a network bug in Qt6:
+ if (reply->error() == QNetworkReply::ContentNotFoundError) {
+ reply.reset(qnam.get(request));
+ spy.wait();
+ }
return QJsonDocument::fromJson(reply->readAll()).array();
}
diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp
index dad962576..e79ed86de 100644
--- a/tests/auto/quick/publicapi/tst_publicapi.cpp
+++ b/tests/auto/quick/publicapi/tst_publicapi.cpp
@@ -34,24 +34,25 @@
#include <QQmlListProperty>
#include <QtTest/QtTest>
#include <QtWebEngine/QQuickWebEngineProfile>
-#include <QtWebEngine/QQuickWebEngineScript>
+#include <QtWebEngineCore/QWebEngineCertificateError>
#include <QtWebEngineCore/QWebEngineFindTextResult>
+#include <QtWebEngineCore/QWebEngineFullScreenRequest>
#include <QtWebEngineCore/QWebEngineNotification>
#include <QtWebEngineCore/QWebEngineQuotaRequest>
#include <QtWebEngineCore/QWebEngineRegisterProtocolHandlerRequest>
+#include <QtWebEngineCore/QWebEngineContextMenuRequest>
+#include <QtWebEngineCore/QWebEngineDownloadRequest>
+#include <QtWebEngineCore/QWebEngineScript>
#include <private/qquickwebengineview_p.h>
#include <private/qquickwebengineaction_p.h>
-#include <private/qquickwebenginecertificateerror_p.h>
#include <private/qquickwebengineclientcertificateselection_p.h>
#include <private/qquickwebenginedialogrequests_p.h>
-#include <private/qquickwebenginedownloaditem_p.h>
#include <private/qquickwebenginehistory_p.h>
#include <private/qquickwebengineloadrequest_p.h>
#include <private/qquickwebenginenavigationrequest_p.h>
#include <private/qquickwebenginenewviewrequest_p.h>
#include <private/qquickwebenginesettings_p.h>
#include <private/qquickwebenginesingleton_p.h>
-#include <private/qquickwebenginecontextmenurequest_p.h>
class tst_publicapi : public QObject {
Q_OBJECT
@@ -62,19 +63,18 @@ private Q_SLOTS:
static const QList<const QMetaObject *> typesToCheck = QList<const QMetaObject *>()
<< &QQuickWebEngineView::staticMetaObject
<< &QQuickWebEngineAction::staticMetaObject
- << &QQuickWebEngineCertificateError::staticMetaObject
<< &QQuickWebEngineClientCertificateOption::staticMetaObject
<< &QQuickWebEngineClientCertificateSelection::staticMetaObject
- << &QQuickWebEngineDownloadItem::staticMetaObject
+ << &QWebEngineDownloadRequest::staticMetaObject
<< &QQuickWebEngineHistory::staticMetaObject
<< &QQuickWebEngineHistoryListModel::staticMetaObject
<< &QQuickWebEngineLoadRequest::staticMetaObject
<< &QQuickWebEngineNavigationRequest::staticMetaObject
<< &QQuickWebEngineNewViewRequest::staticMetaObject
<< &QQuickWebEngineProfile::staticMetaObject
- << &QQuickWebEngineScript::staticMetaObject
<< &QQuickWebEngineSettings::staticMetaObject
- << &QQuickWebEngineFullScreenRequest::staticMetaObject
+ << &QWebEngineFullScreenRequest::staticMetaObject
+ << &QWebEngineScript::staticMetaObject
<< &QQuickWebEngineSingleton::staticMetaObject
<< &QQuickWebEngineAuthenticationDialogRequest::staticMetaObject
<< &QQuickWebEngineJavaScriptDialogRequest::staticMetaObject
@@ -82,7 +82,8 @@ static const QList<const QMetaObject *> typesToCheck = QList<const QMetaObject *
<< &QQuickWebEngineFileDialogRequest::staticMetaObject
<< &QQuickWebEngineFormValidationMessageRequest::staticMetaObject
<< &QQuickWebEngineTooltipRequest::staticMetaObject
- << &QQuickWebEngineContextMenuRequest::staticMetaObject
+ << &QWebEngineContextMenuRequest::staticMetaObject
+ << &QWebEngineCertificateError::staticMetaObject
<< &QWebEngineQuotaRequest::staticMetaObject
<< &QWebEngineRegisterProtocolHandlerRequest::staticMetaObject
<< &QWebEngineNotification::staticMetaObject
@@ -93,7 +94,7 @@ static QList<const char *> knownEnumNames = QList<const char *>();
static const QStringList hardcodedTypes = QStringList()
<< "QJSValue"
- << "QQmlListProperty<QQuickWebEngineScript>"
+ << "QQmlListProperty<QWebEngineScript>"
<< "QQmlListProperty<QQuickWebEngineClientCertificateOption>"
<< "const QQuickWebEngineClientCertificateOption*"
<< "QQmlWebChannel*"
@@ -103,7 +104,7 @@ static const QStringList hardcodedTypes = QStringList()
<< "const QQuickWebEngineContextMenuData*"
<< "QWebEngineCookieStore*"
<< "Qt::LayoutDirection"
- ;
+ << "QQuickWebEngineScriptCollection*";
static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineAction.text --> QString"
@@ -121,29 +122,31 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineAuthenticationDialogRequest.realm --> QString"
<< "QQuickWebEngineAuthenticationDialogRequest.type --> AuthenticationType"
<< "QQuickWebEngineAuthenticationDialogRequest.url --> QUrl"
- << "QQuickWebEngineCertificateError.CertificateAuthorityInvalid --> Error"
- << "QQuickWebEngineCertificateError.CertificateCommonNameInvalid --> Error"
- << "QQuickWebEngineCertificateError.CertificateContainsErrors --> Error"
- << "QQuickWebEngineCertificateError.CertificateDateInvalid --> Error"
- << "QQuickWebEngineCertificateError.CertificateInvalid --> Error"
- << "QQuickWebEngineCertificateError.CertificateKnownInterceptionBlocked --> Error"
- << "QQuickWebEngineCertificateError.CertificateNameConstraintViolation --> Error"
- << "QQuickWebEngineCertificateError.CertificateNoRevocationMechanism --> Error"
- << "QQuickWebEngineCertificateError.CertificateNonUniqueName --> Error"
- << "QQuickWebEngineCertificateError.CertificateRevoked --> Error"
- << "QQuickWebEngineCertificateError.CertificateTransparencyRequired --> Error"
- << "QQuickWebEngineCertificateError.CertificateUnableToCheckRevocation --> Error"
- << "QQuickWebEngineCertificateError.CertificateValidityTooLong --> Error"
- << "QQuickWebEngineCertificateError.CertificateWeakKey --> Error"
- << "QQuickWebEngineCertificateError.CertificateWeakSignatureAlgorithm --> Error"
- << "QQuickWebEngineCertificateError.SslPinnedKeyNotInCertificateChain --> Error"
- << "QQuickWebEngineCertificateError.defer() --> void"
- << "QQuickWebEngineCertificateError.description --> QString"
- << "QQuickWebEngineCertificateError.error --> Error"
- << "QQuickWebEngineCertificateError.ignoreCertificateError() --> void"
- << "QQuickWebEngineCertificateError.overridable --> bool"
- << "QQuickWebEngineCertificateError.rejectCertificate() --> void"
- << "QQuickWebEngineCertificateError.url --> QUrl"
+ << "QWebEngineCertificateError.CertificateAuthorityInvalid --> Type"
+ << "QWebEngineCertificateError.CertificateCommonNameInvalid --> Type"
+ << "QWebEngineCertificateError.CertificateContainsErrors --> Type"
+ << "QWebEngineCertificateError.CertificateDateInvalid --> Type"
+ << "QWebEngineCertificateError.CertificateInvalid --> Type"
+ << "QWebEngineCertificateError.CertificateKnownInterceptionBlocked --> Type"
+ << "QWebEngineCertificateError.CertificateNameConstraintViolation --> Type"
+ << "QWebEngineCertificateError.CertificateNoRevocationMechanism --> Type"
+ << "QWebEngineCertificateError.CertificateNonUniqueName --> Type"
+ << "QWebEngineCertificateError.CertificateRevoked --> Type"
+ << "QWebEngineCertificateError.CertificateTransparencyRequired --> Type"
+ << "QWebEngineCertificateError.CertificateUnableToCheckRevocation --> Type"
+ << "QWebEngineCertificateError.CertificateValidityTooLong --> Type"
+ << "QWebEngineCertificateError.CertificateWeakKey --> Type"
+ << "QWebEngineCertificateError.CertificateWeakSignatureAlgorithm --> Type"
+ << "QWebEngineCertificateError.CertificateSymantecLegacy --> Type"
+ << "QWebEngineCertificateError.SslObsoleteVersion --> Type"
+ << "QWebEngineCertificateError.SslPinnedKeyNotInCertificateChain --> Type"
+ << "QWebEngineCertificateError.defer() --> void"
+ << "QWebEngineCertificateError.description --> QString"
+ << "QWebEngineCertificateError.type --> Type"
+ << "QWebEngineCertificateError.acceptCertificate() --> void"
+ << "QWebEngineCertificateError.overridable --> bool"
+ << "QWebEngineCertificateError.rejectCertificate() --> void"
+ << "QWebEngineCertificateError.url --> QUrl"
<< "QQuickWebEngineClientCertificateOption.issuer --> QString"
<< "QQuickWebEngineClientCertificateOption.subject --> QString"
<< "QQuickWebEngineClientCertificateOption.effectiveDate --> QDateTime"
@@ -157,118 +160,109 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineClientCertificateSelection.selectNone() --> void"
<< "QQuickWebEngineColorDialogRequest.accepted --> bool"
<< "QQuickWebEngineColorDialogRequest.color --> QColor"
- << "QQuickWebEngineContextMenuRequest.CanUndo --> EditFlags"
- << "QQuickWebEngineContextMenuRequest.CanRedo --> EditFlags"
- << "QQuickWebEngineContextMenuRequest.CanCut --> EditFlags"
- << "QQuickWebEngineContextMenuRequest.CanCopy --> EditFlags"
- << "QQuickWebEngineContextMenuRequest.CanPaste --> EditFlags"
- << "QQuickWebEngineContextMenuRequest.CanDelete --> EditFlags"
- << "QQuickWebEngineContextMenuRequest.CanSelectAll --> EditFlags"
- << "QQuickWebEngineContextMenuRequest.CanTranslate --> EditFlags"
- << "QQuickWebEngineContextMenuRequest.CanEditRichly --> EditFlags"
+ << "QWebEngineContextMenuRequest.CanUndo --> EditFlags"
+ << "QWebEngineContextMenuRequest.CanRedo --> EditFlags"
+ << "QWebEngineContextMenuRequest.CanCut --> EditFlags"
+ << "QWebEngineContextMenuRequest.CanCopy --> EditFlags"
+ << "QWebEngineContextMenuRequest.CanPaste --> EditFlags"
+ << "QWebEngineContextMenuRequest.CanDelete --> EditFlags"
+ << "QWebEngineContextMenuRequest.CanSelectAll --> EditFlags"
+ << "QWebEngineContextMenuRequest.CanTranslate --> EditFlags"
+ << "QWebEngineContextMenuRequest.CanEditRichly --> EditFlags"
<< "QQuickWebEngineColorDialogRequest.dialogAccept(QColor) --> void"
<< "QQuickWebEngineColorDialogRequest.dialogReject() --> void"
- << "QQuickWebEngineContextMenuRequest.editFlags --> EditFlags"
- << "QQuickWebEngineContextMenuRequest.MediaInError --> MediaFlags"
- << "QQuickWebEngineContextMenuRequest.MediaPaused --> MediaFlags"
- << "QQuickWebEngineContextMenuRequest.MediaMuted --> MediaFlags"
- << "QQuickWebEngineContextMenuRequest.MediaLoop --> MediaFlags"
- << "QQuickWebEngineContextMenuRequest.MediaCanSave --> MediaFlags"
- << "QQuickWebEngineContextMenuRequest.MediaHasAudio --> MediaFlags"
- << "QQuickWebEngineContextMenuRequest.MediaCanToggleControls --> MediaFlags"
- << "QQuickWebEngineContextMenuRequest.MediaControls --> MediaFlags"
- << "QQuickWebEngineContextMenuRequest.MediaCanPrint --> MediaFlags"
- << "QQuickWebEngineContextMenuRequest.MediaCanRotate --> MediaFlags"
- << "QQuickWebEngineContextMenuRequest.MediaTypeAudio --> MediaType"
- << "QQuickWebEngineContextMenuRequest.MediaTypeCanvas --> MediaType"
- << "QQuickWebEngineContextMenuRequest.MediaTypeFile --> MediaType"
- << "QQuickWebEngineContextMenuRequest.MediaTypeImage --> MediaType"
- << "QQuickWebEngineContextMenuRequest.MediaTypeNone --> MediaType"
- << "QQuickWebEngineContextMenuRequest.MediaTypePlugin --> MediaType"
- << "QQuickWebEngineContextMenuRequest.MediaTypeVideo --> MediaType"
- << "QQuickWebEngineContextMenuRequest.accepted --> bool"
- << "QQuickWebEngineContextMenuRequest.isContentEditable --> bool"
- << "QQuickWebEngineContextMenuRequest.linkText --> QString"
- << "QQuickWebEngineContextMenuRequest.linkUrl --> QUrl"
- << "QQuickWebEngineContextMenuRequest.mediaFlags --> MediaFlags"
- << "QQuickWebEngineContextMenuRequest.mediaType --> MediaType"
- << "QQuickWebEngineContextMenuRequest.mediaUrl --> QUrl"
- << "QQuickWebEngineContextMenuRequest.misspelledWord --> QString"
- << "QQuickWebEngineContextMenuRequest.selectedText --> QString"
- << "QQuickWebEngineContextMenuRequest.spellCheckerSuggestions --> QStringList"
- << "QQuickWebEngineContextMenuRequest.x --> int"
- << "QQuickWebEngineContextMenuRequest.y --> int"
- << "QQuickWebEngineDownloadItem.Attachment --> DownloadType"
- << "QQuickWebEngineDownloadItem.CompleteHtmlSaveFormat --> SavePageFormat"
- << "QQuickWebEngineDownloadItem.DownloadAttribute --> DownloadType"
- << "QQuickWebEngineDownloadItem.DownloadCancelled --> DownloadState"
- << "QQuickWebEngineDownloadItem.DownloadCompleted --> DownloadState"
- << "QQuickWebEngineDownloadItem.DownloadInProgress --> DownloadState"
- << "QQuickWebEngineDownloadItem.DownloadInterrupted --> DownloadState"
- << "QQuickWebEngineDownloadItem.DownloadRequested --> DownloadState"
- << "QQuickWebEngineDownloadItem.FileAccessDenied --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileBlocked --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileFailed --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileHashMismatch --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileNameTooLong --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileNoSpace --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileSecurityCheckFailed --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileTooLarge --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileTooShort --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileTransientError --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileVirusInfected --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.MimeHtmlSaveFormat --> SavePageFormat"
- << "QQuickWebEngineDownloadItem.NetworkDisconnected --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.NetworkFailed --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.NetworkInvalidRequest --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.NetworkServerDown --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.NetworkTimeout --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.NoReason --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.SavePage --> DownloadType"
- << "QQuickWebEngineDownloadItem.ServerBadContent --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.ServerCertProblem --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.ServerFailed --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.ServerForbidden --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.ServerUnauthorized --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.ServerUnreachable --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.SingleHtmlSaveFormat --> SavePageFormat"
- << "QQuickWebEngineDownloadItem.UnknownSaveFormat --> SavePageFormat"
- << "QQuickWebEngineDownloadItem.UserCanceled --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.UserRequested --> DownloadType"
- << "QQuickWebEngineDownloadItem.accept() --> void"
- << "QQuickWebEngineDownloadItem.cancel() --> void"
- << "QQuickWebEngineDownloadItem.id --> uint"
- << "QQuickWebEngineDownloadItem.interruptReason --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.interruptReasonChanged() --> void"
- << "QQuickWebEngineDownloadItem.interruptReasonString --> QString"
- << "QQuickWebEngineDownloadItem.isFinished --> bool"
- << "QQuickWebEngineDownloadItem.isFinishedChanged() --> void"
- << "QQuickWebEngineDownloadItem.isPaused --> bool"
- << "QQuickWebEngineDownloadItem.isPausedChanged() --> void"
- << "QQuickWebEngineDownloadItem.isSavePageDownload --> bool"
- << "QQuickWebEngineDownloadItem.mimeType --> QString"
- << "QQuickWebEngineDownloadItem.mimeTypeChanged() --> void"
- << "QQuickWebEngineDownloadItem.path --> QString"
- << "QQuickWebEngineDownloadItem.pathChanged() --> void"
- << "QQuickWebEngineDownloadItem.pause() --> void"
- << "QQuickWebEngineDownloadItem.receivedBytes --> qlonglong"
- << "QQuickWebEngineDownloadItem.receivedBytesChanged() --> void"
- << "QQuickWebEngineDownloadItem.resume() --> void"
- << "QQuickWebEngineDownloadItem.savePageFormat --> SavePageFormat"
- << "QQuickWebEngineDownloadItem.savePageFormatChanged() --> void"
- << "QQuickWebEngineDownloadItem.state --> DownloadState"
- << "QQuickWebEngineDownloadItem.stateChanged() --> void"
- << "QQuickWebEngineDownloadItem.totalBytes --> qlonglong"
- << "QQuickWebEngineDownloadItem.totalBytesChanged() --> void"
- << "QQuickWebEngineDownloadItem.type --> DownloadType"
- << "QQuickWebEngineDownloadItem.typeChanged() --> void"
- << "QQuickWebEngineDownloadItem.view --> QQuickWebEngineView*"
- << "QQuickWebEngineDownloadItem.url --> QUrl"
- << "QQuickWebEngineDownloadItem.suggestedFileName --> QString"
- << "QQuickWebEngineDownloadItem.downloadDirectory --> QString"
- << "QQuickWebEngineDownloadItem.downloadDirectoryChanged() --> void"
- << "QQuickWebEngineDownloadItem.downloadFileName --> QString"
- << "QQuickWebEngineDownloadItem.downloadFileNameChanged() --> void"
+ << "QWebEngineContextMenuRequest.editFlags --> EditFlags"
+ << "QWebEngineContextMenuRequest.MediaInError --> MediaFlags"
+ << "QWebEngineContextMenuRequest.MediaPaused --> MediaFlags"
+ << "QWebEngineContextMenuRequest.MediaMuted --> MediaFlags"
+ << "QWebEngineContextMenuRequest.MediaLoop --> MediaFlags"
+ << "QWebEngineContextMenuRequest.MediaCanSave --> MediaFlags"
+ << "QWebEngineContextMenuRequest.MediaHasAudio --> MediaFlags"
+ << "QWebEngineContextMenuRequest.MediaCanToggleControls --> MediaFlags"
+ << "QWebEngineContextMenuRequest.MediaControls --> MediaFlags"
+ << "QWebEngineContextMenuRequest.MediaCanPrint --> MediaFlags"
+ << "QWebEngineContextMenuRequest.MediaCanRotate --> MediaFlags"
+ << "QWebEngineContextMenuRequest.MediaTypeAudio --> MediaType"
+ << "QWebEngineContextMenuRequest.MediaTypeCanvas --> MediaType"
+ << "QWebEngineContextMenuRequest.MediaTypeFile --> MediaType"
+ << "QWebEngineContextMenuRequest.MediaTypeImage --> MediaType"
+ << "QWebEngineContextMenuRequest.MediaTypeNone --> MediaType"
+ << "QWebEngineContextMenuRequest.MediaTypePlugin --> MediaType"
+ << "QWebEngineContextMenuRequest.MediaTypeVideo --> MediaType"
+ << "QWebEngineContextMenuRequest.accepted --> bool"
+ << "QWebEngineContextMenuRequest.isContentEditable --> bool"
+ << "QWebEngineContextMenuRequest.linkText --> QString"
+ << "QWebEngineContextMenuRequest.linkUrl --> QUrl"
+ << "QWebEngineContextMenuRequest.mediaFlags --> MediaFlags"
+ << "QWebEngineContextMenuRequest.mediaType --> MediaType"
+ << "QWebEngineContextMenuRequest.mediaUrl --> QUrl"
+ << "QWebEngineContextMenuRequest.misspelledWord --> QString"
+ << "QWebEngineContextMenuRequest.selectedText --> QString"
+ << "QWebEngineContextMenuRequest.spellCheckerSuggestions --> QStringList"
+ << "QWebEngineContextMenuRequest.position --> QPoint"
+ << "QWebEngineDownloadRequest.CompleteHtmlSaveFormat --> SavePageFormat"
+ << "QWebEngineDownloadRequest.DownloadCancelled --> DownloadState"
+ << "QWebEngineDownloadRequest.DownloadCompleted --> DownloadState"
+ << "QWebEngineDownloadRequest.DownloadInProgress --> DownloadState"
+ << "QWebEngineDownloadRequest.DownloadInterrupted --> DownloadState"
+ << "QWebEngineDownloadRequest.DownloadRequested --> DownloadState"
+ << "QWebEngineDownloadRequest.FileAccessDenied --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.FileBlocked --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.FileFailed --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.FileHashMismatch --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.FileNameTooLong --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.FileNoSpace --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.FileSecurityCheckFailed --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.FileTooLarge --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.FileTooShort --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.FileTransientError --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.FileVirusInfected --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.MimeHtmlSaveFormat --> SavePageFormat"
+ << "QWebEngineDownloadRequest.NetworkDisconnected --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.NetworkFailed --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.NetworkInvalidRequest --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.NetworkServerDown --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.NetworkTimeout --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.NoReason --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.ServerBadContent --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.ServerCertProblem --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.ServerFailed --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.ServerForbidden --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.ServerUnauthorized --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.ServerUnreachable --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.SingleHtmlSaveFormat --> SavePageFormat"
+ << "QWebEngineDownloadRequest.UnknownSaveFormat --> SavePageFormat"
+ << "QWebEngineDownloadRequest.UserCanceled --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.accept() --> void"
+ << "QWebEngineDownloadRequest.cancel() --> void"
+ << "QWebEngineDownloadRequest.id --> uint"
+ << "QWebEngineDownloadRequest.interruptReason --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.interruptReasonChanged() --> void"
+ << "QWebEngineDownloadRequest.interruptReasonString --> QString"
+ << "QWebEngineDownloadRequest.isFinished --> bool"
+ << "QWebEngineDownloadRequest.isFinishedChanged() --> void"
+ << "QWebEngineDownloadRequest.isPaused --> bool"
+ << "QWebEngineDownloadRequest.isPausedChanged() --> void"
+ << "QWebEngineDownloadRequest.isSavePageDownload --> bool"
+ << "QWebEngineDownloadRequest.mimeType --> QString"
+ << "QWebEngineDownloadRequest.pause() --> void"
+ << "QWebEngineDownloadRequest.receivedBytes --> qlonglong"
+ << "QWebEngineDownloadRequest.receivedBytesChanged() --> void"
+ << "QWebEngineDownloadRequest.resume() --> void"
+ << "QWebEngineDownloadRequest.savePageFormat --> SavePageFormat"
+ << "QWebEngineDownloadRequest.savePageFormatChanged() --> void"
+ << "QWebEngineDownloadRequest.state --> DownloadState"
+ << "QWebEngineDownloadRequest.stateChanged(QWebEngineDownloadRequest::DownloadState) --> void"
+ << "QWebEngineDownloadRequest.totalBytes --> qlonglong"
+ << "QWebEngineDownloadRequest.totalBytesChanged() --> void"
+ // FIXME << "QWebEngineDownloadRequest.view --> QQuickWebEngineView*"
+ << "QWebEngineDownloadRequest.url --> QUrl"
+ << "QWebEngineDownloadRequest.suggestedFileName --> QString"
+ << "QWebEngineDownloadRequest.downloadDirectory --> QString"
+ << "QWebEngineDownloadRequest.downloadDirectoryChanged() --> void"
+ << "QWebEngineDownloadRequest.downloadFileName --> QString"
+ << "QWebEngineDownloadRequest.downloadFileNameChanged() --> void"
+ << "QWebEngineDownloadRequest.downloadProgress(qlonglong,qlonglong) --> void" // FIXME
<< "QQuickWebEngineFileDialogRequest.FileModeOpen --> FileMode"
<< "QQuickWebEngineFileDialogRequest.FileModeOpenMultiple --> FileMode"
<< "QQuickWebEngineFileDialogRequest.FileModeSave --> FileMode"
@@ -296,10 +290,10 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineTooltipRequest.text --> QString"
<< "QQuickWebEngineTooltipRequest.type --> RequestType"
<< "QQuickWebEngineTooltipRequest.accepted --> bool"
- << "QQuickWebEngineFullScreenRequest.accept() --> void"
- << "QQuickWebEngineFullScreenRequest.origin --> QUrl"
- << "QQuickWebEngineFullScreenRequest.reject() --> void"
- << "QQuickWebEngineFullScreenRequest.toggleOn --> bool"
+ << "QWebEngineFullScreenRequest.accept() --> void"
+ << "QWebEngineFullScreenRequest.origin --> QUrl"
+ << "QWebEngineFullScreenRequest.reject() --> void"
+ << "QWebEngineFullScreenRequest.toggleOn --> bool"
<< "QQuickWebEngineHistory.backItems --> QQuickWebEngineHistoryListModel*"
<< "QQuickWebEngineHistory.clear() --> void"
<< "QQuickWebEngineHistory.forwardItems --> QQuickWebEngineHistoryListModel*"
@@ -340,8 +334,8 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineProfile.cachePath --> QString"
<< "QQuickWebEngineProfile.cachePathChanged() --> void"
<< "QQuickWebEngineProfile.clearHttpCache() --> void"
- << "QQuickWebEngineProfile.downloadFinished(QQuickWebEngineDownloadItem*) --> void"
- << "QQuickWebEngineProfile.downloadRequested(QQuickWebEngineDownloadItem*) --> void"
+ << "QQuickWebEngineProfile.downloadFinished(QWebEngineDownloadRequest*) --> void"
+ << "QQuickWebEngineProfile.downloadRequested(QWebEngineDownloadRequest*) --> void"
<< "QQuickWebEngineProfile.downloadPath --> QString"
<< "QQuickWebEngineProfile.downloadPathChanged() --> void"
<< "QQuickWebEngineProfile.presentNotification(QWebEngineNotification*) --> void"
@@ -367,32 +361,7 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineProfile.storageNameChanged() --> void"
<< "QQuickWebEngineProfile.useForGlobalCertificateVerification --> bool"
<< "QQuickWebEngineProfile.useForGlobalCertificateVerificationChanged() --> void"
- << "QQuickWebEngineProfile.userScripts --> QQmlListProperty<QQuickWebEngineScript>"
- << "QQuickWebEngineScript.ApplicationWorld --> ScriptWorldId"
- << "QQuickWebEngineScript.Deferred --> InjectionPoint"
- << "QQuickWebEngineScript.DocumentCreation --> InjectionPoint"
- << "QQuickWebEngineScript.DocumentReady --> InjectionPoint"
- << "QQuickWebEngineScript.MainWorld --> ScriptWorldId"
- << "QQuickWebEngineScript.UserWorld --> ScriptWorldId"
- << "QQuickWebEngineScript.injectionPoint --> InjectionPoint"
- << "QQuickWebEngineScript.injectionPointChanged(InjectionPoint) --> void"
- << "QQuickWebEngineScript.name --> QString"
- << "QQuickWebEngineScript.nameChanged(QString) --> void"
- << "QQuickWebEngineScript.runOnSubframes --> bool"
- << "QQuickWebEngineScript.runOnSubframesChanged(bool) --> void"
- << "QQuickWebEngineScript.setInjectionPoint(InjectionPoint) --> void"
- << "QQuickWebEngineScript.setName(QString) --> void"
- << "QQuickWebEngineScript.setRunOnSubframes(bool) --> void"
- << "QQuickWebEngineScript.setSourceCode(QString) --> void"
- << "QQuickWebEngineScript.setSourceUrl(QUrl) --> void"
- << "QQuickWebEngineScript.setWorldId(ScriptWorldId) --> void"
- << "QQuickWebEngineScript.sourceCode --> QString"
- << "QQuickWebEngineScript.sourceCodeChanged(QString) --> void"
- << "QQuickWebEngineScript.sourceUrl --> QUrl"
- << "QQuickWebEngineScript.sourceUrlChanged(QUrl) --> void"
- << "QQuickWebEngineScript.toString() --> QString"
- << "QQuickWebEngineScript.worldId --> ScriptWorldId"
- << "QQuickWebEngineScript.worldIdChanged(ScriptWorldId) --> void"
+ << "QQuickWebEngineProfile.userScripts --> QQuickWebEngineScriptCollection*"
<< "QQuickWebEngineSettings.AllowAllUnknownUrlSchemes --> UnknownUrlSchemePolicy"
<< "QQuickWebEngineSettings.AllowUnknownUrlSchemesFromUserInteraction --> UnknownUrlSchemePolicy"
<< "QQuickWebEngineSettings.DisallowUnknownUrlSchemes --> UnknownUrlSchemePolicy"
@@ -460,6 +429,19 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineSettings.webRTCPublicInterfacesOnlyChanged() --> void"
<< "QQuickWebEngineSingleton.defaultProfile --> QQuickWebEngineProfile*"
<< "QQuickWebEngineSingleton.settings --> QQuickWebEngineSettings*"
+ << "QQuickWebEngineSingleton.script() --> QWebEngineScript"
+ << "QWebEngineScript.ApplicationWorld --> ScriptWorldId"
+ << "QWebEngineScript.Deferred --> InjectionPoint"
+ << "QWebEngineScript.DocumentCreation --> InjectionPoint"
+ << "QWebEngineScript.DocumentReady --> InjectionPoint"
+ << "QWebEngineScript.MainWorld --> ScriptWorldId"
+ << "QWebEngineScript.UserWorld --> ScriptWorldId"
+ << "QWebEngineScript.injectionPoint --> InjectionPoint"
+ << "QWebEngineScript.name --> QString"
+ << "QWebEngineScript.runsOnSubFrames --> bool"
+ << "QWebEngineScript.sourceCode --> QString"
+ << "QWebEngineScript.sourceUrl --> QUrl"
+ << "QWebEngineScript.worldId --> uint"
<< "QQuickWebEngineView.action(WebAction) --> QQuickWebEngineAction*"
<< "QQuickWebEngineView.A0 --> PrintedPageSizeId"
<< "QQuickWebEngineView.A1 --> PrintedPageSizeId"
@@ -688,11 +670,11 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.backgroundColorChanged() --> void"
<< "QQuickWebEngineView.canGoBack --> bool"
<< "QQuickWebEngineView.canGoForward --> bool"
- << "QQuickWebEngineView.certificateError(QQuickWebEngineCertificateError*) --> void"
+ << "QQuickWebEngineView.certificateError(QWebEngineCertificateError) --> void"
<< "QQuickWebEngineView.colorDialogRequested(QQuickWebEngineColorDialogRequest*) --> void"
<< "QQuickWebEngineView.contentsSize --> QSizeF"
<< "QQuickWebEngineView.contentsSizeChanged(QSizeF) --> void"
- << "QQuickWebEngineView.contextMenuRequested(QQuickWebEngineContextMenuRequest*) --> void"
+ << "QQuickWebEngineView.contextMenuRequested(QWebEngineContextMenuRequest*) --> void"
<< "QQuickWebEngineView.devToolsView --> QQuickWebEngineView*"
<< "QQuickWebEngineView.devToolsViewChanged() --> void"
<< "QQuickWebEngineView.featurePermissionRequested(QUrl,Feature) --> void"
@@ -703,7 +685,7 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.findTextFinished(QWebEngineFindTextResult) --> void"
<< "QQuickWebEngineView.formValidationMessageRequested(QQuickWebEngineFormValidationMessageRequest*) --> void"
<< "QQuickWebEngineView.fullScreenCancelled() --> void"
- << "QQuickWebEngineView.fullScreenRequested(QQuickWebEngineFullScreenRequest) --> void"
+ << "QQuickWebEngineView.fullScreenRequested(QWebEngineFullScreenRequest) --> void"
<< "QQuickWebEngineView.geometryChangeRequested(QRect,QRect) --> void"
<< "QQuickWebEngineView.goBack() --> void"
<< "QQuickWebEngineView.goBackOrForward(int) --> void"
@@ -771,8 +753,10 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.triggerWebAction(WebAction) --> void"
<< "QQuickWebEngineView.url --> QUrl"
<< "QQuickWebEngineView.urlChanged() --> void"
- << "QQuickWebEngineView.userScripts --> QQmlListProperty<QQuickWebEngineScript>"
+ << "QQuickWebEngineView.userScripts --> QQuickWebEngineScriptCollection*"
+#if QT_CONFIG(webengine_webchannel)
<< "QQuickWebEngineView.webChannel --> QQmlWebChannel*"
+#endif
<< "QQuickWebEngineView.webChannelChanged() --> void"
<< "QQuickWebEngineView.webChannelWorld --> uint"
<< "QQuickWebEngineView.webChannelWorldChanged(uint) --> void"
diff --git a/tests/auto/quick/qmltests/BLACKLIST b/tests/auto/quick/qmltests/BLACKLIST
deleted file mode 100644
index 46bc65923..000000000
--- a/tests/auto/quick/qmltests/BLACKLIST
+++ /dev/null
@@ -1,2 +0,0 @@
-[WebEngineViewSource::test_viewSourceURL]
-*
diff --git a/tests/auto/quick/qmltests/data/TestWebEngineView.qml b/tests/auto/quick/qmltests/data/TestWebEngineView.qml
index 6db076ae8..f2bc09e4b 100644
--- a/tests/auto/quick/qmltests/data/TestWebEngineView.qml
+++ b/tests/auto/quick/qmltests/data/TestWebEngineView.qml
@@ -85,12 +85,14 @@ WebEngineView {
function getElementCenter(element) {
var center;
- runJavaScript("(function() {" +
+ testCase.tryVerify(function() {
+ runJavaScript("(function() {" +
" var elem = document.getElementById('" + element + "');" +
" var rect = elem.getBoundingClientRect();" +
" return { 'x': (rect.left + rect.right) / 2, 'y': (rect.top + rect.bottom) / 2 };" +
"})();", function(result) { center = result } );
- testCase.tryVerify(function() { return center !== undefined; });
+ return center !== undefined;
+ });
return center;
}
diff --git a/tests/auto/quick/qmltests2/data/accepttypes.html b/tests/auto/quick/qmltests/data/accepttypes.html
index aff39f96e..aff39f96e 100644
--- a/tests/auto/quick/qmltests2/data/accepttypes.html
+++ b/tests/auto/quick/qmltests/data/accepttypes.html
diff --git a/tests/auto/quick/qmltests2/data/alert.html b/tests/auto/quick/qmltests/data/alert.html
index 89715a727..89715a727 100644
--- a/tests/auto/quick/qmltests2/data/alert.html
+++ b/tests/auto/quick/qmltests/data/alert.html
diff --git a/tests/auto/quick/qmltests2/data/confirm.html b/tests/auto/quick/qmltests/data/confirm.html
index a4fc5b532..a4fc5b532 100644
--- a/tests/auto/quick/qmltests2/data/confirm.html
+++ b/tests/auto/quick/qmltests/data/confirm.html
diff --git a/tests/auto/quick/qmltests2/data/confirmclose.html b/tests/auto/quick/qmltests/data/confirmclose.html
index c2acbb67f..c2acbb67f 100644
--- a/tests/auto/quick/qmltests2/data/confirmclose.html
+++ b/tests/auto/quick/qmltests/data/confirmclose.html
diff --git a/tests/auto/quick/qmltests2/data/directoryupload.html b/tests/auto/quick/qmltests/data/directoryupload.html
index adc408ebb..adc408ebb 100644
--- a/tests/auto/quick/qmltests2/data/directoryupload.html
+++ b/tests/auto/quick/qmltests/data/directoryupload.html
diff --git a/tests/auto/quick/qmltests2/data/favicon-candidates-gray.html b/tests/auto/quick/qmltests/data/favicon-candidates-gray.html
index ebea35b02..ebea35b02 100644
--- a/tests/auto/quick/qmltests2/data/favicon-candidates-gray.html
+++ b/tests/auto/quick/qmltests/data/favicon-candidates-gray.html
diff --git a/tests/auto/quick/qmltests2/data/favicon-misc.html b/tests/auto/quick/qmltests/data/favicon-misc.html
index 9e788bdf4..9e788bdf4 100644
--- a/tests/auto/quick/qmltests2/data/favicon-misc.html
+++ b/tests/auto/quick/qmltests/data/favicon-misc.html
diff --git a/tests/auto/quick/qmltests2/data/favicon-multi-gray.html b/tests/auto/quick/qmltests/data/favicon-multi-gray.html
index 24b71640f..24b71640f 100644
--- a/tests/auto/quick/qmltests2/data/favicon-multi-gray.html
+++ b/tests/auto/quick/qmltests/data/favicon-multi-gray.html
diff --git a/tests/auto/quick/qmltests2/data/favicon-multi.html b/tests/auto/quick/qmltests/data/favicon-multi.html
index cc5f3fd66..cc5f3fd66 100644
--- a/tests/auto/quick/qmltests2/data/favicon-multi.html
+++ b/tests/auto/quick/qmltests/data/favicon-multi.html
diff --git a/tests/auto/quick/qmltests2/data/favicon-shortcut.html b/tests/auto/quick/qmltests/data/favicon-shortcut.html
index 786cdb816..786cdb816 100644
--- a/tests/auto/quick/qmltests2/data/favicon-shortcut.html
+++ b/tests/auto/quick/qmltests/data/favicon-shortcut.html
diff --git a/tests/auto/quick/qmltests2/data/favicon-single.html b/tests/auto/quick/qmltests/data/favicon-single.html
index eb4675c75..eb4675c75 100644
--- a/tests/auto/quick/qmltests2/data/favicon-single.html
+++ b/tests/auto/quick/qmltests/data/favicon-single.html
diff --git a/tests/auto/quick/qmltests2/data/favicon-touch.html b/tests/auto/quick/qmltests/data/favicon-touch.html
index 271783434..271783434 100644
--- a/tests/auto/quick/qmltests2/data/favicon-touch.html
+++ b/tests/auto/quick/qmltests/data/favicon-touch.html
diff --git a/tests/auto/quick/qmltests2/data/favicon-unavailable.html b/tests/auto/quick/qmltests/data/favicon-unavailable.html
index c45664294..c45664294 100644
--- a/tests/auto/quick/qmltests2/data/favicon-unavailable.html
+++ b/tests/auto/quick/qmltests/data/favicon-unavailable.html
diff --git a/tests/auto/quick/qmltests2/data/favicon2.html b/tests/auto/quick/qmltests/data/favicon2.html
index 81c2690fe..81c2690fe 100644
--- a/tests/auto/quick/qmltests2/data/favicon2.html
+++ b/tests/auto/quick/qmltests/data/favicon2.html
diff --git a/tests/auto/quick/qmltests2/data/icons/gray128.png b/tests/auto/quick/qmltests/data/icons/gray128.png
index bf1cfaba0..bf1cfaba0 100644
--- a/tests/auto/quick/qmltests2/data/icons/gray128.png
+++ b/tests/auto/quick/qmltests/data/icons/gray128.png
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/gray16.png b/tests/auto/quick/qmltests/data/icons/gray16.png
index 2a1a91a76..2a1a91a76 100644
--- a/tests/auto/quick/qmltests2/data/icons/gray16.png
+++ b/tests/auto/quick/qmltests/data/icons/gray16.png
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/gray255.png b/tests/auto/quick/qmltests/data/icons/gray255.png
index 549169551..549169551 100644
--- a/tests/auto/quick/qmltests2/data/icons/gray255.png
+++ b/tests/auto/quick/qmltests/data/icons/gray255.png
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/gray32.png b/tests/auto/quick/qmltests/data/icons/gray32.png
index b269a528f..b269a528f 100644
--- a/tests/auto/quick/qmltests2/data/icons/gray32.png
+++ b/tests/auto/quick/qmltests/data/icons/gray32.png
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/gray64.png b/tests/auto/quick/qmltests/data/icons/gray64.png
index e02559e5b..e02559e5b 100644
--- a/tests/auto/quick/qmltests2/data/icons/gray64.png
+++ b/tests/auto/quick/qmltests/data/icons/gray64.png
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/grayicons.ico b/tests/auto/quick/qmltests/data/icons/grayicons.ico
index 8d8fee839..8d8fee839 100644
--- a/tests/auto/quick/qmltests2/data/icons/grayicons.ico
+++ b/tests/auto/quick/qmltests/data/icons/grayicons.ico
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/qt144.png b/tests/auto/quick/qmltests/data/icons/qt144.png
index 050b1e066..050b1e066 100644
--- a/tests/auto/quick/qmltests2/data/icons/qt144.png
+++ b/tests/auto/quick/qmltests/data/icons/qt144.png
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/qt32.ico b/tests/auto/quick/qmltests/data/icons/qt32.ico
index 2f6fcb5bc..2f6fcb5bc 100644
--- a/tests/auto/quick/qmltests2/data/icons/qt32.ico
+++ b/tests/auto/quick/qmltests/data/icons/qt32.ico
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/qtmulti.ico b/tests/auto/quick/qmltests/data/icons/qtmulti.ico
index 81e5a22e8..81e5a22e8 100644
--- a/tests/auto/quick/qmltests2/data/icons/qtmulti.ico
+++ b/tests/auto/quick/qmltests/data/icons/qtmulti.ico
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/small-favicon.png b/tests/auto/quick/qmltests/data/icons/small-favicon.png
index 8cf9a50a4..8cf9a50a4 100644
--- a/tests/auto/quick/qmltests2/data/icons/small-favicon.png
+++ b/tests/auto/quick/qmltests/data/icons/small-favicon.png
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/multifileupload.html b/tests/auto/quick/qmltests/data/multifileupload.html
index d41ea15c0..d41ea15c0 100644
--- a/tests/auto/quick/qmltests2/data/multifileupload.html
+++ b/tests/auto/quick/qmltests/data/multifileupload.html
diff --git a/tests/auto/quick/qmltests2/data/prompt.html b/tests/auto/quick/qmltests/data/prompt.html
index 3293c0dcf..3293c0dcf 100644
--- a/tests/auto/quick/qmltests2/data/prompt.html
+++ b/tests/auto/quick/qmltests/data/prompt.html
diff --git a/tests/auto/quick/qmltests2/data/singlefileupload.html b/tests/auto/quick/qmltests/data/singlefileupload.html
index ac91c2c0d..ac91c2c0d 100644
--- a/tests/auto/quick/qmltests2/data/singlefileupload.html
+++ b/tests/auto/quick/qmltests/data/singlefileupload.html
diff --git a/tests/auto/quick/qmltests/data/test2.html b/tests/auto/quick/qmltests/data/test2.html
index 629c2a063..7a02bf1f2 100644
--- a/tests/auto/quick/qmltests/data/test2.html
+++ b/tests/auto/quick/qmltests/data/test2.html
@@ -1,6 +1,6 @@
<html>
<head><title>Test page with huge link area</title></head>
<body>
-<a title="A title" href="test1.html"><img width=200 height=200></a>
+<a id="link" title="A title" href="test1.html"><img width=200 height=200></a>
</body>
</html>
diff --git a/tests/auto/quick/qmltests2/data/titleupdate.js b/tests/auto/quick/qmltests/data/titleupdate.js
index c86139c13..c86139c13 100644
--- a/tests/auto/quick/qmltests2/data/titleupdate.js
+++ b/tests/auto/quick/qmltests/data/titleupdate.js
diff --git a/tests/auto/quick/qmltests_ssl/data/tst_certificateError.qml b/tests/auto/quick/qmltests/data/tst_certificateError.qml
index 4c252e210..976de88a9 100644
--- a/tests/auto/quick/qmltests_ssl/data/tst_certificateError.qml
+++ b/tests/auto/quick/qmltests/data/tst_certificateError.qml
@@ -83,7 +83,7 @@ TestWebEngineView {
if (deferError)
error.defer()
else if (acceptCertificate)
- error.ignoreCertificateError()
+ error.acceptCertificate()
else
error.rejectCertificate()
}
@@ -98,7 +98,7 @@ TestWebEngineView {
let error = spyError.signalArguments[0][0]
if (data.acceptCertificate)
- error.ignoreCertificateError()
+ error.acceptCertificate()
else
error.rejectCertificate()
}
diff --git a/tests/auto/quick/qmltests/data/tst_download.qml b/tests/auto/quick/qmltests/data/tst_download.qml
index 1b1750dd8..8607d846d 100644
--- a/tests/auto/quick/qmltests/data/tst_download.qml
+++ b/tests/auto/quick/qmltests/data/tst_download.qml
@@ -155,7 +155,7 @@ TestWebEngineView {
compare(downLoadRequestedSpy.count, 1)
compare(downloadUrl, webEngineView.url)
compare(suggestedFileName, "download.zip")
- compare(downloadState[0], WebEngineDownloadItem.DownloadRequested)
+ compare(downloadState[0], WebEngineDownloadRequest.DownloadRequested)
verify(!downloadInterruptReason)
}
@@ -179,11 +179,11 @@ TestWebEngineView {
compare(downLoadRequestedSpy.count, 1)
compare(downloadUrl, webEngineView.url)
compare(suggestedFileName, "download.zip")
- compare(downloadState[0], WebEngineDownloadItem.DownloadRequested)
- tryCompare(downloadState, "1", WebEngineDownloadItem.DownloadInProgress)
+ compare(downloadState[0], WebEngineDownloadRequest.DownloadRequested)
+ tryCompare(downloadState, "1", WebEngineDownloadRequest.DownloadInProgress)
downloadFinishedSpy.wait()
compare(totalBytes, receivedBytes)
- tryCompare(downloadState, "2", WebEngineDownloadItem.DownloadCompleted)
+ tryCompare(downloadState, "2", WebEngineDownloadRequest.DownloadCompleted)
verify(!downloadInterruptReason)
}
@@ -196,8 +196,8 @@ TestWebEngineView {
compare(downloadUrl, webEngineView.url)
compare(suggestedFileName, "download.zip")
compare(downloadFinishedSpy.count, 1)
- tryCompare(downloadState, "1", WebEngineDownloadItem.DownloadCancelled)
- tryCompare(webEngineView, "downloadInterruptReason", WebEngineDownloadItem.UserCanceled)
+ tryCompare(downloadState, "1", WebEngineDownloadRequest.DownloadCancelled)
+ tryCompare(webEngineView, "downloadInterruptReason", WebEngineDownloadRequest.UserCanceled)
}
function test_downloadLocation() {
@@ -230,15 +230,15 @@ TestWebEngineView {
compare(downLoadRequestedSpy.count, 1);
compare(downloadUrl, webEngineView.url);
compare(suggestedFileName, "download.zip");
- compare(downloadState[0], WebEngineDownloadItem.DownloadRequested);
- tryCompare(downloadState, "1", WebEngineDownloadItem.DownloadInProgress);
+ compare(downloadState[0], WebEngineDownloadRequest.DownloadRequested);
+ tryCompare(downloadState, "1", WebEngineDownloadRequest.DownloadInProgress);
compare(downloadedPath, testDownloadProfile.downloadPath + downloadDirectory + downloadFileName);
compare(downloadDirectoryChanged, 1);
compare(downloadFileNameChanged, 1);
compare(downloadPathChanged, 2);
downloadFinishedSpy.wait();
compare(totalBytes, receivedBytes);
- tryCompare(downloadState, "2", WebEngineDownloadItem.DownloadCompleted);
+ tryCompare(downloadState, "2", WebEngineDownloadRequest.DownloadCompleted);
verify(!downloadInterruptReason);
}
@@ -253,15 +253,15 @@ TestWebEngineView {
compare(downLoadRequestedSpy.count, 1);
compare(downloadUrl, webEngineView.url);
compare(suggestedFileName, "download.zip");
- compare(downloadState[0], WebEngineDownloadItem.DownloadRequested);
- tryCompare(downloadState, "1", WebEngineDownloadItem.DownloadInProgress);
+ compare(downloadState[0], WebEngineDownloadRequest.DownloadRequested);
+ tryCompare(downloadState, "1", WebEngineDownloadRequest.DownloadInProgress);
compare(downloadedPath, testDownloadProfile.downloadPath + downloadDirectory + "download.zip");
compare(downloadDirectoryChanged, 1);
compare(downloadFileNameChanged, 0);
compare(downloadPathChanged, 1);
downloadFinishedSpy.wait();
compare(totalBytes, receivedBytes);
- tryCompare(downloadState, "2", WebEngineDownloadItem.DownloadCompleted);
+ tryCompare(downloadState, "2", WebEngineDownloadRequest.DownloadCompleted);
verify(!downloadInterruptReason);
// Download the same file to another directory with suggested file name.
@@ -277,15 +277,15 @@ TestWebEngineView {
compare(downLoadRequestedSpy.count, 1);
compare(downloadUrl, webEngineView.url);
compare(suggestedFileName, "download.zip");
- compare(downloadState[0], WebEngineDownloadItem.DownloadRequested);
- tryCompare(downloadState, "1", WebEngineDownloadItem.DownloadInProgress);
+ compare(downloadState[0], WebEngineDownloadRequest.DownloadRequested);
+ tryCompare(downloadState, "1", WebEngineDownloadRequest.DownloadInProgress);
compare(downloadedPath, testDownloadProfile.downloadPath + downloadDirectory + "download.zip");
compare(downloadDirectoryChanged, 1);
compare(downloadFileNameChanged, 0);
compare(downloadPathChanged, 1);
downloadFinishedSpy.wait();
compare(totalBytes, receivedBytes);
- tryCompare(downloadState, "2", WebEngineDownloadItem.DownloadCompleted);
+ tryCompare(downloadState, "2", WebEngineDownloadRequest.DownloadCompleted);
verify(!downloadInterruptReason);
// Download same file to same directory second time -> file name should be unified.
@@ -301,15 +301,15 @@ TestWebEngineView {
compare(downLoadRequestedSpy.count, 1);
compare(downloadUrl, webEngineView.url);
compare(suggestedFileName, "download.zip");
- compare(downloadState[0], WebEngineDownloadItem.DownloadRequested);
- tryCompare(downloadState, "1", WebEngineDownloadItem.DownloadInProgress);
+ compare(downloadState[0], WebEngineDownloadRequest.DownloadRequested);
+ tryCompare(downloadState, "1", WebEngineDownloadRequest.DownloadInProgress);
compare(downloadedPath, testDownloadProfile.downloadPath + downloadDirectory + "download (1).zip");
compare(downloadDirectoryChanged, 1);
compare(downloadFileNameChanged, 1);
compare(downloadPathChanged, 1);
downloadFinishedSpy.wait();
compare(totalBytes, receivedBytes);
- tryCompare(downloadState, "2", WebEngineDownloadItem.DownloadCompleted);
+ tryCompare(downloadState, "2", WebEngineDownloadRequest.DownloadCompleted);
verify(!downloadInterruptReason);
}
@@ -323,15 +323,15 @@ TestWebEngineView {
compare(downLoadRequestedSpy.count, 1);
compare(downloadUrl, webEngineView.url);
compare(suggestedFileName, "download.zip");
- compare(downloadState[0], WebEngineDownloadItem.DownloadRequested);
- tryCompare(downloadState, "1", WebEngineDownloadItem.DownloadInProgress);
+ compare(downloadState[0], WebEngineDownloadRequest.DownloadRequested);
+ tryCompare(downloadState, "1", WebEngineDownloadRequest.DownloadInProgress);
compare(downloadedPath, testDownloadProfile.downloadPath + downloadedSetPath);
compare(downloadDirectoryChanged, 1);
compare(downloadFileNameChanged, 1);
compare(downloadPathChanged, 2);
downloadFinishedSpy.wait();
compare(totalBytes, receivedBytes);
- tryCompare(downloadState, "2", WebEngineDownloadItem.DownloadCompleted);
+ tryCompare(downloadState, "2", WebEngineDownloadRequest.DownloadCompleted);
verify(!downloadInterruptReason);
}
}
diff --git a/tests/auto/quick/qmltests2/data/tst_favicon.qml b/tests/auto/quick/qmltests/data/tst_favicon.qml
index 3f522d91a..3f522d91a 100644
--- a/tests/auto/quick/qmltests2/data/tst_favicon.qml
+++ b/tests/auto/quick/qmltests/data/tst_favicon.qml
diff --git a/tests/auto/quick/qmltests2/data/tst_faviconDownload.qml b/tests/auto/quick/qmltests/data/tst_faviconDownload.qml
index 9aa32279c..9aa32279c 100644
--- a/tests/auto/quick/qmltests2/data/tst_faviconDownload.qml
+++ b/tests/auto/quick/qmltests/data/tst_faviconDownload.qml
diff --git a/tests/auto/quick/qmltests2/data/tst_filePicker.qml b/tests/auto/quick/qmltests/data/tst_filePicker.qml
index ab30d9e82..ab30d9e82 100644
--- a/tests/auto/quick/qmltests2/data/tst_filePicker.qml
+++ b/tests/auto/quick/qmltests/data/tst_filePicker.qml
diff --git a/tests/auto/quick/qmltests2/data/tst_inputMethod.qml b/tests/auto/quick/qmltests/data/tst_inputMethod.qml
index 0bf9f7eb0..0bf9f7eb0 100644
--- a/tests/auto/quick/qmltests2/data/tst_inputMethod.qml
+++ b/tests/auto/quick/qmltests/data/tst_inputMethod.qml
diff --git a/tests/auto/quick/qmltests2/data/tst_javaScriptDialogs.qml b/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml
index 658071005..a521ea0d6 100644
--- a/tests/auto/quick/qmltests2/data/tst_javaScriptDialogs.qml
+++ b/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml
@@ -112,6 +112,13 @@ TestWebEngineView {
simulateUserGesture()
webEngineView.triggerWebAction(WebEngineView.RequestClose);
verify(webEngineView.waitForWindowCloseRequested());
+
+ // Navigate away from page with onbeforeunload handler,
+ // otherwise it would trigger an extra dialog request when
+ // navigating in the subsequent test.
+ webEngineView.url = Qt.resolvedUrl("about:blank");
+ verify(webEngineView.waitForLoadSucceeded());
+ compare(JSDialogParams.dialogCount, 2)
}
function test_rejectClose() {
@@ -123,6 +130,14 @@ TestWebEngineView {
simulateUserGesture()
webEngineView.triggerWebAction(WebEngineView.RequestClose);
verify(webEngineView.testSupport.waitForWindowCloseRejected());
+
+ // Navigate away from page with onbeforeunload handler,
+ // otherwise it would trigger an extra dialog request when
+ // navigating in the subsequent test.
+ JSDialogParams.shouldAcceptDialog = true;
+ webEngineView.url = Qt.resolvedUrl("about:blank");
+ verify(webEngineView.waitForLoadSucceeded());
+ compare(JSDialogParams.dialogCount, 2)
}
function test_prompt() {
diff --git a/tests/auto/quick/qmltests2/data/tst_linkHovered.qml b/tests/auto/quick/qmltests/data/tst_linkHovered.qml
index faf943c55..faf943c55 100644
--- a/tests/auto/quick/qmltests2/data/tst_linkHovered.qml
+++ b/tests/auto/quick/qmltests/data/tst_linkHovered.qml
diff --git a/tests/auto/quick/qmltests2/data/tst_loadFail.qml b/tests/auto/quick/qmltests/data/tst_loadFail.qml
index db412f252..db412f252 100644
--- a/tests/auto/quick/qmltests2/data/tst_loadFail.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadFail.qml
diff --git a/tests/auto/quick/qmltests/data/tst_loadUrl.qml b/tests/auto/quick/qmltests/data/tst_loadUrl.qml
index 872c46641..47dbbc087 100644
--- a/tests/auto/quick/qmltests/data/tst_loadUrl.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadUrl.qml
@@ -301,8 +301,8 @@ TestWebEngineView {
// In-page navigation.
webEngineView.url = Qt.resolvedUrl("test4.html#content");
// In-page navigation doesn't trigger load succeeded, wait for load progress instead.
+ tryCompare(loadRequestArray, "length", 3);
tryCompare(webEngineView, "loadProgress", 100);
- compare(loadRequestArray.length, 3);
compare(loadRequestArray[2].status, WebEngineView.LoadStartedStatus);
// Load after in-page navigation.
diff --git a/tests/auto/quick/qmltests2/data/tst_mouseClick.qml b/tests/auto/quick/qmltests/data/tst_mouseClick.qml
index eaa012f86..eaa012f86 100644
--- a/tests/auto/quick/qmltests2/data/tst_mouseClick.qml
+++ b/tests/auto/quick/qmltests/data/tst_mouseClick.qml
diff --git a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
index 80389e9f8..08d63d956 100644
--- a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
+++ b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
@@ -38,6 +38,13 @@ TestWebEngineView {
property var newViewRequest: null
property var dialog: null
property string viewType: ""
+ property var loadRequestArray: []
+
+ onLoadingChanged: {
+ loadRequestArray.push({
+ "status": loadRequest.status,
+ });
+ }
SignalSpy {
id: newViewRequestedSpy
@@ -81,6 +88,7 @@ TestWebEngineView {
newViewRequestedSpy.clear();
newViewRequest = null;
viewType = "";
+ loadRequestArray = [];
}
function cleanup() {
@@ -163,6 +171,23 @@ TestWebEngineView {
}
newViewRequestedSpy.clear();
}
+
+ loadRequestArray = [];
+ compare(loadRequestArray.length, 0);
+ webEngineView.url = Qt.resolvedUrl("test2.html");
+ verify(webEngineView.waitForLoadSucceeded());
+ var center = getElementCenter("link");
+ mouseClick(webEngineView, center.x, center.y, Qt.LeftButton, Qt.ControlModifier);
+ tryCompare(newViewRequestedSpy, "count", 1);
+ compare(newViewRequest.requestedUrl, Qt.resolvedUrl("test1.html"));
+ compare(newViewRequest.destination, WebEngineView.NewViewInBackgroundTab);
+ verify(newViewRequest.userInitiated);
+ if (viewType === "" || viewType === "null") {
+ compare(loadRequestArray[0].status, WebEngineView.LoadStartedStatus);
+ compare(loadRequestArray[1].status, WebEngineView.LoadSucceededStatus);
+ compare(loadRequestArray.length, 2);
+ }
+ newViewRequestedSpy.clear();
}
}
}
diff --git a/tests/auto/quick/qmltests/data/tst_userScripts.qml b/tests/auto/quick/qmltests/data/tst_userScripts.qml
index f4fcc30ab..4d0bd28bf 100644
--- a/tests/auto/quick/qmltests/data/tst_userScripts.qml
+++ b/tests/auto/quick/qmltests/data/tst_userScripts.qml
@@ -31,32 +31,33 @@ import QtTest 1.0
import QtWebEngine 1.2
Item {
- WebEngineScript {
- id: changeDocumentTitleScript
- sourceUrl: Qt.resolvedUrl("change-document-title.js")
- injectionPoint: WebEngineScript.DocumentReady
+
+ function changeDocumentTitleScript() {
+ return { name: "changeDocumentTitleScript",
+ sourceUrl: Qt.resolvedUrl("change-document-title.js"),
+ injectionPoint: WebEngineScript.DocumentReady }
}
- WebEngineScript {
- id: appendDocumentTitleScript
- sourceUrl: Qt.resolvedUrl("append-document-title.js")
- injectionPoint: WebEngineScript.DocumentReady
+ function appendDocumentTitleScript() {
+ return { sourceUrl: Qt.resolvedUrl("append-document-title.js"),
+ injectionPoint: WebEngineScript.DocumentReady }
}
- WebEngineScript {
- id: bigUserScript
- sourceUrl: Qt.resolvedUrl("big-user-script.js")
- injectionPoint: WebEngineScript.DocumentReady
+ function bigUserScript() {
+ return { sourceUrl: Qt.resolvedUrl("big-user-script.js"),
+ injectionPoint: WebEngineScript.DocumentReady }
}
- WebEngineScript {
- id: scriptWithMetadata
- sourceUrl: Qt.resolvedUrl("script-with-metadata.js")
+ function scriptWithMetadata() {
+ var script = WebEngine.script()
+ script.sourceUrl = Qt.resolvedUrl("script-with-metadata.js")
+ return script
}
- WebEngineScript {
- id: scriptWithBadMatchMetadata
- sourceUrl: Qt.resolvedUrl("script-with-bad-match-metadata.js")
+ function scriptWithBadMatchMetadata() {
+ var script = WebEngine.script()
+ script.sourceUrl = Qt.resolvedUrl("script-with-bad-match-metadata.js")
+ return script
}
TestWebEngineView {
@@ -79,21 +80,22 @@ Item {
onNavigationRequested: {
var urlString = request.url.toString();
if (urlString.indexOf("test1.html") !== -1)
- userScripts = [ changeDocumentTitleScript ];
+ userScripts.collection = [ changeDocumentTitleScript() ];
else if (urlString.indexOf("test2.html") !== -1)
- userScripts = [ appendDocumentTitleScript ];
+ userScripts.collection = [ appendDocumentTitleScript() ];
else
- userScripts = [];
+ userScripts.collection = [];
}
}
TestCase {
name: "WebEngineViewUserScripts"
+
function init() {
webEngineView.url = "";
- webEngineView.userScripts = [];
- webEngineView.profile.userScripts = [];
+ webEngineView.userScripts.collection = [];
+ webEngineView.profile.userScripts.collection = [];
}
function test_oneScript() {
@@ -101,7 +103,8 @@ Item {
webEngineView.waitForLoadSucceeded();
tryCompare(webEngineView, "title", "Test page 1");
- webEngineView.userScripts = [ changeDocumentTitleScript ];
+ webEngineView.userScripts.collection = [ changeDocumentTitleScript() ]
+
compare(webEngineView.title, "Test page 1");
webEngineView.reload();
@@ -112,7 +115,7 @@ Item {
webEngineView.waitForLoadSucceeded();
tryCompare(webEngineView, "title", "New title");
- webEngineView.userScripts = [];
+ webEngineView.userScripts.collection = [];
compare(webEngineView.title, "New title");
webEngineView.reload();
@@ -124,23 +127,25 @@ Item {
webEngineView.url = Qt.resolvedUrl("test1.html");
webEngineView.waitForLoadSucceeded();
tryCompare(webEngineView, "title", "Test page 1");
-
- webEngineView.userScripts = [ changeDocumentTitleScript, appendDocumentTitleScript ];
+ var script1 = changeDocumentTitleScript();
+ var script2 = appendDocumentTitleScript();
+ script2.injectionPoint = WebEngineScript.Deferred;
+ webEngineView.userScripts.collection = [ script1, script2 ];
// Make sure the scripts are loaded in order.
- appendDocumentTitleScript.injectionPoint = WebEngineScript.Deferred
webEngineView.reload();
webEngineView.waitForLoadSucceeded();
tryCompare(webEngineView, "title", "New title with appendix");
- appendDocumentTitleScript.injectionPoint = WebEngineScript.DocumentReady
- changeDocumentTitleScript.injectionPoint = WebEngineScript.Deferred
+ script2.injectionPoint = WebEngineScript.DocumentReady
+ script1.injectionPoint = WebEngineScript.Deferred
+ webEngineView.userScripts.collection = [ script1, script2 ];
webEngineView.reload();
webEngineView.waitForLoadSucceeded();
tryCompare(webEngineView, "title", "New title");
// Make sure we can remove scripts from the preload list.
- webEngineView.userScripts = [ appendDocumentTitleScript ];
+ webEngineView.userScripts.collection = [ script2 ];
webEngineView.reload();
webEngineView.waitForLoadSucceeded();
tryCompare(webEngineView, "title", "Test page 1 with appendix");
@@ -163,17 +168,18 @@ Item {
}
function test_bigScript() {
- webEngineView.userScripts = [ bigUserScript ];
+ webEngineView.userScripts.collection = [ bigUserScript() ];
webEngineView.url = Qt.resolvedUrl("test1.html");
webEngineView.waitForLoadSucceeded();
tryCompare(webEngineView , "title", "Big user script changed title");
}
function test_parseMetadataHeader() {
- compare(scriptWithMetadata.name, "Test script");
- compare(scriptWithMetadata.injectionPoint, WebEngineScript.DocumentReady);
+ var script = scriptWithMetadata()
+ compare(script.name, "Test script");
+ compare(script.injectionPoint, WebEngineScript.DocumentReady);
- webEngineView.userScripts = [ scriptWithMetadata ];
+ webEngineView.userScripts.collection = [ script ];
// @include *data/test*.html
webEngineView.url = Qt.resolvedUrl("test1.html");
@@ -197,10 +203,11 @@ Item {
}
function test_dontInjectBadUrlPatternsEverywhere() {
- compare(scriptWithBadMatchMetadata.name, "Test bad match script");
- compare(scriptWithBadMatchMetadata.injectionPoint, WebEngineScript.DocumentReady);
+ var script = scriptWithBadMatchMetadata();
+ compare(script.name, "Test bad match script");
+ compare(script.injectionPoint, WebEngineScript.DocumentReady);
- webEngineView.userScripts = [ scriptWithBadMatchMetadata ];
+ webEngineView.userScripts.collection = [ script ];
// @match some:junk
webEngineView.url = Qt.resolvedUrl("test2.html");
@@ -209,7 +216,7 @@ Item {
}
function test_profileWideScript() {
- webEngineView.profile.userScripts = [ changeDocumentTitleScript ];
+ webEngineView.profile.userScripts.collection = [ changeDocumentTitleScript() ];
webEngineView.url = Qt.resolvedUrl("test1.html");
webEngineView.waitForLoadSucceeded();
diff --git a/tests/auto/quick/qmltests/data/tst_viewSource.qml b/tests/auto/quick/qmltests/data/tst_viewSource.qml
index 4966a052a..22c340c2b 100644
--- a/tests/auto/quick/qmltests/data/tst_viewSource.qml
+++ b/tests/auto/quick/qmltests/data/tst_viewSource.qml
@@ -94,36 +94,6 @@ TestWebEngineView {
compare(webEngineView.url, "view-source:" + Qt.resolvedUrl("test1.html"));
}
- function test_viewSourceURL_data() {
- var testLocalUrl = "view-source:" + Qt.resolvedUrl("test1.html");
- var testLocalUrlWithoutScheme = "view-source:" + Qt.resolvedUrl("test1.html").substring(7);
-
- return [
- { tag: "view-source:", userInputUrl: "view-source:", loadSucceed: true, url: "view-source:", title: "view-source:" },
- { tag: "view-source:about:blank", userInputUrl: "view-source:about:blank", loadSucceed: true, url: "view-source:about:blank", title: "view-source:about:blank" },
- { tag: testLocalUrl, userInputUrl: testLocalUrl, loadSucceed: true, url: testLocalUrl, title: "test1.html" },
- { tag: testLocalUrlWithoutScheme, userInputUrl: testLocalUrlWithoutScheme, loadSucceed: true, url: testLocalUrl, title: "test1.html" },
- { tag: "view-source:http://non.existent", userInputUrl: "view-source:http://non.existent", loadSucceed: false, url: "http://non.existent/", title: "non.existent" },
- { tag: "view-source:non.existent", userInputUrl: "view-source:non.existent", loadSucceed: false, url: "http://non.existent/", title: "non.existent" },
- ];
- }
-
- function test_viewSourceURL(row) {
- WebEngine.settings.errorPageEnabled = true
- webEngineView.url = row.userInputUrl;
-
- if (row.loadSucceed) {
- tryCompare(webEngineView, "loadStatus", WebEngineView.LoadSucceededStatus);
- } else {
- tryCompare(webEngineView, "loadStatus", WebEngineView.LoadFailedStatus, 15000);
- }
- tryVerify(function() { return titleChangedSpy.count == 1; });
-
- compare(webEngineView.url, row.url);
- tryCompare(webEngineView, "title", row.title);
- verify(!webEngineView.action(WebEngineView.ViewSource).enabled);
- }
-
function test_viewSourceCredentials() {
var url = "http://user:passwd@httpbin.org/basic-auth/user/passwd";
diff --git a/tests/auto/quick/qmltests/data/tst_viewSoure.qml b/tests/auto/quick/qmltests/data/tst_viewSoure.qml
new file mode 100644
index 000000000..997582335
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_viewSoure.qml
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebEngine 1.4
+import QtWebEngine.testsupport 1.0
+import "../../qmltests/data" 1.0
+
+TestWebEngineView {
+ id: webEngineView
+ width: 200
+ height: 400
+
+ property var viewRequest: null
+ property var loadRequestArray: []
+
+ testSupport: WebEngineTestSupport {
+ errorPage.onLoadingChanged: {
+ loadRequestArray.push({
+ "status": loadRequest.status,
+ })
+ }
+ }
+
+ onLoadingChanged: {
+ loadRequestArray.push({
+ "status": loadRequest.status,
+ });
+ }
+
+ SignalSpy {
+ id: newViewRequestedSpy
+ target: webEngineView
+ signalName: "newViewRequested"
+ }
+
+ SignalSpy {
+ id: titleChangedSpy
+ target: webEngineView
+ signalName: "titleChanged"
+ }
+
+ onNewViewRequested: {
+ viewRequest = {
+ "destination": request.destination,
+ "userInitiated": request.userInitiated
+ };
+
+ request.openIn(webEngineView);
+ }
+
+ TestCase {
+ id: test
+ name: "WebEngineViewSource"
+
+ function init() {
+ webEngineView.loadStatus = null;
+ webEngineView.url = Qt.resolvedUrl("test1.html");
+ tryCompare(webEngineView, "loadStatus", WebEngineView.LoadSucceededStatus);
+ webEngineView.loadStatus = null;
+
+ newViewRequestedSpy.clear();
+ titleChangedSpy.clear();
+ viewRequest = null;
+ }
+
+ function test_viewSourceURL_data() {
+ var testLocalUrl = "view-source:" + Qt.resolvedUrl("test1.html");
+ var testLocalUrlWithoutScheme = "view-source:" + Qt.resolvedUrl("test1.html").toString().substring(7);
+
+ return [
+ { tag: "view-source:", userInputUrl: "view-source:", loadSucceed: true, url: "view-source:", title: "view-source:" },
+ { tag: "view-source:about:blank", userInputUrl: "view-source:about:blank", loadSucceed: true, url: "view-source:about:blank", title: "view-source:about:blank" },
+ { tag: testLocalUrl, userInputUrl: testLocalUrl, loadSucceed: true, url: testLocalUrl, title: "test1.html" },
+ { tag: testLocalUrlWithoutScheme, userInputUrl: testLocalUrlWithoutScheme, loadSucceed: true, url: testLocalUrl, title: "test1.html" },
+ { tag: "view-source:http://non.existent", userInputUrl: "view-source:http://non.existent", loadSucceed: false, url: "http://non.existent/", title: "non.existent" },
+ { tag: "view-source:non.existent", userInputUrl: "view-source:non.existent", loadSucceed: false, url: "http://non.existent/", title: "non.existent" },
+ ];
+ }
+
+ function test_viewSourceURL(row) {
+ loadRequestArray = [];
+ WebEngine.settings.errorPageEnabled = true
+ webEngineView.url = row.userInputUrl;
+
+ if (row.loadSucceed) {
+ tryVerify(function() { return loadRequestArray.length >= 2 });
+ compare(loadRequestArray[1].status, WebEngineView.LoadSucceededStatus);
+ } else {
+ tryVerify(function() { return loadRequestArray.length >= 2 });
+ compare(loadRequestArray[1].status, WebEngineView.LoadFailedStatus);
+ tryVerify(function() { return loadRequestArray.length == 4 });
+ compare(loadRequestArray[3].status, WebEngineView.LoadSucceededStatus);
+ }
+ tryVerify(function() { return titleChangedSpy.count == 1; });
+
+ compare(webEngineView.url, row.url);
+ tryCompare(webEngineView, "title", row.title);
+ if (row.loadSucceed) {
+ verify(!webEngineView.action(WebEngineView.ViewSource).enabled);
+ } else {
+ verify(webEngineView.action(WebEngineView.ViewSource).enabled);
+ }
+ }
+ }
+}
+
diff --git a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/AlertDialog.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/AlertDialog.qml
index 4ba3be4b9..4ba3be4b9 100644
--- a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/AlertDialog.qml
+++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/AlertDialog.qml
diff --git a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/ConfirmDialog.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/ConfirmDialog.qml
index 9933fc2f7..9933fc2f7 100644
--- a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/ConfirmDialog.qml
+++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/ConfirmDialog.qml
diff --git a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/FilePicker.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/FilePicker.qml
index 745f533f5..745f533f5 100644
--- a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/FilePicker.qml
+++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/FilePicker.qml
diff --git a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/Menu.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/Menu.qml
index 36efa7680..36efa7680 100644
--- a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/Menu.qml
+++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/Menu.qml
diff --git a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/MenuItem.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/MenuItem.qml
index e61f4c230..e61f4c230 100644
--- a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/MenuItem.qml
+++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/MenuItem.qml
diff --git a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/PromptDialog.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/PromptDialog.qml
index 7c5b16eab..7c5b16eab 100644
--- a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/PromptDialog.qml
+++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/PromptDialog.qml
diff --git a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/qmldir b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/qmldir
index cf8ac0512..cf8ac0512 100644
--- a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/qmldir
+++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/qmldir
diff --git a/tests/auto/quick/qmltests2/mock-delegates/TestParams/FilePickerParams.qml b/tests/auto/quick/qmltests/mock-delegates/TestParams/FilePickerParams.qml
index 02b0da1d4..02b0da1d4 100644
--- a/tests/auto/quick/qmltests2/mock-delegates/TestParams/FilePickerParams.qml
+++ b/tests/auto/quick/qmltests/mock-delegates/TestParams/FilePickerParams.qml
diff --git a/tests/auto/quick/qmltests2/mock-delegates/TestParams/JSDialogParams.qml b/tests/auto/quick/qmltests/mock-delegates/TestParams/JSDialogParams.qml
index 70696803c..70696803c 100644
--- a/tests/auto/quick/qmltests2/mock-delegates/TestParams/JSDialogParams.qml
+++ b/tests/auto/quick/qmltests/mock-delegates/TestParams/JSDialogParams.qml
diff --git a/tests/auto/quick/qmltests2/mock-delegates/TestParams/qmldir b/tests/auto/quick/qmltests/mock-delegates/TestParams/qmldir
index 5807f1e6e..5807f1e6e 100644
--- a/tests/auto/quick/qmltests2/mock-delegates/TestParams/qmldir
+++ b/tests/auto/quick/qmltests/mock-delegates/TestParams/qmldir
diff --git a/tests/auto/quick/qmltests/qmltests.pro b/tests/auto/quick/qmltests/qmltests.pro
index a50bfd7e6..5b2ea5d01 100644
--- a/tests/auto/quick/qmltests/qmltests.pro
+++ b/tests/auto/quick/qmltests/qmltests.pro
@@ -1,18 +1,110 @@
+include($$QTWEBENGINE_OUT_ROOT/src/webengine/qtwebengine-config.pri) # workaround for QTBUG-68093
+QT_FOR_CONFIG += webengine-private
+
include(../tests.pri)
-include(../../shared/http.pri)
QT += qmltest
-
+DEFINES += QUICK_TEST_SOURCE_DIR=\\\"$$re_escape($$OUT_PWD$${QMAKE_DIR_SEP}webengine.qmltests)\\\"
IMPORTPATH += $$PWD/data
+QML_TESTS = \
+ $$PWD/data/tst_action.qml \
+ $$PWD/data/tst_activeFocusOnPress.qml \
+ $$PWD/data/tst_audioMuted.qml \
+ $$PWD/data/tst_desktopBehaviorLoadHtml.qml \
+ $$PWD/data/tst_findText.qml \
+ $$PWD/data/tst_focusOnNavigation.qml \
+ $$PWD/data/tst_geopermission.qml \
+ $$PWD/data/tst_getUserMedia.qml \
+ $$PWD/data/tst_keyboardEvents.qml \
+ $$PWD/data/tst_keyboardModifierMapping.qml \
+ $$PWD/data/tst_loadHtml.qml \
+ $$PWD/data/tst_loadProgress.qml \
+ $$PWD/data/tst_loadRecursionCrash.qml \
+ $$PWD/data/tst_loadUrl.qml \
+ $$PWD/data/tst_mouseMove.qml \
+ $$PWD/data/tst_navigationHistory.qml \
+ $$PWD/data/tst_navigationRequested.qml \
+ $$PWD/data/tst_newViewRequest.qml \
+ $$PWD/data/tst_notification.qml \
+ $$PWD/data/tst_profile.qml \
+ $$PWD/data/tst_properties.qml \
+ $$PWD/data/tst_runJavaScript.qml \
+ $$PWD/data/tst_scrollPosition.qml \
+ $$PWD/data/tst_settings.qml \
+ $$PWD/data/tst_titleChanged.qml \
+ $$PWD/data/tst_unhandledKeyEventPropagation.qml \
+ $$PWD/data/tst_userScripts.qml \
+ $$PWD/data/tst_viewSource.qml
+
+qtConfig(webengine-webchannel) {
+ QML_TESTS += $$PWD/data/tst_webchannel.qml
+}
+
+qtConfig(ssl) {
+ include(../../shared/https.pri)
+ QML_TESTS += $$PWD/data/tst_certificateError.qml
+} else {
+ include(../../shared/http.pri)
+}
+
+qtConfig(webengine-testsupport) {
+ QML_TESTS += \
+ $$PWD/data/tst_favicon.qml \
+ $$PWD/data/tst_faviconDownload.qml \
+ $$PWD/data/tst_inputMethod.qml \
+ $$PWD/data/tst_linkHovered.qml \
+ $$PWD/data/tst_loadFail.qml \
+ $$PWD/data/tst_mouseClick.qml \
+ $$PWD/data/tst_viewSoure.qml
+ qtHaveModule(quickcontrols): QML_TESTS += $$PWD/data/tst_javaScriptDialogs.qml
+} else {
+ PLUGIN_EXTENSION = .so
+ PLUGIN_PREFIX = lib
+ macos: PLUGIN_PREFIX = .dylib
+ win32 {
+ PLUGIN_EXTENSION = .dll
+ PLUGIN_PREFIX =
+ }
+
+ TESTSUPPORT_MODULE = $$shell_path($$[QT_INSTALL_QML]/QtWebEngine/testsupport/$${PLUGIN_PREFIX}qtwebenginetestsupportplugin$${PLUGIN_EXTENSION})
+ BUILD_DIR = $$shell_path($$clean_path($$OUT_PWD/../../../..))
+ SRC_DIR = $$shell_path($$clean_path($$PWD/../../../..))
+
+ warning("QML Test Support API is disabled. This means some QML tests that use Test Support API will fail.")
+ warning("Use the following command to build Test Support module and rebuild WebEngineView API:")
+ warning("cd $$BUILD_DIR && qmake -r $$shell_path($$SRC_DIR/qtwebengine.pro -- --feature-testsupport=yes) && make -C $$shell_path($$BUILD_DIR/src/webengine) clean && make")
+ warning("After performing the command above make sure QML module \"QtWebEngine.testsupport\" is deployed at $$TESTSUPPORT_MODULE")
+}
+
+qtHaveModule(quickcontrols) {
+ QML_TESTS += \
+ $$PWD/data/tst_contextMenu.qml \
+ $$PWD/data/tst_download.qml \
+ $$PWD/data/tst_filePicker.qml
+}
+
OTHER_FILES += \
$$PWD/data/TestWebEngineView.qml \
+ $$PWD/data/accepttypes.html \
+ $$PWD/data/alert.html \
+ $$PWD/data/confirm.html \
+ $$PWD/data/confirmclose.html \
$$PWD/data/append-document-title.js \
$$PWD/data/big-user-script.js \
$$PWD/data/change-document-title.js \
$$PWD/data/download.zip \
$$PWD/data/directoryupload.html \
$$PWD/data/favicon.html \
+ $$PWD/data/favicon2.html \
+ $$PWD/data/favicon-candidates-gray.html \
+ $$PWD/data/favicon-misc.html \
+ $$PWD/data/favicon-multi.html \
+ $$PWD/data/favicon-multi-gray.html \
+ $$PWD/data/favicon-single.html \
+ $$PWD/data/favicon-shortcut.html \
+ $$PWD/data/favicon-touch.html \
+ $$PWD/data/favicon-unavailable.html \
$$PWD/data/forms.html \
$$PWD/data/geolocation.html \
$$PWD/data/javascript.html \
@@ -30,40 +122,35 @@ OTHER_FILES += \
$$PWD/data/keyboardModifierMapping.html \
$$PWD/data/keyboardEvents.html \
$$PWD/data/titleupdate.js \
- $$PWD/data/tst_action.qml \
- $$PWD/data/tst_activeFocusOnPress.qml \
- $$PWD/data/tst_audioMuted.qml \
- $$PWD/data/tst_contextMenu.qml \
- $$PWD/data/tst_desktopBehaviorLoadHtml.qml \
- $$PWD/data/tst_download.qml \
- $$PWD/data/tst_filePicker.qml \
- $$PWD/data/tst_findText.qml \
- $$PWD/data/tst_focusOnNavigation.qml \
- $$PWD/data/tst_geopermission.qml \
- $$PWD/data/tst_getUserMedia.qml \
- $$PWD/data/tst_loadHtml.qml \
- $$PWD/data/tst_loadProgress.qml \
- $$PWD/data/tst_loadRecursionCrash.qml \
- $$PWD/data/tst_loadUrl.qml \
- $$PWD/data/tst_mouseMove.qml \
- $$PWD/data/tst_navigationHistory.qml \
- $$PWD/data/tst_navigationRequested.qml \
- $$PWD/data/tst_newViewRequest.qml \
- $$PWD/data/tst_notification.qml \
- $$PWD/data/tst_profile.qml \
- $$PWD/data/tst_properties.qml \
- $$PWD/data/tst_runJavaScript.qml \
- $$PWD/data/tst_scrollPosition.qml \
- $$PWD/data/tst_titleChanged.qml \
- $$PWD/data/tst_unhandledKeyEventPropagation.qml \
- $$PWD/data/tst_userScripts.qml \
- $$PWD/data/tst_viewSource.qml \
- $$PWD/data/tst_webchannel.qml \
- $$PWD/data/tst_settings.qml \
- $$PWD/data/tst_keyboardModifierMapping.qml \
- $$PWD/data/tst_keyboardEvents.qml \
- $$PWD/data/webchannel-test.html \
$$PWD/data/icons/favicon.png \
+ $$PWD/data/icons/gray128.png \
+ $$PWD/data/icons/gray16.png \
+ $$PWD/data/icons/gray255.png \
+ $$PWD/data/icons/gray32.png \
+ $$PWD/data/icons/gray64.png \
+ $$PWD/data/icons/grayicons.ico \
+ $$PWD/data/icons/qt144.png \
+ $$PWD/data/icons/qt32.ico \
+ $$PWD/data/icons/qtmulti.ico \
+ $$PWD/data/icons/small-favicon.png \
+ $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/AlertDialog.qml \
+ $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/ConfirmDialog.qml \
+ $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/FilePicker.qml \
+ $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/Menu.qml \
+ $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/MenuItem.qml \
+ $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/PromptDialog.qml \
+ $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/qmldir \
+ $$PWD/mock-delegates/TestParams/FilePickerParams.qml \
+ $$PWD/mock-delegates/TestParams/JSDialogParams.qml \
+ $$PWD/mock-delegates/TestParams/qmldir
+
+OTHER_FILES += $$QML_TESTS
+
+!build_pass:!isEmpty(QML_TESTS) {
+ for (file, QML_TESTS): QML_TESTS_CONTENT += "$${file}"
+ TEST_FILE = $$OUT_PWD/webengine.qmltests
+ write_file($$TEST_FILE, QML_TESTS_CONTENT)
+}
load(qt_build_paths)
-DEFINES += QUICK_TEST_SOURCE_DIR=\\\"$$re_escape($$PWD$${QMAKE_DIR_SEP}data)\\\"
+
diff --git a/tests/auto/quick/qmltests/tst_qmltests.cpp b/tests/auto/quick/qmltests/tst_qmltests.cpp
index 5677f9047..8423df1bd 100644
--- a/tests/auto/quick/qmltests/tst_qmltests.cpp
+++ b/tests/auto/quick/qmltests/tst_qmltests.cpp
@@ -28,6 +28,10 @@
#include <httpserver.h>
+#if QT_CONFIG(ssl)
+#include <httpsserver.h>
+#endif
+
#include <QtCore/QScopedPointer>
#include <QTemporaryDir>
#include <QtQuickTest/quicktest.h>
@@ -130,7 +134,7 @@ int main(int argc, char **argv)
QLocale::setDefault(QLocale("en"));
static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")};
- QVector<const char *> w_argv(argc); \
+ QList<const char *> w_argv(argc); \
for (int i = 0; i < argc; ++i) \
w_argv[i] = argv[i]; \
for (int i = 0; i < params.size(); ++i) \
@@ -151,6 +155,12 @@ int main(int argc, char **argv)
return server;
});
+#if QT_CONFIG(ssl)
+ qmlRegisterSingletonType<HttpsServer>(
+ "Test.Shared", 1, 0, "HttpsServer",
+ [&](QQmlEngine *, QJSEngine *) { return new HttpsServer; });
+#endif
+
int i = quick_test_main(argc, argv, "qmltests", QUICK_TEST_SOURCE_DIR);
return i;
}
diff --git a/tests/auto/quick/qmltests2/data/favicon.html b/tests/auto/quick/qmltests2/data/favicon.html
deleted file mode 100644
index e1b84a9cc..000000000
--- a/tests/auto/quick/qmltests2/data/favicon.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<html>
-<head>
-<link type="image/png" href="icons/favicon.png" sizes="48x48" rel="icon" />
-</head>
-<body>
-<p>It's expected that you see a favicon displayed for this page when you open it as a local file.</p>
-<p>The favicon looks like this:</p>
-<img id='image' src="icons/favicon.png"/>
-</body>
-</html>
diff --git a/tests/auto/quick/qmltests2/data/icons/favicon.png b/tests/auto/quick/qmltests2/data/icons/favicon.png
deleted file mode 100644
index 35717cca5..000000000
--- a/tests/auto/quick/qmltests2/data/icons/favicon.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/test1.html b/tests/auto/quick/qmltests2/data/test1.html
deleted file mode 100644
index 5c09f06ed..000000000
--- a/tests/auto/quick/qmltests2/data/test1.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>
-<head><title>Test page 1</title></head>
-<body>
-Hello.
-</body>
-</html>
diff --git a/tests/auto/quick/qmltests2/data/test2.html b/tests/auto/quick/qmltests2/data/test2.html
deleted file mode 100644
index 629c2a063..000000000
--- a/tests/auto/quick/qmltests2/data/test2.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>
-<head><title>Test page with huge link area</title></head>
-<body>
-<a title="A title" href="test1.html"><img width=200 height=200></a>
-</body>
-</html>
diff --git a/tests/auto/quick/qmltests2/qmltests2.pro b/tests/auto/quick/qmltests2/qmltests2.pro
deleted file mode 100644
index 4c7a8dc72..000000000
--- a/tests/auto/quick/qmltests2/qmltests2.pro
+++ /dev/null
@@ -1,78 +0,0 @@
-include(../tests.pri)
-
-QT += qmltest
-
-IMPORTPATH += $$PWD/data
-
-OTHER_FILES += \
- $$PWD/data/accepttypes.html \
- $$PWD/data/alert.html \
- $$PWD/data/confirm.html \
- $$PWD/data/confirmclose.html \
- $$PWD/data/directoryupload.html \
- $$PWD/data/favicon.html \
- $$PWD/data/favicon2.html \
- $$PWD/data/favicon-candidates-gray.html \
- $$PWD/data/favicon-misc.html \
- $$PWD/data/favicon-multi.html \
- $$PWD/data/favicon-multi-gray.html \
- $$PWD/data/favicon-single.html \
- $$PWD/data/favicon-shortcut.html \
- $$PWD/data/favicon-touch.html \
- $$PWD/data/favicon-unavailable.html \
- $$PWD/data/multifileupload.html \
- $$PWD/data/prompt.html \
- $$PWD/data/singlefileupload.html \
- $$PWD/data/test1.html \
- $$PWD/data/test2.html \
- $$PWD/data/titleupdate.js \
- $$PWD/data/tst_favicon.qml \
- $$PWD/data/tst_faviconDownload.qml \
- $$PWD/data/tst_inputMethod.qml \
- $$PWD/data/tst_javaScriptDialogs.qml \
- $$PWD/data/tst_linkHovered.qml \
- $$PWD/data/tst_loadFail.qml \
- $$PWD/data/tst_mouseClick.qml \
- $$PWD/data/icons/favicon.png \
- $$PWD/data/icons/gray128.png \
- $$PWD/data/icons/gray16.png \
- $$PWD/data/icons/gray255.png \
- $$PWD/data/icons/gray32.png \
- $$PWD/data/icons/gray64.png \
- $$PWD/data/icons/grayicons.ico \
- $$PWD/data/icons/qt144.png \
- $$PWD/data/icons/qt32.ico \
- $$PWD/data/icons/qtmulti.ico \
- $$PWD/data/icons/small-favicon.png \
- $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/AlertDialog.qml \
- $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/ConfirmDialog.qml \
- $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/FilePicker.qml \
- $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/Menu.qml \
- $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/MenuItem.qml \
- $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/PromptDialog.qml \
- $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/qmldir \
- $$PWD/mock-delegates/TestParams/FilePickerParams.qml \
- $$PWD/mock-delegates/TestParams/JSDialogParams.qml \
- $$PWD/mock-delegates/TestParams/qmldir \
-
-load(qt_build_paths)
-DEFINES += QUICK_TEST_SOURCE_DIR=\\\"$$re_escape($$PWD$${QMAKE_DIR_SEP}data)\\\"
-
-!qtConfig(webengine-testsupport) {
- PLUGIN_EXTENSION = .so
- PLUGIN_PREFIX = lib
- osx: PLUGIN_PREFIX = .dylib
- win32 {
- PLUGIN_EXTENSION = .dll
- PLUGIN_PREFIX =
- }
-
- TESTSUPPORT_MODULE = $$shell_path($$[QT_INSTALL_QML]/QtWebEngine/testsupport/$${PLUGIN_PREFIX}qtwebenginetestsupportplugin$${PLUGIN_EXTENSION})
- BUILD_DIR = $$shell_path($$clean_path($$OUT_PWD/../../../..))
- SRC_DIR = $$shell_path($$clean_path($$PWD/../../../..))
-
- warning("QML Test Support API is disabled. This means some QML tests that use Test Support API will fail.")
- warning("Use the following command to build Test Support module and rebuild WebEngineView API:")
- warning("cd $$BUILD_DIR && qmake -r $$shell_path($$SRC_DIR/qtwebengine.pro -- --feature-testsupport=yes) && make -C $$shell_path($$BUILD_DIR/src/webengine) clean && make")
- warning("After performing the command above make sure QML module \"QtWebEngine.testsupport\" is deployed at $$TESTSUPPORT_MODULE")
-}
diff --git a/tests/auto/quick/qmltests2/tst_qmltests2.cpp b/tests/auto/quick/qmltests2/tst_qmltests2.cpp
deleted file mode 100644
index 8c81ed7f5..000000000
--- a/tests/auto/quick/qmltests2/tst_qmltests2.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 <QtCore/QScopedPointer>
-#include <QtQuickTest/quicktest.h>
-#include <QtWebEngine/QQuickWebEngineProfile>
-#include "qt_webengine_quicktest.h"
-
-#if defined(Q_OS_LINUX) && defined(QT_DEBUG)
-#include <fcntl.h>
-#include <signal.h>
-#include <unistd.h>
-#endif
-
-#if defined(Q_OS_LINUX) && defined(QT_DEBUG)
-static bool debuggerPresent()
-{
- int fd = open("/proc/self/status", O_RDONLY);
- if (fd == -1)
- return false;
- char buffer[2048];
- ssize_t size = read(fd, buffer, sizeof(buffer) - 1);
- if (size == -1) {
- close(fd);
- return false;
- }
- buffer[size] = 0;
- const char tracerPidToken[] = "\nTracerPid:";
- char *tracerPid = strstr(buffer, tracerPidToken);
- if (!tracerPid) {
- close(fd);
- return false;
- }
- tracerPid += sizeof(tracerPidToken);
- long int pid = strtol(tracerPid, &tracerPid, 10);
- close(fd);
- return pid != 0;
-}
-
-static void stackTrace()
-{
- bool ok = false;
- const int disableStackDump = qEnvironmentVariableIntValue("QTEST_DISABLE_STACK_DUMP", &ok);
- if (ok && disableStackDump == 1)
- return;
-
- if (debuggerPresent())
- return;
-
- fprintf(stderr, "\n========= Received signal, dumping stack ==============\n");
- char cmd[512];
- qsnprintf(cmd, 512, "gdb --pid %d 2>/dev/null <<EOF\n"
- "set prompt\n"
- "set height 0\n"
- "thread apply all where full\n"
- "detach\n"
- "quit\n"
- "EOF\n",
- (int)getpid());
-
- if (system(cmd) == -1)
- fprintf(stderr, "calling gdb failed\n");
- fprintf(stderr, "========= End of stack trace ==============\n");
-}
-
-static void sigSegvHandler(int signum)
-{
- stackTrace();
- qFatal("Received signal %d", signum);
-}
-#endif
-
-int main(int argc, char **argv)
-{
-#if defined(Q_OS_LINUX) && defined(QT_DEBUG)
- struct sigaction sigAction;
-
- sigemptyset(&sigAction.sa_mask);
- sigAction.sa_handler = &sigSegvHandler;
- sigAction.sa_flags = 0;
-
- sigaction(SIGSEGV, &sigAction, 0);
-#endif
-
- // Inject the mock ui delegates module
- qputenv("QML2_IMPORT_PATH", QByteArray(TESTS_SOURCE_DIR "qmltests2/mock-delegates"));
- QScopedPointer<Application> app;
-
- // Force to use English language for testing due to error message checks
- QLocale::setDefault(QLocale("en"));
-
- if (!QCoreApplication::instance()) {
- app.reset(new Application(argc, argv));
- }
- QtWebEngine::initialize();
- QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true);
-
- QTEST_SET_MAIN_SOURCE_PATH
-
- int i = quick_test_main(argc, argv, "qmltests2", QUICK_TEST_SOURCE_DIR);
- return i;
-}
diff --git a/tests/auto/quick/qmltests_ssl/data/TestWebEngineView.qml b/tests/auto/quick/qmltests_ssl/data/TestWebEngineView.qml
deleted file mode 100644
index 6db076ae8..000000000
--- a/tests/auto/quick/qmltests_ssl/data/TestWebEngineView.qml
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtTest 1.1
-import QtWebEngine 1.7
-
-WebEngineView {
- property var loadStatus: null
- property bool windowCloseRequestedSignalEmitted: false
- settings.focusOnNavigationEnabled: true
-
- function waitForLoadSucceeded(timeout) {
- var success = _waitFor(function() { return loadStatus == WebEngineView.LoadSucceededStatus }, timeout)
- loadStatus = null
- return success
- }
- function waitForLoadFailed(timeout) {
- var failure = _waitFor(function() { return loadStatus == WebEngineView.LoadFailedStatus }, timeout)
- loadStatus = null
- return failure
- }
- function waitForLoadStopped(timeout) {
- var stop = _waitFor(function() { return loadStatus == WebEngineView.LoadStoppedStatus }, timeout)
- loadStatus = null
- return stop
- }
- function waitForWindowCloseRequested() {
- return _waitFor(function() { return windowCloseRequestedSignalEmitted; });
- }
- function _waitFor(predicate, timeout) {
- if (timeout === undefined)
- timeout = 12000;
- var i = 0
- while (i < timeout && !predicate()) {
- testResult.wait(50)
- i += 50
- }
- return predicate()
- }
-
- function getActiveElementId() {
- var activeElementId;
- runJavaScript("document.activeElement.id", function(result) {
- activeElementId = result;
- });
- testCase.tryVerify(function() { return activeElementId != undefined });
- return activeElementId;
- }
-
- function verifyElementHasFocus(element) {
- testCase.tryVerify(function() { return getActiveElementId() == element; }, 5000,
- "Element \"" + element + "\" has focus");
- }
-
- function setFocusToElement(element) {
- runJavaScript("document.getElementById('" + element + "').focus()");
- verifyElementHasFocus(element);
- }
-
- function getElementCenter(element) {
- var center;
- runJavaScript("(function() {" +
- " var elem = document.getElementById('" + element + "');" +
- " var rect = elem.getBoundingClientRect();" +
- " return { 'x': (rect.left + rect.right) / 2, 'y': (rect.top + rect.bottom) / 2 };" +
- "})();", function(result) { center = result } );
- testCase.tryVerify(function() { return center !== undefined; });
- return center;
- }
-
- function getTextSelection() {
- var textSelection;
- runJavaScript("window.getSelection().toString()", function(result) { textSelection = result });
- testCase.tryVerify(function() { return textSelection !== undefined; });
- return textSelection;
- }
-
- TestResult { id: testResult }
- TestCase { id: testCase }
-
- onLoadingChanged: {
- loadStatus = loadRequest.status
- }
-
- onWindowCloseRequested: {
- windowCloseRequestedSignalEmitted = true;
- }
-
- function getBodyText() {
- let text
- runJavaScript('document.body.innerText', function(t) { text = t })
- testCase.tryVerify(function() { return text !== undefined })
- return text
- }
-}
-
diff --git a/tests/auto/quick/qmltests_ssl/qmltests_ssl.pro b/tests/auto/quick/qmltests_ssl/qmltests_ssl.pro
deleted file mode 100644
index a8325e497..000000000
--- a/tests/auto/quick/qmltests_ssl/qmltests_ssl.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-include(../tests.pri)
-include(../../shared/https.pri)
-QT += qmltest
-
-IMPORTPATH += $$PWD/data
-
-OTHER_FILES += $$PWD/data/tst_certificateError.qml
-
-load(qt_build_paths)
-DEFINES += QUICK_TEST_SOURCE_DIR=\\\"$$re_escape($$PWD$${QMAKE_DIR_SEP}data)\\\"
diff --git a/tests/auto/quick/qmltests_ssl/tst_qmltests_ssl.cpp b/tests/auto/quick/qmltests_ssl/tst_qmltests_ssl.cpp
deleted file mode 100644
index 1f54ffd8e..000000000
--- a/tests/auto/quick/qmltests_ssl/tst_qmltests_ssl.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 <QtWebEngineCore/qtwebenginecoreglobal.h>
-#include <QtNetwork/qtnetwork-config.h>
-
-#if QT_CONFIG(ssl)
-#include <httpsserver.h>
-#endif
-
-#include <QtCore/QScopedPointer>
-#include <QTemporaryDir>
-#include <QtQuickTest/quicktest.h>
-#include <QtWebEngine/QQuickWebEngineProfile>
-#include <QQmlEngine>
-#include "qt_webengine_quicktest.h"
-
-#if defined(Q_OS_LINUX) && defined(QT_DEBUG)
-#include <fcntl.h>
-#include <signal.h>
-#include <unistd.h>
-#endif
-
-#if defined(Q_OS_LINUX) && defined(QT_DEBUG)
-static bool debuggerPresent()
-{
- int fd = open("/proc/self/status", O_RDONLY);
- if (fd == -1)
- return false;
- char buffer[2048];
- ssize_t size = read(fd, buffer, sizeof(buffer) - 1);
- if (size == -1) {
- close(fd);
- return false;
- }
- buffer[size] = 0;
- const char tracerPidToken[] = "\nTracerPid:";
- char *tracerPid = strstr(buffer, tracerPidToken);
- if (!tracerPid) {
- close(fd);
- return false;
- }
- tracerPid += sizeof(tracerPidToken);
- long int pid = strtol(tracerPid, &tracerPid, 10);
- close(fd);
- return pid != 0;
-}
-
-static void stackTrace()
-{
- bool ok = false;
- const int disableStackDump = qEnvironmentVariableIntValue("QTEST_DISABLE_STACK_DUMP", &ok);
- if (ok && disableStackDump == 1)
- return;
-
- if (debuggerPresent())
- return;
-
- fprintf(stderr, "\n========= Received signal, dumping stack ==============\n");
- char cmd[512];
- qsnprintf(cmd, 512, "gdb --pid %d 2>/dev/null <<EOF\n"
- "set prompt\n"
- "set height 0\n"
- "thread apply all where full\n"
- "detach\n"
- "quit\n"
- "EOF\n",
- (int)getpid());
-
- if (system(cmd) == -1)
- fprintf(stderr, "calling gdb failed\n");
- fprintf(stderr, "========= End of stack trace ==============\n");
-}
-
-static void sigSegvHandler(int signum)
-{
- stackTrace();
- qFatal("Received signal %d", signum);
-}
-#endif
-
-class TempDir : public QObject {
- Q_OBJECT
-
-public:
- Q_INVOKABLE QString path() {
- Q_ASSERT(tempDir.isValid());
- return tempDir.isValid() ? tempDir.path() : QString();
- }
-
-private:
- QTemporaryDir tempDir;
-};
-
-int main(int argc, char **argv)
-{
-#if defined(Q_OS_LINUX) && defined(QT_DEBUG)
- struct sigaction sigAction;
-
- sigemptyset(&sigAction.sa_mask);
- sigAction.sa_handler = &sigSegvHandler;
- sigAction.sa_flags = 0;
-
- sigaction(SIGSEGV, &sigAction, 0);
-#endif
-
- QScopedPointer<Application> app;
-
- // Force to use English language for testing due to error message checks
- QLocale::setDefault(QLocale("en"));
-
- static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")};
- QVector<const char *> w_argv(argc); \
- for (int i = 0; i < argc; ++i) \
- w_argv[i] = argv[i]; \
- for (int i = 0; i < params.size(); ++i) \
- w_argv.append(params[i].data()); \
- int w_argc = w_argv.size(); \
-
- if (!QCoreApplication::instance()) {
- app.reset(new Application(w_argc, const_cast<char **>(w_argv.data())));
- }
- QtWebEngine::initialize();
- QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true);
- qmlRegisterType<TempDir>("Test.util", 1, 0, "TempDir");
-
- QTEST_SET_MAIN_SOURCE_PATH
-#if QT_CONFIG(ssl)
- qmlRegisterSingletonType<HttpsServer>("Test.Shared", 1, 0, "HttpsServer", [&] (QQmlEngine *, QJSEngine *) { return new HttpsServer; });
-#endif
- int i = quick_test_main(argc, argv, "qmltests", QUICK_TEST_SOURCE_DIR);
- return i;
-}
-
-#include "tst_qmltests_ssl.moc"
diff --git a/tests/auto/quick/qquickwebengineview/BLACKLIST b/tests/auto/quick/qquickwebengineview/BLACKLIST
new file mode 100644
index 000000000..d4a35a76a
--- /dev/null
+++ b/tests/auto/quick/qquickwebengineview/BLACKLIST
@@ -0,0 +1,2 @@
+[javascriptClipboard]
+ubuntu-20.04
diff --git a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
index 5ee30f165..01fabaf5a 100644
--- a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
+++ b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
@@ -38,6 +38,7 @@
#include <QtQml/QQmlEngine>
#include <QtTest/QtTest>
#include <QtWebEngine/QQuickWebEngineProfile>
+#include <QtWebEngine/QQuickWebEngineScriptCollection>
#include <QtGui/private/qinputmethod_p.h>
#include <QtWebEngine/private/qquickwebengineview_p.h>
#include <QtWebEngine/private/qquickwebenginesettings_p.h>
@@ -584,7 +585,7 @@ void tst_QQuickWebEngineView::interruptImeTextComposition()
QTest::mouseClick(view->window(), Qt::LeftButton, {}, textInputCenter);
} else if (eventType == "Touch") {
QPoint textInputCenter = elementCenter(view, QStringLiteral("input2"));
- QTouchDevice *touchDevice = QTest::createTouchDevice();
+ QPointingDevice *touchDevice = QTest::createTouchDevice();
QTest::touchEvent(view->window(), touchDevice).press(0, textInputCenter, view->window());
QTest::touchEvent(view->window(), touchDevice).release(0, textInputCenter, view->window());
}
@@ -770,9 +771,13 @@ void tst_QQuickWebEngineView::inputMethodHints()
QTRY_COMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QString("a@b.com"));
QVERIFY(input->flags().testFlag(QQuickItem::ItemAcceptsInputMethod));
QVERIFY(view->flags().testFlag(QQuickItem::ItemAcceptsInputMethod));
- QInputMethodQueryEvent query(Qt::ImHints);
- QGuiApplication::sendEvent(input, &query);
- QTRY_COMPARE(Qt::InputMethodHints(query.value(Qt::ImHints).toUInt() & Qt::ImhExclusiveInputMask), Qt::ImhEmailCharactersOnly);
+ {
+ QInputMethodQueryEvent query(Qt::ImHints);
+ QGuiApplication::sendEvent(input, &query);
+ QTRY_COMPARE(
+ Qt::InputMethodHints(query.value(Qt::ImHints).toUInt() & Qt::ImhExclusiveInputMask),
+ Qt::ImhEmailCharactersOnly);
+ }
// The focus of an editable DIV is given directly to it, so no shadow root element
// is necessary. This tests the WebPage::editorState() method ability to get the
@@ -783,9 +788,13 @@ void tst_QQuickWebEngineView::inputMethodHints()
QTRY_COMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QString("bla"));
QVERIFY(input->flags().testFlag(QQuickItem::ItemAcceptsInputMethod));
QVERIFY(view->flags().testFlag(QQuickItem::ItemAcceptsInputMethod));
- query = QInputMethodQueryEvent(Qt::ImHints);
- QGuiApplication::sendEvent(input, &query);
- QTRY_COMPARE(Qt::InputMethodHints(query.value(Qt::ImHints).toUInt()), Qt::ImhPreferLowercase | Qt::ImhNoPredictiveText | Qt::ImhMultiLine | Qt::ImhNoEditMenu | Qt::ImhNoTextHandles);
+ {
+ QInputMethodQueryEvent query(Qt::ImHints);
+ QGuiApplication::sendEvent(input, &query);
+ QTRY_COMPARE(Qt::InputMethodHints(query.value(Qt::ImHints).toUInt()),
+ Qt::ImhPreferLowercase | Qt::ImhNoPredictiveText | Qt::ImhMultiLine
+ | Qt::ImhNoEditMenu | Qt::ImhNoTextHandles);
+ }
}
void tst_QQuickWebEngineView::setZoomFactor()
@@ -875,6 +884,7 @@ public:
QQuickItem(parent), m_eventCounter(0), m_child(child) {
setFlag(ItemHasContents);
setAcceptedMouseButtons(Qt::AllButtons);
+ setAcceptTouchEvents(true);
setAcceptHoverEvents(true);
}
@@ -975,9 +985,7 @@ void tst_QQuickWebEngineView::inputEventForwardingDisabledWhenActiveFocusOnPress
QTest::mousePress(view->window(), Qt::LeftButton);
QTest::mouseRelease(view->window(), Qt::LeftButton);
- QTouchDevice *device = new QTouchDevice;
- device->setType(QTouchDevice::TouchScreen);
- QWindowSystemInterface::registerTouchDevice(device);
+ QPointingDevice *device = QTest::createTouchDevice();
QTest::touchEvent(view->window(), device).press(0, QPoint(0,0), view->window());
QTest::touchEvent(view->window(), device).move(0, QPoint(1, 1), view->window());
@@ -1003,7 +1011,11 @@ void tst_QQuickWebEngineView::changeLocale()
QTRY_VERIFY(!evaluateJavaScriptSync(viewDE.data(), "document.body").isNull());
QTRY_VERIFY(!evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").isNull());
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
errorLines = evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").toString().split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts);
+#else
+ errorLines = evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").toString().split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts);
+#endif
QCOMPARE(errorLines.first().toUtf8(), QByteArrayLiteral("Die Website ist nicht erreichbar"));
QLocale::setDefault(QLocale("en"));
@@ -1013,7 +1025,11 @@ void tst_QQuickWebEngineView::changeLocale()
QTRY_VERIFY(!evaluateJavaScriptSync(viewEN.data(), "document.body").isNull());
QTRY_VERIFY(!evaluateJavaScriptSync(viewEN.data(), "document.body.innerText").isNull());
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
errorLines = evaluateJavaScriptSync(viewEN.data(), "document.body.innerText").toString().split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts);
+#else
+ errorLines = evaluateJavaScriptSync(viewEN.data(), "document.body.innerText").toString().split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts);
+#endif
QCOMPARE(errorLines.first().toUtf8(), QByteArrayLiteral("This site can\xE2\x80\x99t be reached"));
// Reset error page
@@ -1026,7 +1042,11 @@ void tst_QQuickWebEngineView::changeLocale()
QTRY_VERIFY(!evaluateJavaScriptSync(viewDE.data(), "document.body").isNull());
QTRY_VERIFY(!evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").isNull());
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
errorLines = evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").toString().split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts);
+#else
+ errorLines = evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").toString().split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts);
+#endif
QCOMPARE(errorLines.first().toUtf8(), QByteArrayLiteral("Die Website ist nicht erreichbar"));
}
@@ -1037,10 +1057,10 @@ void tst_QQuickWebEngineView::userScripts()
QScopedPointer<QQuickWebEngineView> webEngineView2(newWebEngineView());
webEngineView2->setParentItem(m_window->contentItem());
- QQmlListReference list(webEngineView1->profile(), "userScripts");
- QQuickWebEngineScript script;
+ QQuickWebEngineScriptCollection *collection = webEngineView1->profile()->userScripts();
+ QWebEngineScript script;
script.setSourceCode("document.title = 'New title';");
- list.append(&script);
+ collection->insert(script);
webEngineView1->setUrl(urlFromTestPath("html/basic_page.html"));
QVERIFY(waitForLoadSucceeded(webEngineView1.data()));
@@ -1050,7 +1070,7 @@ void tst_QQuickWebEngineView::userScripts()
QVERIFY(waitForLoadSucceeded(webEngineView2.data()));
QTRY_COMPARE(webEngineView2->title(), QStringLiteral("New title"));
- list.clear();
+ collection->clear();
}
void tst_QQuickWebEngineView::javascriptClipboard_data()
@@ -1164,17 +1184,20 @@ void tst_QQuickWebEngineView::setProfile() {
void tst_QQuickWebEngineView::focusChild_data()
{
QTest::addColumn<QString>("interfaceName");
- QTest::addColumn<QVector<QAccessible::Role>>("ancestorRoles");
+ QTest::addColumn<QList<QAccessible::Role>>("ancestorRoles");
- QTest::newRow("QQuickWebEngineView") << QString("QQuickWebEngineView") << QVector<QAccessible::Role>({QAccessible::Client});
- QTest::newRow("RenderWidgetHostViewQtDelegate") << QString("RenderWidgetHostViewQtDelegate") << QVector<QAccessible::Role>({QAccessible::Client});
- QTest::newRow("QQuickView") << QString("QQuickView") << QVector<QAccessible::Role>({QAccessible::Window, QAccessible::Client /* view */});
+ QTest::newRow("QQuickWebEngineView") << QString("QQuickWebEngineView") << QList<QAccessible::Role>({QAccessible::Client});
+ QTest::newRow("RenderWidgetHostViewQtDelegate") << QString("RenderWidgetHostViewQtDelegate") << QList<QAccessible::Role>({QAccessible::Client});
+ QTest::newRow("QQuickView") << QString("QQuickView") << QList<QAccessible::Role>({QAccessible::Window, QAccessible::Client /* view */});
}
void tst_QQuickWebEngineView::focusChild()
{
+#if QT_VERSION < QT_VERSION_CHECK(5, 14, 1)
+ QSKIP("Requires newer base Qt");
+#endif
auto traverseToWebDocumentAccessibleInterface = [](QAccessibleInterface *iface) -> QAccessibleInterface * {
- QFETCH(QVector<QAccessible::Role>, ancestorRoles);
+ QFETCH(QList<QAccessible::Role>, ancestorRoles);
for (int i = 0; i < ancestorRoles.size(); ++i) {
if (iface->childCount() == 0 || iface->role() != ancestorRoles[i])
return nullptr;
diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro
index 41ea5c4c1..4648b2f64 100644
--- a/tests/auto/quick/quick.pro
+++ b/tests/auto/quick/quick.pro
@@ -10,15 +10,11 @@ SUBDIRS += \
publicapi \
qquickwebenginedefaultsurfaceformat \
qquickwebengineview \
- qtbug-70248
+ qtbug-70248 \
+ certificateerror
qtConfig(webengine-testsupport) {
- SUBDIRS += \
- qmltests2 \
- qquickwebengineviewgraphics
+ SUBDIRS += qquickwebengineviewgraphics
}
-qtConfig(ssl): SUBDIRS += qmltests_ssl
-
-# QTBUG-66055
-boot2qt: SUBDIRS -= inspectorserver qquickwebengineview qmltests qmltests2
+boot2qt: SUBDIRS -= inspectorserver qquickwebengineview qmltests
diff --git a/tests/auto/quick/shared/util.h b/tests/auto/quick/shared/util.h
index b7b7b1564..132c353ca 100644
--- a/tests/auto/quick/shared/util.h
+++ b/tests/auto/quick/shared/util.h
@@ -173,7 +173,7 @@ int main(int argc, char *argv[]) \
{ \
QtWebEngine::initialize(); \
\
- QVector<const char *> w_argv(argc); \
+ QList<const char *> w_argv(argc); \
for (int i = 0; i < argc; ++i) \
w_argv[i] = argv[i]; \
for (int i = 0; i < params.size(); ++i) \
diff --git a/tests/auto/shared/httpserver.cpp b/tests/auto/shared/httpserver.cpp
index 67f491fac..69e8cb6cc 100644
--- a/tests/auto/shared/httpserver.cpp
+++ b/tests/auto/shared/httpserver.cpp
@@ -54,6 +54,7 @@ bool HttpServer::start()
{
m_error = false;
m_expectingError = false;
+ m_ignoreNewConnection = false;
if (!m_tcpServer->listen()) {
qCWarning(gHttpServerLog).noquote() << m_tcpServer->errorString();
@@ -84,6 +85,9 @@ QUrl HttpServer::url(const QString &path) const
void HttpServer::handleNewConnection()
{
+ if (m_ignoreNewConnection)
+ return;
+
auto rr = new HttpReqRep(m_tcpServer->nextPendingConnection(), this);
connect(rr, &HttpReqRep::requestReceived, [this, rr]() {
Q_EMIT newRequest(rr);
@@ -122,5 +126,9 @@ void HttpServer::handleNewConnection()
<< error;
m_error = true;
});
- connect(rr, &HttpReqRep::closed, rr, &QObject::deleteLater);
+
+ if (!m_tcpServer->isListening()) {
+ m_ignoreNewConnection = true;
+ connect(rr, &HttpReqRep::closed, rr, &QObject::deleteLater);
+ }
}
diff --git a/tests/auto/shared/httpserver.h b/tests/auto/shared/httpserver.h
index 9764852de..952ead220 100644
--- a/tests/auto/shared/httpserver.h
+++ b/tests/auto/shared/httpserver.h
@@ -90,6 +90,7 @@ private:
QUrl m_url;
QStringList m_dirs;
bool m_error = false;
+ bool m_ignoreNewConnection = false;
bool m_expectingError = false;
};
diff --git a/tests/auto/shared/httpsserver.h b/tests/auto/shared/httpsserver.h
index 32c8e8345..219d5f7a1 100644
--- a/tests/auto/shared/httpsserver.h
+++ b/tests/auto/shared/httpsserver.h
@@ -55,7 +55,7 @@ struct SslTcpServer : QTcpServer
return;
}
- connect(socket, QOverload<QSslSocket::SocketError>::of(&QSslSocket::error),
+ 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; });
diff --git a/tests/auto/widgets/accessibility/BLACKLIST b/tests/auto/widgets/accessibility/BLACKLIST
new file mode 100644
index 000000000..41d3635d2
--- /dev/null
+++ b/tests/auto/widgets/accessibility/BLACKLIST
@@ -0,0 +1,2 @@
+[focusChild]
+*
diff --git a/tests/auto/widgets/accessibility/tst_accessibility.cpp b/tests/auto/widgets/accessibility/tst_accessibility.cpp
index 84382d6f1..989ad0ee9 100644
--- a/tests/auto/widgets/accessibility/tst_accessibility.cpp
+++ b/tests/auto/widgets/accessibility/tst_accessibility.cpp
@@ -151,17 +151,20 @@ void tst_Accessibility::hierarchy()
void tst_Accessibility::focusChild_data()
{
QTest::addColumn<QString>("interfaceName");
- QTest::addColumn<QVector<QAccessible::Role>>("ancestorRoles");
+ QTest::addColumn<QList<QAccessible::Role>>("ancestorRoles");
- QTest::newRow("QWebEngineView") << QString("QWebEngineView") << QVector<QAccessible::Role>({QAccessible::Client});
- QTest::newRow("RenderWidgetHostViewQtDelegate") << QString("RenderWidgetHostViewQtDelegate") << QVector<QAccessible::Role>({QAccessible::Client});
- QTest::newRow("QMainWindow") << QString("QMainWindow") << QVector<QAccessible::Role>({QAccessible::Window, QAccessible::Client /* central widget */, QAccessible::Client /* view */});
+ QTest::newRow("QWebEngineView") << QString("QWebEngineView") << QList<QAccessible::Role>({QAccessible::Client});
+ QTest::newRow("RenderWidgetHostViewQtDelegate") << QString("RenderWidgetHostViewQtDelegate") << QList<QAccessible::Role>({QAccessible::Client});
+ QTest::newRow("QMainWindow") << QString("QMainWindow") << QList<QAccessible::Role>({QAccessible::Window, QAccessible::Client /* central widget */, QAccessible::Client /* view */});
}
void tst_Accessibility::focusChild()
{
+#if QT_VERSION < QT_VERSION_CHECK(5, 14, 1)
+ QSKIP("Requires newer base Qt");
+#endif
auto traverseToWebDocumentAccessibleInterface = [](QAccessibleInterface *iface) -> QAccessibleInterface * {
- QFETCH(QVector<QAccessible::Role>, ancestorRoles);
+ QFETCH(QList<QAccessible::Role>, ancestorRoles);
for (int i = 0; i < ancestorRoles.size(); ++i) {
if (iface->childCount() == 0 || iface->role() != ancestorRoles[i])
return nullptr;
diff --git a/tests/auto/widgets/certificateerror/tst_certificateerror.cpp b/tests/auto/widgets/certificateerror/tst_certificateerror.cpp
index c5b761818..063a53ae2 100644
--- a/tests/auto/widgets/certificateerror/tst_certificateerror.cpp
+++ b/tests/auto/widgets/certificateerror/tst_certificateerror.cpp
@@ -58,11 +58,18 @@ struct PageWithCertificateErrorHandler : QWebEnginePage
QSignalSpy loadSpy;
QScopedPointer<QWebEngineCertificateError> error;
- bool certificateError(const QWebEngineCertificateError &e) override {
+ void certificateError(QWebEngineCertificateError e) override
+ {
error.reset(new QWebEngineCertificateError(e));
- if (deferError)
+ if (deferError) {
error->defer();
- return acceptCertificate;
+ return;
+ }
+
+ if (acceptCertificate)
+ error->acceptCertificate();
+ else
+ error->rejectCertificate();
}
};
@@ -103,17 +110,14 @@ void tst_CertificateError::handleError()
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());
QCOMPARE(page.loadSpy.count(), 0);
QCOMPARE(toPlainTextSync(&page), QString());
if (acceptCertificate)
- page.error->ignoreCertificateError();
+ page.error->acceptCertificate();
else
page.error->rejectCertificate();
- QVERIFY(page.error->answered());
page.error.reset();
}
QTRY_COMPARE_WITH_TIMEOUT(page.loadSpy.count(), 1, 30000);
diff --git a/tests/auto/widgets/loadsignals/tst_loadsignals.cpp b/tests/auto/widgets/loadsignals/tst_loadsignals.cpp
index 32bf53931..c1e9013df 100644
--- a/tests/auto/widgets/loadsignals/tst_loadsignals.cpp
+++ b/tests/auto/widgets/loadsignals/tst_loadsignals.cpp
@@ -52,6 +52,7 @@ private Q_SLOTS:
void secondLoadForError_WhenErrorPageEnabled();
void loadAfterInPageNavigation_qtbug66869();
void fileDownloadDoesNotTriggerLoadSignals_qtbug66661();
+ void numberOfStartedAndFinishedSignalsIsSame();
private:
QWebEngineProfile profile;
@@ -214,12 +215,12 @@ void tst_LoadSignals::fileDownloadDoesNotTriggerLoadSignals_qtbug66661()
// allow the download
QTemporaryDir tempDir;
QVERIFY(tempDir.isValid());
- QWebEngineDownloadItem::DownloadState downloadState = QWebEngineDownloadItem::DownloadRequested;
+ QWebEngineDownloadRequest::DownloadState downloadState = QWebEngineDownloadRequest::DownloadRequested;
ScopedConnection sc1 =
connect(&profile, &QWebEngineProfile::downloadRequested,
- [&downloadState, &tempDir](QWebEngineDownloadItem *item) {
- connect(item, &QWebEngineDownloadItem::stateChanged,
- [&downloadState](QWebEngineDownloadItem::DownloadState newState) {
+ [&downloadState, &tempDir](QWebEngineDownloadRequest *item) {
+ connect(item, &QWebEngineDownloadRequest::stateChanged,
+ [&downloadState](QWebEngineDownloadRequest::DownloadState newState) {
downloadState = newState;
});
item->setDownloadDirectory(tempDir.path());
@@ -236,12 +237,51 @@ void tst_LoadSignals::fileDownloadDoesNotTriggerLoadSignals_qtbug66661()
|| (loadFinishedSpy.size() != 1), 10000, 100);
// Download must have occurred
- QTRY_COMPARE(downloadState, QWebEngineDownloadItem::DownloadCompleted);
+ QTRY_COMPARE(downloadState, QWebEngineDownloadRequest::DownloadCompleted);
// No further loadStarted should have occurred within this time
QCOMPARE(loadStartedSpy.size(), 1);
QCOMPARE(loadFinishedSpy.size(), 1);
}
+void tst_LoadSignals::numberOfStartedAndFinishedSignalsIsSame() {
+
+ HttpServer server;
+ server.setResourceDirs({ TESTS_SOURCE_DIR "/qwebengineprofile/resources" });
+ connect(&server, &HttpServer::newRequest, [] (HttpReqRep *) {
+ QTest::qWait(250); // just add delay to trigger some progress for every sub resource
+ });
+ QVERIFY(server.start());
+
+ view.load(server.url("/hedgehog.png"));
+ QTRY_COMPARE(loadFinishedSpy.size(), 1);
+ QVERIFY(loadFinishedSpy[0][0].toBool());
+
+ loadStartedSpy.clear();
+ loadFinishedSpy.clear();
+ loadProgressSpy.clear();
+
+ view.page()->setHtml("<html><body>"
+ "<img src=\"" + server.url("/hedgehog.png").toEncoded() + "\">"
+ "<form method='GET' name='hiddenform' action='qrc:///resources/page1.html' />"
+ "<script language='javascript'>document.forms[0].submit();</script>"
+ "</body></html>");
+
+ QTRY_COMPARE(loadStartedSpy.size(), 2);
+ QTRY_COMPARE(loadFinishedSpy.size(), 2);
+
+ QTRY_VERIFY(!loadFinishedSpy[0][0].toBool());
+ QTRY_VERIFY(loadFinishedSpy[1][0].toBool());
+
+ view.page()->setHtml("<html><body>"
+ "<form method='GET' name='hiddenform' action='qrc:///resources/page1.html' />"
+ "<script language='javascript'>document.forms[0].submit();</script>"
+ "</body></html>");
+ QTRY_COMPARE(loadStartedSpy.size(), 4);
+ QTRY_COMPARE(loadFinishedSpy.size(), 4);
+ QVERIFY(loadFinishedSpy[2][0].toBool());
+ QVERIFY(loadFinishedSpy[3][0].toBool());
+}
+
QTEST_MAIN(tst_LoadSignals)
#include "tst_loadsignals.moc"
diff --git a/tests/auto/widgets/origins/origins.pro b/tests/auto/widgets/origins/origins.pro
index 7498354de..8b2fca2e4 100644
--- a/tests/auto/widgets/origins/origins.pro
+++ b/tests/auto/widgets/origins/origins.pro
@@ -1,4 +1,5 @@
include(../tests.pri)
+include(../../shared/http.pri)
CONFIG += c++14
qtConfig(webengine-webchannel):qtHaveModule(websockets) {
QT += websockets
diff --git a/tests/auto/widgets/origins/tst_origins.cpp b/tests/auto/widgets/origins/tst_origins.cpp
index c24fbede4..b9385516f 100644
--- a/tests/auto/widgets/origins/tst_origins.cpp
+++ b/tests/auto/widgets/origins/tst_origins.cpp
@@ -27,21 +27,23 @@
****************************************************************************/
#include "../util.h"
+#include "httpserver.h"
#include <QtCore/qfile.h>
#include <QtTest/QtTest>
#include <QtWebEngineCore/qwebengineurlrequestjob.h>
#include <QtWebEngineCore/qwebengineurlscheme.h>
#include <QtWebEngineCore/qwebengineurlschemehandler.h>
-#include <QtWebEngineWidgets/qwebenginepage.h>
-#include <QtWebEngineWidgets/qwebengineprofile.h>
-#include <QtWebEngineWidgets/qwebenginesettings.h>
+#include <QtWebEngineCore/qwebenginesettings.h>
+#include <QtWebEngineCore/qwebengineprofile.h>
+#include <QtWebEngineCore/qwebenginepage.h>
+
#if defined(WEBSOCKETS)
#include <QtWebSockets/qwebsocket.h>
#include <QtWebSockets/qwebsocketserver.h>
#include <QtWebChannel/qwebchannel.h>
#endif
-#include <QtWidgets/qaction.h>
+#include <qaction.h>
#define QSL QStringLiteral
#define QBAL QByteArrayLiteral
@@ -169,7 +171,7 @@ public:
profile->installUrlSchemeHandler(QBAL("cors"), this);
}
- QVector<QUrl> &requests() { return m_requests; }
+ QList<QUrl> &requests() { return m_requests; }
private:
void requestStarted(QWebEngineUrlRequestJob *job) override
@@ -198,7 +200,7 @@ private:
job->reply(mimeType, file);
}
- QVector<QUrl> m_requests;
+ QList<QUrl> m_requests;
};
class tst_Origins final : public QObject {
@@ -215,6 +217,8 @@ private Q_SLOTS:
void jsUrlOrigin();
void subdirWithAccess();
void subdirWithoutAccess();
+ void fileAccessRemoteUrl_data();
+ void fileAccessRemoteUrl();
void mixedSchemes();
void mixedSchemesWithCsp();
void mixedXHR_data();
@@ -497,6 +501,31 @@ void tst_Origins::subdirWithoutAccess()
QCOMPARE(eval(QSL("msg[1]")), QVariant(QSL("world")));
}
+void tst_Origins::fileAccessRemoteUrl_data()
+{
+ QTest::addColumn<bool>("EnableAccess");
+ QTest::addRow("enabled") << true;
+ QTest::addRow("disabled") << false;
+}
+
+void tst_Origins::fileAccessRemoteUrl()
+{
+ QFETCH(bool, EnableAccess);
+
+ HttpServer server;
+ server.setResourceDirs({ THIS_DIR "resources" });
+ QVERIFY(server.start());
+
+ ScopedAttribute sa(m_page->settings(), QWebEngineSettings::LocalContentCanAccessRemoteUrls, EnableAccess);
+ if (!EnableAccess)
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("blocked by CORS policy")));
+
+ QVERIFY(verifyLoad(QSL("file:" THIS_DIR "resources/mixedXHR.html")));
+
+ eval("sendXHR('" + server.url("/mixedXHR.txt").toString() + "')");
+ QTRY_COMPARE(eval("result"), (EnableAccess ? QString("ok") : QString("error")));
+}
+
// Load the main page over one scheme with an iframe over another scheme.
//
// For file and qrc schemes, the iframe should load but it should not be
diff --git a/tests/auto/widgets/proxy/proxy_server.cpp b/tests/auto/widgets/proxy/proxy_server.cpp
index 3bf915609..3e52de4f2 100644
--- a/tests/auto/widgets/proxy/proxy_server.cpp
+++ b/tests/auto/widgets/proxy/proxy_server.cpp
@@ -39,7 +39,7 @@ ProxyServer::ProxyServer(QObject *parent) : QObject(parent)
void ProxyServer::setCredentials(const QByteArray &user, const QByteArray password)
{
m_auth.append(user);
- m_auth.append(QChar(':'));
+ m_auth.append(':');
m_auth.append(password);
m_auth = m_auth.toBase64();
m_authenticate = true;
diff --git a/tests/auto/widgets/qwebenginedownloaditem/qwebenginedownloaditem.pro b/tests/auto/widgets/qwebenginedownloadrequest/qwebenginedownloadrequest.pro
index 18a66c466..18a66c466 100644
--- a/tests/auto/widgets/qwebenginedownloaditem/qwebenginedownloaditem.pro
+++ b/tests/auto/widgets/qwebenginedownloadrequest/qwebenginedownloadrequest.pro
diff --git a/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp b/tests/auto/widgets/qwebenginedownloadrequest/tst_qwebenginedownloadrequest.cpp
index ac38e2ed2..3c3f1054d 100644
--- a/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp
+++ b/tests/auto/widgets/qwebenginedownloadrequest/tst_qwebenginedownloadrequest.cpp
@@ -34,14 +34,14 @@
#include <QTemporaryDir>
#include <QTest>
#include <QRegularExpression>
-#include <QWebEngineDownloadItem>
+#include <QWebEngineDownloadRequest>
#include <QWebEnginePage>
#include <QWebEngineProfile>
#include <QWebEngineSettings>
#include <QWebEngineView>
#include <httpserver.h>
-class tst_QWebEngineDownloadItem : public QObject
+class tst_QWebEngineDownloadRequest : public QObject
{
Q_OBJECT
@@ -79,9 +79,6 @@ private Q_SLOTS:
void downloadToDefaultLocation();
void downloadToNonExistentDir();
void downloadToReadOnlyDir();
-#if QT_DEPRECATED_SINCE(5, 14)
- void downloadPathValidation();
-#endif
void downloadToDirectoryWithFileName_data();
void downloadToDirectoryWithFileName();
@@ -90,34 +87,30 @@ private:
void clickLink(QPoint linkPos);
void simulateUserAction(QPoint linkPos, UserAction action);
- QWebEngineDownloadItem::DownloadType expectedDownloadType(
- UserAction userAction,
- const QByteArray &contentDisposition = QByteArray());
-
HttpServer *m_server;
QWebEngineProfile *m_profile;
QWebEnginePage *m_page;
QWebEngineView *m_view;
- QSet<QWebEngineDownloadItem *> m_requestedDownloads;
- QSet<QWebEngineDownloadItem *> m_finishedDownloads;
+ QSet<QWebEngineDownloadRequest *> m_requestedDownloads;
+ QSet<QWebEngineDownloadRequest *> m_finishedDownloads;
};
-Q_DECLARE_METATYPE(tst_QWebEngineDownloadItem::UserAction)
-Q_DECLARE_METATYPE(tst_QWebEngineDownloadItem::FileAction)
+Q_DECLARE_METATYPE(tst_QWebEngineDownloadRequest::UserAction)
+Q_DECLARE_METATYPE(tst_QWebEngineDownloadRequest::FileAction)
-void tst_QWebEngineDownloadItem::initTestCase()
+void tst_QWebEngineDownloadRequest::initTestCase()
{
m_server = new HttpServer();
m_profile = new QWebEngineProfile;
m_profile->setHttpCacheType(QWebEngineProfile::NoCache);
m_profile->settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, false);
- connect(m_profile, &QWebEngineProfile::downloadRequested, [this](QWebEngineDownloadItem *item) {
+ connect(m_profile, &QWebEngineProfile::downloadRequested, [this](QWebEngineDownloadRequest *item) {
m_requestedDownloads.insert(item);
- connect(item, &QWebEngineDownloadItem::destroyed, [this, item](){
+ connect(item, &QWebEngineDownloadRequest::destroyed, [this, item](){
m_requestedDownloads.remove(item);
m_finishedDownloads.remove(item);
});
- connect(item, &QWebEngineDownloadItem::finished, [this, item](){
+ connect(item, &QWebEngineDownloadRequest::isFinishedChanged, [this, item](){
m_finishedDownloads.insert(item);
});
});
@@ -128,14 +121,14 @@ void tst_QWebEngineDownloadItem::initTestCase()
m_view->show();
}
-void tst_QWebEngineDownloadItem::init()
+void tst_QWebEngineDownloadRequest::init()
{
QVERIFY(m_server->start());
}
-void tst_QWebEngineDownloadItem::cleanup()
+void tst_QWebEngineDownloadRequest::cleanup()
{
- for (QWebEngineDownloadItem *item : m_finishedDownloads) {
+ for (QWebEngineDownloadRequest *item : m_finishedDownloads) {
item->deleteLater();
}
QTRY_COMPARE(m_requestedDownloads.count(), 0);
@@ -145,7 +138,7 @@ void tst_QWebEngineDownloadItem::cleanup()
m_profile->setDownloadPath("");
}
-void tst_QWebEngineDownloadItem::cleanupTestCase()
+void tst_QWebEngineDownloadRequest::cleanupTestCase()
{
delete m_view;
delete m_page;
@@ -153,7 +146,7 @@ void tst_QWebEngineDownloadItem::cleanupTestCase()
delete m_server;
}
-void tst_QWebEngineDownloadItem::saveLink(QPoint linkPos)
+void tst_QWebEngineDownloadRequest::saveLink(QPoint linkPos)
{
// Simulate right-clicking on link and choosing "save link as" from menu.
QSignalSpy menuSpy(m_view, &QWebEngineView::customContextMenuRequested);
@@ -170,7 +163,7 @@ void tst_QWebEngineDownloadItem::saveLink(QPoint linkPos)
m_page->triggerAction(QWebEnginePage::DownloadLinkToDisk);
}
-void tst_QWebEngineDownloadItem::clickLink(QPoint linkPos)
+void tst_QWebEngineDownloadRequest::clickLink(QPoint linkPos)
{
// Simulate left-clicking on link.
QTRY_VERIFY(m_view->focusWidget());
@@ -178,7 +171,7 @@ void tst_QWebEngineDownloadItem::clickLink(QPoint linkPos)
QTest::mouseClick(renderWidget, Qt::LeftButton, {}, linkPos);
}
-void tst_QWebEngineDownloadItem::simulateUserAction(QPoint linkPos, UserAction action)
+void tst_QWebEngineDownloadRequest::simulateUserAction(QPoint linkPos, UserAction action)
{
switch (action) {
case SaveLink: return saveLink(linkPos);
@@ -186,17 +179,7 @@ void tst_QWebEngineDownloadItem::simulateUserAction(QPoint linkPos, UserAction a
}
}
-QWebEngineDownloadItem::DownloadType tst_QWebEngineDownloadItem::expectedDownloadType(
- UserAction userAction, const QByteArray &contentDisposition)
-{
- if (userAction == SaveLink)
- return QWebEngineDownloadItem::UserRequested;
- if (contentDisposition == QByteArrayLiteral("attachment"))
- return QWebEngineDownloadItem::Attachment;
- return QWebEngineDownloadItem::DownloadAttribute;
-}
-
-void tst_QWebEngineDownloadItem::downloadLink_data()
+void tst_QWebEngineDownloadRequest::downloadLink_data()
{
QTest::addColumn<UserAction>("userAction");
QTest::addColumn<bool>("anchorHasDownloadAttribute");
@@ -207,7 +190,6 @@ void tst_QWebEngineDownloadItem::downloadLink_data()
QTest::addColumn<QByteArray>("fileDisposition");
QTest::addColumn<bool>("fileHasReferer");
QTest::addColumn<FileAction>("fileAction");
- QTest::addColumn<QWebEngineDownloadItem::DownloadType>("downloadType");
// SaveLink should always trigger a download, even for empty files.
QTest::newRow("save link to empty file")
@@ -302,7 +284,7 @@ void tst_QWebEngineDownloadItem::downloadLink_data()
/* fileMimeTypeDeclared */ << QByteArrayLiteral("text/plain")
/* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain")
/* fileDisposition */ << QByteArrayLiteral("")
- /* fileHasReferer */ << false // crbug.com/455987
+ /* fileHasReferer */ << true
/* fileAction */ << FileIsDownloaded;
// ... same with the content disposition header save for the download type.
@@ -326,7 +308,7 @@ void tst_QWebEngineDownloadItem::downloadLink_data()
/* fileMimeTypeDeclared */ << QByteArrayLiteral("text/plain")
/* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain")
/* fileDisposition */ << QByteArrayLiteral("attachment")
- /* fileHasReferer */ << false // crbug.com/455987
+ /* fileHasReferer */ << true
/* fileAction */ << FileIsDownloaded;
// The file's extension has no effect.
@@ -393,7 +375,7 @@ void tst_QWebEngineDownloadItem::downloadLink_data()
/* fileAction */ << FileIsDownloaded;
}
-void tst_QWebEngineDownloadItem::downloadLink()
+void tst_QWebEngineDownloadRequest::downloadLink()
{
QFETCH(UserAction, userAction);
QFETCH(bool, anchorHasDownloadAttribute);
@@ -450,33 +432,31 @@ void tst_QWebEngineDownloadItem::downloadLink()
QUrl downloadUrl = m_server->url(slashFileName);
int acceptedCount = 0;
int finishedCount = 0;
- ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) {
- QCOMPARE(item->state(), QWebEngineDownloadItem::DownloadRequested);
+ ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadRequest *item) {
+ QCOMPARE(item->state(), QWebEngineDownloadRequest::DownloadRequested);
QCOMPARE(item->isFinished(), false);
QCOMPARE(item->totalBytes(), -1);
QCOMPARE(item->receivedBytes(), 0);
- QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), expectedDownloadType(userAction, fileDisposition));
+ QCOMPARE(item->interruptReason(), QWebEngineDownloadRequest::NoReason);
QCOMPARE(item->isSavePageDownload(), false);
QCOMPARE(item->mimeType(), QString(fileMimeTypeDetected));
QCOMPARE(QDir(item->downloadDirectory()).filePath(item->downloadFileName()), suggestedPath);
- QCOMPARE(item->savePageFormat(), QWebEngineDownloadItem::UnknownSaveFormat);
+ QCOMPARE(item->savePageFormat(), QWebEngineDownloadRequest::UnknownSaveFormat);
QCOMPARE(item->url(), downloadUrl);
- QCOMPARE(item->page(), m_page);
+ QCOMPARE(QWebEnginePage::fromDownloadRequest(item), m_page);
- connect(item, &QWebEngineDownloadItem::finished, [&, item]() {
- QCOMPARE(item->state(), QWebEngineDownloadItem::DownloadCompleted);
+ connect(item, &QWebEngineDownloadRequest::isFinishedChanged, [&, item]() {
+ QCOMPARE(item->state(), QWebEngineDownloadRequest::DownloadCompleted);
QCOMPARE(item->isFinished(), true);
QCOMPARE(item->totalBytes(), fileContents.size());
QCOMPARE(item->receivedBytes(), fileContents.size());
- QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), expectedDownloadType(userAction, fileDisposition));
+ QCOMPARE(item->interruptReason(), QWebEngineDownloadRequest::NoReason);
QCOMPARE(item->isSavePageDownload(), false);
QCOMPARE(item->mimeType(), QString(fileMimeTypeDetected));
QCOMPARE(QDir(item->downloadDirectory()).filePath(item->downloadFileName()), downloadPath);
- QCOMPARE(item->savePageFormat(), QWebEngineDownloadItem::UnknownSaveFormat);
+ QCOMPARE(item->savePageFormat(), QWebEngineDownloadRequest::UnknownSaveFormat);
QCOMPARE(item->url(), downloadUrl);
- QCOMPARE(item->page(), m_page);
+ QCOMPARE(QWebEnginePage::fromDownloadRequest(item), m_page);
finishedCount++;
});
@@ -520,7 +500,7 @@ void tst_QWebEngineDownloadItem::downloadLink()
QCOMPARE(file.readAll(), fileContents);
}
-void tst_QWebEngineDownloadItem::downloadTwoLinks_data()
+void tst_QWebEngineDownloadRequest::downloadTwoLinks_data()
{
QTest::addColumn<UserAction>("action1");
QTest::addColumn<UserAction>("action2");
@@ -530,7 +510,7 @@ void tst_QWebEngineDownloadItem::downloadTwoLinks_data()
QTest::newRow("Click+Click") << ClickLink << ClickLink;
}
-void tst_QWebEngineDownloadItem::downloadTwoLinks()
+void tst_QWebEngineDownloadRequest::downloadTwoLinks()
{
QFETCH(UserAction, action1);
QFETCH(UserAction, action2);
@@ -563,29 +543,23 @@ void tst_QWebEngineDownloadItem::downloadTwoLinks()
QString standardDir = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
int acceptedCount = 0;
int finishedCount = 0;
- ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) {
- QCOMPARE(item->state(), QWebEngineDownloadItem::DownloadRequested);
+ ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadRequest *item) {
+ QCOMPARE(item->state(), QWebEngineDownloadRequest::DownloadRequested);
QCOMPARE(item->isFinished(), false);
QCOMPARE(item->totalBytes(), -1);
QCOMPARE(item->receivedBytes(), 0);
- QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->savePageFormat(), QWebEngineDownloadItem::UnknownSaveFormat);
+ QCOMPARE(item->interruptReason(), QWebEngineDownloadRequest::NoReason);
+ QCOMPARE(item->savePageFormat(), QWebEngineDownloadRequest::UnknownSaveFormat);
QCOMPARE(item->mimeType(), QStringLiteral("text/plain"));
QString filePart = QChar('/') + item->url().fileName();
QString fileName = item->url().fileName();
QCOMPARE(QDir(item->downloadDirectory()).filePath(item->downloadFileName()), standardDir + filePart);
// type() is broken due to race condition in DownloadManagerDelegateQt
- if (action1 == ClickLink && action2 == ClickLink) {
- if (filePart == QStringLiteral("/file1"))
- QCOMPARE(item->type(), expectedDownloadType(action1));
- else if (filePart == QStringLiteral("/file2"))
- QCOMPARE(item->type(), expectedDownloadType(action2, QByteArrayLiteral("attachment")));
- else
+ if (action1 == ClickLink && action2 == ClickLink && filePart != QStringLiteral("/file1") && filePart != QStringLiteral("/file2"))
QFAIL(qPrintable("Unexpected file name: " + filePart));
- }
- connect(item, &QWebEngineDownloadItem::finished, [&]() {
+ connect(item, &QWebEngineDownloadRequest::isFinishedChanged, [&]() {
finishedCount++;
});
item->setDownloadDirectory(tmpDir.path());
@@ -611,20 +585,20 @@ void tst_QWebEngineDownloadItem::downloadTwoLinks()
QTRY_COMPARE(finishedCount, 2);
}
-void tst_QWebEngineDownloadItem::downloadPage_data()
+void tst_QWebEngineDownloadRequest::downloadPage_data()
{
QTest::addColumn<bool>("saveWithPageAction");
- QTest::addColumn<QWebEngineDownloadItem::SavePageFormat>("savePageFormat");
- QTest::newRow("SingleHtmlSaveFormat") << false << QWebEngineDownloadItem::SingleHtmlSaveFormat;
- QTest::newRow("CompleteHtmlSaveFormat") << false << QWebEngineDownloadItem::CompleteHtmlSaveFormat;
- QTest::newRow("MimeHtmlSaveFormat") << false << QWebEngineDownloadItem::MimeHtmlSaveFormat;
- QTest::newRow("SavePageAction") << true << QWebEngineDownloadItem::MimeHtmlSaveFormat;
+ QTest::addColumn<QWebEngineDownloadRequest::SavePageFormat>("savePageFormat");
+ QTest::newRow("SingleHtmlSaveFormat") << false << QWebEngineDownloadRequest::SingleHtmlSaveFormat;
+ QTest::newRow("CompleteHtmlSaveFormat") << false << QWebEngineDownloadRequest::CompleteHtmlSaveFormat;
+ QTest::newRow("MimeHtmlSaveFormat") << false << QWebEngineDownloadRequest::MimeHtmlSaveFormat;
+ QTest::newRow("SavePageAction") << true << QWebEngineDownloadRequest::MimeHtmlSaveFormat;
}
-void tst_QWebEngineDownloadItem::downloadPage()
+void tst_QWebEngineDownloadRequest::downloadPage()
{
QFETCH(bool, saveWithPageAction);
- QFETCH(QWebEngineDownloadItem::SavePageFormat, savePageFormat);
+ QFETCH(QWebEngineDownloadRequest::SavePageFormat, savePageFormat);
// Set up HTTP server
int indexRequestCount = 0;
@@ -644,19 +618,18 @@ void tst_QWebEngineDownloadItem::downloadPage()
QUrl downloadUrl = m_server->url("/");
int acceptedCount = 0;
int finishedCount = 0;
- ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) {
- QCOMPARE(item->state(), saveWithPageAction ? QWebEngineDownloadItem::DownloadRequested : QWebEngineDownloadItem::DownloadInProgress);
+ ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadRequest *item) {
+ QCOMPARE(item->state(), saveWithPageAction ? QWebEngineDownloadRequest::DownloadRequested : QWebEngineDownloadRequest::DownloadInProgress);
QCOMPARE(item->isFinished(), false);
QCOMPARE(item->totalBytes(), -1);
QCOMPARE(item->receivedBytes(), 0);
- QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), QWebEngineDownloadItem::SavePage);
+ QCOMPARE(item->interruptReason(), QWebEngineDownloadRequest::NoReason);
QCOMPARE(item->isSavePageDownload(), true);
// FIXME(juvaldma): why is mimeType always the same?
QCOMPARE(item->mimeType(), QStringLiteral("application/x-mimearchive"));
QCOMPARE(item->savePageFormat(), savePageFormat);
QCOMPARE(item->url(), downloadUrl);
- QCOMPARE(item->page(), m_page);
+ QCOMPARE(QWebEnginePage::fromDownloadRequest(item), m_page);
if (saveWithPageAction) {
QVERIFY(!item->downloadDirectory().isEmpty());
@@ -668,19 +641,18 @@ void tst_QWebEngineDownloadItem::downloadPage()
QCOMPARE(QDir(item->downloadDirectory()).filePath(item->downloadFileName()), downloadPath);
- connect(item, &QWebEngineDownloadItem::finished, [&, item]() {
- QCOMPARE(item->state(), QWebEngineDownloadItem::DownloadCompleted);
+ connect(item, &QWebEngineDownloadRequest::isFinishedChanged, [&, item]() {
+ QCOMPARE(item->state(), QWebEngineDownloadRequest::DownloadCompleted);
QCOMPARE(item->isFinished(), true);
QCOMPARE(item->totalBytes(), item->receivedBytes());
QVERIFY(item->receivedBytes() > 0);
- QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), QWebEngineDownloadItem::SavePage);
+ QCOMPARE(item->interruptReason(), QWebEngineDownloadRequest::NoReason);
QCOMPARE(item->isSavePageDownload(), true);
QCOMPARE(item->mimeType(), QStringLiteral("application/x-mimearchive"));
QCOMPARE(QDir(item->downloadDirectory()).filePath(item->downloadFileName()), downloadPath);
QCOMPARE(item->savePageFormat(), savePageFormat);
QCOMPARE(item->url(), downloadUrl);
- QCOMPARE(item->page(), m_page);
+ QCOMPARE(QWebEnginePage::fromDownloadRequest(item), m_page);
finishedCount++;
});
@@ -707,7 +679,7 @@ void tst_QWebEngineDownloadItem::downloadPage()
QVERIFY(file.exists());
}
-void tst_QWebEngineDownloadItem::downloadViaSetUrl()
+void tst_QWebEngineDownloadRequest::downloadViaSetUrl()
{
// Reproduce the scenario described in QTBUG-63388 by triggering downloads
// of the same file multiple times via QWebEnginePage::setUrl
@@ -726,8 +698,8 @@ void tst_QWebEngineDownloadItem::downloadViaSetUrl()
});
// Set up profile and download handler
- QVector<QUrl> downloadUrls;
- ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) {
+ QList<QUrl> downloadUrls;
+ ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadRequest *item) {
downloadUrls.append(item->url());
});
@@ -758,7 +730,7 @@ void tst_QWebEngineDownloadItem::downloadViaSetUrl()
}
}
-void tst_QWebEngineDownloadItem::downloadFileNot1()
+void tst_QWebEngineDownloadRequest::downloadFileNot1()
{
// Trigger file download via download() but don't accept().
@@ -766,11 +738,11 @@ void tst_QWebEngineDownloadItem::downloadFileNot1()
rr->sendResponse(404);
});
- QPointer<QWebEngineDownloadItem> downloadItem;
+ QPointer<QWebEngineDownloadRequest> downloadItem;
int downloadCount = 0;
- ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) {
+ ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadRequest *item) {
QVERIFY(item);
- QCOMPARE(item->state(), QWebEngineDownloadItem::DownloadRequested);
+ QCOMPARE(item->state(), QWebEngineDownloadRequest::DownloadRequested);
downloadItem = item;
downloadCount++;
});
@@ -780,7 +752,7 @@ void tst_QWebEngineDownloadItem::downloadFileNot1()
QVERIFY(!downloadItem);
}
-void tst_QWebEngineDownloadItem::downloadFileNot2()
+void tst_QWebEngineDownloadRequest::downloadFileNot2()
{
// Trigger file download via download() but call cancel() instead of accept().
@@ -788,11 +760,11 @@ void tst_QWebEngineDownloadItem::downloadFileNot2()
rr->sendResponse(404);
});
- QPointer<QWebEngineDownloadItem> downloadItem;
+ QPointer<QWebEngineDownloadRequest> downloadItem;
int downloadCount = 0;
- ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) {
+ ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadRequest *item) {
QVERIFY(item);
- QCOMPARE(item->state(), QWebEngineDownloadItem::DownloadRequested);
+ QCOMPARE(item->state(), QWebEngineDownloadRequest::DownloadRequested);
item->cancel();
downloadItem = item;
downloadCount++;
@@ -801,19 +773,19 @@ void tst_QWebEngineDownloadItem::downloadFileNot2()
m_page->download(m_server->url(QByteArrayLiteral("/file")));
QTRY_COMPARE(downloadCount, 1);
QVERIFY(downloadItem);
- QCOMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCancelled);
+ QCOMPARE(downloadItem->state(), QWebEngineDownloadRequest::DownloadCancelled);
}
-void tst_QWebEngineDownloadItem::downloadDeleted()
+void tst_QWebEngineDownloadRequest::downloadDeleted()
{
- QPointer<QWebEngineDownloadItem> downloadItem;
+ QPointer<QWebEngineDownloadRequest> downloadItem;
int downloadCount = 0, finishedCount = 0;
- ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) {
+ ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadRequest *item) {
QVERIFY(item);
- QCOMPARE(item->state(), QWebEngineDownloadItem::DownloadRequested);
+ QCOMPARE(item->state(), QWebEngineDownloadRequest::DownloadRequested);
downloadItem = item;
- connect(downloadItem, &QWebEngineDownloadItem::finished, [&]() { ++finishedCount; });
+ connect(downloadItem, &QWebEngineDownloadRequest::isFinishedChanged, [&]() { ++finishedCount; });
++downloadCount;
// accept and schedule deletion, and check if it still finishes
item->accept();
@@ -829,16 +801,16 @@ void tst_QWebEngineDownloadItem::downloadDeleted()
QCOMPARE(finishedCount, 1);
}
-void tst_QWebEngineDownloadItem::downloadDeletedByProfile()
+void tst_QWebEngineDownloadRequest::downloadDeletedByProfile()
{
QPointer<QWebEngineProfile> profile(new QWebEngineProfile);
profile->setHttpCacheType(QWebEngineProfile::NoCache);
profile->settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, false);
bool downloadFinished = false;
- QPointer<QWebEngineDownloadItem> downloadItem;
- connect(profile, &QWebEngineProfile::downloadRequested, [&] (QWebEngineDownloadItem *item) {
- connect(item, &QWebEngineDownloadItem::finished, [&] () {
+ QPointer<QWebEngineDownloadRequest> downloadItem;
+ connect(profile, &QWebEngineProfile::downloadRequested, [&] (QWebEngineDownloadRequest *item) {
+ connect(item, &QWebEngineDownloadRequest::isFinishedChanged, [&] () {
downloadFinished = true;
});
downloadItem = item;
@@ -858,7 +830,7 @@ void tst_QWebEngineDownloadItem::downloadDeletedByProfile()
QTRY_COMPARE(downloadItem.isNull(), true);
}
-void tst_QWebEngineDownloadItem::downloadUniqueFilename_data()
+void tst_QWebEngineDownloadRequest::downloadUniqueFilename_data()
{
QTest::addColumn<QString>("baseName");
QTest::addColumn<QString>("extension");
@@ -867,7 +839,7 @@ void tst_QWebEngineDownloadItem::downloadUniqueFilename_data()
QTest::newRow("tar.gz") << QString("test(1.test)") << QString("tar.gz");
}
-void tst_QWebEngineDownloadItem::downloadUniqueFilename()
+void tst_QWebEngineDownloadRequest::downloadUniqueFilename()
{
QFETCH(QString, baseName);
QFETCH(QString, extension);
@@ -882,7 +854,8 @@ void tst_QWebEngineDownloadItem::downloadUniqueFilename()
// Set up HTTP server
ScopedConnection sc1 = connect(m_server, &HttpServer::newRequest, [&](HttpReqRep *rr) {
- if (rr->requestMethod() == "GET" && rr->requestPath() == ("/" + fileName)) {
+ auto requestPath = QString::fromUtf8(rr->requestPath());
+ if (rr->requestMethod() == "GET" && requestPath == ("/" + fileName)) {
rr->setResponseHeader(QByteArrayLiteral("content-type"), QByteArrayLiteral("application/octet-stream"));
rr->setResponseHeader(QByteArrayLiteral("content-disposition"), QByteArrayLiteral("attachment"));
rr->setResponseBody(QByteArrayLiteral("a"));
@@ -893,16 +866,15 @@ void tst_QWebEngineDownloadItem::downloadUniqueFilename()
});
// Set up profile and download handler
- ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) {
+ ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadRequest *item) {
suggestedFileName = item->suggestedFileName();
item->accept();
- connect(item, &QWebEngineDownloadItem::finished, [&, item]() {
- QCOMPARE(item->state(), QWebEngineDownloadItem::DownloadCompleted);
+ connect(item, &QWebEngineDownloadRequest::isFinishedChanged, [&, item]() {
+ QCOMPARE(item->state(), QWebEngineDownloadRequest::DownloadCompleted);
QCOMPARE(item->isFinished(), true);
QCOMPARE(item->totalBytes(), item->receivedBytes());
QVERIFY(item->receivedBytes() > 0);
- QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), QWebEngineDownloadItem::Attachment);
+ QCOMPARE(item->interruptReason(), QWebEngineDownloadRequest::NoReason);
QCOMPARE(item->isSavePageDownload(), false);
downloadedFilePath = QDir(item->downloadDirectory()).filePath(item->downloadFileName());
downloadFinished = true;
@@ -924,7 +896,7 @@ void tst_QWebEngineDownloadItem::downloadUniqueFilename()
}
}
-void tst_QWebEngineDownloadItem::downloadUniqueFilenameWithTimestamp()
+void tst_QWebEngineDownloadRequest::downloadUniqueFilenameWithTimestamp()
{
// Set up HTTP server
QString baseName("test(1.test)");
@@ -939,7 +911,8 @@ void tst_QWebEngineDownloadItem::downloadUniqueFilenameWithTimestamp()
m_profile->setDownloadPath(tmpDir.path());
ScopedConnection sc1 = connect(m_server, &HttpServer::newRequest, [&](HttpReqRep *rr) {
- if (rr->requestMethod() == "GET" && rr->requestPath() == ("/" + fileName)) {
+ auto requestPath = QString::fromUtf8(rr->requestPath());
+ if (rr->requestMethod() == "GET" && requestPath == ("/" + fileName)) {
rr->setResponseHeader(QByteArrayLiteral("content-type"), QByteArrayLiteral("application/octet-stream"));
rr->setResponseHeader(QByteArrayLiteral("content-disposition"), QByteArrayLiteral("attachment"));
rr->setResponseBody(QByteArrayLiteral("a"));
@@ -950,16 +923,16 @@ void tst_QWebEngineDownloadItem::downloadUniqueFilenameWithTimestamp()
});
// Set up profile and download handler
- ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) {
+ ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadRequest *item) {
suggestedFileName = item->suggestedFileName();
item->accept();
- connect(item, &QWebEngineDownloadItem::finished, [&, item]() {
- QCOMPARE(item->state(), QWebEngineDownloadItem::DownloadCompleted);
+ connect(item, &QWebEngineDownloadRequest::isFinishedChanged, [&, item]() {
+ QCOMPARE(item->state(), QWebEngineDownloadRequest::DownloadCompleted);
QCOMPARE(item->isFinished(), true);
QCOMPARE(item->totalBytes(), item->receivedBytes());
QVERIFY(item->receivedBytes() > 0);
- QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->page(), m_page);
+ QCOMPARE(item->interruptReason(), QWebEngineDownloadRequest::NoReason);
+ QCOMPARE(QWebEnginePage::fromDownloadRequest(item), m_page);
downloadFinished = true;
downloadedFilePath = QDir(item->downloadDirectory()).filePath(item->downloadFileName());
});
@@ -1002,7 +975,7 @@ void tst_QWebEngineDownloadItem::downloadUniqueFilenameWithTimestamp()
}
}
-void tst_QWebEngineDownloadItem::downloadToDefaultLocation()
+void tst_QWebEngineDownloadRequest::downloadToDefaultLocation()
{
QTemporaryDir tmpDir;
QVERIFY(tmpDir.isValid());
@@ -1019,7 +992,7 @@ void tst_QWebEngineDownloadItem::downloadToDefaultLocation()
QCOMPARE(m_profile->downloadPath(), QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
}
-void tst_QWebEngineDownloadItem::downloadToNonExistentDir()
+void tst_QWebEngineDownloadRequest::downloadToNonExistentDir()
{
QString baseName("test(1.test)");
QString extension("txt");
@@ -1034,7 +1007,8 @@ void tst_QWebEngineDownloadItem::downloadToNonExistentDir()
// Set up HTTP server
ScopedConnection sc1 = connect(m_server, &HttpServer::newRequest, [&](HttpReqRep *rr) {
- if (rr->requestMethod() == "GET" && rr->requestPath() == ("/" + fileName)) {
+ auto requestPath = QString::fromUtf8(rr->requestPath());
+ if (rr->requestMethod() == "GET" && requestPath == ("/" + fileName)) {
rr->setResponseHeader(QByteArrayLiteral("content-type"), QByteArrayLiteral("application/octet-stream"));
rr->setResponseHeader(QByteArrayLiteral("content-disposition"), QByteArrayLiteral("attachment"));
rr->setResponseBody(QByteArrayLiteral("a"));
@@ -1045,16 +1019,16 @@ void tst_QWebEngineDownloadItem::downloadToNonExistentDir()
});
// Set up profile and download handler
- ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) {
+ ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadRequest *item) {
suggestedFileName = item->suggestedFileName();
item->accept();
- connect(item, &QWebEngineDownloadItem::finished, [&, item]() {
- QCOMPARE(item->state(), QWebEngineDownloadItem::DownloadCompleted);
+ connect(item, &QWebEngineDownloadRequest::isFinishedChanged, [&, item]() {
+ QCOMPARE(item->state(), QWebEngineDownloadRequest::DownloadCompleted);
QCOMPARE(item->isFinished(), true);
QCOMPARE(item->totalBytes(), item->receivedBytes());
QVERIFY(item->receivedBytes() > 0);
- QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->page(), m_page);
+ QCOMPARE(item->interruptReason(), QWebEngineDownloadRequest::NoReason);
+ QCOMPARE(QWebEnginePage::fromDownloadRequest(item), m_page);
downloadFinished = true;
downloadedFilePath = QDir(item->downloadDirectory()).filePath(item->downloadFileName());
});
@@ -1071,7 +1045,7 @@ void tst_QWebEngineDownloadItem::downloadToNonExistentDir()
QCOMPARE(suggestedFileName, fileName);
}
-void tst_QWebEngineDownloadItem::downloadToReadOnlyDir()
+void tst_QWebEngineDownloadRequest::downloadToReadOnlyDir()
{
#ifdef Q_OS_WIN
QSKIP("Cannot change file permissions on Windows.");
@@ -1090,7 +1064,8 @@ void tst_QWebEngineDownloadItem::downloadToReadOnlyDir()
// Set up HTTP server
ScopedConnection sc1 = connect(m_server, &HttpServer::newRequest, [&](HttpReqRep *rr) {
- if (rr->requestMethod() == "GET" && rr->requestPath() == ("/" + fileName)) {
+ auto requestPath = QString::fromUtf8(rr->requestPath());
+ if (rr->requestMethod() == "GET" && requestPath == ("/" + fileName)) {
rr->setResponseHeader(QByteArrayLiteral("content-type"), QByteArrayLiteral("application/octet-stream"));
rr->setResponseHeader(QByteArrayLiteral("content-disposition"), QByteArrayLiteral("attachment"));
rr->setResponseBody(QByteArrayLiteral("a"));
@@ -1100,12 +1075,12 @@ void tst_QWebEngineDownloadItem::downloadToReadOnlyDir()
}
});
- QPointer<QWebEngineDownloadItem> downloadItem;
- ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) {
+ QPointer<QWebEngineDownloadRequest> downloadItem;
+ ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadRequest *item) {
suggestedFileName = item->suggestedFileName();
downloadItem = item;
item->accept();
- connect(item, &QWebEngineDownloadItem::finished, [&]() {
+ connect(item, &QWebEngineDownloadRequest::isFinishedChanged, [&]() {
downloadFinished = true;
});
downloadAccepted = true;
@@ -1119,9 +1094,9 @@ void tst_QWebEngineDownloadItem::downloadToReadOnlyDir()
QTRY_VERIFY(downloadAccepted);
QVERIFY(downloadItem);
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadInterrupted);
+ QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadRequest::DownloadInterrupted);
QCOMPARE(downloadItem->isFinished(), false);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::FileAccessDenied);
+ QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadRequest::FileAccessDenied);
QVERIFY(!QFile(downloadedFilePath).exists());
QCOMPARE(suggestedFileName, fileName);
@@ -1131,125 +1106,7 @@ void tst_QWebEngineDownloadItem::downloadToReadOnlyDir()
QFile(m_profile->downloadPath()).setPermissions(QFileDevice::WriteOwner);
}
-#if QT_DEPRECATED_SINCE(5, 14)
-void tst_QWebEngineDownloadItem::downloadPathValidation()
-{
- const QString fileName = "test.txt";
- QString downloadPath;
- QString originalDownloadPath;
-
- QTemporaryDir tmpDir;
- QVERIFY(tmpDir.isValid());
- m_profile->setDownloadPath(tmpDir.path());
-
- // Set up HTTP server
- ScopedConnection sc1 = connect(m_server, &HttpServer::newRequest, [&](HttpReqRep *rr) {
- if (rr->requestMethod() == "GET" && rr->requestPath() == ("/" + fileName)) {
- rr->setResponseHeader(QByteArrayLiteral("content-type"), QByteArrayLiteral("application/octet-stream"));
- rr->setResponseHeader(QByteArrayLiteral("content-disposition"), QByteArrayLiteral("attachment"));
- rr->setResponseBody(QByteArrayLiteral("a"));
- rr->sendResponse();
- } else {
- rr->sendResponse(404);
- }
- });
-
- // Set up profile and download handler
- QPointer<QWebEngineDownloadItem> downloadItem;
- ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) {
- downloadItem = item;
- originalDownloadPath = item->path();
-
- item->setPath(downloadPath);
- item->accept();
-
- connect(item, &QWebEngineDownloadItem::stateChanged, [&, item](QWebEngineDownloadItem::DownloadState downloadState) {
- if (downloadState == QWebEngineDownloadItem::DownloadInterrupted) {
- item->cancel();
- }
- });
-
- connect(item, &QWebEngineDownloadItem::finished, [&, item]() {
- QCOMPARE(item->isFinished(), true);
- QCOMPARE(item->totalBytes(), item->receivedBytes());
- QVERIFY(item->receivedBytes() > 0);
- QCOMPARE(item->page(), m_page);
- });
- });
-
- QString oldPath = QDir::currentPath();
- QDir::setCurrent(tmpDir.path());
-
- // Set only the file name.
- downloadItem.clear();
- originalDownloadPath = "";
- downloadPath = fileName;
- m_page->setUrl(m_server->url("/" + fileName));
- QTRY_VERIFY(downloadItem);
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCompleted);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(downloadItem->path(), fileName);
-
- // Set only the directory path.
- downloadItem.clear();
- originalDownloadPath = "";
- downloadPath = tmpDir.path();
- m_page->setUrl(m_server->url("/" + fileName));
- QTRY_VERIFY(downloadItem);
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCompleted);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(downloadItem->path(), originalDownloadPath);
-
- // Set only the directory path with separator.
- downloadItem.clear();
- originalDownloadPath = "";
- downloadPath = tmpDir.path() + QDir::separator();
- m_page->setUrl(m_server->url("/" + fileName));
- QTRY_VERIFY(downloadItem);
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCompleted);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(downloadItem->path(), originalDownloadPath);
-
- // Set only the directory with the current directory path without ending separator.
- downloadItem.clear();
- originalDownloadPath = "";
- downloadPath = ".";
- m_page->setUrl(m_server->url("/" + fileName));
- QTRY_VERIFY(downloadItem);
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCompleted);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(downloadItem->path(), originalDownloadPath);
-
- // Set only the directory with the current directory path with ending separator.
- downloadItem.clear();
- originalDownloadPath = "";
- downloadPath = "./";
- m_page->setUrl(m_server->url("/" + fileName));
- QTRY_VERIFY(downloadItem);
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCompleted);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(downloadItem->path(), originalDownloadPath);
-
- downloadItem.clear();
- originalDownloadPath = "";
- downloadPath = "...";
- m_page->setUrl(m_server->url("/" + fileName));
- QTRY_VERIFY(downloadItem);
-#if !defined(Q_OS_WIN)
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCancelled);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::FileFailed);
- QCOMPARE(downloadItem->path(), downloadPath);
-#else
- // Windows interprets the "..." path as a valid path. It will be the current path.
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCompleted);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(downloadItem->path(), originalDownloadPath);
-#endif // !defined(Q_OS_WIN)
- QDir::setCurrent(oldPath);
-}
-#endif
-
-void tst_QWebEngineDownloadItem::downloadToDirectoryWithFileName_data()
+void tst_QWebEngineDownloadRequest::downloadToDirectoryWithFileName_data()
{
QTest::addColumn<bool>("setDirectoryFirst");
@@ -1257,7 +1114,7 @@ void tst_QWebEngineDownloadItem::downloadToDirectoryWithFileName_data()
QTest::newRow("setFileNameFirst") << false;
}
-void tst_QWebEngineDownloadItem::downloadToDirectoryWithFileName()
+void tst_QWebEngineDownloadRequest::downloadToDirectoryWithFileName()
{
QFETCH(bool, setDirectoryFirst);
QString downloadDirectory;
@@ -1275,7 +1132,8 @@ void tst_QWebEngineDownloadItem::downloadToDirectoryWithFileName()
// Set up HTTP server
ScopedConnection sc1 = connect(m_server, &HttpServer::newRequest, [&](HttpReqRep *rr) {
- if (rr->requestMethod() == "GET" && rr->requestPath() == ("/" + fileName)) {
+ auto requestPath = QString::fromUtf8(rr->requestPath());
+ if (rr->requestMethod() == "GET" && requestPath == ("/" + fileName)) {
rr->setResponseHeader(QByteArrayLiteral("content-type"), QByteArrayLiteral("application/octet-stream"));
rr->setResponseHeader(QByteArrayLiteral("content-disposition"), QByteArrayLiteral("attachment"));
rr->setResponseBody(QByteArrayLiteral("a"));
@@ -1286,7 +1144,7 @@ void tst_QWebEngineDownloadItem::downloadToDirectoryWithFileName()
});
// Set up profile and download handler
- ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) {
+ ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadRequest *item) {
if (!downloadDirectory.isEmpty() && setDirectoryFirst) {
item->setDownloadDirectory(downloadDirectory);
@@ -1303,16 +1161,15 @@ void tst_QWebEngineDownloadItem::downloadToDirectoryWithFileName()
QCOMPARE(item->downloadDirectory(), downloadDirectory);
}
- QCOMPARE(item->path(), QDir(item->downloadDirectory()).filePath(item->downloadFileName()));
item->accept();
- connect(item, &QWebEngineDownloadItem::finished, [&, item]() {
- QCOMPARE(item->state(), QWebEngineDownloadItem::DownloadCompleted);
+ connect(item, &QWebEngineDownloadRequest::isFinishedChanged, [&, item]() {
+ QCOMPARE(item->state(), QWebEngineDownloadRequest::DownloadCompleted);
QCOMPARE(item->isFinished(), true);
QCOMPARE(item->totalBytes(), item->receivedBytes());
QVERIFY(item->receivedBytes() > 0);
- QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->page(), m_page);
+ QCOMPARE(item->interruptReason(), QWebEngineDownloadRequest::NoReason);
+ QCOMPARE(QWebEnginePage::fromDownloadRequest(item), m_page);
downloadFinished = true;
downloadedFilePath = QDir(item->downloadDirectory()).filePath(item->downloadFileName());
downloadedSuggestedFileName = item->suggestedFileName();
@@ -1349,7 +1206,7 @@ void tst_QWebEngineDownloadItem::downloadToDirectoryWithFileName()
QCOMPARE(downloadedSuggestedFileName, fileName);
// Download another file to the same directory and set file name by
- // QWebEngineDownloadItem::setDownloadDirectory() and setDownloadFileName() to avoid uniquification.
+ // QWebEngineDownloadRequest::setDownloadDirectory() and setDownloadFileName() to avoid uniquification.
downloadFinished = false;
downloadDirectory = m_profile->downloadPath() + QDir::separator() + "test1" + QDir::separator();
downloadFileName = "test1.txt";
@@ -1370,7 +1227,7 @@ void tst_QWebEngineDownloadItem::downloadToDirectoryWithFileName()
QCOMPARE(downloadedSuggestedFileName, fileName);
// Download the same file to same directory and set file name by
- // QWebEngineDownloadItem::setDownloadDirectory() and setDownloadFileName() to avoid uniquification.
+ // QWebEngineDownloadRequest::setDownloadDirectory() and setDownloadFileName() to avoid uniquification.
downloadFinished = false;
downloadDirectory = m_profile->downloadPath() + QDir::separator() + "test2" + QDir::separator();
downloadFileName = "test1.txt";
@@ -1392,5 +1249,5 @@ void tst_QWebEngineDownloadItem::downloadToDirectoryWithFileName()
QCOMPARE(downloadedSuggestedFileName, fileName);
}
-QTEST_MAIN(tst_QWebEngineDownloadItem)
-#include "tst_qwebenginedownloaditem.moc"
+QTEST_MAIN(tst_QWebEngineDownloadRequest)
+#include "tst_qwebenginedownloadrequest.moc"
diff --git a/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp b/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp
index bdb486793..72a45379b 100644
--- a/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp
+++ b/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp
@@ -320,7 +320,8 @@ void tst_QWebEngineHistory::serialize_2()
hist->forward();
QTRY_COMPARE(loadFinishedSpy->count(), 5);
hist->forward();
- QTRY_COMPARE(loadFinishedSpy->count(), 6);
+ // In-page navigation, the last url was the page5.html
+ QTRY_COMPARE(loadFinishedSpy->count(), 5);
QTRY_COMPARE(hist->currentItemIndex(), initialCurrentIndex);
}
diff --git a/tests/auto/widgets/qwebenginepage/BLACKLIST b/tests/auto/widgets/qwebenginepage/BLACKLIST
index 02b297d5a..2498ed765 100644
--- a/tests/auto/widgets/qwebenginepage/BLACKLIST
+++ b/tests/auto/widgets/qwebenginepage/BLACKLIST
@@ -4,9 +4,3 @@ osx
[mouseMovementProperties]
windows
macos # Can't move cursor (QTBUG-76312)
-
-[devTools]
-msvc-2019
-
-[setLifecycleStateWithDevTools]
-msvc-2019
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 040114258..6a4a5a965 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -31,11 +31,12 @@
#include <QMenu>
#include <QMimeDatabase>
#include <QNetworkProxy>
-#include <QOpenGLWidget>
#include <QPaintEngine>
#include <QPushButton>
#include <QScreen>
-#include <QStateMachine>
+#if defined(QT_STATEMACHINE_LIB)
+# include <QStateMachine>
+#endif
#include <QtGui/QClipboard>
#include <QtTest/QtTest>
#include <QTextCharFormat>
@@ -46,7 +47,7 @@
#include <qnetworkcookiejar.h>
#include <qnetworkreply.h>
#include <qnetworkrequest.h>
-#include <qwebenginedownloaditem.h>
+#include <qwebenginedownloadrequest.h>
#include <qwebenginefindtextresult.h>
#include <qwebenginefullscreenrequest.h>
#include <qwebenginehistory.h>
@@ -130,8 +131,10 @@ private Q_SLOTS:
void findTextCalledOnMatch();
void findTextActiveMatchOrdinal();
void deleteQWebEngineViewTwice();
+#if defined(QT_STATEMACHINE_LIB)
void loadSignalsOrder_data();
void loadSignalsOrder();
+#endif
void openWindowDefaultSize();
#ifdef Q_OS_MAC
@@ -174,6 +177,7 @@ private Q_SLOTS:
void setUrlUsingStateObject();
void setUrlThenLoads_data();
void setUrlThenLoads();
+ void loadFinishedAfterNotFoundError_data();
void loadFinishedAfterNotFoundError();
void loadInSignalHandlers_data();
void loadInSignalHandlers();
@@ -380,7 +384,7 @@ void tst_QWebEnginePage::geolocationRequestJS()
QFETCH(int, errorCode);
QWebEngineView view;
JSTestPage *newPage = new JSTestPage(&view);
- newPage->setView(&view);
+ view.setPage(newPage);
newPage->setGeolocationPermission(allowed);
connect(newPage, SIGNAL(featurePermissionRequested(const QUrl&, QWebEnginePage::Feature)),
@@ -520,7 +524,7 @@ void tst_QWebEnginePage::consoleOutput()
class TestPage : public QWebEnginePage {
Q_OBJECT
public:
- TestPage(QObject* parent = 0) : QWebEnginePage(parent)
+ TestPage(QObject *parent = nullptr) : QWebEnginePage(parent)
{
connect(this, SIGNAL(geometryChangeRequested(QRect)), this, SLOT(slotGeometryChangeRequested(QRect)));
}
@@ -1068,11 +1072,11 @@ void tst_QWebEnginePage::findText()
void tst_QWebEnginePage::findTextResult()
{
QSignalSpy findTextSpy(m_view->page(), &QWebEnginePage::findTextFinished);
- auto signalResult = [&findTextSpy]() -> QVector<int> {
+ auto signalResult = [&findTextSpy]() -> QList<int> {
if (findTextSpy.count() != 1)
- return QVector<int>({-1, -1});
+ return QList<int>({-1, -1});
auto r = findTextSpy.takeFirst().value(0).value<QWebEngineFindTextResult>();
- return QVector<int>({ r.numberOfMatches(), r.activeMatch() });
+ return QList<int>({ r.numberOfMatches(), r.activeMatch() });
};
// findText will abort in blink if the view has an empty size.
@@ -1084,21 +1088,21 @@ void tst_QWebEnginePage::findTextResult()
QTRY_COMPARE(loadSpy.count(), 1);
QCOMPARE(findTextSync(m_page, ""), false);
- QCOMPARE(signalResult(), QVector<int>({0, 0}));
+ QCOMPARE(signalResult(), QList<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(signalResult(), QList<int>({1, 1}));
QCOMPARE(findTextSync(m_page, ""), false);
- QCOMPARE(signalResult(), QVector<int>({0, 0}));
+ QCOMPARE(signalResult(), QList<int>({0, 0}));
}
QCOMPARE(findTextSync(m_page, "blahhh"), false);
- QCOMPARE(signalResult(), QVector<int>({0, 0}));
+ QCOMPARE(signalResult(), QList<int>({0, 0}));
QCOMPARE(findTextSync(m_page, ""), false);
- QCOMPARE(signalResult(), QVector<int>({0, 0}));
+ QCOMPARE(signalResult(), QList<int>({0, 0}));
}
void tst_QWebEnginePage::findTextSuccessiveShouldCallAllCallbacks()
@@ -1357,6 +1361,8 @@ void tst_QWebEnginePage::deleteQWebEngineViewTwice()
}
}
+// TODO: Reimplement test without QStateMachine or add qtscxml module dependency
+#if defined(QT_STATEMACHINE_LIB)
class SpyForLoadSignalsOrder : public QStateMachine {
Q_OBJECT
public:
@@ -1414,6 +1420,7 @@ void tst_QWebEnginePage::loadSignalsOrder()
page.load(url);
QTRY_VERIFY_WITH_TIMEOUT(loadSpy.isFinished(), 20000);
}
+#endif // defined(QT_STATEMACHINE_LIB)
void tst_QWebEnginePage::renderWidgetHostViewNotShowTopLevel()
{
@@ -1680,9 +1687,9 @@ void tst_QWebEnginePage::savePage()
QWebEnginePage *page = view.page();
connect(page->profile(), &QWebEngineProfile::downloadRequested,
- [] (QWebEngineDownloadItem *item)
+ [] (QWebEngineDownloadRequest *item)
{
- connect(item, &QWebEngineDownloadItem::finished,
+ connect(item, &QWebEngineDownloadRequest::isFinishedChanged,
&QTestEventLoop::instance(), &QTestEventLoop::exitLoop, Qt::QueuedConnection);
});
@@ -1696,7 +1703,7 @@ void tst_QWebEnginePage::savePage()
// Save the loaded page as HTML.
QTemporaryDir tempDir(QDir::tempPath() + "/tst_qwebengineview-XXXXXX");
const QString filePath = tempDir.path() + "/thingumbob.html";
- page->save(filePath, QWebEngineDownloadItem::CompleteHtmlSaveFormat);
+ page->save(filePath, QWebEngineDownloadRequest::CompleteHtmlSaveFormat);
QTestEventLoop::instance().enterLoop(10);
// Load something else.
@@ -1713,12 +1720,15 @@ void tst_QWebEnginePage::savePage()
void tst_QWebEnginePage::openWindowDefaultSize()
{
TestPage page;
+ QSignalSpy spyFinished(&page, &QWebEnginePage::loadFinished);
QSignalSpy windowCreatedSpy(&page, SIGNAL(windowCreated()));
QWebEngineView view;
- page.setView(&view);
+ view.setPage(&page);
+ page.settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, true);
+ view.setUrl(QUrl("about:blank"));
view.show();
+ QTRY_COMPARE(spyFinished.count(), 1);
- page.settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, true);
// Open a default window.
page.runJavaScript("window.open()");
QTRY_COMPARE(windowCreatedSpy.count(), 1);
@@ -2057,7 +2067,7 @@ private Q_SLOTS:
void continueError()
{
- emit error(this->error());
+ emit errorOccurred(this->error());
emit finished();
}
};
@@ -2413,9 +2423,13 @@ void tst_QWebEnginePage::setContent_data()
QString str = QString::fromUtf8("ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει");
QTest::newRow("UTF-8 plain text") << "text/plain; charset=utf-8" << str.toUtf8() << str;
- QTextCodec *utf16 = QTextCodec::codecForName("UTF-16");
- if (utf16)
- QTest::newRow("UTF-16 plain text") << "text/plain; charset=utf-16" << utf16->fromUnicode(str) << str;
+ QBuffer out16;
+ out16.open(QIODevice::WriteOnly);
+ QTextStream stream16(&out16);
+ stream16.setEncoding(QStringConverter::Utf16);
+ stream16 << str;
+ stream16.flush();
+ QTest::newRow("UTF-16 plain text") << "text/plain; charset=utf-16" << out16.buffer() << str;
str = QString::fromUtf8("Une chaîne de caractères à sa façon.");
QTest::newRow("latin-1 plain text") << "text/plain; charset=iso-8859-1" << str.toLatin1() << str;
@@ -2820,18 +2834,49 @@ void tst_QWebEnginePage::setUrlThenLoads()
QCOMPARE(baseUrlSync(m_page), extractBaseUrl(urlToLoad2));
}
+void tst_QWebEnginePage::loadFinishedAfterNotFoundError_data()
+{
+ QTest::addColumn<bool>("rfcInvalid");
+ QTest::addColumn<bool>("withServer");
+ QTest::addRow("rfc_invalid") << true << false;
+ QTest::addRow("non_existent") << false << false;
+ QTest::addRow("server_404") << false << true;
+}
+
void tst_QWebEnginePage::loadFinishedAfterNotFoundError()
{
+ QFETCH(bool, withServer);
+ QFETCH(bool, rfcInvalid);
+
+ QScopedPointer<HttpServer> server;
+ if (withServer) {
+ server.reset(new HttpServer);
+ QVERIFY(server->start());
+ }
+
QWebEnginePage page;
QSignalSpy spy(&page, SIGNAL(loadFinished(bool)));
page.settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false);
- page.setUrl(QUrl("http://non.existent/url"));
+ auto url = server
+ ? server->url("/not-found-page.html")
+ : QUrl(rfcInvalid ? "http://some.invalid" : "http://non.existent/url");
+ page.setUrl(url);
QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000);
+ QVERIFY(!spy.at(0).at(0).toBool());
+ QCOMPARE(toPlainTextSync(&page), QString());
+ QCOMPARE(spy.count(), 1);
page.settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, true);
- page.setUrl(QUrl("http://another.non.existent/url"));
+ url = server
+ ? server->url("/another-missing-one.html")
+ : QUrl(rfcInvalid ? "http://some.other.invalid" : "http://another.non.existent/url");
+ page.setUrl(url);
QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 2, 20000);
+ QVERIFY(!spy.at(1).at(0).toBool());
+
+ QEXPECT_FAIL("", "No more loads (like separate load for error pages) are expected", Continue);
+ QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 3, 1000);
}
class URLSetter : public QObject {
@@ -3349,7 +3394,7 @@ void tst_QWebEnginePage::devTools()
QCOMPARE(devToolsPage.devToolsPage(), nullptr);
QCOMPARE(devToolsPage.inspectedPage(), &inspectedPage1);
- QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 30000);
+ QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 90000);
QVERIFY(spy.takeFirst().value(0).toBool());
devToolsPage.setInspectedPage(&inspectedPage2);
@@ -3361,7 +3406,7 @@ void tst_QWebEnginePage::devTools()
QCOMPARE(devToolsPage.devToolsPage(), nullptr);
QCOMPARE(devToolsPage.inspectedPage(), &inspectedPage2);
- QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 30000);
+ QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 90000);
QVERIFY(spy.takeFirst().value(0).toBool());
devToolsPage.setInspectedPage(nullptr);
@@ -3458,7 +3503,11 @@ void tst_QWebEnginePage::openLinkInNewPage_data()
// the disposition and performing the navigation request normally.
QTest::newRow("BlockPopup") << Decision::ReturnNull << Cause::TargetBlank << Effect::Blocked;
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ QTest::newRow("IgnoreIntent") << Decision::ReturnNull << Cause::MiddleClick << Effect::Blocked;
+#else
QTest::newRow("IgnoreIntent") << Decision::ReturnNull << Cause::MiddleClick << Effect::LoadInSelf;
+#endif
QTest::newRow("OverridePopup") << Decision::ReturnSelf << Cause::TargetBlank << Effect::LoadInSelf;
QTest::newRow("OverrideIntent") << Decision::ReturnSelf << Cause::MiddleClick << Effect::LoadInSelf;
QTest::newRow("AcceptPopup") << Decision::ReturnOther << Cause::TargetBlank << Effect::LoadInOther;
@@ -3535,7 +3584,10 @@ void tst_QWebEnginePage::openLinkInNewPage()
switch (effect) {
case Effect::Blocked:
- // Nothing to test
+ // Test nothing new loaded
+ QTest::qWait(500);
+ QCOMPARE(page1.spy.count(), 0);
+ QCOMPARE(page2.spy.count(), 0);
break;
case Effect::LoadInSelf:
QTRY_COMPARE(page1.spy.count(), 1);
@@ -4028,16 +4080,16 @@ void tst_QWebEnginePage::setLifecycleStateWithDevTools()
// Ensure pages are initialized
inspectedPage.load(QStringLiteral("about:blank"));
devToolsPage.load(QStringLiteral("about:blank"));
- QTRY_COMPARE_WITH_TIMEOUT(inspectedSpy.count(), 1, 30000);
+ QTRY_COMPARE_WITH_TIMEOUT(inspectedSpy.count(), 1, 90000);
QCOMPARE(inspectedSpy.takeFirst().value(0), QVariant(true));
- QTRY_COMPARE_WITH_TIMEOUT(devToolsSpy.count(), 1, 30000);
+ QTRY_COMPARE_WITH_TIMEOUT(devToolsSpy.count(), 1, 90000);
QCOMPARE(devToolsSpy.takeFirst().value(0), QVariant(true));
// Open DevTools with Frozen inspectedPage
inspectedPage.setLifecycleState(QWebEnginePage::LifecycleState::Frozen);
inspectedPage.setDevToolsPage(&devToolsPage);
QCOMPARE(inspectedPage.lifecycleState(), QWebEnginePage::LifecycleState::Active);
- QTRY_COMPARE(devToolsSpy.count(), 1);
+ QTRY_COMPARE_WITH_TIMEOUT(devToolsSpy.count(), 1, 90000);
QCOMPARE(devToolsSpy.takeFirst().value(0), QVariant(true));
inspectedPage.setDevToolsPage(nullptr);
@@ -4045,7 +4097,7 @@ void tst_QWebEnginePage::setLifecycleStateWithDevTools()
inspectedPage.setLifecycleState(QWebEnginePage::LifecycleState::Discarded);
inspectedPage.setDevToolsPage(&devToolsPage);
QCOMPARE(inspectedPage.lifecycleState(), QWebEnginePage::LifecycleState::Active);
- QTRY_COMPARE(devToolsSpy.count(), 1);
+ QTRY_COMPARE_WITH_TIMEOUT(devToolsSpy.count(), 1, 90000);
QCOMPARE(devToolsSpy.takeFirst().value(0), QVariant(true));
QTRY_COMPARE(inspectedSpy.count(), 1);
QCOMPARE(inspectedSpy.takeFirst().value(0), QVariant(true));
@@ -4055,7 +4107,7 @@ void tst_QWebEnginePage::setLifecycleStateWithDevTools()
devToolsPage.setLifecycleState(QWebEnginePage::LifecycleState::Frozen);
devToolsPage.setInspectedPage(&inspectedPage);
QCOMPARE(devToolsPage.lifecycleState(), QWebEnginePage::LifecycleState::Active);
- QTRY_COMPARE(devToolsSpy.count(), 1);
+ QTRY_COMPARE_WITH_TIMEOUT(devToolsSpy.count(), 1, 90000);
QCOMPARE(devToolsSpy.takeFirst().value(0), QVariant(true));
devToolsPage.setInspectedPage(nullptr);
@@ -4063,7 +4115,7 @@ void tst_QWebEnginePage::setLifecycleStateWithDevTools()
devToolsPage.setLifecycleState(QWebEnginePage::LifecycleState::Discarded);
devToolsPage.setInspectedPage(&inspectedPage);
QCOMPARE(devToolsPage.lifecycleState(), QWebEnginePage::LifecycleState::Active);
- QTRY_COMPARE(devToolsSpy.count(), 2);
+ QTRY_COMPARE_WITH_TIMEOUT(devToolsSpy.count(), 2, 90000);
QCOMPARE(devToolsSpy.takeFirst().value(0), QVariant(false));
QCOMPARE(devToolsSpy.takeFirst().value(0), QVariant(true));
// keep DevTools open
@@ -4664,13 +4716,16 @@ void tst_QWebEnginePage::audioMuted()
void tst_QWebEnginePage::closeContents()
{
TestPage page;
+ QSignalSpy spyFinished(&page, &QWebEnginePage::loadFinished);
QSignalSpy windowCreatedSpy(&page, &TestPage::windowCreated);
+ page.setUrl(QUrl("about:blank"));
+ QTRY_COMPARE(spyFinished.count(), 1);
page.runJavaScript("var dialog = window.open('', '', 'width=100, height=100');");
QTRY_COMPARE(windowCreatedSpy.count(), 1);
QWebEngineView *dialogView = new QWebEngineView;
QWebEnginePage *dialogPage = page.createdWindows[0];
- dialogPage->setView(dialogView);
+ dialogView->setPage(dialogPage);
QCOMPARE(dialogPage->lifecycleState(), QWebEnginePage::LifecycleState::Active);
// This should not crash.
diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
index f4c0484eb..93a7c6acd 100644
--- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
+++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
@@ -35,11 +35,11 @@
#include <QtWebEngineCore/qwebenginecookiestore.h>
#include <QtWebEngineCore/qwebengineurlscheme.h>
#include <QtWebEngineCore/qwebengineurlschemehandler.h>
-#include <QtWebEngineWidgets/qwebengineprofile.h>
-#include <QtWebEngineWidgets/qwebenginepage.h>
-#include <QtWebEngineWidgets/qwebenginesettings.h>
+#include <QtWebEngineCore/qwebenginesettings.h>
+#include <QtWebEngineCore/qwebengineprofile.h>
+#include <QtWebEngineCore/qwebenginepage.h>
+#include <QtWebEngineCore/qwebenginedownloadrequest.h>
#include <QtWebEngineWidgets/qwebengineview.h>
-#include <QtWebEngineWidgets/qwebenginedownloaditem.h>
#if QT_CONFIG(webengine_webchannel)
#include <QWebChannel>
@@ -116,7 +116,7 @@ void tst_QWebEngineProfile::init()
QCOMPARE(profile->persistentCookiesPolicy(), QWebEngineProfile::AllowPersistentCookies);
QCOMPARE(profile->cachePath(), QStandardPaths::writableLocation(QStandardPaths::CacheLocation)
+ QStringLiteral("/QtWebEngine/Default"));
- QCOMPARE(profile->persistentStoragePath(), QStandardPaths::writableLocation(QStandardPaths::DataLocation)
+ QCOMPARE(profile->persistentStoragePath(), QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
+ QStringLiteral("/QtWebEngine/Default"));
}
@@ -136,7 +136,7 @@ void tst_QWebEngineProfile::privateProfile()
QCOMPARE(otrProfile.httpCacheType(), QWebEngineProfile::MemoryHttpCache);
QCOMPARE(otrProfile.persistentCookiesPolicy(), QWebEngineProfile::NoPersistentCookies);
QCOMPARE(otrProfile.cachePath(), QString());
- QCOMPARE(otrProfile.persistentStoragePath(), QStandardPaths::writableLocation(QStandardPaths::DataLocation)
+ QCOMPARE(otrProfile.persistentStoragePath(), QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
+ QStringLiteral("/QtWebEngine/OffTheRecord"));
// TBD: setters do not really work
otrProfile.setCachePath(QStringLiteral("/home/foo/bar"));
@@ -159,7 +159,7 @@ void tst_QWebEngineProfile::testProfile()
QCOMPARE(profile.persistentCookiesPolicy(), QWebEngineProfile::AllowPersistentCookies);
QCOMPARE(profile.cachePath(), QStandardPaths::writableLocation(QStandardPaths::CacheLocation)
+ QStringLiteral("/QtWebEngine/Test"));
- QCOMPARE(profile.persistentStoragePath(), QStandardPaths::writableLocation(QStandardPaths::DataLocation)
+ QCOMPARE(profile.persistentStoragePath(), QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
+ QStringLiteral("/QtWebEngine/Test"));
}
@@ -832,10 +832,10 @@ void tst_QWebEngineProfile::httpAcceptLanguage()
void tst_QWebEngineProfile::downloadItem()
{
- qRegisterMetaType<QWebEngineDownloadItem *>();
+ qRegisterMetaType<QWebEngineDownloadRequest *>();
QWebEngineProfile testProfile;
QWebEnginePage page(&testProfile);
- QSignalSpy downloadSpy(&testProfile, SIGNAL(downloadRequested(QWebEngineDownloadItem *)));
+ QSignalSpy downloadSpy(&testProfile, SIGNAL(downloadRequested(QWebEngineDownloadRequest *)));
page.load(QUrl::fromLocalFile(QCoreApplication::applicationFilePath()));
QTRY_COMPARE(downloadSpy.count(), 1);
}
@@ -845,9 +845,9 @@ void tst_QWebEngineProfile::changePersistentPath()
TestServer server;
QVERIFY(server.start());
- AutoDir dataDir1(QStandardPaths::writableLocation(QStandardPaths::DataLocation)
+ AutoDir dataDir1(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
+ QStringLiteral("/QtWebEngine/Test"));
- AutoDir dataDir2(QStandardPaths::writableLocation(QStandardPaths::DataLocation)
+ AutoDir dataDir2(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
+ QStringLiteral("/QtWebEngine/Test2"));
QWebEngineProfile testProfile(QStringLiteral("Test"));
@@ -871,7 +871,7 @@ void tst_QWebEngineProfile::changeHttpUserAgent()
TestServer server;
QVERIFY(server.start());
- QVector<QByteArray> userAgents;
+ QList<QByteArray> userAgents;
connect(&server, &HttpServer::newRequest, [&](HttpReqRep *rr) {
if (rr->requestPath() == "/hedgehog.html")
userAgents.push_back(rr->requestHeader(QByteArrayLiteral("user-agent")));
@@ -898,7 +898,7 @@ void tst_QWebEngineProfile::changeHttpAcceptLanguage()
TestServer server;
QVERIFY(server.start());
- QVector<QByteArray> languages;
+ QList<QByteArray> languages;
connect(&server, &HttpServer::newRequest, [&](HttpReqRep *rr) {
if (rr->requestPath() == "/hedgehog.html")
languages.push_back(rr->requestHeader(QByteArrayLiteral("accept-language")));
diff --git a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
index 32384aec2..5699f1d36 100644
--- a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
+++ b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
@@ -40,6 +40,8 @@ static bool verifyOrder(QStringList orderList)
"Deferred"
};
+ if (orderList.size() != 5)
+ return false;
if (orderList.at(4) == "load (timeout)") {
if (orderList.at(3) != "Deferred")
return false;
@@ -320,8 +322,8 @@ void tst_QWebEngineScript::scriptModifications()
QVERIFY(spyFinished.wait());
QCOMPARE(evaluateJavaScriptSync(&page, "document.body.innerText"), QVariant::fromValue(QStringLiteral("SUCCESS")));
QVERIFY(page.scripts().count() == 1);
- QWebEngineScript s = page.scripts().findScript(QStringLiteral("String1"));
- QVERIFY(page.scripts().remove(s));
+ QList<QWebEngineScript> s = page.scripts().find(QStringLiteral("String1"));
+ QVERIFY(page.scripts().remove(s.first()));
QVERIFY(page.scripts().count() == 0);
}
diff --git a/tests/auto/widgets/qwebenginesettings/BLACKLIST b/tests/auto/widgets/qwebenginesettings/BLACKLIST
new file mode 100644
index 000000000..d4a35a76a
--- /dev/null
+++ b/tests/auto/widgets/qwebenginesettings/BLACKLIST
@@ -0,0 +1,2 @@
+[javascriptClipboard]
+ubuntu-20.04
diff --git a/tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp b/tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp
index a09901e69..a7c3ccb3c 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::defaultSettings()->setAttribute(QWebEngineSettings::JavascriptEnabled, false);
+ QWebEngineProfile::defaultProfile()->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, false);
QVERIFY(!page.settings()->testAttribute(QWebEngineSettings::JavascriptEnabled));
page.load(QUrl("about:blank"));
diff --git a/tests/auto/widgets/qwebengineview/BLACKLIST b/tests/auto/widgets/qwebengineview/BLACKLIST
index 266f08886..05ebee4ce 100644
--- a/tests/auto/widgets/qwebengineview/BLACKLIST
+++ b/tests/auto/widgets/qwebengineview/BLACKLIST
@@ -1,8 +1,8 @@
[microFocusCoordinates]
osx
-[textSelectionOutOfInputField]
-*
-
[visibilityState3]
windows
+
+[horizontalScrollbarTest]
+osx
diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
index 5e16361c5..234049a38 100644
--- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
+++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
@@ -25,12 +25,12 @@
#include <private/qinputmethod_p.h>
#include <qpainter.h>
#include <qpagelayout.h>
-#include <qpa/qplatforminputcontext.h>
#include <qwebengineview.h>
#include <qwebenginepage.h>
#include <qwebenginesettings.h>
-#include <qnetworkrequest.h>
+#include <qaction.h>
#include <qdiriterator.h>
+#include <qnetworkrequest.h>
#include <qstackedlayout.h>
#include <qtemporarydir.h>
#include <QClipboard>
@@ -45,7 +45,6 @@
#include <QTcpServer>
#include <QTcpSocket>
#include <QStyle>
-#include <QtWidgets/qaction.h>
#include <QWebEngineProfile>
#include <QtCore/qregularexpression.h>
@@ -60,44 +59,6 @@ do { \
QCOMPARE((__expr), __expected); \
} while (0)
-static QTouchDevice* s_touchDevice = nullptr;
-
-static QPoint elementCenter(QWebEnginePage *page, const QString &id)
-{
- const QString jsCode(
- "(function(){"
- " var elem = document.getElementById('" + id + "');"
- " var rect = elem.getBoundingClientRect();"
- " return [(rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2];"
- "})()");
- QVariantList rectList = evaluateJavaScriptSync(page, jsCode).toList();
-
- if (rectList.count() != 2) {
- qWarning("elementCenter failed.");
- return QPoint();
- }
-
- return QPoint(rectList.at(0).toInt(), rectList.at(1).toInt());
-}
-
-static QRect elementGeometry(QWebEnginePage *page, const QString &id)
-{
- const QString jsCode(
- "(function() {"
- " var elem = document.getElementById('" + id + "');"
- " var rect = elem.getBoundingClientRect();"
- " return [rect.left, rect.top, rect.right, rect.bottom];"
- "})()");
- QVariantList coords = evaluateJavaScriptSync(page, jsCode).toList();
-
- if (coords.count() != 4) {
- qWarning("elementGeometry faield.");
- return QRect();
- }
-
- return QRect(coords[0].toInt(), coords[1].toInt(), coords[2].toInt(), coords[3].toInt());
-}
-
QT_BEGIN_NAMESPACE
namespace QTest {
int Q_TESTLIB_EXPORT defaultMouseDelay();
@@ -167,9 +128,6 @@ private Q_SLOTS:
void keyboardEvents();
void keyboardFocusAfterPopup();
void mouseClick();
- void touchTap();
- void touchTapAndHold();
- void touchTapAndHoldCancelled();
void postData();
void inputFieldOverridesShortcuts();
@@ -216,7 +174,6 @@ private Q_SLOTS:
// It is only called once.
void tst_QWebEngineView::initTestCase()
{
- s_touchDevice = QTest::createTouchDevice();
}
// This will be called after the last test function is executed.
@@ -350,7 +307,7 @@ void tst_QWebEngineView::changePage()
if (!fromIsNullPage) {
QVERIFY(!pageFrom->iconUrl().isEmpty());
QCOMPARE(spyIconUrl.last().value(0).toUrl(), pageFrom->iconUrl());
- QCOMPARE(spyIcon.last().value(0), QVariant::fromValue(pageFrom->icon()));
+ QCOMPARE(spyIcon.last().value(0).value<QIcon>(), pageFrom->icon());
}
QScopedPointer<QWebEnginePage> pageTo(new QWebEnginePage);
@@ -379,7 +336,7 @@ void tst_QWebEngineView::changePage()
QCOMPARE(pageFrom->iconUrl() == pageTo->iconUrl(), iconIsSame);
if (!iconIsSame) {
QCOMPARE(spyIconUrl.last().value(0).toUrl(), pageTo->iconUrl());
- QCOMPARE(spyIcon.last().value(0), QVariant::fromValue(pageTo->icon()));
+ QCOMPARE(spyIcon.last().value(0).value<QIcon>(), pageTo->icon());
}
// verify no emits on destroy with the same number of signals in spy
@@ -616,10 +573,10 @@ void tst_QWebEngineView::focusInputTypes()
class KeyEventRecordingWidget : public QWidget {
public:
- QList<QKeyEvent> pressEvents;
- QList<QKeyEvent> releaseEvents;
- void keyPressEvent(QKeyEvent *e) override { pressEvents << *e; }
- void keyReleaseEvent(QKeyEvent *e) override { releaseEvents << *e; }
+ QList<QKeyEvent *> pressEvents;
+ QList<QKeyEvent *> releaseEvents;
+ void keyPressEvent(QKeyEvent *e) override { pressEvents << e->clone(); }
+ void keyReleaseEvent(QKeyEvent *e) override { releaseEvents << e->clone(); }
};
void tst_QWebEngineView::unhandledKeyEventPropagation()
@@ -665,15 +622,15 @@ void tst_QWebEngineView::unhandledKeyEventPropagation()
// The page will consume the Tab key to change focus between elements while the arrow
// keys won't be used.
QCOMPARE(parentWidget.pressEvents.size(), 3);
- QCOMPARE(parentWidget.pressEvents[0].key(), (int)Qt::Key_Right);
- QCOMPARE(parentWidget.pressEvents[1].key(), (int)Qt::Key_Left);
- QCOMPARE(parentWidget.pressEvents[2].key(), (int)Qt::Key_Y);
+ QCOMPARE(parentWidget.pressEvents[0]->key(), (int)Qt::Key_Right);
+ QCOMPARE(parentWidget.pressEvents[1]->key(), (int)Qt::Key_Left);
+ QCOMPARE(parentWidget.pressEvents[2]->key(), (int)Qt::Key_Y);
// Key releases will all come back unconsumed.
- QCOMPARE(parentWidget.releaseEvents[0].key(), (int)Qt::Key_Right);
- QCOMPARE(parentWidget.releaseEvents[1].key(), (int)Qt::Key_Tab);
- QCOMPARE(parentWidget.releaseEvents[2].key(), (int)Qt::Key_Left);
- QCOMPARE(parentWidget.releaseEvents[3].key(), (int)Qt::Key_Y);
+ QCOMPARE(parentWidget.releaseEvents[0]->key(), (int)Qt::Key_Right);
+ QCOMPARE(parentWidget.releaseEvents[1]->key(), (int)Qt::Key_Tab);
+ QCOMPARE(parentWidget.releaseEvents[2]->key(), (int)Qt::Key_Left);
+ QCOMPARE(parentWidget.releaseEvents[3]->key(), (int)Qt::Key_Y);
}
void tst_QWebEngineView::horizontalScrollbarTest()
@@ -961,7 +918,7 @@ public:
private:
int m_eventCounter;
- QVector<QString> m_eventHistory;
+ QList<QString> m_eventHistory;
};
void tst_QWebEngineView::doNotSendMouseKeyboardEventsWhenDisabled()
@@ -1213,7 +1170,11 @@ void tst_QWebEngineView::changeLocale()
QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpyDE.count(), 1, 20000);
QTRY_VERIFY(!toPlainTextSync(viewDE.page()).isEmpty());
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
errorLines = toPlainTextSync(viewDE.page()).split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts);
+#else
+ errorLines = toPlainTextSync(viewDE.page()).split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts);
+#endif
QCOMPARE(errorLines.first().toUtf8(), QByteArrayLiteral("Die Website ist nicht erreichbar"));
QLocale::setDefault(QLocale("en"));
@@ -1223,7 +1184,11 @@ void tst_QWebEngineView::changeLocale()
QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpyEN.count(), 1, 20000);
QTRY_VERIFY(!toPlainTextSync(viewEN.page()).isEmpty());
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
errorLines = toPlainTextSync(viewEN.page()).split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts);
+#else
+ errorLines = toPlainTextSync(viewEN.page()).split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts);
+#endif
QCOMPARE(errorLines.first().toUtf8(), QByteArrayLiteral("This site can\xE2\x80\x99t be reached"));
// Reset error page
@@ -1236,7 +1201,11 @@ void tst_QWebEngineView::changeLocale()
QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpyDE.count(), 1, 20000);
QTRY_VERIFY(!toPlainTextSync(viewDE.page()).isEmpty());
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
errorLines = toPlainTextSync(viewDE.page()).split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts);
+#else
+ errorLines = toPlainTextSync(viewDE.page()).split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts);
+#endif
QCOMPARE(errorLines.first().toUtf8(), QByteArrayLiteral("Die Website ist nicht erreichbar"));
}
@@ -1283,6 +1252,7 @@ void tst_QWebEngineView::inputMethodsTextFormat()
evaluateJavaScriptSync(view.page(), "document.getElementById('input1').focus()");
view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QFETCH(QString, string);
QFETCH(int, start);
@@ -1520,172 +1490,6 @@ void tst_QWebEngineView::mouseClick()
QVERIFY(view.focusProxy()->inputMethodQuery(Qt::ImCurrentSelection).toString().isEmpty());
}
-void tst_QWebEngineView::touchTap()
-{
-#if defined(Q_OS_MACOS)
- QSKIP("Synthetic touch events are not supported on macOS");
-#endif
-
- QWebEngineView view;
- view.show();
- view.resize(200, 200);
- QVERIFY(QTest::qWaitForWindowExposed(&view));
-
- QSignalSpy loadFinishedSpy(&view, &QWebEngineView::loadFinished);
-
- view.settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, false);
- view.setHtml("<html><body>"
- "<p id='text' style='width: 150px;'>The Qt Company</p>"
- "<div id='notext' style='width: 150px; height: 100px; background-color: #f00;'></div>"
- "<form><input id='input' width='150px' type='text' value='The Qt Company2' /></form>"
- "</body></html>");
- QVERIFY(loadFinishedSpy.wait());
- QVERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty());
-
- auto singleTap = [](QWidget* target, const QPoint& tapCoords) -> void {
- QTest::touchEvent(target, s_touchDevice).press(1, tapCoords, target);
- QTest::touchEvent(target, s_touchDevice).stationary(1);
- QTest::touchEvent(target, s_touchDevice).release(1, tapCoords, target);
- };
-
- // Single tap on text doesn't trigger a selection
- singleTap(view.focusProxy(), elementCenter(view.page(), "text"));
- QTRY_VERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty());
- QTRY_VERIFY(!view.hasSelection());
-
- // Single tap inside the input field focuses it without selecting the text
- singleTap(view.focusProxy(), elementCenter(view.page(), "input"));
- QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input"));
- QTRY_VERIFY(!view.hasSelection());
-
- // Single tap on the div clears the input field focus
- singleTap(view.focusProxy(), elementCenter(view.page(), "notext"));
- QTRY_VERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty());
-
- // Double tap on text still doesn't trigger a selection
- singleTap(view.focusProxy(), elementCenter(view.page(), "text"));
- singleTap(view.focusProxy(), elementCenter(view.page(), "text"));
- QTRY_VERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty());
- QTRY_VERIFY(!view.hasSelection());
-
- // Double tap inside the input field focuses it and selects the word under it
- singleTap(view.focusProxy(), elementCenter(view.page(), "input"));
- singleTap(view.focusProxy(), elementCenter(view.page(), "input"));
- QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input"));
- QTRY_COMPARE(view.selectedText(), QStringLiteral("Company2"));
-
- // Double tap outside the input field behaves like a single tap: clears its focus and selection
- singleTap(view.focusProxy(), elementCenter(view.page(), "notext"));
- singleTap(view.focusProxy(), elementCenter(view.page(), "notext"));
- QTRY_VERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty());
- QTRY_VERIFY(!view.hasSelection());
-}
-
-void tst_QWebEngineView::touchTapAndHold()
-{
-#if defined(Q_OS_MACOS)
- QSKIP("Synthetic touch events are not supported on macOS");
-#endif
-
- QWebEngineView view;
- view.show();
- view.resize(200, 200);
- QVERIFY(QTest::qWaitForWindowExposed(&view));
-
- QSignalSpy loadFinishedSpy(&view, &QWebEngineView::loadFinished);
-
- view.settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, false);
- view.setHtml("<html><body>"
- "<p id='text' style='width: 150px;'>The Qt Company</p>"
- "<div id='notext' style='width: 150px; height: 100px; background-color: #f00;'></div>"
- "<form><input id='input' width='150px' type='text' value='The Qt Company2' /></form>"
- "</body></html>");
- QVERIFY(loadFinishedSpy.wait());
- QVERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty());
-
- auto tapAndHold = [](QWidget* target, const QPoint& tapCoords) -> void {
- QTest::touchEvent(target, s_touchDevice).press(1, tapCoords, target);
- QTest::touchEvent(target, s_touchDevice).stationary(1);
- QTest::qWait(1000);
- QTest::touchEvent(target, s_touchDevice).release(1, tapCoords, target);
- };
-
- // Tap-and-hold on text selects the word under it
- tapAndHold(view.focusProxy(), elementCenter(view.page(), "text"));
- QTRY_VERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty());
- QTRY_COMPARE(view.selectedText(), QStringLiteral("Company"));
-
- // Tap-and-hold inside the input field focuses it and selects the word under it
- tapAndHold(view.focusProxy(), elementCenter(view.page(), "input"));
- QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input"));
- QTRY_COMPARE(view.selectedText(), QStringLiteral("Company2"));
-
- // Only test the page context menu on Windows, as Linux doesn't handle context menus consistently
- // and other non-desktop platforms like Android may not even support context menus at all
-#if defined(Q_OS_WIN)
- // Tap-and-hold clears the text selection and shows the page's context menu
- QVERIFY(QApplication::activePopupWidget() == nullptr);
- tapAndHold(view.focusProxy(), elementCenter(view.page(), "notext"));
- QTRY_VERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty());
- QTRY_VERIFY(!view.hasSelection());
- QTRY_VERIFY(QApplication::activePopupWidget() != nullptr);
-
- QApplication::activePopupWidget()->close();
- QVERIFY(QApplication::activePopupWidget() == nullptr);
-#endif
-}
-
-void tst_QWebEngineView::touchTapAndHoldCancelled()
-{
-#if defined(Q_OS_MACOS)
- QSKIP("Synthetic touch events are not supported on macOS");
-#endif
-
- QWebEngineView view;
- view.show();
- view.resize(200, 200);
- QVERIFY(QTest::qWaitForWindowExposed(&view));
-
- QSignalSpy loadFinishedSpy(&view, &QWebEngineView::loadFinished);
-
- view.settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, false);
- view.setHtml("<html><body>"
- "<p id='text' style='width: 150px;'>The Qt Company</p>"
- "<div id='notext' style='width: 150px; height: 100px; background-color: #f00;'></div>"
- "<form><input id='input' width='150px' type='text' value='The Qt Company2' /></form>"
- "</body></html>");
- QVERIFY(loadFinishedSpy.wait());
- QVERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty());
-
- auto cancelledTapAndHold = [](QWidget* target, const QPoint& tapCoords) -> void {
- QTest::touchEvent(target, s_touchDevice).press(1, tapCoords, target);
- QTest::touchEvent(target, s_touchDevice).stationary(1);
- QTest::qWait(1000);
- QWindowSystemInterface::handleTouchCancelEvent(target->windowHandle(), s_touchDevice);
- };
-
- // A cancelled tap-and-hold should cancel text selection, but currently doesn't
- cancelledTapAndHold(view.focusProxy(), elementCenter(view.page(), "text"));
- QEXPECT_FAIL("", "Incorrect Chromium selection behavior when cancelling tap-and-hold on text", Continue);
- QTRY_VERIFY_WITH_TIMEOUT(!view.hasSelection(), 100);
-
- // A cancelled tap-and-hold should cancel input field focusing and selection, but currently doesn't
- cancelledTapAndHold(view.focusProxy(), elementCenter(view.page(), "input"));
- QEXPECT_FAIL("", "Incorrect Chromium selection behavior when cancelling tap-and-hold on input field", Continue);
- QTRY_VERIFY_WITH_TIMEOUT(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty(), 100);
- QEXPECT_FAIL("", "Incorrect Chromium focus behavior when cancelling tap-and-hold on input field", Continue);
- QTRY_VERIFY_WITH_TIMEOUT(!view.hasSelection(), 100);
-
- // Only test the page context menu on Windows, as Linux doesn't handle context menus consistently
- // and other non-desktop platforms like Android may not even support context menus at all
-#if defined(Q_OS_WIN)
- // A cancelled tap-and-hold cancels the context menu
- QVERIFY(QApplication::activePopupWidget() == nullptr);
- cancelledTapAndHold(view.focusProxy(), elementCenter(view.page(), "notext"));
- QVERIFY(QApplication::activePopupWidget() == nullptr);
-#endif
-}
-
void tst_QWebEngineView::postData()
{
QMap<QString, QString> postData;
@@ -1709,7 +1513,11 @@ void tst_QWebEngineView::postData()
QStringList lines = QString::fromLocal8Bit(rawData).split("\r\n");
// examine request
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
QStringList request = lines[0].split(" ", Qt::SkipEmptyParts);
+#else
+ QStringList request = lines[0].split(" ", QString::SkipEmptyParts);
+#endif
bool requestOk = request.length() > 2
&& request[2].toUpper().startsWith("HTTP/")
&& request[0].toUpper() == "POST"
@@ -1848,7 +1656,7 @@ void tst_QWebEngineView::inputFieldOverridesShortcuts()
};
// The input form is not focused. The action is triggered on pressing Shift+Delete.
- action->setShortcut(Qt::SHIFT + Qt::Key_Delete);
+ action->setShortcut(Qt::SHIFT | Qt::Key_Delete);
QTest::keyClick(view.windowHandle(), Qt::Key_Delete, Qt::ShiftModifier);
QTRY_VERIFY(actionTriggered);
QCOMPARE(inputFieldValue(), QString("x"));
@@ -1884,7 +1692,7 @@ void tst_QWebEngineView::inputFieldOverridesShortcuts()
// A Ctrl-1 action is no default Qt key binding and should be triggerable.
evaluateJavaScriptSync(view.page(), "document.getElementById('input1').focus();");
QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input1"));
- action->setShortcut(Qt::CTRL + Qt::Key_1);
+ action->setShortcut(Qt::CTRL | Qt::Key_1);
QTest::keyClick(view.windowHandle(), Qt::Key_1, Qt::ControlModifier);
QTRY_VERIFY(actionTriggered);
QCOMPARE(inputFieldValue(), QString("yxx"));
@@ -2051,6 +1859,7 @@ void tst_QWebEngineView::inputContextQueryInput()
" <input type='text' id='input1' value='' size='50'/>"
"</body></html>");
QTRY_COMPARE(loadFinishedSpy.count(), 1);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QCOMPARE(testContext.infos.count(), 0);
// Set focus on an input field.
@@ -2202,6 +2011,7 @@ void tst_QWebEngineView::inputMethods()
" <input type='text' id='input1' style='font-family: serif' value='' maxlength='20' size='50'/>"
"</body></html>");
QTRY_COMPARE(loadFinishedSpy.size(), 1);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QPoint textInputCenter = elementCenter(view.page(), "input1");
QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, textInputCenter);
@@ -2299,6 +2109,7 @@ void tst_QWebEngineView::textSelectionInInputField()
" <input type='text' id='input1' value='QtWebEngine' size='50'/>"
"</body></html>");
QVERIFY(loadFinishedSpy.wait());
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
// Tests for Selection when the Editor is NOT in Composition mode
@@ -2372,6 +2183,7 @@ void tst_QWebEngineView::textSelectionInInputField()
void tst_QWebEngineView::textSelectionOutOfInputField()
{
QWebEngineView view;
+ view.settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, true);
view.resize(640, 480);
view.show();
@@ -2381,6 +2193,7 @@ void tst_QWebEngineView::textSelectionOutOfInputField()
" This is a text"
"</body></html>");
QVERIFY(loadFinishedSpy.wait());
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QCOMPARE(selectionChangedSpy.count(), 0);
QVERIFY(!view.hasSelection());
@@ -2429,6 +2242,7 @@ void tst_QWebEngineView::textSelectionOutOfInputField()
" <input type='text' id='input1' value='QtWebEngine' size='50'/>"
"</body></html>");
QVERIFY(loadFinishedSpy.wait());
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QCOMPARE(selectionChangedSpy.count(), 0);
QVERIFY(!view.hasSelection());
@@ -2508,6 +2322,7 @@ void tst_QWebEngineView::emptyInputMethodEvent()
" <input type='text' id='input1' value='QtWebEngine'/>"
"</body></html>");
QVERIFY(loadFinishedSpy.wait());
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
evaluateJavaScriptSync(view.page(), "var inputEle = document.getElementById('input1'); inputEle.focus(); inputEle.select();");
QTRY_COMPARE(selectionChangedSpy.count(), 1);
@@ -2556,6 +2371,7 @@ void tst_QWebEngineView::imeComposition()
" <input type='text' id='input1' value='QtWebEngine inputMethod'/>"
"</body></html>");
QVERIFY(loadFinishedSpy.wait());
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
evaluateJavaScriptSync(view.page(), "var inputEle = document.getElementById('input1'); inputEle.focus(); inputEle.select();");
QTRY_COMPARE(selectionChangedSpy.count(), 1);
@@ -2773,6 +2589,7 @@ void tst_QWebEngineView::newlineInTextarea()
" <textarea rows='5' cols='1' id='input1'></textarea>"
"</body></html>");
QVERIFY(loadFinishedSpy.wait());
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
evaluateJavaScriptSync(view.page(), "var inputEle = document.getElementById('input1'); inputEle.focus(); inputEle.select();");
QTRY_VERIFY(evaluateJavaScriptSync(view.page(), "document.getElementById('input1').value").toString().isEmpty());
@@ -2897,6 +2714,7 @@ void tst_QWebEngineView::imeJSInputEvents()
" <pre id='log'></pre>"
"</body></html>");
QVERIFY(loadFinishedSpy.wait());
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
evaluateJavaScriptSync(view.page(), "document.getElementById('input').focus()");
QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input"));
@@ -3019,6 +2837,7 @@ void tst_QWebEngineView::imeCompositionQueryEvent()
" <input type='text' id='input1' />"
"</body></html>");
QVERIFY(loadFinishedSpy.wait());
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
evaluateJavaScriptSync(view.page(), "document.getElementById('input1').focus()");
QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input1"));
@@ -3483,6 +3302,12 @@ void tst_QWebEngineView::switchPage()
QWebEnginePage page2(&profile);
QSignalSpy loadFinishedSpy1(&page1, SIGNAL(loadFinished(bool)));
QSignalSpy loadFinishedSpy2(&page2, SIGNAL(loadFinished(bool)));
+ // TODO fixme: page without the view has no real widget behind, so
+ // reading graphical content will fail, add view for now.
+ QWebEngineView webView1;
+ QWebEngineView webView2;
+ webView1.setPage(&page1);
+ webView2.setPage(&page2);
page1.setHtml("<html><body bgcolor=\"#000000\"></body></html>");
page2.setHtml("<html><body bgcolor=\"#ffffff\"></body></html>");
QTRY_VERIFY(loadFinishedSpy1.count() && loadFinishedSpy2.count());
@@ -3526,7 +3351,7 @@ void tst_QWebEngineView::setViewDeletesImplicitPage()
QWebEngineView view;
QPointer<QWebEnginePage> implicitPage = view.page();
QWebEnginePage explicitPage;
- explicitPage.setView(&view);
+ view.setPage(&explicitPage);
QCOMPARE(view.page(), &explicitPage);
QVERIFY(!implicitPage); // should be deleted
}
@@ -3547,8 +3372,8 @@ void tst_QWebEngineView::setViewPreservesExplicitPage()
QWebEngineView view;
QPointer<QWebEnginePage> explicitPage1 = new QWebEnginePage(&view);
QPointer<QWebEnginePage> explicitPage2 = new QWebEnginePage(&view);
- explicitPage1->setView(&view);
- explicitPage2->setView(&view);
+ view.setPage(explicitPage1.data());
+ view.setPage(explicitPage2.data());
QCOMPARE(view.page(), explicitPage2.data());
QVERIFY(explicitPage1); // should not be deleted
}
diff --git a/tests/auto/widgets/spellchecking/tst_spellchecking.cpp b/tests/auto/widgets/spellchecking/tst_spellchecking.cpp
index 801e2a76c..258071559 100644
--- a/tests/auto/widgets/spellchecking/tst_spellchecking.cpp
+++ b/tests/auto/widgets/spellchecking/tst_spellchecking.cpp
@@ -28,9 +28,8 @@
#include "util.h"
#include <QtTest/QtTest>
-#include <QtWebEngineWidgets/qwebenginecontextmenudata.h>
-#include <QtWebEngineWidgets/qwebengineprofile.h>
-#include <QtWebEngineWidgets/qwebenginepage.h>
+#include <QtWebEngineCore/qwebengineprofile.h>
+#include <QtWebEngineCore/qwebenginepage.h>
#include <QtWebEngineWidgets/qwebengineview.h>
#include <qwebenginesettings.h>
@@ -47,10 +46,7 @@ public:
QTest::mouseRelease(widget, Qt::RightButton, {}, position);
}
- const QWebEngineContextMenuData& data()
- {
- return m_data;
- }
+ QWebEngineContextMenuRequest *data() { return m_data; }
signals:
void menuReady();
@@ -58,11 +54,11 @@ signals:
protected:
void contextMenuEvent(QContextMenuEvent *)
{
- m_data = page()->contextMenuData();
+ m_data = lastContextMenuRequest();
emit menuReady();
}
private:
- QWebEngineContextMenuData m_data;
+ QWebEngineContextMenuRequest *m_data;
};
class tst_Spellchecking : public QObject
@@ -204,17 +200,17 @@ void tst_Spellchecking::spellcheck()
return false;
}
- if (!m_view->data().isValid()) {
+ if (!m_view->data()) {
detail = "invalid data";
return false;
}
- if (!m_view->data().isContentEditable()) {
+ if (!m_view->data()->isContentEditable()) {
detail = "content is not editable";
return false;
}
- if (m_view->data().misspelledWord().isEmpty()) {
+ if (m_view->data()->misspelledWord().isEmpty()) {
detail = "no misspelled word";
return false;
};
@@ -224,10 +220,10 @@ void tst_Spellchecking::spellcheck()
} (), qPrintable(QString("Context menu: %1").arg(detail)));
// check misspelled word
- QCOMPARE(m_view->data().misspelledWord(), QStringLiteral("lowe"));
+ QCOMPARE(m_view->data()->misspelledWord(), QStringLiteral("lowe"));
// check suggestions
- QCOMPARE(m_view->data().spellCheckerSuggestions(), suggestions);
+ QCOMPARE(m_view->data()->spellCheckerSuggestions(), suggestions);
// check replace word
m_view->page()->replaceMisspelledWord("love");
diff --git a/tests/auto/widgets/touchinput/touchinput.pro b/tests/auto/widgets/touchinput/touchinput.pro
new file mode 100644
index 000000000..d91c0074b
--- /dev/null
+++ b/tests/auto/widgets/touchinput/touchinput.pro
@@ -0,0 +1,2 @@
+include(../tests.pri)
+QT *= gui-private
diff --git a/tests/auto/widgets/touchinput/tst_touchinput.cpp b/tests/auto/widgets/touchinput/tst_touchinput.cpp
new file mode 100644
index 000000000..359b11eb2
--- /dev/null
+++ b/tests/auto/widgets/touchinput/tst_touchinput.cpp
@@ -0,0 +1,349 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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 "../util.h"
+
+#include <QtGui/qpa/qwindowsysteminterface.h>
+#include <QSignalSpy>
+#include <QTest>
+#include <QPointingDevice>
+#include <QWebEngineSettings>
+#include <QWebEngineView>
+
+static QPointingDevice* s_touchDevice = nullptr;
+
+class TouchInputTest : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void initTestCase();
+ void init();
+ void cleanup();
+
+private Q_SLOTS:
+ void touchTap();
+ void touchTapAndHold();
+ void touchTapAndHoldCancelled();
+ void scrolling();
+ void pinchZoom_data();
+ void pinchZoom();
+ void complexSequence();
+
+private:
+ QWebEngineView view;
+ QSignalSpy loadSpy { &view, &QWebEngineView::loadFinished };
+ QPoint notextCenter, textCenter, inputCenter;
+
+ QString activeElement() { return evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(); }
+
+ void gestureScroll(bool down) {
+ auto target = view.focusProxy();
+ QPoint p(target->width() / 2, target->height() / 4 * (down ? 3 : 1));
+
+ QTest::touchEvent(target, s_touchDevice).press(42, p, target);
+
+ QSignalSpy spy(view.page(), &QWebEnginePage::scrollPositionChanged);
+ for (int i = 0; i < 3; ++i) {
+ down ? p -= QPoint(5, 15) : p += QPoint(5, 15);
+ QTest::qWait(100); // too fast and events are recognized as fling gesture
+ QTest::touchEvent(target, s_touchDevice).move(42, p, target);
+ spy.wait();
+ }
+
+ QTest::touchEvent(target, s_touchDevice).release(42, p, target);
+ }
+
+ void gesturePinch(bool zoomIn, bool tapOneByOne = false) {
+ auto target = view.focusProxy();
+ QPoint p(target->width() / 2, target->height() / 2);
+ auto t1 = p - QPoint(zoomIn ? 50 : 150, 10), t2 = p + QPoint(zoomIn ? 50 : 150, 10);
+
+ if (tapOneByOne) {
+ QTest::touchEvent(target, s_touchDevice).press(42, t1, target);
+ QTest::touchEvent(target, s_touchDevice).stationary(42).press(24, t2, target);
+ } else {
+ QTest::touchEvent(target, s_touchDevice).press(42, t1, target).press(24, t2, target);
+ }
+
+ for (int i = 0; i < 3; ++i) {
+ if (zoomIn) {
+ t1 -= QPoint(25, 5);
+ t2 += QPoint(25, 5);
+ } else {
+ t1 += QPoint(35, 5);
+ t2 -= QPoint(35, 5);
+ }
+ QTest::qWait(100); // too fast and events are recognized as fling gesture
+ QTest::touchEvent(target, s_touchDevice).move(24, t1, target).move(42, t2, target);
+ }
+
+ if (tapOneByOne) {
+ QTest::touchEvent(target, s_touchDevice).stationary(42).release(24, t2, target);
+ QTest::touchEvent(target, s_touchDevice).release(42, t1, target);
+ } else {
+ QTest::touchEvent(target, s_touchDevice).release(42, t1, target).release(24, t2, target);
+ }
+ }
+
+ int getScrollPosition(int *position = nullptr) {
+ int p = evaluateJavaScriptSync(view.page(), "window.scrollY").toInt();
+ return position ? (*position = p) : p;
+ }
+
+ int pageScrollPosition() {
+ // this one is updated later in page in asynchronous way
+ return qRound(view.page()->scrollPosition().y());
+ }
+
+ double getScaleFactor(double *scale = nullptr) {
+ double s = evaluateJavaScriptSync(view.page(), "window.visualViewport.scale").toDouble();
+ return scale ? (*scale = s) : s;
+ }
+};
+
+void TouchInputTest::initTestCase()
+{
+ s_touchDevice = QTest::createTouchDevice();
+
+ view.settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, false);
+
+ view.show(); view.resize(480, 320);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+
+ view.setHtml("<html><head><style>.rect { min-width: 240px; min-height: 120px; }</style></head><body>"
+ "<p id='text' style='width: 150px;'>The Qt Company</p>"
+ "<div id='notext' style='width: 150px; height: 100px; background-color: #f00;'></div>"
+ "<form><input id='input' width='150px' type='text' value='The Qt Company2' /></form>"
+ "<table style='width: 100%; padding: 15px; text-align: center;'>"
+ "<tr><td>BEFORE</td><td><div class='rect' style='background-color: #00f;'></div></td><td>AFTER</td></tr>"
+ "<tr><td>BEFORE</td><td><div class='rect' style='background-color: #0f0;'></div></td><td>AFTER</td></tr>"
+ "<tr><td>BEFORE</td><td><div class='rect' style='background-color: #f00;'></div></td><td>AFTER</td></tr></table>"
+ "</body></html>");
+ QVERIFY(loadSpy.wait() && loadSpy.first().first().toBool());
+
+ notextCenter = elementCenter(view.page(), "notext");
+ textCenter = elementCenter(view.page(), "text");
+ inputCenter = elementCenter(view.page(), "input");
+}
+
+void TouchInputTest::init()
+{
+ QCOMPARE(activeElement(), QString());
+}
+
+void TouchInputTest::cleanup()
+{
+ evaluateJavaScriptSync(view.page(), "if (document.activeElement) document.activeElement.blur()");
+ evaluateJavaScriptSync(view.page(), "window.scrollTo(0, 0)");
+ QTRY_COMPARE(getScrollPosition(), 0);
+ QTRY_COMPARE(pageScrollPosition(), 0);
+}
+
+void TouchInputTest::touchTap()
+{
+ auto singleTap = [target = view.focusProxy()] (const QPoint& tapCoords) -> void {
+ QTest::touchEvent(target, s_touchDevice).press(1, tapCoords, target);
+ QTest::touchEvent(target, s_touchDevice).stationary(1);
+ QTest::touchEvent(target, s_touchDevice).release(1, tapCoords, target);
+ };
+
+ // Single tap on text doesn't trigger a selection
+ singleTap(textCenter);
+ QTRY_COMPARE(activeElement(), QString());
+ QTRY_VERIFY(!view.hasSelection());
+
+ // Single tap inside the input field focuses it without selecting the text
+ singleTap(inputCenter);
+ QTRY_COMPARE(activeElement(), QStringLiteral("input"));
+ QTRY_VERIFY(!view.hasSelection());
+
+ // Single tap on the div clears the input field focus
+ singleTap(notextCenter);
+ QTRY_COMPARE(activeElement(), QString());
+
+ // Double tap on text still doesn't trigger a selection
+ singleTap(textCenter);
+ singleTap(textCenter);
+ QTRY_COMPARE(activeElement(), QString());
+ QTRY_VERIFY(!view.hasSelection());
+
+ // Double tap inside the input field focuses it and selects the word under it
+ singleTap(inputCenter);
+ singleTap(inputCenter);
+ QTRY_COMPARE(activeElement(), QStringLiteral("input"));
+ QTRY_COMPARE(view.selectedText(), QStringLiteral("Company2"));
+
+ // Double tap outside the input field behaves like a single tap: clears its focus and selection
+ singleTap(notextCenter);
+ singleTap(notextCenter);
+ QTRY_COMPARE(activeElement(), QString());
+ QTRY_VERIFY(!view.hasSelection());
+}
+
+void TouchInputTest::touchTapAndHold()
+{
+ auto tapAndHold = [target = view.focusProxy()] (const QPoint& tapCoords) -> void {
+ QTest::touchEvent(target, s_touchDevice).press(1, tapCoords, target);
+ QTest::touchEvent(target, s_touchDevice).stationary(1);
+ QTest::qWait(1000);
+ QTest::touchEvent(target, s_touchDevice).release(1, tapCoords, target);
+ };
+
+ // Tap-and-hold on text selects the word under it
+ tapAndHold(textCenter);
+ QTRY_COMPARE(activeElement(), QString());
+ QTRY_COMPARE(view.selectedText(), QStringLiteral("Company"));
+
+ // Tap-and-hold inside the input field focuses it and selects the word under it
+ tapAndHold(inputCenter);
+ QTRY_COMPARE(activeElement(), QStringLiteral("input"));
+ QTRY_COMPARE(view.selectedText(), QStringLiteral("Company2"));
+
+ // Only test the page context menu on Windows, as Linux doesn't handle context menus consistently
+ // and other non-desktop platforms like Android may not even support context menus at all
+#if defined(Q_OS_WIN)
+ // Tap-and-hold clears the text selection and shows the page's context menu
+ QVERIFY(QApplication::activePopupWidget() == nullptr);
+ tapAndHold(notextCenter);
+ QTRY_COMPARE(activeElement(), QString());
+ QTRY_VERIFY(!view.hasSelection());
+ QTRY_VERIFY(QApplication::activePopupWidget() != nullptr);
+
+ QApplication::activePopupWidget()->close();
+ QVERIFY(QApplication::activePopupWidget() == nullptr);
+#endif
+}
+
+void TouchInputTest::touchTapAndHoldCancelled()
+{
+ auto cancelledTapAndHold = [target = view.focusProxy()] (const QPoint& tapCoords) -> void {
+ QTest::touchEvent(target, s_touchDevice).press(1, tapCoords, target);
+ QTest::touchEvent(target, s_touchDevice).stationary(1);
+ QTest::qWait(1000);
+ QWindowSystemInterface::handleTouchCancelEvent(target->windowHandle(), s_touchDevice);
+ };
+
+ // A cancelled tap-and-hold should cancel text selection, but currently doesn't
+ cancelledTapAndHold(textCenter);
+ QEXPECT_FAIL("", "Incorrect Chromium selection behavior when cancelling tap-and-hold on text", Continue);
+ QTRY_VERIFY_WITH_TIMEOUT(!view.hasSelection(), 100);
+
+ // A cancelled tap-and-hold should cancel input field focusing and selection, but currently doesn't
+ cancelledTapAndHold(inputCenter);
+ QEXPECT_FAIL("", "Incorrect Chromium selection behavior when cancelling tap-and-hold on input field", Continue);
+ QTRY_VERIFY_WITH_TIMEOUT(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty(), 100);
+ QEXPECT_FAIL("", "Incorrect Chromium focus behavior when cancelling tap-and-hold on input field", Continue);
+ QTRY_VERIFY_WITH_TIMEOUT(!view.hasSelection(), 100);
+
+ // Only test the page context menu on Windows, as Linux doesn't handle context menus consistently
+ // and other non-desktop platforms like Android may not even support context menus at all
+#if defined(Q_OS_WIN)
+ // A cancelled tap-and-hold cancels the context menu
+ QVERIFY(QApplication::activePopupWidget() == nullptr);
+ cancelledTapAndHold(notextCenter);
+ QVERIFY(QApplication::activePopupWidget() == nullptr);
+#endif
+}
+
+void TouchInputTest::scrolling()
+{
+ int p = getScrollPosition();
+ QCOMPARE(p, 0);
+
+ // scroll a bit down...
+ for (int i = 0; i < 3; ++i) {
+ gestureScroll(/* down = */true);
+ int positionBefore = p;
+ QTRY_VERIFY2(getScrollPosition(&p) > positionBefore, qPrintable(QString("i: %1, position: %2 -> %3").arg(i).arg(positionBefore).arg(p)));
+ }
+
+ // ... and then scroll page again but in opposite direction
+ for (int i = 0; i < 3; ++i) {
+ gestureScroll(/* down = */false);
+ int positionBefore = p;
+ QTRY_VERIFY2(getScrollPosition(&p) < positionBefore, qPrintable(QString("i: %1, position: %2 -> %3").arg(i).arg(positionBefore).arg(p)));
+ }
+
+ QTRY_COMPARE(getScrollPosition(), 0);
+}
+
+void TouchInputTest::pinchZoom_data()
+{
+ QTest::addColumn<bool>("tapOneByOne");
+ QTest::addRow("sequential") << true;
+ QTest::addRow("simultaneous") << false;
+}
+
+void TouchInputTest::pinchZoom()
+{
+ QFETCH(bool, tapOneByOne);
+ double scale = getScaleFactor();
+ QCOMPARE(scale, 1.0);
+
+ for (int i = 0; i < 3; ++i) {
+ gesturePinch(/* zoomIn = */true, tapOneByOne);
+ QTRY_VERIFY2(getScaleFactor(&scale) > 1.5, qPrintable(QString("i: %1, scale: %2").arg(i).arg(scale)));
+ gesturePinch(/* zoomIn = */false, tapOneByOne);
+ QTRY_COMPARE(getScaleFactor(&scale), 1.0);
+ }
+}
+
+void TouchInputTest::complexSequence()
+{
+ auto t = view.focusProxy();
+ QPoint pc(view.width() / 2, view.height() / 2), p1 = pc - QPoint(50, 25), p2 = pc + QPoint(50, 25);
+
+ for (int i = 0; i < 4; ++i) {
+ QTest::touchEvent(t, s_touchDevice).press(42, p1, t); QTest::qWait(50);
+ QTest::touchEvent(t, s_touchDevice).stationary(42).press(24, p2, t); QTest::qWait(50);
+ QTest::touchEvent(t, s_touchDevice).release(42, p1, t).release(24, p2, t);
+
+ // for additional variablity add zooming in on even steps and zooming out on odd steps
+ // MEMO scroll position will always be 0 while viewport scale factor > 1.0, so do zoom in after scroll
+ bool zoomIn = i % 2 == 0;
+
+ if (!zoomIn) {
+ gesturePinch(false);
+ QTRY_COMPARE(getScaleFactor(), 1.0);
+ }
+
+ int p = getScrollPosition(), positionBefore = p;
+ gestureScroll(true);
+ QTRY_VERIFY2_WITH_TIMEOUT(getScrollPosition(&p) > positionBefore, qPrintable(QString("i: %1, position: %2 -> %3").arg(i).arg(positionBefore).arg(p)), 1000);
+
+ if (zoomIn) {
+ double s = getScaleFactor(), scaleBefore = s;
+ gesturePinch(true);
+ QTRY_VERIFY2(getScaleFactor(&s) > scaleBefore, qPrintable(QString("i: %1, scale: %2").arg(i).arg(s)));
+ }
+ }
+}
+
+QTEST_MAIN(TouchInputTest)
+#include "tst_touchinput.moc"
diff --git a/tests/auto/widgets/util.h b/tests/auto/widgets/util.h
index af0b9bf6f..3be9a91b9 100644
--- a/tests/auto/widgets/util.h
+++ b/tests/auto/widgets/util.h
@@ -184,12 +184,49 @@ static inline bool loadSync(QWebEngineView *view, const QUrl &url, bool ok = tru
return loadSync(view->page(), url, ok);
}
+static inline QPoint elementCenter(QWebEnginePage *page, const QString &id)
+{
+ const QString jsCode(
+ "(function(){"
+ " var elem = document.getElementById('" + id + "');"
+ " var rect = elem.getBoundingClientRect();"
+ " return [(rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2];"
+ "})()");
+ QVariantList rectList = evaluateJavaScriptSync(page, jsCode).toList();
+
+ if (rectList.count() != 2) {
+ qWarning("elementCenter failed.");
+ return QPoint();
+ }
+
+ return QPoint(rectList.at(0).toInt(), rectList.at(1).toInt());
+}
+
+static inline QRect elementGeometry(QWebEnginePage *page, const QString &id)
+{
+ const QString jsCode(
+ "(function() {"
+ " var elem = document.getElementById('" + id + "');"
+ " var rect = elem.getBoundingClientRect();"
+ " return [rect.left, rect.top, rect.right, rect.bottom];"
+ "})()");
+ QVariantList coords = evaluateJavaScriptSync(page, jsCode).toList();
+
+ if (coords.count() != 4) {
+ qWarning("elementGeometry faield.");
+ return QRect();
+ }
+
+ return QRect(coords[0].toInt(), coords[1].toInt(), coords[2].toInt(), coords[3].toInt());
+}
+
+
#define W_QSKIP(a, b) QSKIP(a)
#define W_QTEST_MAIN(TestObject, params) \
int main(int argc, char *argv[]) \
{ \
- QVector<const char *> w_argv(argc); \
+ QList<const char *> w_argv(argc); \
for (int i = 0; i < argc; ++i) \
w_argv[i] = argv[i]; \
for (int i = 0; i < params.size(); ++i) \
diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro
index 6d65eecb5..4ec9e5d63 100644
--- a/tests/auto/widgets/widgets.pro
+++ b/tests/auto/widgets/widgets.pro
@@ -14,7 +14,7 @@ SUBDIRS += \
proxypac \
schemes \
shutdown \
- qwebenginedownloaditem \
+ qwebenginedownloadrequest \
qwebenginepage \
qwebenginehistory \
qwebengineprofile \
@@ -22,6 +22,9 @@ SUBDIRS += \
qwebenginesettings \
qwebengineview
+# Synthetic touch events are not supported on macOS
+!macos: SUBDIRS += touchinput
+
qtConfig(accessibility) {
SUBDIRS += accessibility
}
@@ -48,4 +51,4 @@ boot2qt: SUBDIRS -= accessibility defaultsurfaceformat devtools \
qwebengineprofile \
qwebengineview
-win32: SUBDIRS -= offscreen
+darwin|win32: SUBDIRS -= offscreen
diff --git a/tests/manual/quick/quick.pro b/tests/manual/quick/quick.pro
index 5251c4b42..8522763f8 100644
--- a/tests/manual/quick/quick.pro
+++ b/tests/manual/quick/quick.pro
@@ -1,4 +1,5 @@
TEMPLATE = subdirs
SUBDIRS += \
- faviconbrowser
+ faviconbrowser \
+ touchbrowser
diff --git a/tests/manual/quick/touchbrowser/AddressBar.qml b/tests/manual/quick/touchbrowser/AddressBar.qml
new file mode 100644
index 000000000..1daae6dbf
--- /dev/null
+++ b/tests/manual/quick/touchbrowser/AddressBar.qml
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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$
+**
+****************************************************************************/
+
+import QtQuick 2.5
+import QtQuick.Controls 1.4
+import QtQuick.Controls.Styles 1.4
+
+Rectangle {
+ id: root
+
+ property int progress: 0
+ property url iconUrl: ""
+ property url pageUrl: ""
+
+ signal accepted(url addressUrl)
+
+ clip: true
+
+ onActiveFocusChanged: {
+ if (activeFocus)
+ addressField.forceActiveFocus();
+ }
+
+ Rectangle {
+ width: addressField.width / 100 * root.progress
+ height: root.height
+
+ visible: root.progress < 100
+
+ color: "#b6dca6"
+ radius: root.radius
+ }
+
+ TextField {
+ id: addressField
+ anchors.fill: parent
+
+ Image {
+ anchors.verticalCenter: addressField.verticalCenter
+ x: 5; z: parent.z + 1
+ width: 16; height: 16
+ sourceSize: Qt.size(width, height)
+ source: root.iconUrl
+ visible: root.progress == 100
+ }
+
+ Text {
+ text: root.progress < 0 ? "" : root.progress + "%"
+ x: 5; z: parent.z + 1
+ font.bold: true
+ anchors.verticalCenter: parent.verticalCenter
+
+ visible: root.progress < 100
+ }
+
+ style: TextFieldStyle {
+ padding.left: 30
+
+ background: Rectangle {
+ color: "transparent"
+ border.color: "black"
+ border.width: 1
+ radius: root.radius
+ }
+ }
+
+ onActiveFocusChanged: {
+ if (activeFocus)
+ selectAll();
+ else
+ deselect();
+ }
+
+ text: root.pageUrl
+ onAccepted: root.accepted(utils.fromUserInput(text))
+ }
+}
diff --git a/tests/manual/quick/touchbrowser/main.cpp b/tests/manual/quick/touchbrowser/main.cpp
new file mode 100644
index 000000000..5808fe167
--- /dev/null
+++ b/tests/manual/quick/touchbrowser/main.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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$
+**
+****************************************************************************/
+
+#if defined(DESKTOP_BUILD)
+#include "touchmockingapplication.h"
+#endif
+#include "utils.h"
+
+#include <QtGui/QGuiApplication>
+#include <QtQml/QQmlApplicationEngine>
+#include <QtQml/QQmlContext>
+#include <QtQuick/QQuickView>
+#include <QtWebEngine/qtwebengineglobal.h>
+
+static QUrl startupUrl()
+{
+ QUrl ret;
+ QStringList args(qApp->arguments());
+ args.takeFirst();
+ for (const QString &arg : qAsConst(args)) {
+ if (arg.startsWith(QLatin1Char('-')))
+ continue;
+ ret = Utils::fromUserInput(arg);
+ if (ret.isValid())
+ return ret;
+ }
+ return QUrl(QStringLiteral("https://www.qt.io/"));
+}
+
+int main(int argc, char **argv)
+{
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
+
+ // We use touch mocking on desktop and apply all the mobile switches.
+ QByteArrayList args = QByteArrayList()
+ << QByteArrayLiteral("--enable-embedded-switches")
+ << QByteArrayLiteral("--log-level=0");
+ const int count = args.size() + argc;
+ QList<char*> qargv(count);
+
+ qargv[0] = argv[0];
+ for (int i = 0; i < args.size(); ++i)
+ qargv[i + 1] = args[i].data();
+ for (int i = args.size() + 1; i < count; ++i)
+ qargv[i] = argv[i - args.size()];
+
+ int qAppArgCount = qargv.size();
+
+ QtWebEngine::initialize();
+
+#if defined(DESKTOP_BUILD)
+ TouchMockingApplication app(qAppArgCount, qargv.data());
+#else
+ QGuiApplication app(qAppArgCount, qargv.data());
+#endif
+
+ QQuickView view;
+ Utils utils;
+ view.rootContext()->setContextProperty("utils", &utils);
+
+ view.setTitle("Touch Browser");
+ view.setFlags(Qt::Window | Qt::WindowTitleHint);
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl("qrc:/main.qml"));
+
+ QObject::connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));
+
+ view.show();
+ if (view.size().isEmpty())
+ view.setGeometry(0, 0, 800, 600);
+ QMetaObject::invokeMethod(reinterpret_cast<QObject *>(view.rootObject()), "load", Q_ARG(QVariant, startupUrl()));
+
+ return app.exec();
+}
diff --git a/tests/manual/quick/touchbrowser/main.qml b/tests/manual/quick/touchbrowser/main.qml
new file mode 100644
index 000000000..926b3a941
--- /dev/null
+++ b/tests/manual/quick/touchbrowser/main.qml
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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$
+**
+****************************************************************************/
+
+import QtQuick 2.5
+import QtQuick.Layouts 1.3
+import QtWebEngine 1.3
+
+Item {
+ function load(url) {
+ webEngineView.url = url;
+ }
+
+ ColumnLayout {
+ anchors.fill: parent
+
+ AddressBar {
+ id: addressBar
+
+ Layout.fillWidth: true
+ Layout.margins: 5
+ height: 25
+
+ color: "white"
+ radius: 4
+
+ progress: webEngineView && webEngineView.loadProgress
+ iconUrl: webEngineView && webEngineView.icon
+ pageUrl: webEngineView && webEngineView.url
+
+ onAccepted: webEngineView.url = addressUrl
+ }
+
+ WebEngineView {
+ id: webEngineView
+
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ }
+}
diff --git a/tests/manual/quick/touchbrowser/qml.qrc b/tests/manual/quick/touchbrowser/qml.qrc
new file mode 100644
index 000000000..45210fe36
--- /dev/null
+++ b/tests/manual/quick/touchbrowser/qml.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>AddressBar.qml</file>
+ </qresource>
+</RCC>
diff --git a/tests/manual/quick/touchbrowser/touchbrowser.pro b/tests/manual/quick/touchbrowser/touchbrowser.pro
new file mode 100644
index 000000000..21e3d6f68
--- /dev/null
+++ b/tests/manual/quick/touchbrowser/touchbrowser.pro
@@ -0,0 +1,19 @@
+TEMPLATE = app
+
+QT += quick webengine
+CONFIG += c++11
+
+SOURCES += \
+ main.cpp
+
+HEADERS += \
+ utils.h
+
+RESOURCES += qml.qrc
+
+!cross_compile {
+ DEFINES += DESKTOP_BUILD
+ SOURCES += touchmockingapplication.cpp
+ HEADERS += touchmockingapplication.h
+ QT += gui-private
+}
diff --git a/tests/manual/quick/touchbrowser/touchmockingapplication.cpp b/tests/manual/quick/touchbrowser/touchmockingapplication.cpp
new file mode 100644
index 000000000..41b731a6a
--- /dev/null
+++ b/tests/manual/quick/touchbrowser/touchmockingapplication.cpp
@@ -0,0 +1,287 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 "touchmockingapplication.h"
+
+#include <qpa/qwindowsysteminterface.h>
+#include <QtCore/QEvent>
+#include <QtGui/QMouseEvent>
+#include <QtGui/QTouchDevice>
+#include <QtGui/QTouchEvent>
+#include <QtQuick/QQuickItem>
+#include <QtQuick/QQuickView>
+
+static inline bool isTouchEvent(const QEvent* event)
+{
+ switch (event->type()) {
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static inline bool isMouseEvent(const QEvent* event)
+{
+ switch (event->type()) {
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseMove:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseButtonDblClick:
+ return true;
+ default:
+ return false;
+ }
+}
+
+TouchMockingApplication::TouchMockingApplication(int& argc, char** argv)
+ : QGuiApplication(argc, argv)
+ , m_realTouchEventReceived(false)
+ , m_pendingFakeTouchEventCount(0)
+ , m_holdingControl(false)
+{
+}
+
+bool TouchMockingApplication::notify(QObject* target, QEvent* event)
+{
+ // We try to be smart, if we received real touch event, we are probably on a device
+ // with touch screen, and we should not have touch mocking.
+
+ if (!event->spontaneous() || m_realTouchEventReceived)
+ return QGuiApplication::notify(target, event);
+
+ if (isTouchEvent(event)) {
+ if (m_pendingFakeTouchEventCount)
+ --m_pendingFakeTouchEventCount;
+ else
+ m_realTouchEventReceived = true;
+ return QGuiApplication::notify(target, event);
+ }
+
+ QQuickView* window = qobject_cast<QQuickView*>(target);
+ if (!window)
+ return QGuiApplication::notify(target, event);
+
+ m_holdingControl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
+
+ if (event->type() == QEvent::KeyRelease && static_cast<QKeyEvent*>(event)->key() == Qt::Key_Control) {
+ foreach (int id, m_heldTouchPoints)
+ if (m_touchPoints.contains(id) && !QGuiApplication::mouseButtons().testFlag(Qt::MouseButton(id))) {
+ m_touchPoints[id].setState(Qt::TouchPointReleased);
+ m_heldTouchPoints.remove(id);
+ } else
+ m_touchPoints[id].setState(Qt::TouchPointStationary);
+
+ sendTouchEvent(window, m_heldTouchPoints.isEmpty() ? QEvent::TouchEnd : QEvent::TouchUpdate, static_cast<QKeyEvent*>(event)->timestamp());
+ }
+
+ if (isMouseEvent(event)) {
+ const QMouseEvent* const mouseEvent = static_cast<QMouseEvent*>(event);
+
+ QTouchEvent::TouchPoint touchPoint;
+ touchPoint.setPressure(1);
+
+ QEvent::Type touchType = QEvent::None;
+
+ switch (mouseEvent->type()) {
+ case QEvent::MouseButtonPress:
+ touchPoint.setId(mouseEvent->button());
+ if (m_touchPoints.contains(touchPoint.id())) {
+ touchPoint.setState(Qt::TouchPointMoved);
+ touchType = QEvent::TouchUpdate;
+ } else {
+ touchPoint.setState(Qt::TouchPointPressed);
+ // Check if more buttons are held down than just the event triggering one.
+ if (mouseEvent->buttons() > mouseEvent->button())
+ touchType = QEvent::TouchUpdate;
+ else
+ touchType = QEvent::TouchBegin;
+ }
+ break;
+ case QEvent::MouseMove:
+ if (!mouseEvent->buttons()) {
+ // We have to swallow the event instead of propagating it,
+ // since we avoid sending the mouse release events and if the
+ // Flickable is the mouse grabber it would receive the event
+ // and would move the content.
+ event->accept();
+ return true;
+ }
+ touchType = QEvent::TouchUpdate;
+ touchPoint.setId(mouseEvent->buttons());
+ touchPoint.setState(Qt::TouchPointMoved);
+ break;
+ case QEvent::MouseButtonRelease:
+ // Check if any buttons are still held down after this event.
+ if (mouseEvent->buttons())
+ touchType = QEvent::TouchUpdate;
+ else
+ touchType = QEvent::TouchEnd;
+ touchPoint.setId(mouseEvent->button());
+ touchPoint.setState(Qt::TouchPointReleased);
+ break;
+ case QEvent::MouseButtonDblClick:
+ // Eat double-clicks, their accompanying press event is all we need.
+ event->accept();
+ return true;
+ default:
+ Q_ASSERT_X(false, "multi-touch mocking", "unhandled event type");
+ }
+
+ // A move can have resulted in multiple buttons, so we need check them individually.
+ if (touchPoint.id() & Qt::LeftButton)
+ updateTouchPoint(mouseEvent, touchPoint, Qt::LeftButton);
+ if (touchPoint.id() & Qt::MiddleButton)
+ updateTouchPoint(mouseEvent, touchPoint, Qt::MiddleButton);
+ if (touchPoint.id() & Qt::RightButton)
+ updateTouchPoint(mouseEvent, touchPoint, Qt::RightButton);
+
+ if (m_holdingControl && touchPoint.state() == Qt::TouchPointReleased) {
+ // We avoid sending the release event because the Flickable is
+ // listening to mouse events and would start a bounce-back
+ // animation if it received a mouse release.
+ event->accept();
+ return true;
+ }
+
+ // Update states for all other touch-points
+ for (QHash<int, QTouchEvent::TouchPoint>::iterator it = m_touchPoints.begin(), end = m_touchPoints.end(); it != end; ++it) {
+ if (!(it.value().id() & touchPoint.id()))
+ it.value().setState(Qt::TouchPointStationary);
+ }
+
+ Q_ASSERT(touchType != QEvent::None);
+
+ if (!sendTouchEvent(window, touchType, mouseEvent->timestamp()))
+ return QGuiApplication::notify(target, event);
+
+ event->accept();
+ return true;
+ }
+
+ return QGuiApplication::notify(target, event);
+}
+
+void TouchMockingApplication::updateTouchPoint(const QMouseEvent* mouseEvent, QTouchEvent::TouchPoint touchPoint, Qt::MouseButton mouseButton)
+{
+ // Ignore inserting additional touch points if Ctrl isn't held because it produces
+ // inconsistent touch events and results in assers in the gesture recognizers.
+ if (!m_holdingControl && m_touchPoints.size() && !m_touchPoints.contains(mouseButton))
+ return;
+
+ if (m_holdingControl && touchPoint.state() == Qt::TouchPointReleased) {
+ m_heldTouchPoints.insert(mouseButton);
+ return;
+ }
+
+ // Gesture recognition uses the screen position for the initial threshold
+ // but since the canvas translates touch events we actually need to pass
+ // the screen position as the scene position to deliver the appropriate
+ // coordinates to the target.
+ touchPoint.setPos(mouseEvent->localPos());
+ touchPoint.setScenePos(mouseEvent->screenPos());
+
+ if (touchPoint.state() == Qt::TouchPointPressed)
+ touchPoint.setStartScenePos(mouseEvent->screenPos());
+ else {
+ const QTouchEvent::TouchPoint& oldTouchPoint = m_touchPoints[mouseButton];
+ touchPoint.setStartScenePos(oldTouchPoint.startScenePos());
+ touchPoint.setLastPos(oldTouchPoint.pos());
+ touchPoint.setLastScenePos(oldTouchPoint.scenePos());
+ }
+
+ // Update current touch-point.
+ touchPoint.setId(mouseButton);
+ m_touchPoints.insert(mouseButton, touchPoint);
+}
+
+bool TouchMockingApplication::sendTouchEvent(QQuickView* window, QEvent::Type type, ulong timestamp)
+{
+ static QTouchDevice* device = 0;
+ if (!device) {
+ device = new QTouchDevice;
+ device->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(device);
+ }
+
+ m_pendingFakeTouchEventCount++;
+
+ const QList<QTouchEvent::TouchPoint>& currentTouchPoints = m_touchPoints.values();
+ Qt::TouchPointStates touchPointStates = Qt::TouchPointState();
+ foreach (const QTouchEvent::TouchPoint& touchPoint, currentTouchPoints)
+ touchPointStates |= touchPoint.state();
+
+ QTouchEvent event(type, device, Qt::NoModifier, touchPointStates, currentTouchPoints);
+ event.setTimestamp(timestamp);
+ event.setAccepted(false);
+
+ QGuiApplication::notify(window, &event);
+
+ updateVisualMockTouchPoints(window,m_holdingControl ? currentTouchPoints : QList<QTouchEvent::TouchPoint>());
+
+ // Get rid of touch-points that are no longer valid
+ foreach (const QTouchEvent::TouchPoint& touchPoint, currentTouchPoints) {
+ if (touchPoint.state() == Qt::TouchPointReleased)
+ m_touchPoints.remove(touchPoint.id());
+ }
+
+ return event.isAccepted();
+}
+
+void TouchMockingApplication::updateVisualMockTouchPoints(QQuickView* window,const QList<QTouchEvent::TouchPoint>& touchPoints)
+{
+ if (touchPoints.isEmpty()) {
+ // Hide all touch indicator items.
+ foreach (QQuickItem* item, m_activeMockComponents.values())
+ item->setProperty("pressed", false);
+
+ return;
+ }
+
+ foreach (const QTouchEvent::TouchPoint& touchPoint, touchPoints) {
+ QQuickItem* mockTouchPointItem = m_activeMockComponents.value(touchPoint.id());
+
+ if (!mockTouchPointItem) {
+ QQmlComponent touchMockPointComponent(window->engine(), QUrl("qrc:///qml/MockTouchPoint.qml"));
+ mockTouchPointItem = qobject_cast<QQuickItem*>(touchMockPointComponent.create());
+ Q_ASSERT(mockTouchPointItem);
+ m_activeMockComponents.insert(touchPoint.id(), mockTouchPointItem);
+ mockTouchPointItem->setProperty("pointId", QVariant(touchPoint.id()));
+ mockTouchPointItem->setParent(window->rootObject());
+ mockTouchPointItem->setParentItem(window->rootObject());
+ }
+
+ mockTouchPointItem->setX(touchPoint.pos().x());
+ mockTouchPointItem->setY(touchPoint.pos().y());
+ mockTouchPointItem->setWidth(touchPoint.ellipseDiameters().width());
+ mockTouchPointItem->setHeight(touchPoint.ellipseDiameters().height());
+ mockTouchPointItem->setProperty("pressed", QVariant(touchPoint.state() != Qt::TouchPointReleased));
+ }
+}
diff --git a/tests/manual/quick/touchbrowser/touchmockingapplication.h b/tests/manual/quick/touchbrowser/touchmockingapplication.h
new file mode 100644
index 000000000..cdabe871f
--- /dev/null
+++ b/tests/manual/quick/touchbrowser/touchmockingapplication.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 TOUCHMOCKINGAPPLICATION_H
+#define TOUCHMOCKINGAPPLICATION_H
+
+#include <QtCore/QHash>
+#include <QtCore/QSet>
+#include <QtCore/QUrl>
+#include <QtGui/QGuiApplication>
+#include <QtGui/QTouchEvent>
+
+QT_BEGIN_NAMESPACE
+class QQuickView;
+class QQuickItem;
+QT_END_NAMESPACE
+
+class TouchMockingApplication : public QGuiApplication
+{
+ Q_OBJECT
+
+public:
+ TouchMockingApplication(int &argc, char **argv);
+
+ virtual bool notify(QObject *, QEvent *) override;
+
+private:
+ void updateTouchPoint(const QMouseEvent *, QTouchEvent::TouchPoint, Qt::MouseButton);
+ bool sendTouchEvent(QQuickView *, QEvent::Type, ulong timestamp);
+ void updateVisualMockTouchPoints(QQuickView *,const QList<QTouchEvent::TouchPoint> &touchPoints);
+
+private:
+ bool m_realTouchEventReceived;
+ int m_pendingFakeTouchEventCount;
+
+ QPointF m_lastPos;
+ QPointF m_lastScreenPos;
+ QPointF m_startScreenPos;
+
+ QHash<int, QTouchEvent::TouchPoint> m_touchPoints;
+ QSet<int> m_heldTouchPoints;
+ QHash<int, QQuickItem*> m_activeMockComponents;
+
+ bool m_holdingControl;
+};
+
+#endif // TOUCHMOCKINGAPPLICATION_H
diff --git a/tests/manual/quick/touchbrowser/utils.h b/tests/manual/quick/touchbrowser/utils.h
new file mode 100644
index 000000000..b7aeefce0
--- /dev/null
+++ b/tests/manual/quick/touchbrowser/utils.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 UTILS_H
+#define UTILS_H
+
+#include <QtCore/QFileInfo>
+#include <QtCore/QUrl>
+
+class Utils : public QObject {
+ Q_OBJECT
+public:
+ Q_INVOKABLE static QUrl fromUserInput(const QString& userInput);
+};
+
+inline QUrl Utils::fromUserInput(const QString& userInput)
+{
+ QFileInfo fileInfo(userInput);
+ if (fileInfo.exists())
+ return QUrl::fromLocalFile(fileInfo.absoluteFilePath());
+ return QUrl::fromUserInput(userInput);
+}
+
+#endif // UTILS_H
diff --git a/tests/manual/widgets/inputmethods/colorpicker.cpp b/tests/manual/widgets/inputmethods/colorpicker.cpp
index f279eb418..ee2e2e43f 100644
--- a/tests/manual/widgets/inputmethods/colorpicker.cpp
+++ b/tests/manual/widgets/inputmethods/colorpicker.cpp
@@ -41,7 +41,6 @@ ColorPicker::ColorPicker(QWidget *parent)
m_chooseButton->setText(tr("Choose"));
QHBoxLayout *layout = new QHBoxLayout;
- layout->setMargin(0);
layout->addWidget(m_colorInput);
layout->addWidget(m_chooseButton);
setLayout(layout);