diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-03-21 14:35:01 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-03-21 14:35:01 +0100 |
commit | 432af50e930b7f11455fc1daec17d9c215ea88ee (patch) | |
tree | 75f8e9cc04069de32c25660298c4fce046f88b4e /tests/auto | |
parent | 809afc26fe0c47b249cf11376c8ea484a2bfaaf1 (diff) | |
parent | d5a479a720ee76fae9fa7b0f7b6b3d0a61718ff0 (diff) |
Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: If771fabe97c4d75edc4627999f04f70ca1901060
Diffstat (limited to 'tests/auto')
26 files changed, 755 insertions, 33 deletions
diff --git a/tests/auto/core/core.pro b/tests/auto/core/core.pro index c1b2147bd..1dc5e052c 100644 --- a/tests/auto/core/core.pro +++ b/tests/auto/core/core.pro @@ -1,8 +1,9 @@ TEMPLATE = subdirs +QT_FOR_CONFIG += network-private SUBDIRS += \ qwebenginecookiestore \ - qwebengineurlrequestinterceptor \ + qwebengineurlrequestinterceptor + +qtConfig(ssl): SUBDIRS += qwebengineclientcertificatestore -# QTBUG-60268 -boot2qt: SUBDIRS = "" diff --git a/tests/auto/core/qwebengineclientcertificatestore/qwebengineclientcertificatestore.pro b/tests/auto/core/qwebengineclientcertificatestore/qwebengineclientcertificatestore.pro new file mode 100644 index 000000000..e99c7f493 --- /dev/null +++ b/tests/auto/core/qwebengineclientcertificatestore/qwebengineclientcertificatestore.pro @@ -0,0 +1 @@ +include(../tests.pri) diff --git a/tests/auto/core/qwebengineclientcertificatestore/resources/certificate.crt b/tests/auto/core/qwebengineclientcertificatestore/resources/certificate.crt new file mode 100644 index 000000000..1c7a4e6a1 --- /dev/null +++ b/tests/auto/core/qwebengineclientcertificatestore/resources/certificate.crt @@ -0,0 +1,23 @@ +-----BEGIN CERTIFICATE----- +MIID6zCCAtOgAwIBAgIUR7/FZjFjCH94EgGF1VOOca1p8PUwDQYJKoZIhvcNAQEL +BQAwgY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Srtays9yEZO1DRtSKcBrsipdH3KKu3kkAIVL +GJ4igY2+2EO+64usMROzaL0WiNexHLPCm9KkURPvGRE3GJULYHEEw15ClYryJI5A +fwVbcMKhQAQipIgrdoPe6aXfTeELD2RpRvU9nMKTelJI5czx4dYGRXVjjF21qiTr +ov7+d2rXx/133K13kmeeMzOIJkDX3QJwlcKvegygU6QfJwnkRM7ZUAXGTlt3jW0= +-----END CERTIFICATE----- diff --git a/tests/auto/core/qwebengineclientcertificatestore/resources/certificate1.crt b/tests/auto/core/qwebengineclientcertificatestore/resources/certificate1.crt new file mode 100644 index 000000000..cd3ee969e --- /dev/null +++ b/tests/auto/core/qwebengineclientcertificatestore/resources/certificate1.crt @@ -0,0 +1,23 @@ +-----BEGIN CERTIFICATE----- +MIID4zCCAsugAwIBAgIUcEB7LtzUwdKmEY5b8yDuC/rvMLswDQYJKoZIhvcNAQEL +BQAwgYAxCzAJBgNVBAYTAklOMRIwEAYDVQQIDAlLYXJuYXRha2ExEjAQBgNVBAcM +CUJBTkdBTE9SRTEQMA4GA1UECgwHQ2xheXNvbDEUMBIGA1UEAwwLY2xheXNvbC5j +b20xITAfBgkqhkiG9w0BCQEWEnZpaml0aEBjbGF5c29sLmNvbTAeFw0xOTAyMTkx +MjM4NDhaFw0yMDAyMTkxMjM4NDhaMIGAMQswCQYDVQQGEwJJTjESMBAGA1UECAwJ +S2FybmF0YWthMRIwEAYDVQQHDAlCQU5HQUxPUkUxEDAOBgNVBAoMB0NsYXlzb2wx +FDASBgNVBAMMC2NsYXlzb2wuY29tMSEwHwYJKoZIhvcNAQkBFhJ2aWppdGhAY2xh +eXNvbC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9pvbiJJnL +oe5YA6MCUryOYiTmj3PVdPpKMrBe2sdzvO0cx2NXpxWERK9QNnFaJb4fTY+j9fgv +ru1tsIH3AbnDbXfpEPSD4DmpSXiKgB2+KZhA82ZerJendxqaXaj2BgTG2Tc++Chk +0wzx/3KRSb97mgPKJK5yNwx3KQjeXAhR5Mkwmmf+ZUfoYHRu4BNneYs7qX9rEPDl +vrd3AaPTgjapz7EEnSO19BrZHgLWFsM0Kni2vux1jHq1wYRXRTaOG0MrNuvuHuNC +2j5C+N/MPcuuN9izbshrlteIi2a4526V4Hp1KX1BKAI2LgI+ufzdDEkuPs/u28J7 +tGiXjAmf4YUBAgMBAAGjUzBRMB0GA1UdDgQWBBQFfq9BP0BwBToA5U6gfNaxPDFt +3jAfBgNVHSMEGDAWgBQFfq9BP0BwBToA5U6gfNaxPDFt3jAPBgNVHRMBAf8EBTAD +AQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBmruPekYCAAgHig66OBEHcl2jCp+MH1dmW +amM5ET3X0mC588S4+JXCVOOh2XJ2ZSRiy0syPbGd0lG6niX5h35gsqSx9uZyXW/+ +KcTf+LsaxZNusLFtAOExnYuTeeAzofMvIGQpujMhD0p/gk8s64gXnlJZZh8S1OGV +3Me8PV/cat0nuGpLi/0CYj2lAquG0LfeoGZAp+JHAMJTl/xyK4B/KMvbZ7USK9zz +gqwLag93s4vBW0dpgu+g80GGhb0bF2ZFjD+j8I0i9OjFbTWxAiHomofQ6Qx12eVY +rfJs/kVG86cOLJarFHBadjlLz4pu1/sp97TsohFYDy7isRbOQdO2 +-----END CERTIFICATE----- diff --git a/tests/auto/core/qwebengineclientcertificatestore/resources/privatekey.key b/tests/auto/core/qwebengineclientcertificatestore/resources/privatekey.key new file mode 100644 index 000000000..ff9ce14df --- /dev/null +++ b/tests/auto/core/qwebengineclientcertificatestore/resources/privatekey.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDqawqUVrD1HWvf +LKdokLHvG1HMGmkWlpdi6il7vRC6XiJ0tXavr/PzTMe3OuzdgftZeXTjNQj7CGdu +5iC9mNOH8ufJRjrcLaSYOTJ0edFZfJRvzcaAFo3NlyWIYVR3y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szZLRmz4MXxHhm1N2PbRjfhqvSoHwgQVHxR0BSTFaYwQKBgQDQ +8+Zdd4UtXdjZWcw/ah3En4kWS8xFH9qcbS+tl+4t7SYYgqz24hYcPWKNeoM1xfj+ +R0mB7KY+Go/AvmY51AEN+bAvJneEQFGaUKK5AFtL93Y3v/pI9NbZrXjDGSCUaE2z +yXUk92yLJ8s1eR9vIRWNR2qc7WsgTaQtT5w+rwfPVwKBgQC3udM2j59yDCoAOk3g +Myz3PU9I3gLk+yQ2yHWRjE0Cundr3zQ7PqlsITUe9xhUfj+soBsRw7yeg5/wYcVJ +F3hDmAOFb54pW912sD9CQbkhJMX6oVuSegUghPrXDhgiJ9i3TArc9xOKoER4A1s6 +N10tV3NPQprnu2m4jTBykPUJBw== +-----END PRIVATE KEY----- diff --git a/tests/auto/core/qwebengineclientcertificatestore/resources/privatekey1.key b/tests/auto/core/qwebengineclientcertificatestore/resources/privatekey1.key new file mode 100644 index 000000000..f4ae0d2d0 --- /dev/null +++ b/tests/auto/core/qwebengineclientcertificatestore/resources/privatekey1.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC9pvbiJJnLoe5Y +A6MCUryOYiTmj3PVdPpKMrBe2sdzvO0cx2NXpxWERK9QNnFaJb4fTY+j9fgvru1t +sIH3AbnDbXfpEPSD4DmpSXiKgB2+KZhA82ZerJendxqaXaj2BgTG2Tc++Chk0wzx +/3KRSb97mgPKJK5yNwx3KQjeXAhR5Mkwmmf+ZUfoYHRu4BNneYs7qX9rEPDlvrd3 +AaPTgjapz7EEnSO19BrZHgLWFsM0Kni2vux1jHq1wYRXRTaOG0MrNuvuHuNC2j5C ++N/MPcuuN9izbshrlteIi2a4526V4Hp1KX1BKAI2LgI+ufzdDEkuPs/u28J7tGiX +jAmf4YUBAgMBAAECggEADLcnEl512UtQGaKUyVEWx00ZQEQZ9hPTvCnN3W45tS7T +jvxnUrcn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fPhbYw9qSRNvST28s4lLtyRPvoKCpmlUMm5F6Xb65rvICMxc3 +DPnB9iLY6fLY7tETVeV9DEOXki3hoZQ4qkI7OIVbZQn1rA1Du95ZZEGdgE5eEMOC +SQ9g3B7NYJT3Zs8rkxKajWM= +-----END PRIVATE KEY----- diff --git a/tests/auto/core/qwebengineclientcertificatestore/tst_qwebengineclientcertificatestore.cpp b/tests/auto/core/qwebengineclientcertificatestore/tst_qwebengineclientcertificatestore.cpp new file mode 100644 index 000000000..6d51bf7af --- /dev/null +++ b/tests/auto/core/qwebengineclientcertificatestore/tst_qwebengineclientcertificatestore.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QtWebEngineCore/qwebengineclientcertificatestore.h> +#include <QtWebEngineWidgets/qwebengineprofile.h> + +class tst_QWebEngineClientCertificateStore : public QObject +{ + Q_OBJECT + +public: + tst_QWebEngineClientCertificateStore(); + ~tst_QWebEngineClientCertificateStore(); + +private Q_SLOTS: + void addAndListCertificates(); + void removeAndClearCertificates(); +}; + +tst_QWebEngineClientCertificateStore::tst_QWebEngineClientCertificateStore() +{ +} + +tst_QWebEngineClientCertificateStore::~tst_QWebEngineClientCertificateStore() +{ +} + +void tst_QWebEngineClientCertificateStore::addAndListCertificates() +{ + // Load QSslCertificate + QFile certFile(":/resources/certificate.crt"); + certFile.open(QIODevice::ReadOnly); + const QSslCertificate cert(certFile.readAll(), QSsl::Pem); + + // Load QSslKey + QFile keyFile(":/resources/privatekey.key"); + keyFile.open(QIODevice::ReadOnly); + const QSslKey sslKey(keyFile.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, ""); + + // Load second QSslCertificate + QFile certFileSecond(":/resources/certificate1.crt"); + certFileSecond.open(QIODevice::ReadOnly); + const QSslCertificate certSecond(certFileSecond.readAll(), QSsl::Pem); + + // Load second QSslKey + QFile keyFileSecond(":/resources/privatekey1.key"); + keyFileSecond.open(QIODevice::ReadOnly); + const QSslKey sslKeySecond(keyFileSecond.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, ""); + + // Add certificates to in-memory store + QWebEngineProfile::defaultProfile()->clientCertificateStore()->add(cert, sslKey); + QWebEngineProfile::defaultProfile()->clientCertificateStore()->add(certSecond, sslKeySecond); + + QCOMPARE(2, QWebEngineProfile::defaultProfile()->clientCertificateStore()->certificates().length()); +} + +void tst_QWebEngineClientCertificateStore::removeAndClearCertificates() +{ + QCOMPARE(2, QWebEngineProfile::defaultProfile()->clientCertificateStore()->certificates().length()); + + // Remove one certificate from in-memory store + auto list = QWebEngineProfile::defaultProfile()->clientCertificateStore()->certificates(); + QWebEngineProfile::defaultProfile()->clientCertificateStore()->remove(list[0]); + QCOMPARE(1, QWebEngineProfile::defaultProfile()->clientCertificateStore()->certificates().length()); + + // Remove all certificates in-memory store + QWebEngineProfile::defaultProfile()->clientCertificateStore()->clear(); + QCOMPARE(0, QWebEngineProfile::defaultProfile()->clientCertificateStore()->certificates().length()); +} + +QTEST_MAIN(tst_QWebEngineClientCertificateStore) +#include "tst_qwebengineclientcertificatestore.moc" diff --git a/tests/auto/core/qwebengineclientcertificatestore/tst_qwebengineclientcertificatestore.qrc b/tests/auto/core/qwebengineclientcertificatestore/tst_qwebengineclientcertificatestore.qrc new file mode 100644 index 000000000..db481fef6 --- /dev/null +++ b/tests/auto/core/qwebengineclientcertificatestore/tst_qwebengineclientcertificatestore.qrc @@ -0,0 +1,8 @@ +<RCC> + <qresource prefix="/"> + <file>resources/certificate.crt</file> + <file>resources/privatekey.key</file> + <file>resources/certificate1.crt</file> + <file>resources/privatekey1.key</file> + </qresource> +</RCC> diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp index 5d869c14f..3e5d24381 100644 --- a/tests/auto/quick/publicapi/tst_publicapi.cpp +++ b/tests/auto/quick/publicapi/tst_publicapi.cpp @@ -100,6 +100,7 @@ static const QStringList hardcodedTypes = QStringList() << "QQuickWebEngineErrorPage*" << "const QQuickWebEngineContextMenuData*" << "QWebEngineCookieStore*" + << "Qt::LayoutDirection" ; static const QStringList expectedAPI = QStringList() @@ -140,10 +141,41 @@ 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" + << "QQuickWebEngineContextMenuRequest.CanRedo --> EditFlags" + << "QQuickWebEngineContextMenuRequest.CanCut --> EditFlags" + << "QQuickWebEngineContextMenuRequest.CanCopy --> EditFlags" + << "QQuickWebEngineContextMenuRequest.CanPaste --> EditFlags" + << "QQuickWebEngineContextMenuRequest.CanDelete --> EditFlags" + << "QQuickWebEngineContextMenuRequest.CanSelectAll --> EditFlags" + << "QQuickWebEngineContextMenuRequest.CanTranslate --> EditFlags" + << "QQuickWebEngineContextMenuRequest.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" @@ -155,6 +187,7 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineContextMenuRequest.isContentEditable --> bool" << "QQuickWebEngineContextMenuRequest.linkText --> QString" << "QQuickWebEngineContextMenuRequest.linkUrl --> QUrl" + << "QQuickWebEngineContextMenuRequest.mediaFlags --> MediaFlags" << "QQuickWebEngineContextMenuRequest.mediaType --> MediaType" << "QQuickWebEngineContextMenuRequest.mediaUrl --> QUrl" << "QQuickWebEngineContextMenuRequest.misspelledWord --> QString" @@ -226,6 +259,7 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineDownloadItem.totalBytesChanged() --> void" << "QQuickWebEngineDownloadItem.type --> DownloadType" << "QQuickWebEngineDownloadItem.typeChanged() --> void" + << "QQuickWebEngineDownloadItem.view --> QQuickWebEngineView*" << "QQuickWebEngineFileDialogRequest.FileModeOpen --> FileMode" << "QQuickWebEngineFileDialogRequest.FileModeOpenMultiple --> FileMode" << "QQuickWebEngineFileDialogRequest.FileModeSave --> FileMode" @@ -296,6 +330,8 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineProfile.clearHttpCache() --> void" << "QQuickWebEngineProfile.downloadFinished(QQuickWebEngineDownloadItem*) --> void" << "QQuickWebEngineProfile.downloadRequested(QQuickWebEngineDownloadItem*) --> void" + << "QQuickWebEngineProfile.downloadPath --> QString" + << "QQuickWebEngineProfile.downloadPathChanged() --> void" << "QQuickWebEngineProfile.userNotification(QWebEngineNotification*) --> void" << "QQuickWebEngineProfile.httpAcceptLanguage --> QString" << "QQuickWebEngineProfile.httpAcceptLanguageChanged() --> void" @@ -317,6 +353,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" @@ -360,6 +398,8 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineSettings.autoLoadImagesChanged() --> void" << "QQuickWebEngineSettings.defaultTextEncoding --> QString" << "QQuickWebEngineSettings.defaultTextEncodingChanged() --> void" + << "QQuickWebEngineSettings.dnsPrefetchEnabled --> bool" + << "QQuickWebEngineSettings.dnsPrefetchEnabledChanged() --> void" << "QQuickWebEngineSettings.errorPageEnabled --> bool" << "QQuickWebEngineSettings.errorPageEnabledChanged() --> void" << "QQuickWebEngineSettings.focusOnNavigationEnabled --> bool" @@ -372,6 +412,8 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineSettings.javascriptCanAccessClipboardChanged() --> void" << "QQuickWebEngineSettings.javascriptCanOpenWindows --> bool" << "QQuickWebEngineSettings.javascriptCanOpenWindowsChanged() --> void" + << "QQuickWebEngineSettings.javascriptCanPaste --> bool" + << "QQuickWebEngineSettings.javascriptCanPasteChanged() --> void" << "QQuickWebEngineSettings.javascriptEnabled --> bool" << "QQuickWebEngineSettings.javascriptEnabledChanged() --> void" << "QQuickWebEngineSettings.linksIncludedInFocusChain --> bool" @@ -382,6 +424,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" @@ -667,6 +711,7 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineView.navigationRequested(QQuickWebEngineNavigationRequest*) --> void" << "QQuickWebEngineView.newViewRequested(QQuickWebEngineNewViewRequest*) --> void" << "QQuickWebEngineView.pdfPrintingFinished(QString,bool) --> void" + << "QQuickWebEngineView.printRequested() --> void" << "QQuickWebEngineView.printToPdf(QJSValue) --> void" << "QQuickWebEngineView.printToPdf(QJSValue,PrintedPageSizeId) --> void" << "QQuickWebEngineView.printToPdf(QJSValue,PrintedPageSizeId,PrintedPageOrientation) --> void" @@ -689,11 +734,14 @@ 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" +#if QT_CONFIG(webengine_testsupport) << "QQuickWebEngineView.testSupport --> QQuickWebEngineTestSupport*" << "QQuickWebEngineView.testSupportChanged() --> void" +#endif << "QQuickWebEngineView.title --> QString" << "QQuickWebEngineView.titleChanged() --> void" << "QQuickWebEngineView.tooltipRequested(QQuickWebEngineTooltipRequest*) --> void" @@ -722,10 +770,7 @@ static const QStringList expectedAPI = QStringList() << "QWebEngineNotification.message --> QString" << "QWebEngineNotification.tag --> QString" << "QWebEngineNotification.language --> QString" - << "QWebEngineNotification.direction --> Direction" - << "QWebEngineNotification.LeftToRight --> Direction" - << "QWebEngineNotification.RightToLeft --> Direction" - << "QWebEngineNotification.DirectionAuto --> Direction" + << "QWebEngineNotification.direction --> Qt::LayoutDirection" << "QWebEngineNotification.show() --> void" << "QWebEngineNotification.click() --> void" << "QWebEngineNotification.close() --> void" @@ -824,18 +869,23 @@ void tst_publicapi::publicAPI() // for (const QString &actual : qAsConst(sortedAPI)) // printf(" << \"%s\"\n", qPrintable(actual)); + bool apiMatch = true; // Make sure that nothing slips in the public API unintentionally. for (const QString &actual : qAsConst(actualAPI)) { - if (!expectedAPI.contains(actual)) - QEXPECT_FAIL("", qPrintable("Expected list is not up-to-date: " + actual), Continue); - QVERIFY2(expectedAPI.contains(actual), qPrintable(actual)); + if (!expectedAPI.contains(actual)) { + QWARN(qPrintable("Expected list is not up-to-date: " + actual)); + apiMatch = false; + } } // Make sure that the expected list is up-to-date with intentionally added APIs. for (const QString &expected : expectedAPI) { - if (!actualAPI.contains(expected)) - QEXPECT_FAIL("", qPrintable("Not implemented: " + expected), Continue); - QVERIFY2(actualAPI.contains(expected), qPrintable(expected)); + if (!actualAPI.contains(expected)) { + apiMatch = false; + QWARN(qPrintable("Not implemented: " + expected)); + } } + + QVERIFY2(apiMatch, "Unexpected, missing or misspelled API!"); } QTEST_MAIN(tst_publicapi) diff --git a/tests/auto/quick/qmltests/data/tst_favicon.qml b/tests/auto/quick/qmltests/data/tst_favicon.qml index 563a87c83..50a412384 100644 --- a/tests/auto/quick/qmltests/data/tst_favicon.qml +++ b/tests/auto/quick/qmltests/data/tst_favicon.qml @@ -375,5 +375,38 @@ TestWebEngineView { faviconImage.destroy() } + + function test_touchIconWithSameURL() + { + WebEngine.settings.touchIconsEnabled = false; + + var icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="; + + webEngineView.loadHtml( + "<html>" + + "<link rel='icon' type='image/png' href='" + icon + "'/>" + + "<link rel='apple-touch-icon' type='image/png' href='" + icon + "'/>" + + "</html>" + ); + verify(webEngineView.waitForLoadSucceeded()); + + // The default favicon has to be loaded even if its URL is also set as a touch icon while touch icons are disabled. + tryCompare(iconChangedSpy, "count", 1); + compare(webEngineView.icon.toString().replace(/^image:\/\/favicon\//, ''), icon); + + iconChangedSpy.clear(); + + webEngineView.loadHtml( + "<html>" + + "<link rel='apple-touch-icon' type='image/png' href='" + icon + "'/>" + + "</html>" + ); + verify(webEngineView.waitForLoadSucceeded()); + + // This page only has a touch icon. With disabled touch icons we don't expect any icon to be shown even if the same icon + // was loaded previously. + tryCompare(iconChangedSpy, "count", 1); + verify(!webEngineView.icon.toString().replace(/^image:\/\/favicon\//, '')); + } } } diff --git a/tests/auto/quick/qmltests/data/tst_notification.qml b/tests/auto/quick/qmltests/data/tst_notification.qml index 609a04f61..af4aebafc 100644 --- a/tests/auto/quick/qmltests/data/tst_notification.qml +++ b/tests/auto/quick/qmltests/data/tst_notification.qml @@ -37,6 +37,7 @@ TestWebEngineView { property bool permissionRequested: false property bool grantPermission: false + property url securityOrigin: '' signal consoleMessage(string message) @@ -48,7 +49,8 @@ TestWebEngineView { onFeaturePermissionRequested: { if (feature === WebEngineView.Notifications) { - permissionRequested = true + view.permissionRequested = true + view.securityOrigin = securityOrigin view.grantFeaturePermission(securityOrigin, feature, grantPermission) } } @@ -111,6 +113,10 @@ TestWebEngineView { 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/quick.pro b/tests/auto/quick/quick.pro index 46dd57f76..81b62b4e7 100644 --- a/tests/auto/quick/quick.pro +++ b/tests/auto/quick/quick.pro @@ -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/shared/data/notification.html b/tests/auto/shared/data/notification.html index cadcbd942..1d1e9c411 100644 --- a/tests/auto/shared/data/notification.html +++ b/tests/auto/shared/data/notification.html @@ -8,7 +8,7 @@ function getPermission() { return document.Notification } function sendNotification(title, body) { - let notification = new Notification(title, { body: body }) + let notification = new Notification(title, { body: body, dir: 'rtl', lang: 'de', tag: 'tst' }) notification.onclick = function() { console.info('onclick') } notification.onclose = function() { console.info('onclose') } notification.onerror = function(error) { console.info('onerror: ' + error) } diff --git a/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp b/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp index 606d05d9e..540c8d505 100644 --- a/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp +++ b/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp @@ -62,6 +62,7 @@ private Q_SLOTS: void downloadTouchIconsEnabled_data(); void downloadTouchIconsEnabled(); void dynamicFavicon(); + void touchIconWithSameURL(); private: QWebEngineView *m_view; @@ -508,6 +509,43 @@ void tst_FaviconManager::dynamicFavicon() } } +void tst_FaviconManager::touchIconWithSameURL() +{ + m_page->settings()->setAttribute(QWebEngineSettings::TouchIconsEnabled, false); + + const QString icon("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="); + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); + QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); + + m_page->setHtml("<html>" + "<link rel='icon' type='image/png' href='" + icon + "'/>" + "<link rel='apple-touch-icon' type='image/png' href='" + icon + "'/>" + "</html>"); + QTRY_COMPARE(loadFinishedSpy.count(), 1); + + // The default favicon has to be loaded even if its URL is also set as a touch icon while touch icons are disabled. + QTRY_COMPARE(iconUrlChangedSpy.count(), 1); + QCOMPARE(m_page->iconUrl().toString(), icon); + QTRY_COMPARE(iconChangedSpy.count(), 1); + + loadFinishedSpy.clear(); + iconUrlChangedSpy.clear(); + iconChangedSpy.clear(); + + m_page->setHtml("<html>" + "<link rel='apple-touch-icon' type='image/png' href='" + icon + "'/>" + "</html>"); + QTRY_COMPARE(loadFinishedSpy.count(), 1); + + // This page only has a touch icon. With disabled touch icons we don't expect any icon to be shown even if the same icon + // was loaded previously. + QTRY_COMPARE(iconUrlChangedSpy.count(), 1); + QVERIFY(m_page->iconUrl().toString().isEmpty()); + QTRY_COMPARE(iconChangedSpy.count(), 1); + +} + QTEST_MAIN(tst_FaviconManager) #include "tst_faviconmanager.moc" diff --git a/tests/auto/widgets/offscreen/offscreen.pro b/tests/auto/widgets/offscreen/offscreen.pro new file mode 100644 index 000000000..b8e5632f9 --- /dev/null +++ b/tests/auto/widgets/offscreen/offscreen.pro @@ -0,0 +1,6 @@ +include(../tests.pri) +QT += webengine +qpa.name = QT_QPA_PLATFORM +qpa.value = offscreen +QT_TOOL_ENV += qpa + diff --git a/tests/auto/widgets/offscreen/tst_offscreen.cpp b/tests/auto/widgets/offscreen/tst_offscreen.cpp new file mode 100644 index 000000000..98cbe55fe --- /dev/null +++ b/tests/auto/widgets/offscreen/tst_offscreen.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qtwebengineglobal.h" +#include <QTest> +#include <QSignalSpy> +#include <QWebEngineProfile> +#include <QWebEnginePage> +#include <QWebEngineView> + +class tst_OffScreen : public QObject { + Q_OBJECT +public: + tst_OffScreen(){} + +private slots: + void offscreen(); +}; + +void tst_OffScreen::offscreen() +{ + QWebEngineProfile profile; + QWebEnginePage page(&profile); + QWebEngineView view; + QSignalSpy loadFinishedSpy(&page, SIGNAL(loadFinished(bool))); + view.setPage(&page); + page.load(QUrl("http://qt.io")); + view.show(); + QTRY_COMPARE(view.isVisible(), true); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count() > 0, true, 20000); +} + +#include "tst_offscreen.moc" +QTEST_MAIN(tst_OffScreen) + diff --git a/tests/auto/widgets/proxy/proxy.pro b/tests/auto/widgets/proxy/proxy.pro new file mode 100644 index 000000000..802dfad05 --- /dev/null +++ b/tests/auto/widgets/proxy/proxy.pro @@ -0,0 +1,9 @@ +include(../tests.pri) +QT += core-private webengine webengine-private + +HEADERS += \ + proxy_server.h + +SOURCES += \ + proxy_server.cpp + diff --git a/tests/auto/widgets/proxy/proxy_server.cpp b/tests/auto/widgets/proxy/proxy_server.cpp new file mode 100644 index 000000000..55f014914 --- /dev/null +++ b/tests/auto/widgets/proxy/proxy_server.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "proxy_server.h" +#include <QDataStream> +#include <QTcpSocket> +#include <QDebug> + +ProxyServer::ProxyServer(QObject *parent) : QObject(parent) +{ + connect(&m_server, &QTcpServer::newConnection, this, &ProxyServer::handleNewConnection); +} + +void ProxyServer::setCredentials(const QByteArray &user, const QByteArray password) +{ + m_auth.append(user); + m_auth.append(QChar(':')); + m_auth.append(password); + m_auth = m_auth.toBase64(); +} + +bool ProxyServer::isListening() +{ + return m_server.isListening(); +} + +void ProxyServer::run() +{ + if (!m_server.listen(QHostAddress::LocalHost, 5555)) + qFatal("Could not start the test server"); +} + +void ProxyServer::handleNewConnection() +{ + // do one connection at the time + Q_ASSERT(m_data.isEmpty()); + QTcpSocket *socket = m_server.nextPendingConnection(); + Q_ASSERT(socket); + connect(socket, &QAbstractSocket::disconnected, socket, &QObject::deleteLater); + connect(socket, &QAbstractSocket::readyRead, this, &ProxyServer::handleReadReady); +} + +void ProxyServer::handleReadReady() +{ + QTcpSocket *socket = qobject_cast<QTcpSocket*>(sender()); + Q_ASSERT(socket); + + m_data.append(socket->readAll()); + + if (!m_data.endsWith("\r\n\r\n")) + return; + + if (!m_data.contains(QByteArrayLiteral("Proxy-Authorization: Basic"))) { + socket->write("HTTP/1.1 407 Proxy Authentication Required\nProxy-Authenticate: " + "Basic realm=\"Proxy requires authentication\"\r\n" + "content-length: 0\r\n" + "\r\n"); + return; + } + + if (m_data.contains(m_auth)) { + emit success(); + } + m_data.clear(); +} diff --git a/tests/auto/widgets/proxy/proxy_server.h b/tests/auto/widgets/proxy/proxy_server.h new file mode 100644 index 000000000..cb7c30600 --- /dev/null +++ b/tests/auto/widgets/proxy/proxy_server.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PROXY_SERVER_H +#define PROXY_SERVER_H + +#include <QObject> +#include <QTcpServer> + +class ProxyServer : public QObject +{ + Q_OBJECT + +public: + explicit ProxyServer(QObject *parent = nullptr); + void setCredentials(const QByteArray &user, const QByteArray password); + bool isListening(); + +public slots: + void run(); + +private slots: + void handleNewConnection(); + void handleReadReady(); + +signals: + void success(); +private: + QByteArray m_data; + QTcpServer m_server; + QByteArray m_auth; +}; + +#endif // PROXY_SERVER_H diff --git a/tests/auto/widgets/proxy/tst_proxy.cpp b/tests/auto/widgets/proxy/tst_proxy.cpp new file mode 100644 index 000000000..5f5dec016 --- /dev/null +++ b/tests/auto/widgets/proxy/tst_proxy.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "proxy_server.h" +#include <QTest> +#include <QSignalSpy> +#include <QNetworkProxy> +#include <QWebEnginePage> +#include <QWebEngineView> + + +class tst_Proxy : public QObject { + Q_OBJECT +public: + tst_Proxy(){} + +private slots: + void proxyAuthentication(); +}; + +void tst_Proxy::proxyAuthentication() +{ + QByteArray user(QByteArrayLiteral("test")); + QByteArray password(QByteArrayLiteral("pass")); + QNetworkProxy proxy; + proxy.setType(QNetworkProxy::HttpProxy); + proxy.setHostName("localhost"); + proxy.setPort(5555); + proxy.setUser(user); + proxy.setPassword(password); + QNetworkProxy::setApplicationProxy(proxy); + ProxyServer server; + server.setCredentials(user,password); + server.run(); + QTRY_VERIFY2(server.isListening(), "Could not setup authentication server"); + QWebEnginePage page; + QSignalSpy successSpy(&server, &ProxyServer::success); + page.load(QUrl("http://www.qt.io")); + QTRY_VERIFY2(successSpy.count() > 0, "Could not get authentication token"); +} + +#include "tst_proxy.moc" +QTEST_MAIN(tst_Proxy) + diff --git a/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp b/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp index 32823d30d..ee1e6ee04 100644 --- a/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp +++ b/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp @@ -70,6 +70,7 @@ private Q_SLOTS: void downloadFileNot1(); void downloadFileNot2(); void downloadDeleted(); + void downloadDeletedByProfile(); void downloadUniqueFilename_data(); void downloadUniqueFilename(); void downloadUniqueFileNameWithTimeStamp(); @@ -821,6 +822,37 @@ void tst_QWebEngineDownloadItem::downloadDeleted() QTRY_COMPARE(finishedCount, 1); } +void tst_QWebEngineDownloadItem::downloadDeletedByProfile() +{ + m_server->setExpectError(true); + + 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, [&] () { + downloadFinished = true; + }); + downloadItem = item; + item->accept(); + }); + + QPointer<QWebEnginePage> page(new QWebEnginePage(profile)); + page->download(m_server->url(QByteArrayLiteral("/file"))); + + QTRY_COMPARE(downloadItem.isNull(), false); + QVERIFY(downloadItem); + + page->deleteLater(); + profile->deleteLater(); + + QTRY_COMPARE(downloadFinished, true); + QTRY_COMPARE(downloadItem.isNull(), true); +} + void tst_QWebEngineDownloadItem::downloadUniqueFilename_data() { QTest::addColumn<QString>("baseName"); diff --git a/tests/auto/widgets/qwebenginepage/BLACKLIST b/tests/auto/widgets/qwebenginepage/BLACKLIST index 228efd61c..f3dc51fdd 100644 --- a/tests/auto/widgets/qwebenginepage/BLACKLIST +++ b/tests/auto/widgets/qwebenginepage/BLACKLIST @@ -1,9 +1,3 @@ -[comboBoxPopupPositionAfterMove] -* - -[comboBoxPopupPositionAfterChildMove] -* - [macCopyUnicodeToClipboard] osx diff --git a/tests/auto/widgets/qwebenginepage/resources/reload.html b/tests/auto/widgets/qwebenginepage/resources/reload.html new file mode 100644 index 000000000..d9c33dfcd --- /dev/null +++ b/tests/auto/widgets/qwebenginepage/resources/reload.html @@ -0,0 +1,8 @@ +<html> +<head> +<meta http-equiv="refresh" content="2"> +</head> +<body> +This is test content +</body> +</html> diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 0504d39fa..3792b5522 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -138,6 +138,7 @@ private Q_SLOTS: void runJavaScript(); void runJavaScriptDisabled(); + void runJavaScriptFromSlot(); void fullScreenRequested(); void quotaRequested(); @@ -561,11 +562,17 @@ void tst_QWebEnginePage::acceptNavigationRequestNavigationType() QTRY_COMPARE(loadSpy.count(), 4); QTRY_COMPARE(page.navigations.count(), 4); + page.load(QUrl("qrc:///resources/reload.html")); + QTRY_COMPARE(loadSpy.count(), 6); + QTRY_COMPARE(page.navigations.count(), 6); + QList<QWebEnginePage::NavigationType> expectedList; expectedList << QWebEnginePage::NavigationTypeTyped << QWebEnginePage::NavigationTypeTyped << QWebEnginePage::NavigationTypeBackForward - << QWebEnginePage::NavigationTypeReload; + << QWebEnginePage::NavigationTypeReload + << QWebEnginePage::NavigationTypeTyped + << QWebEnginePage::NavigationTypeOther; QVERIFY(expectedList.count() == page.navigations.count()); for (int i = 0; i < expectedList.count(); ++i) { QCOMPARE(page.navigations[i].type, expectedList[i]); @@ -1008,9 +1015,8 @@ static QWindow *findNewTopLevelWindow(const QWindowList &oldTopLevelWindows) void tst_QWebEnginePage::comboBoxPopupPositionAfterMove() { - QScreen *screen = QGuiApplication::primaryScreen(); QWebEngineView view; - view.move(screen->availableGeometry().topLeft()); + view.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft()); view.resize(640, 480); view.show(); @@ -1026,18 +1032,29 @@ void tst_QWebEnginePage::comboBoxPopupPositionAfterMove() QWindow *popup = nullptr; QTRY_VERIFY(popup = findNewTopLevelWindow(oldTlws)); + QTRY_VERIFY(QGuiApplication::topLevelWindows().contains(popup)); + QTRY_VERIFY(!popup->position().isNull()); QPoint popupPos = popup->position(); // Close the popup by clicking somewhere into the page. QTest::mouseClick(window, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(1, 1)); QTRY_VERIFY(!QGuiApplication::topLevelWindows().contains(popup)); + auto jsViewPosition = [&view]() { + QLatin1String script("(function() { return [window.screenX, window.screenY]; })()"); + QVariantList posList = evaluateJavaScriptSync(view.page(), script).toList(); + return QPoint(posList.at(0).toInt(), posList.at(1).toInt()); + }; + // Move the top-level QWebEngineView a little and check the popup's position. const QPoint offset(12, 13); - view.move(screen->availableGeometry().topLeft() + offset); + view.move(view.pos() + offset); + QTRY_COMPARE(jsViewPosition(), view.pos()); QTest::mouseClick(window, Qt::LeftButton, Qt::KeyboardModifiers(), elementCenter(view.page(), "foo")); QTRY_VERIFY(popup = findNewTopLevelWindow(oldTlws)); + QTRY_VERIFY(QGuiApplication::topLevelWindows().contains(popup)); + QTRY_VERIFY(!popup->position().isNull()); QCOMPARE(popupPos + offset, popup->position()); } @@ -1047,7 +1064,6 @@ void tst_QWebEnginePage::comboBoxPopupPositionAfterChildMove() mainWidget.setLayout(new QHBoxLayout); QWidget spacer; - spacer.setMinimumWidth(50); mainWidget.layout()->addWidget(&spacer); QWebEngineView view; @@ -1070,6 +1086,8 @@ void tst_QWebEnginePage::comboBoxPopupPositionAfterChildMove() QWindow *popup = nullptr; QTRY_VERIFY(popup = findNewTopLevelWindow(oldTlws)); + QTRY_VERIFY(QGuiApplication::topLevelWindows().contains(popup)); + QTRY_VERIFY(!popup->position().isNull()); QPoint popupPos = popup->position(); // Close the popup by clicking somewhere into the page. @@ -1077,11 +1095,22 @@ void tst_QWebEnginePage::comboBoxPopupPositionAfterChildMove() view.mapTo(view.window(), QPoint(1, 1))); QTRY_VERIFY(!QGuiApplication::topLevelWindows().contains(popup)); + int originalViewWidth = view.size().width(); + auto jsViewWidth = [&view]() { + QLatin1String script("(function() { return window.innerWidth; })()"); + int viewWidth = evaluateJavaScriptSync(view.page(), script).toInt(); + return viewWidth; + }; + // Resize the "spacer" widget, and implicitly change the global position of the QWebEngineView. - spacer.setMinimumWidth(100); + const int offset = 50; + spacer.setMinimumWidth(spacer.size().width() + offset); + QTRY_COMPARE(jsViewWidth(), originalViewWidth - offset); + QTest::mouseClick(window, Qt::LeftButton, Qt::KeyboardModifiers(), view.mapTo(view.window(), elementCenter(view.page(), "foo"))); QTRY_VERIFY(popup = findNewTopLevelWindow(oldTlws)); + QTRY_VERIFY(!popup->position().isNull()); QCOMPARE(popupPos + QPoint(50, 0), popup->position()); } @@ -1644,6 +1673,28 @@ void tst_QWebEnginePage::runJavaScriptDisabled() QVariant(2)); } +// Based on https://bugreports.qt.io/browse/QTBUG-73876 +void tst_QWebEnginePage::runJavaScriptFromSlot() +{ + QWebEngineProfile profile; + QWebEnginePage page(&profile); + + QSignalSpy loadFinishedSpy(&page, &QWebEnginePage::loadFinished); + page.setHtml("<html><body>" + " <input type='text' id='input1' value='QtWebEngine' size='50' />" + "</body></html>"); + QTRY_COMPARE(loadFinishedSpy.count(), 1); + + QVariant result(-1); + connect(&page, &QWebEnginePage::selectionChanged, [&]() { + result = evaluateJavaScriptSync(&page, QStringLiteral("2+2")); + }); + evaluateJavaScriptSync(&page, QStringLiteral("const input = document.getElementById('input1');" + "input.focus();" + "input.select();")); + QTRY_COMPARE(result, QVariant(4)); +} + void tst_QWebEnginePage::fullScreenRequested() { JavaScriptCallbackWatcher watcher; @@ -3284,10 +3335,13 @@ void tst_QWebEnginePage::sendNotification() auto notification = presenter.waitForResult(); QVERIFY(presenter.wasCalled()); - QVERIFY(!notification.isNull()); + QVERIFY(notification.isValid()); QCOMPARE(notification.title(), title); QCOMPARE(notification.message(), message); QCOMPARE(notification.origin(), origin); + QCOMPARE(notification.direction(), Qt::RightToLeft); + QCOMPARE(notification.language(), "de"); + QCOMPARE(notification.tag(), "tst"); notification.show(); QTRY_VERIFY2(page.messages.contains("onshow"), page.messages.join("\n").toLatin1().constData()); diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc index 757e151c1..cf32486e7 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc @@ -14,6 +14,7 @@ <file>resources/user.css</file> <file>resources/image.png</file> <file>resources/pasteimage.html</file> + <file>resources/reload.html</file> <file>resources/style.css</file> <file>resources/test1.html</file> <file>resources/test2.html</file> diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro index 0addb9671..15b3efd3b 100644 --- a/tests/auto/widgets/widgets.pro +++ b/tests/auto/widgets/widgets.pro @@ -8,7 +8,9 @@ SUBDIRS += \ devtools \ faviconmanager \ loadsignals \ + offscreen \ origins \ + proxy \ proxypac \ schemes \ shutdown \ @@ -38,7 +40,8 @@ qtConfig(webengine-spellchecker):!cross_compile { # QTBUG-60268 boot2qt: SUBDIRS -= accessibility defaultsurfaceformat devtools \ - faviconmanager qwebenginepage qwebenginehistory \ - qwebengineprofile qwebenginescript \ - qwebengineview qwebenginedownloaditem qwebenginesettings \ - schemes origins loadsignals proxypac + qwebenginepage \ + qwebengineprofile \ + qwebengineview \ + qwebenginescript \ + proxypac offscreen |