diff options
Diffstat (limited to 'tests/auto/quick')
21 files changed, 390 insertions, 51 deletions
diff --git a/tests/auto/quick/dialogs/dialogs.pro b/tests/auto/quick/dialogs/dialogs.pro index e262c3814..29d509b20 100644 --- a/tests/auto/quick/dialogs/dialogs.pro +++ b/tests/auto/quick/dialogs/dialogs.pro @@ -1,5 +1,5 @@ include(../tests.pri) -QT += webengine webengine-private +QT += core-private webengine webengine-private HEADERS += \ server.h \ diff --git a/tests/auto/quick/dialogs/server.cpp b/tests/auto/quick/dialogs/server.cpp index dc9cfe582..dfc7c97ad 100644 --- a/tests/auto/quick/dialogs/server.cpp +++ b/tests/auto/quick/dialogs/server.cpp @@ -33,7 +33,6 @@ Server::Server(QObject *parent) : QObject(parent) { - m_data.clear(); connect(&m_server, &QTcpServer::newConnection, this, &Server::handleNewConnection); } @@ -42,6 +41,11 @@ bool Server::isListening() return m_server.isListening(); } +void Server::setReply(const QByteArray &reply) +{ + m_reply = reply; +} + void Server::run() { if (!m_server.listen(QHostAddress::LocalHost, 5555)) @@ -69,12 +73,7 @@ void Server::handleReadReady() if (!m_data.endsWith("\r\n\r\n")) return; - if (m_data.contains(QByteArrayLiteral("OPEN_AUTH"))) - socket->write("HTTP/1.1 401 Unauthorized\nWWW-Authenticate: " - "Basic realm=\"Very Restricted Area\"\r\n\r\n"); - if (m_data.contains(QByteArrayLiteral("OPEN_PROXY"))) - socket->write("HTTP/1.1 407 Proxy Auth Required\nProxy-Authenticate: " - "Basic realm=\"Proxy requires authentication\"\r\n\r\n"); + socket->write(m_reply); m_data.clear(); socket->disconnectFromHost(); } diff --git a/tests/auto/quick/dialogs/server.h b/tests/auto/quick/dialogs/server.h index 24da47523..fa9a73811 100644 --- a/tests/auto/quick/dialogs/server.h +++ b/tests/auto/quick/dialogs/server.h @@ -40,6 +40,7 @@ public: explicit Server(QObject *parent = nullptr); bool isListening(); + void setReply(const QByteArray &reply); public slots: void run(); @@ -50,6 +51,7 @@ private slots: private: QByteArray m_data; + QByteArray m_reply; QTcpServer m_server; }; diff --git a/tests/auto/quick/dialogs/tst_dialogs.cpp b/tests/auto/quick/dialogs/tst_dialogs.cpp index f3a041b62..eee6b2bb6 100644 --- a/tests/auto/quick/dialogs/tst_dialogs.cpp +++ b/tests/auto/quick/dialogs/tst_dialogs.cpp @@ -26,7 +26,6 @@ ** ****************************************************************************/ -#include "qtwebengineglobal.h" #include "testhandler.h" #include "server.h" #include <QtWebEngine/private/qquickwebenginedialogrequests_p.h> @@ -146,12 +145,19 @@ void tst_Dialogs::authenticationDialogRequested_data() QTest::addColumn<QUrl>("url"); QTest::addColumn<QQuickWebEngineAuthenticationDialogRequest::AuthenticationType>("type"); QTest::addColumn<QString>("realm"); - QTest::newRow("Http Authentication Dialog") << QUrl("http://localhost:5555/OPEN_AUTH") + QTest::addColumn<QByteArray>("reply"); + QTest::newRow("Http Authentication Dialog") << QUrl("http://localhost:5555/") << QQuickWebEngineAuthenticationDialogRequest::AuthenticationTypeHTTP - << QStringLiteral("Very Restricted Area"); - QTest::newRow("Proxy Authentication Dialog") << QUrl("http://localhost.:5555/OPEN_PROXY") + << QStringLiteral("Very Restricted Area") + << QByteArrayLiteral("HTTP/1.1 401 Unauthorized\nWWW-Authenticate: " + "Basic realm=\"Very Restricted Area\"\r\n\r\n"); + QTest::newRow("Proxy Authentication Dialog")<< QUrl("http://qt.io/") << QQuickWebEngineAuthenticationDialogRequest::AuthenticationTypeProxy - << QStringLiteral("Proxy requires authentication"); + << QStringLiteral("Proxy requires authentication") + << QByteArrayLiteral("HTTP/1.1 407 Proxy Auth Required\nProxy-Authenticate: " + "Basic realm=\"Proxy requires authentication\"\r\n" + "content-length: 0\r\n\r\n"); + } void tst_Dialogs::authenticationDialogRequested() @@ -160,7 +166,9 @@ void tst_Dialogs::authenticationDialogRequested() QFETCH(QQuickWebEngineAuthenticationDialogRequest::AuthenticationType, type); QFETCH(QString, realm); + QFETCH(QByteArray, reply); Server server; + server.setReply(reply); server.run(); QTRY_VERIFY2(server.isListening(), "Could not setup authentication server"); diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp index 59973f7d0..90b768ac7 100644 --- a/tests/auto/quick/publicapi/tst_publicapi.cpp +++ b/tests/auto/quick/publicapi/tst_publicapi.cpp @@ -35,11 +35,13 @@ #include <QtTest/QtTest> #include <QtWebEngine/QQuickWebEngineProfile> #include <QtWebEngine/QQuickWebEngineScript> +#include <QtWebEngineCore/QWebEngineNotification> #include <QtWebEngineCore/QWebEngineQuotaRequest> #include <QtWebEngineCore/QWebEngineRegisterProtocolHandlerRequest> #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> @@ -60,6 +62,8 @@ static const QList<const QMetaObject *> typesToCheck = QList<const QMetaObject * << &QQuickWebEngineView::staticMetaObject << &QQuickWebEngineAction::staticMetaObject << &QQuickWebEngineCertificateError::staticMetaObject + << &QQuickWebEngineClientCertificateOption::staticMetaObject + << &QQuickWebEngineClientCertificateSelection::staticMetaObject << &QQuickWebEngineDownloadItem::staticMetaObject << &QQuickWebEngineHistory::staticMetaObject << &QQuickWebEngineHistoryListModel::staticMetaObject @@ -79,6 +83,7 @@ static const QList<const QMetaObject *> typesToCheck = QList<const QMetaObject * << &QQuickWebEngineContextMenuRequest::staticMetaObject << &QWebEngineQuotaRequest::staticMetaObject << &QWebEngineRegisterProtocolHandlerRequest::staticMetaObject + << &QWebEngineNotification::staticMetaObject ; static QList<const char *> knownEnumNames = QList<const char *>(); @@ -86,12 +91,15 @@ static QList<const char *> knownEnumNames = QList<const char *>(); static const QStringList hardcodedTypes = QStringList() << "QJSValue" << "QQmlListProperty<QQuickWebEngineScript>" + << "QQmlListProperty<QQuickWebEngineClientCertificateOption>" + << "const QQuickWebEngineClientCertificateOption*" << "QQmlWebChannel*" // Ignore the testSupport types without making a fuss. << "QQuickWebEngineTestSupport*" << "QQuickWebEngineErrorPage*" << "const QQuickWebEngineContextMenuData*" << "QWebEngineCookieStore*" + << "Qt::LayoutDirection" ; static const QStringList expectedAPI = QStringList() @@ -132,6 +140,17 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineCertificateError.overridable --> bool" << "QQuickWebEngineCertificateError.rejectCertificate() --> void" << "QQuickWebEngineCertificateError.url --> QUrl" + << "QQuickWebEngineClientCertificateOption.issuer --> QString" + << "QQuickWebEngineClientCertificateOption.subject --> QString" + << "QQuickWebEngineClientCertificateOption.effectiveDate --> QDateTime" + << "QQuickWebEngineClientCertificateOption.expiryDate --> QDateTime" + << "QQuickWebEngineClientCertificateOption.isSelfSigned --> bool" + << "QQuickWebEngineClientCertificateOption.select() --> void" + << "QQuickWebEngineClientCertificateSelection.host --> QUrl" + << "QQuickWebEngineClientCertificateSelection.certificates --> QQmlListProperty<QQuickWebEngineClientCertificateOption>" + << "QQuickWebEngineClientCertificateSelection.select(int) --> void" + << "QQuickWebEngineClientCertificateSelection.select(const QQuickWebEngineClientCertificateOption*) --> void" + << "QQuickWebEngineClientCertificateSelection.selectNone() --> void" << "QQuickWebEngineColorDialogRequest.accepted --> bool" << "QQuickWebEngineColorDialogRequest.color --> QColor" << "QQuickWebEngineContextMenuRequest.CanUndo --> EditFlags" @@ -303,6 +322,9 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineProfile.clearHttpCache() --> void" << "QQuickWebEngineProfile.downloadFinished(QQuickWebEngineDownloadItem*) --> void" << "QQuickWebEngineProfile.downloadRequested(QQuickWebEngineDownloadItem*) --> void" + << "QQuickWebEngineProfile.downloadPath --> QString" + << "QQuickWebEngineProfile.downloadPathChanged() --> void" + << "QQuickWebEngineProfile.presentNotification(QWebEngineNotification*) --> void" << "QQuickWebEngineProfile.httpAcceptLanguage --> QString" << "QQuickWebEngineProfile.httpAcceptLanguageChanged() --> void" << "QQuickWebEngineProfile.httpCacheMaximumSize --> int" @@ -323,6 +345,8 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineProfile.spellCheckLanguagesChanged() --> void" << "QQuickWebEngineProfile.storageName --> QString" << "QQuickWebEngineProfile.storageNameChanged() --> void" + << "QQuickWebEngineProfile.useForGlobalCertificateVerification --> bool" + << "QQuickWebEngineProfile.useForGlobalCertificateVerificationChanged() --> void" << "QQuickWebEngineProfile.userScripts --> QQmlListProperty<QQuickWebEngineScript>" << "QQuickWebEngineScript.ApplicationWorld --> ScriptWorldId" << "QQuickWebEngineScript.Deferred --> InjectionPoint" @@ -392,6 +416,8 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineSettings.localContentCanAccessRemoteUrlsChanged() --> void" << "QQuickWebEngineSettings.localStorageEnabled --> bool" << "QQuickWebEngineSettings.localStorageEnabledChanged() --> void" + << "QQuickWebEngineSettings.pdfViewerEnabled --> bool" + << "QQuickWebEngineSettings.pdfViewerEnabledChanged() --> void" << "QQuickWebEngineSettings.playbackRequiresUserGesture --> bool" << "QQuickWebEngineSettings.playbackRequiresUserGestureChanged() --> void" << "QQuickWebEngineSettings.pluginsEnabled --> bool" @@ -585,6 +611,7 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineView.NewViewInTab --> NewViewDestination" << "QQuickWebEngineView.NewViewInWindow --> NewViewDestination" << "QQuickWebEngineView.NoErrorDomain --> ErrorDomain" + << "QQuickWebEngineView.Notifications --> Feature" << "QQuickWebEngineView.NoWebAction --> WebAction" << "QQuickWebEngineView.NormalTerminationStatus --> RenderProcessTerminationStatus" << "QQuickWebEngineView.Note --> PrintedPageSizeId" @@ -699,6 +726,7 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineView.runJavaScript(QString,uint,QJSValue) --> void" << "QQuickWebEngineView.scrollPosition --> QPointF" << "QQuickWebEngineView.scrollPositionChanged(QPointF) --> void" + << "QQuickWebEngineView.selectClientCertificate(QQuickWebEngineClientCertificateSelection*) --> void" << "QQuickWebEngineView.setActiveFocusOnPress(bool) --> void" << "QQuickWebEngineView.settings --> QQuickWebEngineSettings*" << "QQuickWebEngineView.stop() --> void" @@ -727,6 +755,16 @@ static const QStringList expectedAPI = QStringList() << "QWebEngineRegisterProtocolHandlerRequest.origin --> QUrl" << "QWebEngineRegisterProtocolHandlerRequest.reject() --> void" << "QWebEngineRegisterProtocolHandlerRequest.scheme --> QString" + << "QWebEngineNotification.origin --> QUrl" + << "QWebEngineNotification.title --> QString" + << "QWebEngineNotification.message --> QString" + << "QWebEngineNotification.tag --> QString" + << "QWebEngineNotification.language --> QString" + << "QWebEngineNotification.direction --> Qt::LayoutDirection" + << "QWebEngineNotification.show() --> void" + << "QWebEngineNotification.click() --> void" + << "QWebEngineNotification.close() --> void" + << "QWebEngineNotification.closed() --> void" ; static bool isCheckedEnum(const QByteArray &typeName) diff --git a/tests/auto/quick/qmltests/BLACKLIST b/tests/auto/quick/qmltests/BLACKLIST index dfafbaea4..957911c3b 100644 --- a/tests/auto/quick/qmltests/BLACKLIST +++ b/tests/auto/quick/qmltests/BLACKLIST @@ -4,15 +4,6 @@ osx [WebViewGeopermission::test_geoPermissionRequest] osx -[WebEngineViewSingleFileUpload::test_acceptDirectory] -* - -[WebEngineViewSingleFileUpload::test_acceptMultipleFilesSelection] -* - -[WebEngineViewSingleFileUpload::test_acceptSingleFileSelection] -* - [WebViewFindText::test_findTextInterruptedByLoad] * diff --git a/tests/auto/quick/qmltests/data/multifileupload.html b/tests/auto/quick/qmltests/data/multifileupload.html index 1f788a377..d41ea15c0 100644 --- a/tests/auto/quick/qmltests/data/multifileupload.html +++ b/tests/auto/quick/qmltests/data/multifileupload.html @@ -1,7 +1,7 @@ <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> -<title> Mutli-file Upload </title> +<title> Failed to Upload </title> <script src = "./titleupdate.js"> </script> </head> diff --git a/tests/auto/quick/qmltests/data/singlefileupload.html b/tests/auto/quick/qmltests/data/singlefileupload.html index 6cfef7ade..ac91c2c0d 100644 --- a/tests/auto/quick/qmltests/data/singlefileupload.html +++ b/tests/auto/quick/qmltests/data/singlefileupload.html @@ -1,7 +1,7 @@ <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> -<title> Single File Upload </title> +<title> Failed to Upload </title> <script src = "./titleupdate.js"> </script> </head> diff --git a/tests/auto/quick/qmltests/data/tst_download.qml b/tests/auto/quick/qmltests/data/tst_download.qml index 019ebd9dc..5eb704cce 100644 --- a/tests/auto/quick/qmltests/data/tst_download.qml +++ b/tests/auto/quick/qmltests/data/tst_download.qml @@ -28,7 +28,8 @@ import QtQuick 2.0 import QtTest 1.0 -import QtWebEngine 1.5 +import QtWebEngine 1.9 +import Qt.labs.platform 1.0 TestWebEngineView { id: webEngineView @@ -42,6 +43,12 @@ TestWebEngineView { property var downloadState: [] property var downloadInterruptReason: null + function urlToPath(url) { + var path = url.toString() + path = path.replace(/^(file:\/{2})/,"") + return path + } + SignalSpy { id: downLoadRequestedSpy target: testDownloadProfile @@ -135,5 +142,16 @@ TestWebEngineView { tryCompare(downloadState, "1", WebEngineDownloadItem.DownloadCancelled) tryCompare(webEngineView, "downloadInterruptReason", WebEngineDownloadItem.UserCanceled) } + + function test_downloadLocation() { + var tmpPath = urlToPath(StandardPaths.writableLocation(StandardPaths.TempLocation)); + var downloadPath = urlToPath(StandardPaths.writableLocation(StandardPaths.DownloadLocation)); + + testDownloadProfile.downloadPath = tmpPath; + compare(testDownloadProfile.downloadPath, tmpPath); + + testDownloadProfile.downloadPath = downloadPath; + compare(testDownloadProfile.downloadPath, downloadPath); + } } } diff --git a/tests/auto/quick/qmltests/data/tst_filePicker.qml b/tests/auto/quick/qmltests/data/tst_filePicker.qml index 655789bb3..2f813b966 100644 --- a/tests/auto/quick/qmltests/data/tst_filePicker.qml +++ b/tests/auto/quick/qmltests/data/tst_filePicker.qml @@ -70,16 +70,61 @@ TestWebEngineView { webEngineView.waitForLoadSucceeded() } - function test_acceptSingleFileSelection() { - webEngineView.url = Qt.resolvedUrl("singlefileupload.html") - verify(webEngineView.waitForLoadSucceeded()) + function test_acceptSingleFileSelection_data() { + return [ + { tag: "/test.txt)", input: "/test.txt", passDefaultDialog: false, passCustomDialog: true }, + { tag: "/tést.txt", input: "/tést.txt", passDefaultDialog: false, passCustomDialog: true }, + { tag: "file:///test.txt", input: "file:///test.txt", passDefaultDialog: true, passCustomDialog: false }, + { tag: "file:///tést.txt", input: "file:///tést.txt", passDefaultDialog: true, passCustomDialog: false }, + { tag: "file:///t%C3%A9st.txt", input: "file:///t%C3%A9st.txt", passDefaultDialog: true, passCustomDialog: false }, + { tag: "file://test.txt", input: "file://test.txt", passDefaultDialog: false, passCustomDialog: false }, + { tag: "file:/test.txt", input: "file:/test.txt", passDefaultDialog: true, passCustomDialog: false }, + { tag: "file:test//test.txt", input: "file:test//test.txt", passDefaultDialog: false, passCustomDialog: false }, + { tag: "http://test.txt", input: "http://test.txt", passDefaultDialog: false, passCustomDialog: false }, + { tag: "qrc:/test.txt", input: "qrc:/test.txt", passDefaultDialog: false, passCustomDialog: false }, + ]; + } - FilePickerParams.selectFiles = true - FilePickerParams.selectedFilesUrl.push(Qt.resolvedUrl("test1.html")) + function test_acceptSingleFileSelection(row) { + var expectedFileName; - keyPress(Qt.Key_Enter) // Focus is on the button. Open FileDialog. - tryCompare(FilePickerParams, "filePickerOpened", true) - tryCompare(webEngineView, "title", "test1.html") + // Default dialog (expects URL). + expectedFileName = "Failed to Upload"; + if (row.passDefaultDialog) + expectedFileName = row.input.slice(row.input.lastIndexOf('/') + 1); + + webEngineView.url = Qt.resolvedUrl("singlefileupload.html"); + verify(webEngineView.waitForLoadSucceeded()); + + FilePickerParams.selectFiles = true; + FilePickerParams.selectedFilesUrl.push(row.input); + + keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog. + tryCompare(FilePickerParams, "filePickerOpened", true); + tryCompare(webEngineView, "title", decodeURIComponent(expectedFileName)); + + + // Custom dialog (expects absolute path). + var finished = false; + + expectedFileName = "Failed to Upload"; + if (row.passCustomDialog) + expectedFileName = row.input.slice(row.input.lastIndexOf('/') + 1); + + function acceptedFileHandler(request) { + request.accepted = true; + request.dialogAccept(row.input); + finished = true; + } + + webEngineView.fileDialogRequested.connect(acceptedFileHandler); + webEngineView.url = Qt.resolvedUrl("singlefileupload.html"); + verify(webEngineView.waitForLoadSucceeded()); + + keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog. + tryVerify(function() { return finished; }); + tryCompare(webEngineView, "title", expectedFileName); + webEngineView.fileDialogRequested.disconnect(acceptedFileHandler); } function test_acceptMultipleFilesSelection() { @@ -102,9 +147,10 @@ TestWebEngineView { FilePickerParams.selectFiles = true FilePickerParams.selectedFilesUrl.push(Qt.resolvedUrl("../data")) - keyPress(Qt.Key_Enter) // Focus is on the button. Open FileDialog. + keyClick(Qt.Key_Enter) // Focus is on the button. Open FileDialog. tryCompare(FilePickerParams, "filePickerOpened", true) - tryCompare(webEngineView, "title", "data") + // Check that the title is a file list (eg. "test1.html,test2.html") + tryVerify(function() { return webEngineView.title.match("^([^,]+,)+[^,]+$"); }) } function test_reject() { @@ -116,5 +162,45 @@ TestWebEngineView { wait(100) compare(titleSpy.count, 0) } + + function test_acceptMultipleFilesWithCustomDialog_data() { + return [ + { tag: "path", input: ["/test1.txt", "/test2.txt"], expectedValueForDefaultDialog: "Failed to Upload", expectedValueForCustomDialog: "test1.txt,test2.txt" }, + { tag: "file", input: ["file:///test1.txt", "file:///test2.txt"], expectedValueForDefaultDialog: "test1.txt,test2.txt", expectedValueForCustomDialog: "Failed to Upload" }, + { tag: "mixed", input: ["file:///test1.txt", "/test2.txt"], expectedValueForDefaultDialog: "test1.txt", expectedValueForCustomDialog: "test2.txt" }, + ]; + } + + function test_acceptMultipleFilesWithCustomDialog(row) { + // Default dialog (expects URL). + webEngineView.url = Qt.resolvedUrl("multifileupload.html"); + verify(webEngineView.waitForLoadSucceeded()); + + FilePickerParams.selectFiles = true; + FilePickerParams.selectedFilesUrl = row.input; + + keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog. + tryCompare(FilePickerParams, "filePickerOpened", true); + tryCompare(webEngineView, "title", row.expectedValueForDefaultDialog); + + + // Custom dialog (expects absolute path). + var finished = false; + + function acceptedFileHandler(request) { + request.accepted = true; + request.dialogAccept(row.input); + finished = true; + } + + webEngineView.fileDialogRequested.connect(acceptedFileHandler); + webEngineView.url = Qt.resolvedUrl("multifileupload.html"); + verify(webEngineView.waitForLoadSucceeded()); + + keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog. + tryVerify(function() { return finished; }); + tryCompare(webEngineView, "title", row.expectedValueForCustomDialog); + webEngineView.fileDialogRequested.disconnect(acceptedFileHandler); + } } } diff --git a/tests/auto/quick/qmltests/data/tst_findText.qml b/tests/auto/quick/qmltests/data/tst_findText.qml index dfcfd586f..1ec574fae 100644 --- a/tests/auto/quick/qmltests/data/tst_findText.qml +++ b/tests/auto/quick/qmltests/data/tst_findText.qml @@ -116,7 +116,7 @@ TestWebEngineView { webEngineView.clear() webEngineView.findText("bla", findFlags, webEngineView.findTextCallback) - tryCompare(webEngineView, "matchCount", 100) + tryCompare(webEngineView, "matchCount", 100, 20000) verify(!findFailed) } @@ -172,7 +172,7 @@ TestWebEngineView { webEngineView.clear() webEngineView.findText("hello", findFlags, webEngineView.findTextCallback) - tryCompare(webEngineView, "matchCount", 0) + tryCompare(webEngineView, "matchCount", 0, 20000) verify(findFailed) runJavaScript("document.body.innerHTML = 'blahellobla'"); diff --git a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml index 4becbb620..a671c2ec7 100644 --- a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml +++ b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml @@ -98,7 +98,8 @@ TestWebEngineView { verify(dialog.webEngineView.waitForLoadSucceeded()); compare(dialog.webEngineView.url, ""); - compare(newViewRequest.requestedUrl, 'about:blank'); + // https://chromium-review.googlesource.com/c/chromium/src/+/1300395 + compare(newViewRequest.requestedUrl, 'about:blank#blocked'); newViewRequestedSpy.clear(); dialog.destroy(); @@ -129,8 +130,8 @@ TestWebEngineView { verify(webEngineView.waitForLoadSucceeded()); verifyElementHasFocus("popupButton"); keyPress(Qt.Key_Enter); - compare(newViewRequest.requestedUrl, url); tryCompare(newViewRequestedSpy, "count", 1); + compare(newViewRequest.requestedUrl, url); compare(newViewRequest.destination, WebEngineView.NewViewInDialog); verify(newViewRequest.userInitiated); diff --git a/tests/auto/quick/qmltests/data/tst_notification.qml b/tests/auto/quick/qmltests/data/tst_notification.qml new file mode 100644 index 000000000..773bf4a8e --- /dev/null +++ b/tests/auto/quick/qmltests/data/tst_notification.qml @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 +import QtTest 1.0 +import QtWebEngine 1.9 + +TestWebEngineView { + id: view + width: 320 + height: 320 + + property bool permissionRequested: false + property bool grantPermission: false + property url securityOrigin: '' + + signal consoleMessage(string message) + + SignalSpy { + id: spyRequest + target: view + signalName: 'featurePermissionRequested' + } + + onFeaturePermissionRequested: { + if (feature === WebEngineView.Notifications) { + view.permissionRequested = true + view.securityOrigin = securityOrigin + view.grantFeaturePermission(securityOrigin, feature, grantPermission) + } + } + + TestCase { + name: 'WebEngineNotification' + when: windowShown + + function resolverUrl(html) { + return Qt.resolvedUrl('../../../shared/data/' + html) + } + + function init() { + permissionRequested = false + spyRequest.clear() + } + + function test_request_data() { + return [ + { tag: 'grant', grant: true, permission: 'granted' }, + { tag: 'deny', grant: false, permission: 'denied' }, + ] + } + + function test_request(data) { + grantPermission = data.grant + + view.url = resolverUrl('notification.html') + verify(view.waitForLoadSucceeded()) + + view.runJavaScript('resetPermission()') + let result = {} + + view.runJavaScript('getPermission()', function (permission) { result.permission = permission }) + tryCompare(result, 'permission', 'default') + + view.runJavaScript('requestPermission()') + spyRequest.wait() + verify(permissionRequested) + compare(spyRequest.count, 1) + + view.runJavaScript('getPermission()', function (permission) { result.permission = permission }) + tryCompare(result, 'permission', data.permission) + } + + function test_notification() { + grantPermission = true + + view.url = resolverUrl('notification.html') + view.waitForLoadSucceeded() + + view.runJavaScript('requestPermission()') + spyRequest.wait() + verify(permissionRequested) + + let title = 'Title', message = 'Message', notification = null + view.profile.presentNotification.connect(function (n) { notification = n }) + + view.runJavaScript('sendNotification("' + title + '", "' + message + '")') + tryVerify(function () { return notification !== null }) + compare(notification.title, title) + compare(notification.message, message) + compare(notification.direction, Qt.RightToLeft) + compare(notification.origin, securityOrigin) + compare(notification.tag, 'tst') + compare(notification.language, 'de') + } + } +} diff --git a/tests/auto/quick/qmltests/data/tst_profile.qml b/tests/auto/quick/qmltests/data/tst_profile.qml new file mode 100644 index 000000000..ee7fa4e99 --- /dev/null +++ b/tests/auto/quick/qmltests/data/tst_profile.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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.0 +import QtTest 1.0 +import QtWebEngine 1.9 + +TestWebEngineView { + id: webEngineView + width: 400 + height: 300 + + + WebEngineProfile { + id: profile1 + } + WebEngineProfile { + id: profile2 + } + property bool profile1UsedForGlobalCertificateVerification: profile1.useForGlobalCertificateVerification + + TestCase { + name: "WebEngineProfile" + + function test_useForGlobalCertificateVerification() { + verify(!profile1.useForGlobalCertificateVerification); + verify(!profile2.useForGlobalCertificateVerification); + verify(!webEngineView.profile1UsedForGlobalCertificateVerification); + + profile1.useForGlobalCertificateVerification = true; + verify(profile1.useForGlobalCertificateVerification); + verify(!profile2.useForGlobalCertificateVerification); + verify(webEngineView.profile1UsedForGlobalCertificateVerification); + + profile2.useForGlobalCertificateVerification = true; + verify(!webEngineView.profile1UsedForGlobalCertificateVerification); + verify(!profile1.useForGlobalCertificateVerification); + verify(profile2.useForGlobalCertificateVerification); + } + } +} diff --git a/tests/auto/quick/qmltests/qmltests.pro b/tests/auto/quick/qmltests/qmltests.pro index a2b05e091..00e884e11 100644 --- a/tests/auto/quick/qmltests/qmltests.pro +++ b/tests/auto/quick/qmltests/qmltests.pro @@ -67,6 +67,8 @@ OTHER_FILES += \ $$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 \ diff --git a/tests/auto/quick/qquickwebengineview/BLACKLIST b/tests/auto/quick/qquickwebengineview/BLACKLIST index 76cb18c1e..166a6894e 100644 --- a/tests/auto/quick/qquickwebengineview/BLACKLIST +++ b/tests/auto/quick/qquickwebengineview/BLACKLIST @@ -9,8 +9,9 @@ windows [basicRenderingSanity] * + [javascriptClipboard:default] opensuse-leap + [javascriptClipboard:canPaste] opensuse-leap - diff --git a/tests/auto/quick/qquickwebengineview/qquickwebengineview.pro b/tests/auto/quick/qquickwebengineview/qquickwebengineview.pro index c253bc2a6..38c130aa3 100644 --- a/tests/auto/quick/qquickwebengineview/qquickwebengineview.pro +++ b/tests/auto/quick/qquickwebengineview/qquickwebengineview.pro @@ -1,6 +1,6 @@ include(../tests.pri) exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc -QT_PRIVATE += webengine-private gui-private webenginecore-private +QT_PRIVATE += core_private gui-private webengine-private webenginecore-private HEADERS += ../shared/util.h diff --git a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp index 007acb8b0..74c04635f 100644 --- a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp +++ b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp @@ -31,6 +31,7 @@ #include <QScopedPointer> #include <QtCore/qelapsedtimer.h> +#include <QtCore/qregularexpression.h> #include <QtGui/qclipboard.h> #include <QtGui/qguiapplication.h> #include <QtGui/qpa/qwindowsysteminterface.h> @@ -40,6 +41,7 @@ #include <QtGui/private/qinputmethod_p.h> #include <QtWebEngine/private/qquickwebengineview_p.h> #include <QtWebEngine/private/qquickwebenginesettings_p.h> +#include <QtWebEngineCore/private/qtwebenginecore-config_p.h> #include <qpa/qplatforminputcontext.h> #include <functional> @@ -876,7 +878,7 @@ public: setAcceptHoverEvents(true); } - bool event(QEvent *event) Q_DECL_OVERRIDE + bool event(QEvent *event) override { switch (event->type()) { case QEvent::TabletPress: @@ -999,8 +1001,9 @@ void tst_QQuickWebEngineView::changeLocale() viewDE->setUrl(url); QVERIFY(waitForLoadFailed(viewDE.data())); + QTRY_VERIFY(!evaluateJavaScriptSync(viewDE.data(), "document.body").isNull()); QTRY_VERIFY(!evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").isNull()); - errorLines = evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").toString().split(QRegExp("[\r\n]"), QString::SkipEmptyParts); + errorLines = evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").toString().split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts); QCOMPARE(errorLines.first().toUtf8(), QByteArrayLiteral("Die Website ist nicht erreichbar")); QLocale::setDefault(QLocale("en")); @@ -1008,8 +1011,9 @@ void tst_QQuickWebEngineView::changeLocale() viewEN->setUrl(url); QVERIFY(waitForLoadFailed(viewEN.data())); + QTRY_VERIFY(!evaluateJavaScriptSync(viewEN.data(), "document.body").isNull()); QTRY_VERIFY(!evaluateJavaScriptSync(viewEN.data(), "document.body.innerText").isNull()); - errorLines = evaluateJavaScriptSync(viewEN.data(), "document.body.innerText").toString().split(QRegExp("[\r\n]"), QString::SkipEmptyParts); + errorLines = evaluateJavaScriptSync(viewEN.data(), "document.body.innerText").toString().split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts); QCOMPARE(errorLines.first().toUtf8(), QByteArrayLiteral("This site can\xE2\x80\x99t be reached")); // Reset error page @@ -1020,8 +1024,9 @@ void tst_QQuickWebEngineView::changeLocale() viewDE->setUrl(url); QVERIFY(waitForLoadFailed(viewDE.data())); + QTRY_VERIFY(!evaluateJavaScriptSync(viewDE.data(), "document.body").isNull()); QTRY_VERIFY(!evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").isNull()); - errorLines = evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").toString().split(QRegExp("[\r\n]"), QString::SkipEmptyParts); + errorLines = evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").toString().split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts); QCOMPARE(errorLines.first().toUtf8(), QByteArrayLiteral("Die Website ist nicht erreichbar")); } diff --git a/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp b/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp index 2b9742b99..b587f3b27 100644 --- a/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp +++ b/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp @@ -46,7 +46,7 @@ public: Qt::QueuedConnection); } - virtual void exposeEvent(QExposeEvent *e) Q_DECL_OVERRIDE { + virtual void exposeEvent(QExposeEvent *e) override { QQuickView::exposeEvent(e); emit _q_exposeChanged(); } diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro index 50a6a8587..81b62b4e7 100644 --- a/tests/auto/quick/quick.pro +++ b/tests/auto/quick/quick.pro @@ -1,5 +1,5 @@ -include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri) # workaround for QTBUG-68093 -QT_FOR_CONFIG += webenginecore-private +include($$QTWEBENGINE_OUT_ROOT/src/webengine/qtwebengine-config.pri) # workaround for QTBUG-68093 +QT_FOR_CONFIG += webengine-private TEMPLATE = subdirs @@ -18,4 +18,4 @@ qtConfig(webengine-testsupport) { } # QTBUG-66055 -boot2qt: SUBDIRS -= inspectorserver qquickwebenginedefaultsurfaceformat qquickwebengineview qmltests dialogs qtbug-70248 +boot2qt: SUBDIRS -= inspectorserver qquickwebengineview qmltests diff --git a/tests/auto/quick/tests.pri b/tests/auto/quick/tests.pri index f7104ad9c..1bf69da43 100644 --- a/tests/auto/quick/tests.pri +++ b/tests/auto/quick/tests.pri @@ -1,5 +1,5 @@ -include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri) # workaround for QTBUG-68093 -QT_FOR_CONFIG += webenginecore-private +include($$QTWEBENGINE_OUT_ROOT/src/webengine/qtwebengine-config.pri) # workaround for QTBUG-68093 +QT_FOR_CONFIG += webengine-private TEMPLATE = app |