summaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/CMakeLists.txt15
-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/CMakeLists.txt28
-rw-r--r--tests/auto/quick/dialogs/WebView.qml39
-rw-r--r--tests/auto/quick/dialogs/dialogs.pro13
-rw-r--r--tests/auto/quick/dialogs/dialogs.qrc6
-rw-r--r--tests/auto/quick/dialogs/server.cpp79
-rw-r--r--tests/auto/quick/dialogs/server.h59
-rw-r--r--tests/auto/quick/dialogs/testhandler.cpp31
-rw-r--r--tests/auto/quick/dialogs/testhandler.h29
-rw-r--r--tests/auto/quick/dialogs/tst_dialogs.cpp136
-rw-r--r--tests/auto/quick/inspectorserver/BLACKLIST2
-rw-r--r--tests/auto/quick/inspectorserver/CMakeLists.txt12
-rw-r--r--tests/auto/quick/inspectorserver/html/basic_page.html (renamed from tests/auto/quick/html/basic_page.html)0
-rw-r--r--tests/auto/quick/inspectorserver/inspectorserver.pro4
-rw-r--r--tests/auto/quick/inspectorserver/tst_inspectorserver.cpp84
-rw-r--r--tests/auto/quick/publicapi/CMakeLists.txt10
-rw-r--r--tests/auto/quick/publicapi/publicapi.pro3
-rw-r--r--tests/auto/quick/publicapi/tst_publicapi.cpp489
-rw-r--r--tests/auto/quick/qmltests/BLACKLIST12
-rw-r--r--tests/auto/quick/qmltests/CMakeLists.txt94
-rw-r--r--tests/auto/quick/qmltests/data/TestWebEngineView.qml114
-rw-r--r--tests/auto/quick/qmltests/data/favicon-misc.html4
-rw-r--r--tests/auto/quick/qmltests/data/filesystemapi.html66
-rw-r--r--tests/auto/quick/qmltests/data/geolocation.html9
-rw-r--r--tests/auto/quick/qmltests/data/test2.html2
-rw-r--r--tests/auto/quick/qmltests/data/test4.html2
-rw-r--r--tests/auto/quick/qmltests/data/titleupdate.js29
-rw-r--r--tests/auto/quick/qmltests/data/tst_action.qml51
-rw-r--r--tests/auto/quick/qmltests/data/tst_activeFocusOnPress.qml34
-rw-r--r--tests/auto/quick/qmltests/data/tst_audioMuted.qml37
-rw-r--r--tests/auto/quick/qmltests/data/tst_basicProfiles.qml90
-rw-r--r--tests/auto/quick/qmltests/data/tst_certificateError.qml74
-rw-r--r--tests/auto/quick/qmltests/data/tst_contextMenu.qml114
-rw-r--r--tests/auto/quick/qmltests/data/tst_datalist.qml186
-rw-r--r--tests/auto/quick/qmltests/data/tst_desktopBehaviorLoadHtml.qml37
-rw-r--r--tests/auto/quick/qmltests/data/tst_download.qml90
-rw-r--r--tests/auto/quick/qmltests/data/tst_dragHandlerUnderView.qml67
-rw-r--r--tests/auto/quick/qmltests/data/tst_favicon.qml428
-rw-r--r--tests/auto/quick/qmltests/data/tst_faviconDatabase.qml216
-rw-r--r--tests/auto/quick/qmltests/data/tst_faviconDownload.qml121
-rw-r--r--tests/auto/quick/qmltests/data/tst_filePicker.qml81
-rw-r--r--tests/auto/quick/qmltests/data/tst_filesystem.qml124
-rw-r--r--tests/auto/quick/qmltests/data/tst_findText.qml44
-rw-r--r--tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml38
-rw-r--r--tests/auto/quick/qmltests/data/tst_fullScreenRequest.qml6
-rw-r--r--tests/auto/quick/qmltests/data/tst_geopermission.qml97
-rw-r--r--tests/auto/quick/qmltests/data/tst_getUserMedia.qml72
-rw-r--r--tests/auto/quick/qmltests/data/tst_inputMethod.qml46
-rw-r--r--tests/auto/quick/qmltests/data/tst_inputTextDirection.qml43
-rw-r--r--tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml76
-rw-r--r--tests/auto/quick/qmltests/data/tst_keyboardEvents.qml52
-rw-r--r--tests/auto/quick/qmltests/data/tst_keyboardModifierMapping.qml35
-rw-r--r--tests/auto/quick/qmltests/data/tst_linkHovered.qml67
-rw-r--r--tests/auto/quick/qmltests/data/tst_loadFail.qml121
-rw-r--r--tests/auto/quick/qmltests/data/tst_loadHtml.qml36
-rw-r--r--tests/auto/quick/qmltests/data/tst_loadProgress.qml37
-rw-r--r--tests/auto/quick/qmltests/data/tst_loadRecursionCrash.qml35
-rw-r--r--tests/auto/quick/qmltests/data/tst_loadUrl.qml80
-rw-r--r--tests/auto/quick/qmltests/data/tst_mouseClick.qml62
-rw-r--r--tests/auto/quick/qmltests/data/tst_mouseMove.qml35
-rw-r--r--tests/auto/quick/qmltests/data/tst_navigationHistory.qml105
-rw-r--r--tests/auto/quick/qmltests/data/tst_navigationRequested.qml70
-rw-r--r--tests/auto/quick/qmltests/data/tst_newViewRequest.qml95
-rw-r--r--tests/auto/quick/qmltests/data/tst_notification.qml60
-rw-r--r--tests/auto/quick/qmltests/data/tst_profile.qml66
-rw-r--r--tests/auto/quick/qmltests/data/tst_properties.qml35
-rw-r--r--tests/auto/quick/qmltests/data/tst_runJavaScript.qml38
-rw-r--r--tests/auto/quick/qmltests/data/tst_save.qml185
-rw-r--r--tests/auto/quick/qmltests/data/tst_scrollPosition.qml42
-rw-r--r--tests/auto/quick/qmltests/data/tst_settings.qml102
-rw-r--r--tests/auto/quick/qmltests/data/tst_titleChanged.qml35
-rw-r--r--tests/auto/quick/qmltests/data/tst_unhandledKeyEventPropagation.qml44
-rw-r--r--tests/auto/quick/qmltests/data/tst_userScriptCollection.qml127
-rw-r--r--tests/auto/quick/qmltests/data/tst_userScripts.qml81
-rw-r--r--tests/auto/quick/qmltests/data/tst_viewSource.qml118
-rw-r--r--tests/auto/quick/qmltests/data/tst_webchannel.qml46
-rw-r--r--tests/auto/quick/qmltests/data/webchannel-test.html1
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/AlertDialog.qml32
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/ConfirmDialog.qml49
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/FilePicker.qml49
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/Menu.qml57
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/MenuItem.qml44
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/PromptDialog.qml52
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/qmldir5
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/AlertDialog.qml5
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/ConfirmDialog.qml24
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/DirectoryPicker.qml18
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/FilePicker.qml24
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/Menu.qml18
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/MenuItem.qml8
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/PromptDialog.qml27
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/TestParams/FilePickerParams.qml32
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/TestParams/JSDialogParams.qml31
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/TestParams/MenuParams.qml9
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/TestParams/qmldir1
-rw-r--r--tests/auto/quick/qmltests/qmltests.pro155
-rw-r--r--tests/auto/quick/qmltests/resources/server.key27
-rw-r--r--tests/auto/quick/qmltests/resources/server.pem41
-rw-r--r--tests/auto/quick/qmltests/tst_qmltests.cpp210
-rw-r--r--tests/auto/quick/qquickwebenginedefaultsurfaceformat/CMakeLists.txt13
-rw-r--r--tests/auto/quick/qquickwebenginedefaultsurfaceformat/html/basic_page.html6
-rw-r--r--tests/auto/quick/qquickwebenginedefaultsurfaceformat/qquickwebenginedefaultsurfaceformat.pro6
-rw-r--r--tests/auto/quick/qquickwebenginedefaultsurfaceformat/tst_qquickwebenginedefaultsurfaceformat.cpp45
-rw-r--r--tests/auto/quick/qquickwebengineprofile/qquickwebengineprofile.pro1
-rw-r--r--tests/auto/quick/qquickwebengineprofile/tst_qquickwebengineprofile.cpp73
-rw-r--r--tests/auto/quick/qquickwebengineview/CMakeLists.txt16
-rw-r--r--tests/auto/quick/qquickwebengineview/html/basic_page.html6
-rw-r--r--tests/auto/quick/qquickwebengineview/html/basic_page2.html (renamed from tests/auto/quick/html/basic_page2.html)0
-rw-r--r--tests/auto/quick/qquickwebengineview/html/direct-image-compositing.html (renamed from tests/auto/quick/html/direct-image-compositing.html)0
-rw-r--r--tests/auto/quick/qquickwebengineview/html/inputmethod.html (renamed from tests/auto/quick/html/inputmethod.html)0
-rw-r--r--tests/auto/quick/qquickwebengineview/html/resources/simple_image.png (renamed from tests/auto/quick/html/resources/simple_image.png)bin10585 -> 10585 bytes
-rw-r--r--tests/auto/quick/qquickwebengineview/html/scroll.html (renamed from tests/auto/quick/html/scroll.html)0
-rw-r--r--tests/auto/quick/qquickwebengineview/qquickwebengineview.pro6
-rw-r--r--tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp326
-rw-r--r--tests/auto/quick/qquickwebengineviewgraphics/CMakeLists.txt13
-rw-r--r--tests/auto/quick/qquickwebengineviewgraphics/qquickwebengineviewgraphics.pro4
-rw-r--r--tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp52
-rw-r--r--tests/auto/quick/qtbug-70248/CMakeLists.txt20
-rw-r--r--tests/auto/quick/qtbug-70248/qtbug-70248.pro5
-rw-r--r--tests/auto/quick/qtbug-70248/test.qml6
-rw-r--r--tests/auto/quick/qtbug-70248/test.qrc5
-rw-r--r--tests/auto/quick/qtbug-70248/tst_qtbug-70248.cpp33
-rw-r--r--tests/auto/quick/quick.pro20
-rw-r--r--tests/auto/quick/shared/qt_webengine_quicktest.h57
-rw-r--r--tests/auto/quick/shared/testwindow.h68
-rw-r--r--tests/auto/quick/shared/util.h190
-rw-r--r--tests/auto/quick/tests.pri20
-rw-r--r--tests/auto/quick/uidelegates/CMakeLists.txt17
-rw-r--r--tests/auto/quick/uidelegates/tst_uidelegates.cpp228
135 files changed, 3780 insertions, 4050 deletions
diff --git a/tests/auto/quick/CMakeLists.txt b/tests/auto/quick/CMakeLists.txt
new file mode 100644
index 000000000..d2cf7c3b3
--- /dev/null
+++ b/tests/auto/quick/CMakeLists.txt
@@ -0,0 +1,15 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+add_subdirectory(dialogs)
+add_subdirectory(publicapi)
+add_subdirectory(qquickwebenginedefaultsurfaceformat)
+add_subdirectory(qtbug-70248)
+# Re-enable if QTBUG-101744 and QTBUG-103354 have been fixed.
+if(NOT MACOS)
+ add_subdirectory(uidelegates)
+endif()
+add_subdirectory(inspectorserver)
+add_subdirectory(qmltests)
+add_subdirectory(qquickwebengineview)
+add_subdirectory(qquickwebengineviewgraphics)
diff --git a/tests/auto/quick/certificateerror/WebView.qml b/tests/auto/quick/certificateerror/WebView.qml
deleted file mode 100644
index 97abdfb98..000000000
--- a/tests/auto/quick/certificateerror/WebView.qml
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** 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
deleted file mode 100644
index 27d5a3cc1..000000000
--- a/tests/auto/quick/certificateerror/certificateerror.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-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
deleted file mode 100644
index bfc3013e7..000000000
--- a/tests/auto/quick/certificateerror/certificateerror.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<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
deleted file mode 100644
index cb6710aa3..000000000
--- a/tests/auto/quick/certificateerror/testhandler.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** 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
deleted file mode 100644
index a6d95d9a9..000000000
--- a/tests/auto/quick/certificateerror/testhandler.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** 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
deleted file mode 100644
index 3e2dc85fb..000000000
--- a/tests/auto/quick/certificateerror/tst_certificateerror.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/****************************************************************************
-**
-** 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/CMakeLists.txt b/tests/auto/quick/dialogs/CMakeLists.txt
new file mode 100644
index 000000000..4d8dc853b
--- /dev/null
+++ b/tests/auto/quick/dialogs/CMakeLists.txt
@@ -0,0 +1,28 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+include(../../httpserver/httpserver.cmake)
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_dialogs
+ SOURCES
+ testhandler.cpp testhandler.h
+ tst_dialogs.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::WebEngineQuickPrivate
+ Test::HttpServer
+ Test::Util
+)
+
+set(dialogs_resource_files
+ "WebView.qml"
+ "index.html"
+)
+
+qt_internal_add_resource(tst_dialogs "dialogs"
+ PREFIX
+ "/"
+ FILES
+ ${dialogs_resource_files}
+)
diff --git a/tests/auto/quick/dialogs/WebView.qml b/tests/auto/quick/dialogs/WebView.qml
index 01f4ac297..45fafb42d 100644
--- a/tests/auto/quick/dialogs/WebView.qml
+++ b/tests/auto/quick/dialogs/WebView.qml
@@ -1,36 +1,11 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-import QtQuick 2.0
-import QtWebEngine 1.4
-import QtQuick.Window 2.0
-import QtTest 1.0
-import io.qt.tester 1.0
+import QtQuick
+import QtWebEngine
+import QtQuick.Window
+import QtTest
+import io.qt.tester
Window {
width: 50
diff --git a/tests/auto/quick/dialogs/dialogs.pro b/tests/auto/quick/dialogs/dialogs.pro
deleted file mode 100644
index 29d509b20..000000000
--- a/tests/auto/quick/dialogs/dialogs.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-include(../tests.pri)
-QT += core-private webengine webengine-private
-
-HEADERS += \
- server.h \
- testhandler.h
-
-SOURCES += \
- server.cpp \
- testhandler.cpp
-
-RESOURCES += \
- dialogs.qrc
diff --git a/tests/auto/quick/dialogs/dialogs.qrc b/tests/auto/quick/dialogs/dialogs.qrc
deleted file mode 100644
index a0715dbce..000000000
--- a/tests/auto/quick/dialogs/dialogs.qrc
+++ /dev/null
@@ -1,6 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>index.html</file>
- <file>WebView.qml</file>
- </qresource>
-</RCC>
diff --git a/tests/auto/quick/dialogs/server.cpp b/tests/auto/quick/dialogs/server.cpp
deleted file mode 100644
index dfc7c97ad..000000000
--- a/tests/auto/quick/dialogs/server.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** 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 "server.h"
-#include <QDataStream>
-#include <QTcpSocket>
-#include <QDebug>
-
-Server::Server(QObject *parent) : QObject(parent)
-{
- connect(&m_server, &QTcpServer::newConnection, this, &Server::handleNewConnection);
-}
-
-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))
- qFatal("Could not start the test server");
-}
-
-void Server::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, &Server::handleReadReady);
-}
-
-void Server::handleReadReady()
-{
- QTcpSocket *socket = qobject_cast<QTcpSocket*>(sender());
- Q_ASSERT(socket);
-
- m_data.append(socket->readAll());
-
- //simply wait for whole request
- if (!m_data.endsWith("\r\n\r\n"))
- return;
-
- 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
deleted file mode 100644
index fa9a73811..000000000
--- a/tests/auto/quick/dialogs/server.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** 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 SERVER_H
-#define SERVER_H
-
-#include <QObject>
-#include <QTcpServer>
-
-class Server : public QObject
-{
- Q_OBJECT
-
-public:
- explicit Server(QObject *parent = nullptr);
-
- bool isListening();
- void setReply(const QByteArray &reply);
-
-public slots:
- void run();
-
-private slots:
- void handleNewConnection();
- void handleReadReady();
-
-private:
- QByteArray m_data;
- QByteArray m_reply;
- QTcpServer m_server;
-
-};
-
-#endif // SERVER_H
diff --git a/tests/auto/quick/dialogs/testhandler.cpp b/tests/auto/quick/dialogs/testhandler.cpp
index bdd63a547..f45852630 100644
--- a/tests/auto/quick/dialogs/testhandler.cpp
+++ b/tests/auto/quick/dialogs/testhandler.cpp
@@ -1,36 +1,11 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "testhandler.h"
TestHandler::TestHandler(QObject *parent) : QObject(parent)
{
- setObjectName(QStringLiteral("TestListner"));
+ setObjectName(QStringLiteral("TestListener"));
}
QObject* TestHandler::request() const
diff --git a/tests/auto/quick/dialogs/testhandler.h b/tests/auto/quick/dialogs/testhandler.h
index 93ecfcdcb..c72e81841 100644
--- a/tests/auto/quick/dialogs/testhandler.h
+++ b/tests/auto/quick/dialogs/testhandler.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef TESTHANDLER_H
#define TESTHANDLER_H
diff --git a/tests/auto/quick/dialogs/tst_dialogs.cpp b/tests/auto/quick/dialogs/tst_dialogs.cpp
index dca872aad..2b861efa6 100644
--- a/tests/auto/quick/dialogs/tst_dialogs.cpp
+++ b/tests/auto/quick/dialogs/tst_dialogs.cpp
@@ -1,50 +1,26 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "testhandler.h"
-#include "server.h"
-#include "util.h"
-#include <QtWebEngine/private/qquickwebenginedialogrequests_p.h>
+#include <quickutil.h>
+#include <httpserver.h>
+
+#include <QtWebEngineQuick/private/qquickwebenginedialogrequests_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 +33,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 +46,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 +60,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);
- QTRY_COMPARE(dialogSpy.count(), 1);
+ 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.size(), 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 +92,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);
- QTRY_COMPARE(dialogSpy.count(), 1);
- auto dialog = qobject_cast<QWebEngineContextMenuRequest *>(m_listner->request());
+ 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.size(), 1);
+ 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");
@@ -146,7 +122,7 @@ void tst_Dialogs::authenticationDialogRequested_data()
QTest::addColumn<QUrl>("url");
QTest::addColumn<QQuickWebEngineAuthenticationDialogRequest::AuthenticationType>("type");
QTest::addColumn<QString>("realm");
- QTest::addColumn<QByteArray>("reply");
+ QTest::addColumn<QByteArray>("response");
QTest::newRow("Http Authentication Dialog") << QUrl("http://localhost:5555/")
<< QQuickWebEngineAuthenticationDialogRequest::AuthenticationTypeHTTP
<< QStringLiteral("Very Restricted Area")
@@ -166,18 +142,19 @@ void tst_Dialogs::authenticationDialogRequested()
QFETCH(QUrl, url);
QFETCH(QQuickWebEngineAuthenticationDialogRequest::AuthenticationType, type);
QFETCH(QString, realm);
+ QFETCH(QByteArray, response);
- QFETCH(QByteArray, reply);
- Server server;
- server.setReply(reply);
- server.run();
- QTRY_VERIFY2(server.isListening(), "Could not setup authentication server");
+ HttpServer server(QHostAddress::LocalHost, 5555);
+ connect(&server, &HttpServer::newRequest, [url, response](HttpReqRep *rr) {
+ rr->sendResponse(response);
+ });
+ QVERIFY(server.start());
- 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());
+ QTRY_COMPARE(dialogSpy.size(), 1);
+ auto *dialog = qobject_cast<QQuickWebEngineAuthenticationDialogRequest*>(m_listener->request());
QVERIFY2(dialog, "Incorrect dialog requested");
dialog->dialogReject();
QVERIFY2(dialog->isAccepted(), "Dialog is not accepted");
@@ -185,6 +162,7 @@ void tst_Dialogs::authenticationDialogRequested()
QCOMPARE(dialog->realm(),realm);
QCOMPARE(dialog->url(), url);
QCOMPARE(dialog->proxyHost(), QStringLiteral("localhost"));
+ QVERIFY(server.stop());
}
void tst_Dialogs::javaScriptDialogRequested_data()
@@ -214,20 +192,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);
- QTRY_COMPARE(dialogSpy.count(), 1);
- auto dialog = qobject_cast<QQuickWebEngineJavaScriptDialogRequest*>(m_listner->request());
+ QSignalSpy dialogSpy(m_listener, &TestHandler::requestChanged);
+ m_listener->runJavaScript(script);
+ QTRY_COMPARE(dialogSpy.size(), 1);
+ 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/BLACKLIST b/tests/auto/quick/inspectorserver/BLACKLIST
new file mode 100644
index 000000000..076dd5f10
--- /dev/null
+++ b/tests/auto/quick/inspectorserver/BLACKLIST
@@ -0,0 +1,2 @@
+[openRemoteDebuggingSession]
+macos
diff --git a/tests/auto/quick/inspectorserver/CMakeLists.txt b/tests/auto/quick/inspectorserver/CMakeLists.txt
new file mode 100644
index 000000000..d890581b8
--- /dev/null
+++ b/tests/auto/quick/inspectorserver/CMakeLists.txt
@@ -0,0 +1,12 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_test(tst_inspectorserver
+ SOURCES
+ tst_inspectorserver.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::WebEngineQuickPrivate
+)
+
+
diff --git a/tests/auto/quick/html/basic_page.html b/tests/auto/quick/inspectorserver/html/basic_page.html
index 53726e4a6..53726e4a6 100644
--- a/tests/auto/quick/html/basic_page.html
+++ b/tests/auto/quick/inspectorserver/html/basic_page.html
diff --git a/tests/auto/quick/inspectorserver/inspectorserver.pro b/tests/auto/quick/inspectorserver/inspectorserver.pro
deleted file mode 100644
index fdc213f38..000000000
--- a/tests/auto/quick/inspectorserver/inspectorserver.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-include(../tests.pri)
-QT += webengine
-QT_PRIVATE += core-private webengine-private webenginecore-private
-DEFINES += IMPORT_DIR=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}imports\\\"\"
diff --git a/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp b/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
index 1f30fce5b..a9638bee4 100644
--- a/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
+++ b/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QNetworkAccessManager>
#include <QNetworkReply>
@@ -33,7 +8,8 @@
#include <QtQml/QQmlEngine>
#include <QtTest/QtTest>
#include <QQuickWebEngineProfile>
-#include <QtWebEngine/private/qquickwebengineview_p.h>
+#include <QtWebEngineQuick/private/qquickwebengineview_p.h>
+#include <QWebEnginePage>
#define INSPECTOR_SERVER_PORT "23654"
static const QUrl s_inspectorServerHttpBaseUrl("http://localhost:" INSPECTOR_SERVER_PORT);
@@ -47,6 +23,7 @@ private Q_SLOTS:
void init();
void cleanup();
+ void testDevToolsId();
void testPageList();
void testRemoteDebuggingMessage();
void openRemoteDebuggingSession();
@@ -61,8 +38,9 @@ private:
tst_InspectorServer::tst_InspectorServer()
{
+ qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--remote-allow-origins=*");
qputenv("QTWEBENGINE_REMOTE_DEBUGGING", INSPECTOR_SERVER_PORT);
- QtWebEngine::initialize();
+ QtWebEngineQuick::initialize();
QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true);
prepareWebViewComponent();
}
@@ -70,12 +48,10 @@ tst_InspectorServer::tst_InspectorServer()
void tst_InspectorServer::prepareWebViewComponent()
{
static QQmlEngine* engine = new QQmlEngine(this);
- engine->addImportPath(QString::fromUtf8(IMPORT_DIR));
-
m_component.reset(new QQmlComponent(engine, this));
- m_component->setData(QByteArrayLiteral("import QtQuick 2.0\n"
- "import QtWebEngine 1.2\n"
+ m_component->setData(QByteArrayLiteral("import QtQuick\n"
+ "import QtWebEngine\n"
"WebEngineView { }")
, QUrl());
}
@@ -105,7 +81,7 @@ inline QQuickWebEngineView* tst_InspectorServer::webView() const
QJsonArray tst_InspectorServer::fetchPageList() const
{
QNetworkAccessManager qnam;
- QSignalSpy spy(&qnam, &QNetworkAccessManager::finished);;
+ QSignalSpy spy(&qnam, &QNetworkAccessManager::finished);
QNetworkRequest request(s_inspectorServerHttpBaseUrl.resolved(QUrl("json/list")));
QScopedPointer<QNetworkReply> reply(qnam.get(request));
spy.wait();
@@ -117,12 +93,28 @@ QJsonArray tst_InspectorServer::fetchPageList() const
return QJsonDocument::fromJson(reply->readAll()).array();
}
+void tst_InspectorServer::testDevToolsId()
+{
+ const QUrl testPageUrl = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/html/basic_page.html"));
+ QSignalSpy loadSpy(webView(), SIGNAL(loadingChanged(QWebEngineLoadingInfo)));
+ webView()->setUrl(testPageUrl);
+ QTRY_VERIFY_WITH_TIMEOUT(loadSpy.size() && !webView()->isLoading(), 10000);
+
+ // Our page should be the only one in the list.
+ QJsonArray pageList = fetchPageList();
+ QCOMPARE(pageList.size(), 1);
+ QCOMPARE(testPageUrl.toString(), pageList.at(0).toObject().value("url").toString());
+ QCOMPARE(webView()->devToolsId(), pageList.at(0).toObject().value("id").toString());
+}
+
void tst_InspectorServer::testPageList()
{
- const QUrl testPageUrl = QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
- QSignalSpy loadSpy(webView(), SIGNAL(loadingChanged(QQuickWebEngineLoadRequest*)));
+ const QUrl testPageUrl = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/html/basic_page.html"));
+ QSignalSpy loadSpy(webView(), SIGNAL(loadingChanged(QWebEngineLoadingInfo)));
webView()->setUrl(testPageUrl);
- QTRY_VERIFY(loadSpy.size() && !webView()->isLoading());
+ QTRY_VERIFY_WITH_TIMEOUT(loadSpy.size() && !webView()->isLoading(), 10000);
// Our page has developerExtrasEnabled and should be the only one in the list.
QJsonArray pageList = fetchPageList();
@@ -132,10 +124,11 @@ void tst_InspectorServer::testPageList()
void tst_InspectorServer::testRemoteDebuggingMessage()
{
- const QUrl testPageUrl = QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
- QSignalSpy loadSpy(webView(), SIGNAL(loadingChanged(QQuickWebEngineLoadRequest*)));
+ const QUrl testPageUrl = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/html/basic_page.html"));
+ QSignalSpy loadSpy(webView(), SIGNAL(loadingChanged(QWebEngineLoadingInfo)));
webView()->setUrl(testPageUrl);
- QTRY_VERIFY(loadSpy.size() && !webView()->isLoading());
+ QTRY_VERIFY_WITH_TIMEOUT(loadSpy.size() && !webView()->isLoading(), 10000);
QJsonArray pageList = fetchPageList();
QCOMPARE(pageList.size(), 1);
@@ -161,15 +154,16 @@ void tst_InspectorServer::testRemoteDebuggingMessage()
.arg(pageList.at(0).toObject().value("webSocketDebuggerUrl").toString())
.arg(jsExpression));
- QTRY_COMPARE(webSocketQueryWebView->title(), jsExpressionResult);
+ QTRY_COMPARE_WITH_TIMEOUT(webSocketQueryWebView->title(), jsExpressionResult, 10000);
}
void tst_InspectorServer::openRemoteDebuggingSession()
{
- const QUrl testPageUrl = QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
- QSignalSpy loadSpy(webView(), SIGNAL(loadingChanged(QQuickWebEngineLoadRequest*)));
+ const QUrl testPageUrl = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/html/basic_page.html"));
+ QSignalSpy loadSpy(webView(), SIGNAL(loadingChanged(QWebEngineLoadingInfo)));
webView()->setUrl(testPageUrl);
- QTRY_VERIFY(loadSpy.size() && !webView()->isLoading());
+ QTRY_VERIFY_WITH_TIMEOUT(loadSpy.size() && !webView()->isLoading(), 10000);
QJsonArray pageList = fetchPageList();
QCOMPARE(pageList.size(), 1);
@@ -184,7 +178,7 @@ void tst_InspectorServer::openRemoteDebuggingSession()
// - The page list didn't return a valid inspector URL
// - Or the front-end couldn't be loaded through the inspector HTTP server
// - Or the web socket connection couldn't be established between the front-end and the page through the inspector server
- QTRY_VERIFY_WITH_TIMEOUT(inspectorWebView->title().startsWith("DevTools -"), 30000);
+ QTRY_VERIFY_WITH_TIMEOUT(inspectorWebView->title().startsWith("DevTools -"), 60000);
}
QTEST_MAIN(tst_InspectorServer)
diff --git a/tests/auto/quick/publicapi/CMakeLists.txt b/tests/auto/quick/publicapi/CMakeLists.txt
new file mode 100644
index 000000000..e345a076a
--- /dev/null
+++ b/tests/auto/quick/publicapi/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_test(tst_publicapi
+ SOURCES
+ tst_publicapi.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::WebEngineQuickPrivate
+)
diff --git a/tests/auto/quick/publicapi/publicapi.pro b/tests/auto/quick/publicapi/publicapi.pro
deleted file mode 100644
index c56fd2503..000000000
--- a/tests/auto/quick/publicapi/publicapi.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-include(../tests.pri)
-QT += webengine
-QT_PRIVATE += core-private webengine-private webenginecore-private
diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp
index e79ed86de..e6605dc41 100644
--- a/tests/auto/quick/publicapi/tst_publicapi.cpp
+++ b/tests/auto/quick/publicapi/tst_publicapi.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QMetaEnum>
#include <QMetaMethod>
@@ -33,26 +8,34 @@
#include <QMetaType>
#include <QQmlListProperty>
#include <QtTest/QtTest>
-#include <QtWebEngine/QQuickWebEngineProfile>
+#include <QtWebEngineQuick/QQuickWebEngineProfile>
#include <QtWebEngineCore/QWebEngineCertificateError>
+#include <QtWebEngineCore/QWebEngineDesktopMediaRequest>
+#include <QtWebEngineCore/QWebEngineFileSystemAccessRequest>
#include <QtWebEngineCore/QWebEngineFindTextResult>
#include <QtWebEngineCore/QWebEngineFullScreenRequest>
+#include <QtWebEngineCore/QWebEngineHistory>
+#include <QtWebEngineCore/QWebEngineNavigationRequest>
+#include <QtWebEngineCore/QWebEngineNewWindowRequest>
#include <QtWebEngineCore/QWebEngineNotification>
#include <QtWebEngineCore/QWebEngineQuotaRequest>
#include <QtWebEngineCore/QWebEngineRegisterProtocolHandlerRequest>
#include <QtWebEngineCore/QWebEngineContextMenuRequest>
#include <QtWebEngineCore/QWebEngineDownloadRequest>
#include <QtWebEngineCore/QWebEngineScript>
+#include <QtWebEngineCore/QWebEngineLoadingInfo>
+#include <QtWebEngineCore/QWebEngineWebAuthUxRequest>
+#include <QtWebEngineCore/QWebEngineFrame>
+#include <QtWebEngineCore/QWebEnginePermission>
#include <private/qquickwebengineview_p.h>
#include <private/qquickwebengineaction_p.h>
#include <private/qquickwebengineclientcertificateselection_p.h>
#include <private/qquickwebenginedialogrequests_p.h>
-#include <private/qquickwebenginehistory_p.h>
-#include <private/qquickwebengineloadrequest_p.h>
-#include <private/qquickwebenginenavigationrequest_p.h>
-#include <private/qquickwebenginenewviewrequest_p.h>
+#include <private/qquickwebenginedownloadrequest_p.h>
+#include <private/qquickwebenginenewwindowrequest_p.h>
#include <private/qquickwebenginesettings_p.h>
#include <private/qquickwebenginesingleton_p.h>
+#include <private/qquickwebenginetouchselectionmenurequest_p.h>
class tst_publicapi : public QObject {
Q_OBJECT
@@ -65,12 +48,10 @@ static const QList<const QMetaObject *> typesToCheck = QList<const QMetaObject *
<< &QQuickWebEngineAction::staticMetaObject
<< &QQuickWebEngineClientCertificateOption::staticMetaObject
<< &QQuickWebEngineClientCertificateSelection::staticMetaObject
+ << &QQuickWebEngineDownloadRequest::staticMetaObject
<< &QWebEngineDownloadRequest::staticMetaObject
- << &QQuickWebEngineHistory::staticMetaObject
- << &QQuickWebEngineHistoryListModel::staticMetaObject
- << &QQuickWebEngineLoadRequest::staticMetaObject
- << &QQuickWebEngineNavigationRequest::staticMetaObject
- << &QQuickWebEngineNewViewRequest::staticMetaObject
+ << &QWebEngineHistory::staticMetaObject
+ << &QWebEngineHistoryModel::staticMetaObject
<< &QQuickWebEngineProfile::staticMetaObject
<< &QQuickWebEngineSettings::staticMetaObject
<< &QWebEngineFullScreenRequest::staticMetaObject
@@ -80,17 +61,31 @@ static const QList<const QMetaObject *> typesToCheck = QList<const QMetaObject *
<< &QQuickWebEngineJavaScriptDialogRequest::staticMetaObject
<< &QQuickWebEngineColorDialogRequest::staticMetaObject
<< &QQuickWebEngineFileDialogRequest::staticMetaObject
- << &QQuickWebEngineFormValidationMessageRequest::staticMetaObject
+ << &QQuickWebEngineNewWindowRequest::staticMetaObject
<< &QQuickWebEngineTooltipRequest::staticMetaObject
<< &QWebEngineContextMenuRequest::staticMetaObject
<< &QWebEngineCertificateError::staticMetaObject
+ << &QWebEngineDesktopMediaRequest::staticMetaObject
+ << &QWebEngineFileSystemAccessRequest::staticMetaObject
+ << &QWebEngineFindTextResult::staticMetaObject
+ << &QWebEngineLoadingInfo::staticMetaObject
+ << &QAbstractListModel::staticMetaObject
+ << &QWebEngineNavigationRequest::staticMetaObject
+ << &QWebEngineNewWindowRequest::staticMetaObject
+ << &QWebEngineNotification::staticMetaObject
+ << &QWebEnginePermission::staticMetaObject
<< &QWebEngineQuotaRequest::staticMetaObject
<< &QWebEngineRegisterProtocolHandlerRequest::staticMetaObject
- << &QWebEngineNotification::staticMetaObject
- << &QWebEngineFindTextResult::staticMetaObject
+ << &QQuickWebEngineTouchSelectionMenuRequest::staticMetaObject
+ << &QWebEngineWebAuthUxRequest::staticMetaObject
+ << &QWebEngineWebAuthPinRequest::staticMetaObject
+ << &QWebEngineFrame::staticMetaObject
;
-static QList<const char *> knownEnumNames = QList<const char *>();
+static QList<QMetaEnum> knownEnumNames = QList<QMetaEnum>()
+ << QWebEngineDownloadRequest::staticMetaObject.enumerator(QWebEngineDownloadRequest::staticMetaObject.indexOfEnumerator("SavePageFormat"))
+ << QWebEnginePermission::staticMetaObject.enumerator(QWebEnginePermission::staticMetaObject.indexOfEnumerator("Feature"))
+ ;
static const QStringList hardcodedTypes = QStringList()
<< "QJSValue"
@@ -98,13 +93,14 @@ static const QStringList hardcodedTypes = QStringList()
<< "QQmlListProperty<QQuickWebEngineClientCertificateOption>"
<< "const QQuickWebEngineClientCertificateOption*"
<< "QQmlWebChannel*"
- // Ignore the testSupport types without making a fuss.
- << "QQuickWebEngineTestSupport*"
- << "QQuickWebEngineErrorPage*"
<< "const QQuickWebEngineContextMenuData*"
<< "QWebEngineCookieStore*"
<< "Qt::LayoutDirection"
- << "QQuickWebEngineScriptCollection*";
+ << "QQuickWebEngineScriptCollection*"
+ << "QQmlComponent*"
+ << "QMultiMap<QByteArray,QByteArray>"
+ << "QList<QWebEnginePermission>"
+ ;
static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineAction.text --> QString"
@@ -120,7 +116,7 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineAuthenticationDialogRequest.dialogReject() --> void"
<< "QQuickWebEngineAuthenticationDialogRequest.proxyHost --> QString"
<< "QQuickWebEngineAuthenticationDialogRequest.realm --> QString"
- << "QQuickWebEngineAuthenticationDialogRequest.type --> AuthenticationType"
+ << "QQuickWebEngineAuthenticationDialogRequest.type --> QQuickWebEngineAuthenticationDialogRequest::AuthenticationType"
<< "QQuickWebEngineAuthenticationDialogRequest.url --> QUrl"
<< "QWebEngineCertificateError.CertificateAuthorityInvalid --> Type"
<< "QWebEngineCertificateError.CertificateCommonNameInvalid --> Type"
@@ -142,7 +138,8 @@ static const QStringList expectedAPI = QStringList()
<< "QWebEngineCertificateError.SslPinnedKeyNotInCertificateChain --> Type"
<< "QWebEngineCertificateError.defer() --> void"
<< "QWebEngineCertificateError.description --> QString"
- << "QWebEngineCertificateError.type --> Type"
+ << "QWebEngineCertificateError.type --> QWebEngineCertificateError::Type"
+ << "QWebEngineCertificateError.isMainFrame --> bool"
<< "QWebEngineCertificateError.acceptCertificate() --> void"
<< "QWebEngineCertificateError.overridable --> bool"
<< "QWebEngineCertificateError.rejectCertificate() --> void"
@@ -171,7 +168,7 @@ static const QStringList expectedAPI = QStringList()
<< "QWebEngineContextMenuRequest.CanEditRichly --> EditFlags"
<< "QQuickWebEngineColorDialogRequest.dialogAccept(QColor) --> void"
<< "QQuickWebEngineColorDialogRequest.dialogReject() --> void"
- << "QWebEngineContextMenuRequest.editFlags --> EditFlags"
+ << "QWebEngineContextMenuRequest.editFlags --> QFlags<QWebEngineContextMenuRequest::EditFlag>"
<< "QWebEngineContextMenuRequest.MediaInError --> MediaFlags"
<< "QWebEngineContextMenuRequest.MediaPaused --> MediaFlags"
<< "QWebEngineContextMenuRequest.MediaMuted --> MediaFlags"
@@ -193,8 +190,8 @@ static const QStringList expectedAPI = QStringList()
<< "QWebEngineContextMenuRequest.isContentEditable --> bool"
<< "QWebEngineContextMenuRequest.linkText --> QString"
<< "QWebEngineContextMenuRequest.linkUrl --> QUrl"
- << "QWebEngineContextMenuRequest.mediaFlags --> MediaFlags"
- << "QWebEngineContextMenuRequest.mediaType --> MediaType"
+ << "QWebEngineContextMenuRequest.mediaFlags --> QFlags<QWebEngineContextMenuRequest::MediaFlag>"
+ << "QWebEngineContextMenuRequest.mediaType --> QWebEngineContextMenuRequest::MediaType"
<< "QWebEngineContextMenuRequest.mediaUrl --> QUrl"
<< "QWebEngineContextMenuRequest.misspelledWord --> QString"
<< "QWebEngineContextMenuRequest.selectedText --> QString"
@@ -236,7 +233,7 @@ static const QStringList expectedAPI = QStringList()
<< "QWebEngineDownloadRequest.accept() --> void"
<< "QWebEngineDownloadRequest.cancel() --> void"
<< "QWebEngineDownloadRequest.id --> uint"
- << "QWebEngineDownloadRequest.interruptReason --> DownloadInterruptReason"
+ << "QWebEngineDownloadRequest.interruptReason --> QWebEngineDownloadRequest::DownloadInterruptReason"
<< "QWebEngineDownloadRequest.interruptReasonChanged() --> void"
<< "QWebEngineDownloadRequest.interruptReasonString --> QString"
<< "QWebEngineDownloadRequest.isFinished --> bool"
@@ -249,20 +246,19 @@ static const QStringList expectedAPI = QStringList()
<< "QWebEngineDownloadRequest.receivedBytes --> qlonglong"
<< "QWebEngineDownloadRequest.receivedBytesChanged() --> void"
<< "QWebEngineDownloadRequest.resume() --> void"
- << "QWebEngineDownloadRequest.savePageFormat --> SavePageFormat"
+ << "QWebEngineDownloadRequest.savePageFormat --> QWebEngineDownloadRequest::SavePageFormat"
<< "QWebEngineDownloadRequest.savePageFormatChanged() --> void"
- << "QWebEngineDownloadRequest.state --> DownloadState"
+ << "QWebEngineDownloadRequest.state --> QWebEngineDownloadRequest::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
+ << "QQuickWebEngineDownloadRequest.view --> QQuickWebEngineView*"
<< "QQuickWebEngineFileDialogRequest.FileModeOpen --> FileMode"
<< "QQuickWebEngineFileDialogRequest.FileModeOpenMultiple --> FileMode"
<< "QQuickWebEngineFileDialogRequest.FileModeSave --> FileMode"
@@ -272,32 +268,39 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineFileDialogRequest.defaultFileName --> QString"
<< "QQuickWebEngineFileDialogRequest.dialogAccept(QStringList) --> void"
<< "QQuickWebEngineFileDialogRequest.dialogReject() --> void"
- << "QQuickWebEngineFileDialogRequest.mode --> FileMode"
+ << "QQuickWebEngineFileDialogRequest.mode --> QQuickWebEngineFileDialogRequest::FileMode"
<< "QWebEngineFindTextResult.numberOfMatches --> int"
<< "QWebEngineFindTextResult.activeMatch --> int"
- << "QQuickWebEngineFormValidationMessageRequest.Hide --> RequestType"
- << "QQuickWebEngineFormValidationMessageRequest.Move --> RequestType"
- << "QQuickWebEngineFormValidationMessageRequest.Show --> RequestType"
- << "QQuickWebEngineFormValidationMessageRequest.accepted --> bool"
- << "QQuickWebEngineFormValidationMessageRequest.anchor --> QRect"
- << "QQuickWebEngineFormValidationMessageRequest.subText --> QString"
- << "QQuickWebEngineFormValidationMessageRequest.text --> QString"
- << "QQuickWebEngineFormValidationMessageRequest.type --> RequestType"
<< "QQuickWebEngineTooltipRequest.Hide --> RequestType"
<< "QQuickWebEngineTooltipRequest.Show --> RequestType"
<< "QQuickWebEngineTooltipRequest.x --> int"
<< "QQuickWebEngineTooltipRequest.y --> int"
<< "QQuickWebEngineTooltipRequest.text --> QString"
- << "QQuickWebEngineTooltipRequest.type --> RequestType"
+ << "QQuickWebEngineTooltipRequest.type --> QQuickWebEngineTooltipRequest::RequestType"
<< "QQuickWebEngineTooltipRequest.accepted --> bool"
+ << "QWebEngineDesktopMediaRequest.screensModel --> QAbstractListModel*"
+ << "QWebEngineDesktopMediaRequest.windowsModel --> QAbstractListModel*"
+ << "QWebEngineDesktopMediaRequest.selectScreen(QModelIndex) --> void"
+ << "QWebEngineDesktopMediaRequest.selectWindow(QModelIndex) --> void"
+ << "QWebEngineDesktopMediaRequest.cancel() --> void"
<< "QWebEngineFullScreenRequest.accept() --> void"
<< "QWebEngineFullScreenRequest.origin --> QUrl"
<< "QWebEngineFullScreenRequest.reject() --> void"
<< "QWebEngineFullScreenRequest.toggleOn --> bool"
- << "QQuickWebEngineHistory.backItems --> QQuickWebEngineHistoryListModel*"
- << "QQuickWebEngineHistory.clear() --> void"
- << "QQuickWebEngineHistory.forwardItems --> QQuickWebEngineHistoryListModel*"
- << "QQuickWebEngineHistory.items --> QQuickWebEngineHistoryListModel*"
+ << "QWebEngineFileSystemAccessRequest.File --> HandleType"
+ << "QWebEngineFileSystemAccessRequest.Directory --> HandleType"
+ << "QWebEngineFileSystemAccessRequest.Read --> AccessFlags"
+ << "QWebEngineFileSystemAccessRequest.Write --> AccessFlags"
+ << "QWebEngineFileSystemAccessRequest.origin --> QUrl"
+ << "QWebEngineFileSystemAccessRequest.filePath --> QUrl"
+ << "QWebEngineFileSystemAccessRequest.handleType --> QWebEngineFileSystemAccessRequest::HandleType"
+ << "QWebEngineFileSystemAccessRequest.accessFlags --> QFlags<QWebEngineFileSystemAccessRequest::AccessFlag>"
+ << "QWebEngineFileSystemAccessRequest.accept() --> void"
+ << "QWebEngineFileSystemAccessRequest.reject() --> void"
+ << "QWebEngineHistory.backItems --> QWebEngineHistoryModel*"
+ << "QWebEngineHistory.clear() --> void"
+ << "QWebEngineHistory.forwardItems --> QWebEngineHistoryModel*"
+ << "QWebEngineHistory.items --> QWebEngineHistoryModel*"
<< "QQuickWebEngineJavaScriptDialogRequest.DialogTypeAlert --> DialogType"
<< "QQuickWebEngineJavaScriptDialogRequest.DialogTypeBeforeUnload --> DialogType"
<< "QQuickWebEngineJavaScriptDialogRequest.DialogTypeConfirm --> DialogType"
@@ -310,57 +313,121 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineJavaScriptDialogRequest.message --> QString"
<< "QQuickWebEngineJavaScriptDialogRequest.securityOrigin --> QUrl"
<< "QQuickWebEngineJavaScriptDialogRequest.title --> QString"
- << "QQuickWebEngineJavaScriptDialogRequest.type --> DialogType"
- << "QQuickWebEngineLoadRequest.errorCode --> int"
- << "QQuickWebEngineLoadRequest.errorDomain --> QQuickWebEngineView::ErrorDomain"
- << "QQuickWebEngineLoadRequest.errorString --> QString"
- << "QQuickWebEngineLoadRequest.status --> QQuickWebEngineView::LoadStatus"
- << "QQuickWebEngineLoadRequest.url --> QUrl"
- << "QQuickWebEngineNavigationRequest.action --> QQuickWebEngineView::NavigationRequestAction"
- << "QQuickWebEngineNavigationRequest.actionChanged() --> void"
- << "QQuickWebEngineNavigationRequest.isMainFrame --> bool"
- << "QQuickWebEngineNavigationRequest.navigationType --> QQuickWebEngineView::NavigationType"
- << "QQuickWebEngineNavigationRequest.url --> QUrl"
- << "QQuickWebEngineNewViewRequest.destination --> QQuickWebEngineView::NewViewDestination"
- << "QQuickWebEngineNewViewRequest.openIn(QQuickWebEngineView*) --> void"
- << "QQuickWebEngineNewViewRequest.requestedUrl --> QUrl"
- << "QQuickWebEngineNewViewRequest.userInitiated --> bool"
+ << "QQuickWebEngineJavaScriptDialogRequest.type --> QQuickWebEngineJavaScriptDialogRequest::DialogType"
+ << "QWebEngineLoadingInfo.errorCode --> int"
+ << "QWebEngineLoadingInfo.responseHeaders --> QMultiMap<QByteArray,QByteArray>"
+ << "QWebEngineLoadingInfo.errorDomain --> QWebEngineLoadingInfo::ErrorDomain"
+ << "QWebEngineLoadingInfo.errorString --> QString"
+ << "QWebEngineLoadingInfo.status --> QWebEngineLoadingInfo::LoadStatus"
+ << "QWebEngineLoadingInfo.url --> QUrl"
+ << "QWebEngineLoadingInfo.isErrorPage --> bool"
+ << "QWebEngineLoadingInfo.LoadFailedStatus --> LoadStatus"
+ << "QWebEngineLoadingInfo.LoadStartedStatus --> LoadStatus"
+ << "QWebEngineLoadingInfo.LoadStoppedStatus --> LoadStatus"
+ << "QWebEngineLoadingInfo.LoadSucceededStatus --> LoadStatus"
+ << "QWebEngineLoadingInfo.HttpStatusCodeDomain --> ErrorDomain"
+ << "QWebEngineLoadingInfo.CertificateErrorDomain --> ErrorDomain"
+ << "QWebEngineLoadingInfo.ConnectionErrorDomain --> ErrorDomain"
+ << "QWebEngineLoadingInfo.DnsErrorDomain --> ErrorDomain"
+ << "QWebEngineLoadingInfo.FtpErrorDomain --> ErrorDomain"
+ << "QWebEngineLoadingInfo.HttpErrorDomain --> ErrorDomain"
+ << "QWebEngineLoadingInfo.InternalErrorDomain --> ErrorDomain"
+ << "QWebEngineLoadingInfo.NoErrorDomain --> ErrorDomain"
+ << "QWebEngineNavigationRequest.action --> QWebEngineNavigationRequest::NavigationRequestAction"
+ << "QWebEngineNavigationRequest.actionChanged() --> void"
+ << "QWebEngineNavigationRequest.isMainFrame --> bool"
+ << "QWebEngineNavigationRequest.hasFormData --> bool"
+ << "QWebEngineNavigationRequest.navigationType --> QWebEngineNavigationRequest::NavigationType"
+ << "QWebEngineNavigationRequest.url --> QUrl"
+ << "QWebEngineNavigationRequest.AcceptRequest --> NavigationRequestAction"
+ << "QWebEngineNavigationRequest.IgnoreRequest --> NavigationRequestAction"
+ << "QWebEngineNavigationRequest.BackForwardNavigation --> NavigationType"
+ << "QWebEngineNavigationRequest.FormSubmittedNavigation --> NavigationType"
+ << "QWebEngineNavigationRequest.LinkClickedNavigation --> NavigationType"
+ << "QWebEngineNavigationRequest.OtherNavigation --> NavigationType"
+ << "QWebEngineNavigationRequest.RedirectNavigation --> NavigationType"
+ << "QWebEngineNavigationRequest.ReloadNavigation --> NavigationType"
+ << "QWebEngineNavigationRequest.TypedNavigation --> NavigationType"
+ << "QWebEngineNavigationRequest.accept() --> void"
+ << "QWebEngineNavigationRequest.reject() --> void"
+ << "QWebEngineNewWindowRequest.destination --> QWebEngineNewWindowRequest::DestinationType"
+ << "QWebEngineNewWindowRequest.requestedUrl --> QUrl"
+ << "QWebEngineNewWindowRequest.requestedGeometry --> QRect"
+ << "QWebEngineNewWindowRequest.userInitiated --> bool"
+ << "QWebEngineNewWindowRequest.InNewBackgroundTab --> DestinationType"
+ << "QWebEngineNewWindowRequest.InNewDialog --> DestinationType"
+ << "QWebEngineNewWindowRequest.InNewTab --> DestinationType"
+ << "QWebEngineNewWindowRequest.InNewWindow --> DestinationType"
+ << "QWebEnginePermission.Unsupported --> Feature"
+ << "QWebEnginePermission.MediaAudioCapture --> Feature"
+ << "QWebEnginePermission.MediaVideoCapture --> Feature"
+ << "QWebEnginePermission.MediaAudioVideoCapture --> Feature"
+ << "QWebEnginePermission.DesktopVideoCapture --> Feature"
+ << "QWebEnginePermission.DesktopAudioVideoCapture --> Feature"
+ << "QWebEnginePermission.MouseLock --> Feature"
+ << "QWebEnginePermission.Notifications --> Feature"
+ << "QWebEnginePermission.Geolocation --> Feature"
+ << "QWebEnginePermission.ClipboardReadWrite --> Feature"
+ << "QWebEnginePermission.LocalFontsAccess --> Feature"
+ << "QWebEnginePermission.Invalid --> State"
+ << "QWebEnginePermission.Ask --> State"
+ << "QWebEnginePermission.Granted --> State"
+ << "QWebEnginePermission.Denied --> State"
+ << "QWebEnginePermission.origin --> QUrl"
+ << "QWebEnginePermission.feature --> QWebEnginePermission::Feature"
+ << "QWebEnginePermission.state --> QWebEnginePermission::State"
+ << "QWebEnginePermission.isValid --> bool"
+ << "QWebEnginePermission.grant() --> void"
+ << "QWebEnginePermission.deny() --> void"
+ << "QWebEnginePermission.reset() --> void"
+ << "QWebEnginePermission.isTransient(QWebEnginePermission::Feature) --> bool"
+ << "QQuickWebEngineNewWindowRequest.openIn(QQuickWebEngineView*) --> void"
<< "QQuickWebEngineProfile.AllowPersistentCookies --> PersistentCookiesPolicy"
<< "QQuickWebEngineProfile.DiskHttpCache --> HttpCacheType"
<< "QQuickWebEngineProfile.ForcePersistentCookies --> PersistentCookiesPolicy"
<< "QQuickWebEngineProfile.MemoryHttpCache --> HttpCacheType"
<< "QQuickWebEngineProfile.NoCache --> HttpCacheType"
<< "QQuickWebEngineProfile.NoPersistentCookies --> PersistentCookiesPolicy"
+ << "QQuickWebEngineProfile.NoPersistentPermissions --> PersistentPermissionsPolicy"
+ << "QQuickWebEngineProfile.PersistentPermissionsInMemory --> PersistentPermissionsPolicy"
+ << "QQuickWebEngineProfile.PersistentPermissionsOnDisk --> PersistentPermissionsPolicy"
<< "QQuickWebEngineProfile.cachePath --> QString"
<< "QQuickWebEngineProfile.cachePathChanged() --> void"
<< "QQuickWebEngineProfile.clearHttpCache() --> void"
- << "QQuickWebEngineProfile.downloadFinished(QWebEngineDownloadRequest*) --> void"
- << "QQuickWebEngineProfile.downloadRequested(QWebEngineDownloadRequest*) --> void"
+ << "QQuickWebEngineProfile.clearHttpCacheCompleted() --> void"
+ << "QQuickWebEngineProfile.downloadFinished(QQuickWebEngineDownloadRequest*) --> void"
+ << "QQuickWebEngineProfile.downloadRequested(QQuickWebEngineDownloadRequest*) --> void"
<< "QQuickWebEngineProfile.downloadPath --> QString"
<< "QQuickWebEngineProfile.downloadPathChanged() --> void"
+ << "QQuickWebEngineProfile.getPermission(QUrl,QWebEnginePermission::Feature) --> QWebEnginePermission"
+ << "QQuickWebEngineProfile.listPermissions() --> QList<QWebEnginePermission>"
+ << "QQuickWebEngineProfile.listPermissions(QUrl) --> QList<QWebEnginePermission>"
+ << "QQuickWebEngineProfile.listPermissions(QWebEnginePermission::Feature) --> QList<QWebEnginePermission>"
+ << "QQuickWebEngineProfile.persistentPermissionsPolicy --> QQuickWebEngineProfile::PersistentPermissionsPolicy"
+ << "QQuickWebEngineProfile.persistentPermissionsPolicyChanged() --> void"
<< "QQuickWebEngineProfile.presentNotification(QWebEngineNotification*) --> void"
<< "QQuickWebEngineProfile.httpAcceptLanguage --> QString"
<< "QQuickWebEngineProfile.httpAcceptLanguageChanged() --> void"
<< "QQuickWebEngineProfile.httpCacheMaximumSize --> int"
<< "QQuickWebEngineProfile.httpCacheMaximumSizeChanged() --> void"
- << "QQuickWebEngineProfile.httpCacheType --> HttpCacheType"
+ << "QQuickWebEngineProfile.httpCacheType --> QQuickWebEngineProfile::HttpCacheType"
<< "QQuickWebEngineProfile.httpCacheTypeChanged() --> void"
<< "QQuickWebEngineProfile.httpUserAgent --> QString"
<< "QQuickWebEngineProfile.httpUserAgentChanged() --> void"
<< "QQuickWebEngineProfile.offTheRecord --> bool"
<< "QQuickWebEngineProfile.offTheRecordChanged() --> void"
- << "QQuickWebEngineProfile.persistentCookiesPolicy --> PersistentCookiesPolicy"
+ << "QQuickWebEngineProfile.persistentCookiesPolicy --> QQuickWebEngineProfile::PersistentCookiesPolicy"
<< "QQuickWebEngineProfile.persistentCookiesPolicyChanged() --> void"
<< "QQuickWebEngineProfile.persistentStoragePath --> QString"
<< "QQuickWebEngineProfile.persistentStoragePathChanged() --> void"
+ << "QQuickWebEngineProfile.isPushServiceEnabled --> bool"
+ << "QQuickWebEngineProfile.pushServiceEnabledChanged() --> void"
<< "QQuickWebEngineProfile.spellCheckEnabled --> bool"
<< "QQuickWebEngineProfile.spellCheckEnabledChanged() --> void"
<< "QQuickWebEngineProfile.spellCheckLanguages --> QStringList"
<< "QQuickWebEngineProfile.spellCheckLanguagesChanged() --> void"
<< "QQuickWebEngineProfile.storageName --> QString"
<< "QQuickWebEngineProfile.storageNameChanged() --> void"
- << "QQuickWebEngineProfile.useForGlobalCertificateVerification --> bool"
- << "QQuickWebEngineProfile.useForGlobalCertificateVerificationChanged() --> void"
<< "QQuickWebEngineProfile.userScripts --> QQuickWebEngineScriptCollection*"
<< "QQuickWebEngineSettings.AllowAllUnknownUrlSchemes --> UnknownUrlSchemePolicy"
<< "QQuickWebEngineSettings.AllowUnknownUrlSchemesFromUserInteraction --> UnknownUrlSchemePolicy"
@@ -383,6 +450,10 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineSettings.dnsPrefetchEnabledChanged() --> void"
<< "QQuickWebEngineSettings.errorPageEnabled --> bool"
<< "QQuickWebEngineSettings.errorPageEnabledChanged() --> void"
+ << "QQuickWebEngineSettings.forceDarkMode --> bool"
+ << "QQuickWebEngineSettings.forceDarkModeChanged() --> void"
+ << "QQuickWebEngineSettings.scrollAnimatorEnabled --> bool"
+ << "QQuickWebEngineSettings.scrollAnimatorEnabledChanged() --> void"
<< "QQuickWebEngineSettings.focusOnNavigationEnabled --> bool"
<< "QQuickWebEngineSettings.focusOnNavigationEnabledChanged() --> void"
<< "QQuickWebEngineSettings.fullScreenSupportEnabled --> bool"
@@ -405,6 +476,8 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineSettings.localContentCanAccessRemoteUrlsChanged() --> void"
<< "QQuickWebEngineSettings.localStorageEnabled --> bool"
<< "QQuickWebEngineSettings.localStorageEnabledChanged() --> void"
+ << "QQuickWebEngineSettings.navigateOnDropEnabled --> bool"
+ << "QQuickWebEngineSettings.navigateOnDropEnabledChanged() --> void"
<< "QQuickWebEngineSettings.pdfViewerEnabled --> bool"
<< "QQuickWebEngineSettings.pdfViewerEnabledChanged() --> void"
<< "QQuickWebEngineSettings.playbackRequiresUserGesture --> bool"
@@ -421,22 +494,30 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineSettings.spatialNavigationEnabledChanged() --> void"
<< "QQuickWebEngineSettings.touchIconsEnabled --> bool"
<< "QQuickWebEngineSettings.touchIconsEnabledChanged() --> void"
- << "QQuickWebEngineSettings.unknownUrlSchemePolicy --> UnknownUrlSchemePolicy"
+ << "QQuickWebEngineSettings.unknownUrlSchemePolicy --> QQuickWebEngineSettings::UnknownUrlSchemePolicy"
<< "QQuickWebEngineSettings.unknownUrlSchemePolicyChanged() --> void"
<< "QQuickWebEngineSettings.webGLEnabled --> bool"
<< "QQuickWebEngineSettings.webGLEnabledChanged() --> void"
<< "QQuickWebEngineSettings.webRTCPublicInterfacesOnly --> bool"
<< "QQuickWebEngineSettings.webRTCPublicInterfacesOnlyChanged() --> void"
+ << "QQuickWebEngineSettings.readingFromCanvasEnabled --> bool"
+ << "QQuickWebEngineSettings.readingFromCanvasEnabledChanged() --> void"
<< "QQuickWebEngineSingleton.defaultProfile --> QQuickWebEngineProfile*"
<< "QQuickWebEngineSingleton.settings --> QQuickWebEngineSettings*"
<< "QQuickWebEngineSingleton.script() --> QWebEngineScript"
+ << "QQuickWebEngineTouchSelectionMenuRequest.accepted --> bool"
+ << "QQuickWebEngineTouchSelectionMenuRequest.Cut --> TouchSelectionCommandFlags"
+ << "QQuickWebEngineTouchSelectionMenuRequest.Copy --> TouchSelectionCommandFlags"
+ << "QQuickWebEngineTouchSelectionMenuRequest.Paste --> TouchSelectionCommandFlags"
+ << "QQuickWebEngineTouchSelectionMenuRequest.selectionBounds --> QRect"
+ << "QQuickWebEngineTouchSelectionMenuRequest.touchSelectionCommandFlags --> QFlags<QQuickWebEngineTouchSelectionMenuRequest::TouchSelectionCommandFlag>"
<< "QWebEngineScript.ApplicationWorld --> ScriptWorldId"
<< "QWebEngineScript.Deferred --> InjectionPoint"
<< "QWebEngineScript.DocumentCreation --> InjectionPoint"
<< "QWebEngineScript.DocumentReady --> InjectionPoint"
<< "QWebEngineScript.MainWorld --> ScriptWorldId"
<< "QWebEngineScript.UserWorld --> ScriptWorldId"
- << "QWebEngineScript.injectionPoint --> InjectionPoint"
+ << "QWebEngineScript.injectionPoint --> QWebEngineScript::InjectionPoint"
<< "QWebEngineScript.name --> QString"
<< "QWebEngineScript.runsOnSubFrames --> bool"
<< "QWebEngineScript.sourceCode --> QString"
@@ -445,7 +526,6 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.action(WebAction) --> QQuickWebEngineAction*"
<< "QQuickWebEngineView.A0 --> PrintedPageSizeId"
<< "QQuickWebEngineView.A1 --> PrintedPageSizeId"
- << "QQuickWebEngineView.A10 --> PrintedPageSizeId"
<< "QQuickWebEngineView.A2 --> PrintedPageSizeId"
<< "QQuickWebEngineView.A3 --> PrintedPageSizeId"
<< "QQuickWebEngineView.A3Extra --> PrintedPageSizeId"
@@ -459,8 +539,8 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.A7 --> PrintedPageSizeId"
<< "QQuickWebEngineView.A8 --> PrintedPageSizeId"
<< "QQuickWebEngineView.A9 --> PrintedPageSizeId"
+ << "QQuickWebEngineView.A10 --> PrintedPageSizeId"
<< "QQuickWebEngineView.AbnormalTerminationStatus --> RenderProcessTerminationStatus"
- << "QQuickWebEngineView.AcceptRequest --> NavigationRequestAction"
<< "QQuickWebEngineView.AlignCenter --> WebAction"
<< "QQuickWebEngineView.AlignJustified --> WebAction"
<< "QQuickWebEngineView.AlignLeft --> WebAction"
@@ -477,7 +557,6 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.ArchE --> PrintedPageSizeId"
<< "QQuickWebEngineView.B0 --> PrintedPageSizeId"
<< "QQuickWebEngineView.B1 --> PrintedPageSizeId"
- << "QQuickWebEngineView.B10 --> PrintedPageSizeId"
<< "QQuickWebEngineView.B2 --> PrintedPageSizeId"
<< "QQuickWebEngineView.B3 --> PrintedPageSizeId"
<< "QQuickWebEngineView.B4 --> PrintedPageSizeId"
@@ -487,10 +566,23 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.B7 --> PrintedPageSizeId"
<< "QQuickWebEngineView.B8 --> PrintedPageSizeId"
<< "QQuickWebEngineView.B9 --> PrintedPageSizeId"
+ << "QQuickWebEngineView.B10 --> PrintedPageSizeId"
<< "QQuickWebEngineView.Back --> WebAction"
- << "QQuickWebEngineView.BackForwardNavigation --> NavigationType"
<< "QQuickWebEngineView.C5E --> PrintedPageSizeId"
+#if QT_DEPRECATED_SINCE(6, 8)
+ << "QQuickWebEngineView.ClipboardReadWrite --> Feature"
+ << "QQuickWebEngineView.DesktopAudioVideoCapture --> Feature"
+ << "QQuickWebEngineView.DesktopVideoCapture --> Feature"
+ << "QQuickWebEngineView.Geolocation --> Feature"
+ << "QQuickWebEngineView.LocalFontsAccess --> Feature"
+ << "QQuickWebEngineView.MediaAudioCapture --> Feature"
+ << "QQuickWebEngineView.MediaAudioVideoCapture --> Feature"
+ << "QQuickWebEngineView.MediaVideoCapture --> Feature"
+ << "QQuickWebEngineView.Notifications --> Feature"
+#endif
<< "QQuickWebEngineView.CertificateErrorDomain --> ErrorDomain"
+ << "QQuickWebEngineView.ChangeTextDirectionLTR --> WebAction"
+ << "QQuickWebEngineView.ChangeTextDirectionRTL --> WebAction"
<< "QQuickWebEngineView.Comm10E --> PrintedPageSizeId"
<< "QQuickWebEngineView.ConnectionErrorDomain --> ErrorDomain"
<< "QQuickWebEngineView.Copy --> WebAction"
@@ -502,8 +594,6 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.Custom --> PrintedPageSizeId"
<< "QQuickWebEngineView.Cut --> WebAction"
<< "QQuickWebEngineView.DLE --> PrintedPageSizeId"
- << "QQuickWebEngineView.DesktopAudioVideoCapture --> Feature"
- << "QQuickWebEngineView.DesktopVideoCapture --> Feature"
<< "QQuickWebEngineView.DnsErrorDomain --> ErrorDomain"
<< "QQuickWebEngineView.DoublePostcard --> PrintedPageSizeId"
<< "QQuickWebEngineView.DownloadImageToDisk --> WebAction"
@@ -556,12 +646,9 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.FindBackward --> FindFlags"
<< "QQuickWebEngineView.FindCaseSensitively --> FindFlags"
<< "QQuickWebEngineView.Folio --> PrintedPageSizeId"
- << "QQuickWebEngineView.FormSubmittedNavigation --> NavigationType"
<< "QQuickWebEngineView.Forward --> WebAction"
<< "QQuickWebEngineView.FtpErrorDomain --> ErrorDomain"
- << "QQuickWebEngineView.Geolocation --> Feature"
<< "QQuickWebEngineView.HttpErrorDomain --> ErrorDomain"
- << "QQuickWebEngineView.IgnoreRequest --> NavigationRequestAction"
<< "QQuickWebEngineView.Imperial10x11 --> PrintedPageSizeId"
<< "QQuickWebEngineView.Imperial10x13 --> PrintedPageSizeId"
<< "QQuickWebEngineView.Imperial10x14 --> PrintedPageSizeId"
@@ -601,29 +688,17 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.LifecycleState.Active --> LifecycleState"
<< "QQuickWebEngineView.LifecycleState.Discarded --> LifecycleState"
<< "QQuickWebEngineView.LifecycleState.Frozen --> LifecycleState"
- << "QQuickWebEngineView.LinkClickedNavigation --> NavigationType"
<< "QQuickWebEngineView.LoadFailedStatus --> LoadStatus"
<< "QQuickWebEngineView.LoadStartedStatus --> LoadStatus"
<< "QQuickWebEngineView.LoadStoppedStatus --> LoadStatus"
<< "QQuickWebEngineView.LoadSucceededStatus --> LoadStatus"
- << "QQuickWebEngineView.MediaAudioCapture --> Feature"
- << "QQuickWebEngineView.MediaAudioVideoCapture --> Feature"
- << "QQuickWebEngineView.MediaVideoCapture --> Feature"
- << "QQuickWebEngineView.NPageSize --> PrintedPageSizeId"
- << "QQuickWebEngineView.NPaperSize --> PrintedPageSizeId"
- << "QQuickWebEngineView.NewViewInBackgroundTab --> NewViewDestination"
- << "QQuickWebEngineView.NewViewInDialog --> NewViewDestination"
- << "QQuickWebEngineView.NewViewInTab --> NewViewDestination"
- << "QQuickWebEngineView.NewViewInWindow --> NewViewDestination"
<< "QQuickWebEngineView.NoErrorDomain --> ErrorDomain"
- << "QQuickWebEngineView.Notifications --> Feature"
<< "QQuickWebEngineView.NoWebAction --> WebAction"
<< "QQuickWebEngineView.NormalTerminationStatus --> RenderProcessTerminationStatus"
<< "QQuickWebEngineView.Note --> PrintedPageSizeId"
<< "QQuickWebEngineView.OpenLinkInNewTab --> WebAction"
<< "QQuickWebEngineView.OpenLinkInNewWindow --> WebAction"
<< "QQuickWebEngineView.OpenLinkInThisWindow --> WebAction"
- << "QQuickWebEngineView.OtherNavigation --> NavigationType"
<< "QQuickWebEngineView.Outdent --> WebAction"
<< "QQuickWebEngineView.Paste --> WebAction"
<< "QQuickWebEngineView.PasteAndMatchStyle --> WebAction"
@@ -633,11 +708,9 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.Prc32K --> PrintedPageSizeId"
<< "QQuickWebEngineView.Prc32KBig --> PrintedPageSizeId"
<< "QQuickWebEngineView.Quarto --> PrintedPageSizeId"
- << "QQuickWebEngineView.RedirectNavigation --> NavigationType"
<< "QQuickWebEngineView.Redo --> WebAction"
<< "QQuickWebEngineView.Reload --> WebAction"
<< "QQuickWebEngineView.ReloadAndBypassCache --> WebAction"
- << "QQuickWebEngineView.ReloadNavigation --> NavigationType"
<< "QQuickWebEngineView.RequestClose --> WebAction"
<< "QQuickWebEngineView.SavePage --> WebAction"
<< "QQuickWebEngineView.SelectAll --> WebAction"
@@ -655,9 +728,9 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.ToggleMediaPlayPause --> WebAction"
<< "QQuickWebEngineView.ToggleStrikethrough --> WebAction"
<< "QQuickWebEngineView.ToggleUnderline --> WebAction"
- << "QQuickWebEngineView.TypedNavigation --> NavigationType"
<< "QQuickWebEngineView.Undo --> WebAction"
<< "QQuickWebEngineView.Unselect --> WebAction"
+ << "QQuickWebEngineView.OpenLinkInNewBackgroundTab --> WebAction"
<< "QQuickWebEngineView.ViewSource --> WebAction"
<< "QQuickWebEngineView.WarningMessageLevel --> JavaScriptConsoleMessageLevel"
<< "QQuickWebEngineView.WebActionCount --> WebAction"
@@ -669,50 +742,73 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.backgroundColor --> QColor"
<< "QQuickWebEngineView.backgroundColorChanged() --> void"
<< "QQuickWebEngineView.canGoBack --> bool"
+ << "QQuickWebEngineView.canGoBackChanged() --> void"
<< "QQuickWebEngineView.canGoForward --> bool"
+ << "QQuickWebEngineView.canGoForwardChanged() --> void"
<< "QQuickWebEngineView.certificateError(QWebEngineCertificateError) --> void"
<< "QQuickWebEngineView.colorDialogRequested(QQuickWebEngineColorDialogRequest*) --> void"
<< "QQuickWebEngineView.contentsSize --> QSizeF"
<< "QQuickWebEngineView.contentsSizeChanged(QSizeF) --> void"
<< "QQuickWebEngineView.contextMenuRequested(QWebEngineContextMenuRequest*) --> void"
+ << "QQuickWebEngineView.desktopMediaRequested(QWebEngineDesktopMediaRequest) --> void"
+ << "QQuickWebEngineView.devToolsId --> QString"
<< "QQuickWebEngineView.devToolsView --> QQuickWebEngineView*"
<< "QQuickWebEngineView.devToolsViewChanged() --> void"
- << "QQuickWebEngineView.featurePermissionRequested(QUrl,Feature) --> void"
+ << "QQuickWebEngineView.featurePermissionRequested(QUrl,QQuickWebEngineView::Feature) --> void"
<< "QQuickWebEngineView.fileDialogRequested(QQuickWebEngineFileDialogRequest*) --> void"
+ << "QQuickWebEngineView.fileSystemAccessRequested(QWebEngineFileSystemAccessRequest) --> void"
+ << "QQuickWebEngineView.findFrameByName(QString) --> QWebEngineFrame"
<< "QQuickWebEngineView.findText(QString) --> void"
<< "QQuickWebEngineView.findText(QString,FindFlags) --> void"
<< "QQuickWebEngineView.findText(QString,FindFlags,QJSValue) --> void"
<< "QQuickWebEngineView.findTextFinished(QWebEngineFindTextResult) --> void"
- << "QQuickWebEngineView.formValidationMessageRequested(QQuickWebEngineFormValidationMessageRequest*) --> void"
<< "QQuickWebEngineView.fullScreenCancelled() --> void"
<< "QQuickWebEngineView.fullScreenRequested(QWebEngineFullScreenRequest) --> void"
<< "QQuickWebEngineView.geometryChangeRequested(QRect,QRect) --> void"
<< "QQuickWebEngineView.goBack() --> void"
<< "QQuickWebEngineView.goBackOrForward(int) --> void"
<< "QQuickWebEngineView.goForward() --> void"
- << "QQuickWebEngineView.grantFeaturePermission(QUrl,Feature,bool) --> void"
+#if QT_DEPRECATED_SINCE(6, 8)
+ << "QQuickWebEngineView.grantFeaturePermission(QUrl,QQuickWebEngineView::Feature,bool) --> void"
+#endif
+ << "QQuickWebEngineView.history --> QWebEngineHistory*"
<< "QQuickWebEngineView.icon --> QUrl"
<< "QQuickWebEngineView.iconChanged() --> void"
<< "QQuickWebEngineView.inspectedView --> QQuickWebEngineView*"
<< "QQuickWebEngineView.inspectedViewChanged() --> void"
<< "QQuickWebEngineView.isFullScreen --> bool"
<< "QQuickWebEngineView.isFullScreenChanged() --> void"
- << "QQuickWebEngineView.javaScriptConsoleMessage(JavaScriptConsoleMessageLevel,QString,int,QString) --> void"
+ << "QQuickWebEngineView.javaScriptConsoleMessage(QQuickWebEngineView::JavaScriptConsoleMessageLevel,QString,int,QString) --> void"
<< "QQuickWebEngineView.javaScriptDialogRequested(QQuickWebEngineJavaScriptDialogRequest*) --> void"
- << "QQuickWebEngineView.lifecycleState --> LifecycleState"
- << "QQuickWebEngineView.lifecycleStateChanged(LifecycleState) --> void"
+ << "QQuickWebEngineView.lifecycleState --> QQuickWebEngineView::LifecycleState"
+ << "QQuickWebEngineView.lifecycleStateChanged(QQuickWebEngineView::LifecycleState) --> void"
<< "QQuickWebEngineView.linkHovered(QUrl) --> void"
<< "QQuickWebEngineView.loadHtml(QString) --> void"
<< "QQuickWebEngineView.loadHtml(QString,QUrl) --> void"
<< "QQuickWebEngineView.loadProgress --> int"
<< "QQuickWebEngineView.loadProgressChanged() --> void"
<< "QQuickWebEngineView.loading --> bool"
- << "QQuickWebEngineView.loadingChanged(QQuickWebEngineLoadRequest*) --> void"
- << "QQuickWebEngineView.navigationHistory --> QQuickWebEngineHistory*"
- << "QQuickWebEngineView.navigationRequested(QQuickWebEngineNavigationRequest*) --> void"
- << "QQuickWebEngineView.newViewRequested(QQuickWebEngineNewViewRequest*) --> void"
+ << "QQuickWebEngineView.loadingChanged(QWebEngineLoadingInfo) --> void"
+ << "QQuickWebEngineView.mainFrame --> QWebEngineFrame"
+ << "QQuickWebEngineView.navigationRequested(QWebEngineNavigationRequest*) --> void"
+ << "QQuickWebEngineView.newWindowRequested(QQuickWebEngineNewWindowRequest*) --> void"
+ << "QQuickWebEngineView.AcceptRequest --> NavigationRequestAction"
+ << "QQuickWebEngineView.IgnoreRequest --> NavigationRequestAction"
+ << "QQuickWebEngineView.BackForwardNavigation --> NavigationType"
+ << "QQuickWebEngineView.FormSubmittedNavigation --> NavigationType"
+ << "QQuickWebEngineView.LinkClickedNavigation --> NavigationType"
+ << "QQuickWebEngineView.OtherNavigation --> NavigationType"
+ << "QQuickWebEngineView.RedirectNavigation --> NavigationType"
+ << "QQuickWebEngineView.ReloadNavigation --> NavigationType"
+ << "QQuickWebEngineView.TypedNavigation --> NavigationType"
+ << "QQuickWebEngineView.NewViewInBackgroundTab --> NewViewDestination"
+ << "QQuickWebEngineView.NewViewInDialog --> NewViewDestination"
+ << "QQuickWebEngineView.NewViewInTab --> NewViewDestination"
+ << "QQuickWebEngineView.NewViewInWindow --> NewViewDestination"
+ << "QQuickWebEngineView.permissionRequested(QWebEnginePermission) --> void"
<< "QQuickWebEngineView.pdfPrintingFinished(QString,bool) --> void"
<< "QQuickWebEngineView.printRequested() --> void"
+ << "QQuickWebEngineView.printRequestedByFrame(QWebEngineFrame) --> void"
<< "QQuickWebEngineView.printToPdf(QJSValue) --> void"
<< "QQuickWebEngineView.printToPdf(QJSValue,PrintedPageSizeId) --> void"
<< "QQuickWebEngineView.printToPdf(QJSValue,PrintedPageSizeId,PrintedPageOrientation) --> void"
@@ -726,12 +822,12 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.recentlyAudibleChanged(bool) --> void"
<< "QQuickWebEngineView.renderProcessPid --> qlonglong"
<< "QQuickWebEngineView.renderProcessPidChanged(qlonglong) --> void"
- << "QQuickWebEngineView.recommendedState --> LifecycleState"
- << "QQuickWebEngineView.recommendedStateChanged(LifecycleState) --> void"
+ << "QQuickWebEngineView.recommendedState --> QQuickWebEngineView::LifecycleState"
+ << "QQuickWebEngineView.recommendedStateChanged(QQuickWebEngineView::LifecycleState) --> void"
<< "QQuickWebEngineView.registerProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest) --> void"
<< "QQuickWebEngineView.reload() --> void"
<< "QQuickWebEngineView.reloadAndBypassCache() --> void"
- << "QQuickWebEngineView.renderProcessTerminated(RenderProcessTerminationStatus,int) --> void"
+ << "QQuickWebEngineView.renderProcessTerminated(QQuickWebEngineView::RenderProcessTerminationStatus,int) --> void"
<< "QQuickWebEngineView.replaceMisspelledWord(QString) --> void"
<< "QQuickWebEngineView.runJavaScript(QString) --> void"
<< "QQuickWebEngineView.runJavaScript(QString,QJSValue) --> void"
@@ -743,13 +839,12 @@ static const QStringList expectedAPI = QStringList()
<< "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"
+ << "QQuickWebEngineView.touchHandleDelegate --> QQmlComponent*"
+ << "QQuickWebEngineView.touchHandleDelegateChanged() --> void"
+ << "QQuickWebEngineView.touchSelectionMenuRequested(QQuickWebEngineTouchSelectionMenuRequest*) --> void"
<< "QQuickWebEngineView.triggerWebAction(WebAction) --> void"
<< "QQuickWebEngineView.url --> QUrl"
<< "QQuickWebEngineView.urlChanged() --> void"
@@ -763,6 +858,9 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.windowCloseRequested() --> void"
<< "QQuickWebEngineView.zoomFactor --> double"
<< "QQuickWebEngineView.zoomFactorChanged(double) --> void"
+ << "QQuickWebEngineView.acceptAsNewWindow(QWebEngineNewWindowRequest*) --> void"
+ << "QQuickWebEngineView.save(QString) --> void"
+ << "QQuickWebEngineView.save(QString,QWebEngineDownloadRequest::SavePageFormat) --> void"
<< "QWebEngineQuotaRequest.accept() --> void"
<< "QWebEngineQuotaRequest.origin --> QUrl"
<< "QWebEngineQuotaRequest.reject() --> void"
@@ -781,26 +879,84 @@ static const QStringList expectedAPI = QStringList()
<< "QWebEngineNotification.click() --> void"
<< "QWebEngineNotification.close() --> void"
<< "QWebEngineNotification.closed() --> void"
+ << "QQuickWebEngineView.webAuthUxRequested(QWebEngineWebAuthUxRequest*) --> void"
+ << "QWebEngineWebAuthUxRequest.WebAuthUxState.NotStarted --> WebAuthUxState"
+ << "QWebEngineWebAuthUxRequest.WebAuthUxState.SelectAccount --> WebAuthUxState"
+ << "QWebEngineWebAuthUxRequest.WebAuthUxState.CollectPin --> WebAuthUxState"
+ << "QWebEngineWebAuthUxRequest.WebAuthUxState.FinishTokenCollection --> WebAuthUxState"
+ << "QWebEngineWebAuthUxRequest.WebAuthUxState.RequestFailed --> WebAuthUxState"
+ << "QWebEngineWebAuthUxRequest.WebAuthUxState.Cancelled --> WebAuthUxState"
+ << "QWebEngineWebAuthUxRequest.WebAuthUxState.Completed --> WebAuthUxState"
+ << "QWebEngineWebAuthUxRequest.PinEntryReason.Set --> PinEntryReason"
+ << "QWebEngineWebAuthUxRequest.PinEntryReason.Change --> PinEntryReason"
+ << "QWebEngineWebAuthUxRequest.PinEntryReason.Challenge --> PinEntryReason"
+ << "QWebEngineWebAuthUxRequest.PinEntryError.NoError --> PinEntryError"
+ << "QWebEngineWebAuthUxRequest.PinEntryError.InternalUvLocked --> PinEntryError"
+ << "QWebEngineWebAuthUxRequest.PinEntryError.WrongPin --> PinEntryError"
+ << "QWebEngineWebAuthUxRequest.PinEntryError.TooShort --> PinEntryError"
+ << "QWebEngineWebAuthUxRequest.PinEntryError.InvalidCharacters --> PinEntryError"
+ << "QWebEngineWebAuthUxRequest.PinEntryError.SameAsCurrentPin --> PinEntryError"
+ << "QWebEngineWebAuthUxRequest.RequestFailureReason.Timeout --> RequestFailureReason"
+ << "QWebEngineWebAuthUxRequest.RequestFailureReason.KeyNotRegistered --> RequestFailureReason"
+ << "QWebEngineWebAuthUxRequest.RequestFailureReason.KeyAlreadyRegistered --> RequestFailureReason"
+ << "QWebEngineWebAuthUxRequest.RequestFailureReason.SoftPinBlock --> RequestFailureReason"
+ << "QWebEngineWebAuthUxRequest.RequestFailureReason.HardPinBlock --> RequestFailureReason"
+ << "QWebEngineWebAuthUxRequest.RequestFailureReason.AuthenticatorRemovedDuringPinEntry --> RequestFailureReason"
+ << "QWebEngineWebAuthUxRequest.RequestFailureReason.AuthenticatorMissingResidentKeys --> RequestFailureReason"
+ << "QWebEngineWebAuthUxRequest.RequestFailureReason.AuthenticatorMissingUserVerification --> RequestFailureReason"
+ << "QWebEngineWebAuthUxRequest.RequestFailureReason.AuthenticatorMissingLargeBlob --> RequestFailureReason"
+ << "QWebEngineWebAuthUxRequest.RequestFailureReason.NoCommonAlgorithms --> RequestFailureReason"
+ << "QWebEngineWebAuthUxRequest.RequestFailureReason.StorageFull --> RequestFailureReason"
+ << "QWebEngineWebAuthUxRequest.RequestFailureReason.UserConsentDenied --> RequestFailureReason"
+ << "QWebEngineWebAuthUxRequest.RequestFailureReason.WinUserCancelled --> RequestFailureReason"
+ << "QWebEngineWebAuthUxRequest.userNames --> QStringList"
+ << "QWebEngineWebAuthUxRequest.state --> QWebEngineWebAuthUxRequest::WebAuthUxState"
+ << "QWebEngineWebAuthUxRequest.relyingPartyId --> QString"
+ << "QWebEngineWebAuthUxRequest.pinRequest --> QWebEngineWebAuthPinRequest"
+ << "QWebEngineWebAuthUxRequest.requestFailureReason --> QWebEngineWebAuthUxRequest::RequestFailureReason"
+ << "QWebEngineWebAuthUxRequest.stateChanged(QWebEngineWebAuthUxRequest::WebAuthUxState) --> void"
+ << "QWebEngineWebAuthUxRequest.cancel() --> void"
+ << "QWebEngineWebAuthUxRequest.retry() --> void"
+ << "QWebEngineWebAuthUxRequest.setSelectedAccount(QString) --> void"
+ << "QWebEngineWebAuthUxRequest.setPin(QString) --> void"
+ << "QWebEngineWebAuthPinRequest.reason --> QWebEngineWebAuthUxRequest::PinEntryReason"
+ << "QWebEngineWebAuthPinRequest.error --> QWebEngineWebAuthUxRequest::PinEntryError"
+ << "QWebEngineWebAuthPinRequest.minPinLength --> int"
+ << "QWebEngineWebAuthPinRequest.remainingAttempts --> int"
+ << "QQuickWebEngineSettings.AllowImageAnimation --> ImageAnimationPolicy"
+ << "QQuickWebEngineSettings.AnimateImageOnce --> ImageAnimationPolicy"
+ << "QQuickWebEngineSettings.DisallowImageAnimation --> ImageAnimationPolicy"
+ << "QQuickWebEngineSettings.imageAnimationPolicy --> QQuickWebEngineSettings::ImageAnimationPolicy"
+ << "QQuickWebEngineSettings.imageAnimationPolicyChanged() --> void"
+ << "QWebEngineFrame.htmlName --> QString"
+ << "QWebEngineFrame.isMainFrame --> bool"
+ << "QWebEngineFrame.isValid --> bool"
+ << "QWebEngineFrame.name --> QString"
+ << "QWebEngineFrame.printToPdf(QJSValue) --> void"
+ << "QWebEngineFrame.printToPdf(QString) --> void"
+ << "QWebEngineFrame.runJavaScript(QString) --> void"
+ << "QWebEngineFrame.runJavaScript(QString,uint) --> void"
+ << "QWebEngineFrame.runJavaScript(QString,QJSValue) --> void"
+ << "QWebEngineFrame.runJavaScript(QString,uint,QJSValue) --> void"
+ << "QWebEngineFrame.size --> QSizeF"
+ << "QWebEngineFrame.url --> QUrl"
;
-static bool isCheckedEnum(const QByteArray &typeName)
+static bool isCheckedEnum(QMetaType t)
{
- QList<QByteArray> tokens = typeName.split(':');
- if (tokens.size() == 3) {
- QByteArray &enumClass = tokens[0];
- QByteArray &enumName = tokens[2];
- for (const QMetaObject *mo : typesToCheck) {
- if (mo->className() != enumClass)
- continue;
- for (int i = mo->enumeratorOffset(); i < mo->enumeratorCount(); ++i)
- if (mo->enumerator(i).name() == enumName)
+ if (t.flags() & QMetaType::IsEnumeration) {
+ if (const QMetaObject *metaObject = t.metaObject()) {
+ QRegularExpression re("^QFlags<(.*)>$");
+ QRegularExpressionMatch match = re.match(t.name());
+ const QByteArray enumName =
+ match.hasMatch() ? match.captured(1).toUtf8() : QByteArray(t.name());
+ const char *lastColon = std::strrchr(enumName, ':');
+ QMetaEnum type = metaObject->enumerator(metaObject->indexOfEnumerator(
+ lastColon ? lastColon + 1 : enumName.constData()));
+ for (auto knownEnum : knownEnumNames) {
+ if (type.name() == knownEnum.name() && type.scope() == knownEnum.scope())
return true;
- }
- } else if (tokens.size() == 1) {
- QByteArray &enumName = tokens[0];
- for (const char *knownEnumName : qAsConst(knownEnumNames)) {
- if (enumName == knownEnumName)
- return true;
+ }
}
}
return false;
@@ -816,10 +972,12 @@ static bool isCheckedClass(const QByteArray &typeName)
return false;
}
-static void checkKnownType(const QByteArray &typeName)
+static void checkKnownType(const QMetaType &type)
{
- if ((!hardcodedTypes.contains(typeName) && !QMetaType::type(typeName)) || QMetaType::type(typeName) >= QMetaType::User) {
- bool knownEnum = isCheckedEnum(typeName);
+ const QByteArray typeName = type.name();
+ // calling id() registers the object
+ if (!hardcodedTypes.contains(typeName) && type.id() >= QMetaType::User) {
+ bool knownEnum = isCheckedEnum(type);
bool knownClass = isCheckedClass(typeName);
QVERIFY2(knownEnum || knownClass, qPrintable(QString("The API uses an unknown type [%1], you might have to add it to the typesToCheck list.").arg(typeName.constData())));
}
@@ -830,12 +988,13 @@ static void gatherAPI(const QString &prefix, const QMetaEnum &metaEnum, QStringL
const auto format = metaEnum.isScoped() ? "%1%3.%2 --> %3" : "%1%2 --> %3";
for (int i = 0; i < metaEnum.keyCount(); ++i)
*output << QString::fromLatin1(format).arg(prefix).arg(metaEnum.key(i)).arg(metaEnum.name());
+ knownEnumNames << metaEnum;
}
static void gatherAPI(const QString &prefix, const QMetaProperty &property, QStringList *output)
{
*output << QString::fromLatin1("%1%2 --> %3").arg(prefix).arg(property.name()).arg(property.typeName());
- checkKnownType(property.typeName());
+ checkKnownType(property.metaType());
}
static void gatherAPI(const QString &prefix, const QMetaMethod &method, QStringList *output)
@@ -844,20 +1003,21 @@ static void gatherAPI(const QString &prefix, const QMetaMethod &method, QStringL
const char *methodTypeName = !!strlen(method.typeName()) ? method.typeName() : "void";
*output << QString::fromLatin1("%1%2 --> %3").arg(prefix).arg(QString::fromLatin1(method.methodSignature())).arg(QString::fromLatin1(methodTypeName));
- checkKnownType(methodTypeName);
- const QList<QByteArray> paramTypes = method.parameterTypes();
- for (const QByteArray &paramType : paramTypes)
- checkKnownType(paramType);
+ checkKnownType(method.returnMetaType());
+
+ const auto parameterCount = method.parameterCount();
+ for (int i = 0; i < parameterCount; ++i) {
+ const QMetaType metaType = method.parameterMetaType(i);
+ checkKnownType(metaType);
+ }
}
}
static void gatherAPI(const QString &prefix, const QMetaObject *meta, QStringList *output)
{
// *Offset points us only at the leaf class members, we don't have inheritance in our API yet anyway.
- for (int i = meta->enumeratorOffset(); i < meta->enumeratorCount(); ++i) {
- knownEnumNames << meta->enumerator(i).name();
+ for (int i = meta->enumeratorOffset(); i < meta->enumeratorCount(); ++i)
gatherAPI(prefix, meta->enumerator(i), output);
- }
for (int i = meta->propertyOffset(); i < meta->propertyCount(); ++i)
gatherAPI(prefix, meta->property(i), output);
for (int i = meta->methodOffset(); i < meta->methodCount(); ++i)
@@ -873,14 +1033,14 @@ void tst_publicapi::publicAPI()
// Uncomment to print the actual API.
// QStringList sortedAPI(actualAPI);
// std::sort(sortedAPI.begin(), sortedAPI.end());
- // for (const QString &actual : qAsConst(sortedAPI))
+ // for (const QString &actual : std::as_const(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)) {
+ for (const QString &actual : std::as_const(actualAPI)) {
if (!expectedAPI.contains(actual)) {
- QWARN(qPrintable("Expected list is not up-to-date: " + actual));
+ qWarning("Expected list is not up-to-date: %ls", qUtf16Printable(actual));
apiMatch = false;
}
}
@@ -888,7 +1048,7 @@ void tst_publicapi::publicAPI()
for (const QString &expected : expectedAPI) {
if (!actualAPI.contains(expected)) {
apiMatch = false;
- QWARN(qPrintable("Not implemented: " + expected));
+ qWarning("Not implemented: %ls", qUtf16Printable(expected));
}
}
@@ -898,4 +1058,3 @@ void tst_publicapi::publicAPI()
QTEST_MAIN(tst_publicapi)
#include "tst_publicapi.moc"
-
diff --git a/tests/auto/quick/qmltests/BLACKLIST b/tests/auto/quick/qmltests/BLACKLIST
index 46bc65923..fc8f9f0d8 100644
--- a/tests/auto/quick/qmltests/BLACKLIST
+++ b/tests/auto/quick/qmltests/BLACKLIST
@@ -1,2 +1,12 @@
-[WebEngineViewSource::test_viewSourceURL]
+[NewWindowRequest::test_loadNewWindowRequest]
+macos
+
+[WebEngineViewContextMenu::test_contextMenuLinkAndSelectedText]
+macos
+
+[CertificateError::test_fatalError]
*
+
+[CertificateError::test_error]
+*
+
diff --git a/tests/auto/quick/qmltests/CMakeLists.txt b/tests/auto/quick/qmltests/CMakeLists.txt
new file mode 100644
index 000000000..daae6d60d
--- /dev/null
+++ b/tests/auto/quick/qmltests/CMakeLists.txt
@@ -0,0 +1,94 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+include(../../httpserver/httpserver.cmake)
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_qmltests
+ SOURCES
+ tst_qmltests.cpp
+ LIBRARIES
+ Qt::GuiPrivate
+ Qt::QuickTest
+ Qt::TestPrivate
+ Qt::WebEngineQuick
+ Test::HttpServer
+ Test::Util
+)
+
+set(testList
+ tst_action.qml
+ tst_activeFocusOnPress.qml
+ tst_audioMuted.qml
+ tst_contextMenu.qml
+ tst_basicProfiles.qml
+ tst_datalist.qml
+ tst_desktopBehaviorLoadHtml.qml
+ tst_download.qml
+ tst_dragHandlerUnderView.qml
+ tst_favicon.qml
+ tst_faviconDatabase.qml
+ tst_filePicker.qml
+ tst_filesystem.qml
+ tst_findText.qml
+ tst_focusOnNavigation.qml
+ tst_fullScreenRequest.qml
+ tst_getUserMedia.qml
+ tst_inputMethod.qml
+ tst_inputTextDirection.qml
+ tst_javaScriptDialogs.qml
+ tst_keyboardEvents.qml
+ tst_keyboardModifierMapping.qml
+ tst_linkHovered.qml
+ tst_loadFail.qml
+ tst_loadHtml.qml
+ tst_loadProgress.qml
+ tst_loadRecursionCrash.qml
+ tst_loadUrl.qml
+ tst_mouseClick.qml
+ tst_mouseMove.qml
+ tst_navigationHistory.qml
+ tst_navigationRequested.qml
+ tst_newViewRequest.qml
+ tst_notification.qml
+ tst_properties.qml
+ tst_runJavaScript.qml
+ tst_scrollPosition.qml
+ tst_settings.qml
+ tst_titleChanged.qml
+ tst_unhandledKeyEventPropagation.qml
+ tst_userScripts.qml
+ tst_userScriptCollection.qml
+ tst_viewSource.qml
+ tst_save.qml
+)
+
+if(QT_FEATURE_webengine_webchannel)
+ list(APPEND testList tst_webchannel.qml)
+endif()
+
+if(QT_FEATURE_ssl)
+ list(APPEND testList tst_certificateError.qml)
+endif()
+
+if (NOT APPLE)
+ list(APPEND testList tst_geopermission.qml)
+endif()
+
+set(content "")
+foreach(test ${testList})
+ set(contents "${contents}${CMAKE_CURRENT_LIST_DIR}/data/${test}\n")
+endforeach()
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/webengine.qmltests ${contents})
+
+set(tst_qmltests_resource_files
+ "resources/server.pem"
+ "resources/server.key"
+)
+
+qt_internal_add_resource(tst_qmltests "tst_qmltests"
+ PREFIX
+ "/"
+ FILES
+ ${tst_qmltests_resource_files}
+)
diff --git a/tests/auto/quick/qmltests/data/TestWebEngineView.qml b/tests/auto/quick/qmltests/data/TestWebEngineView.qml
index 6db076ae8..415985471 100644
--- a/tests/auto/quick/qmltests/data/TestWebEngineView.qml
+++ b/tests/auto/quick/qmltests/data/TestWebEngineView.qml
@@ -1,53 +1,38 @@
-/****************************************************************************
-**
-** 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
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
WebEngineView {
property var loadStatus: null
property bool windowCloseRequestedSignalEmitted: false
settings.focusOnNavigationEnabled: true
+ function loadSucceeded() { return loadStatus == WebEngineView.LoadSucceededStatus }
+ function loadFailed() { return loadStatus == WebEngineView.LoadFailedStatus }
+ function loadStopped() { return loadStatus == WebEngineView.LoadStoppedStatus }
+
+ function waitForLoadResult(timeout) {
+ loadStatus = null
+ var r = _waitFor(function() { return loadStatus != null && loadStatus != WebEngineView.LoadStartedStatus }, timeout)
+ return r
+ }
+
function waitForLoadSucceeded(timeout) {
- var success = _waitFor(function() { return loadStatus == WebEngineView.LoadSucceededStatus }, timeout)
loadStatus = null
+ var success = _waitFor(function() { return loadStatus == WebEngineView.LoadSucceededStatus }, timeout)
return success
}
function waitForLoadFailed(timeout) {
- var failure = _waitFor(function() { return loadStatus == WebEngineView.LoadFailedStatus }, timeout)
loadStatus = null
+ var failure = _waitFor(function() { return loadStatus == WebEngineView.LoadFailedStatus }, timeout)
return failure
}
function waitForLoadStopped(timeout) {
- var stop = _waitFor(function() { return loadStatus == WebEngineView.LoadStoppedStatus }, timeout)
loadStatus = null
+ var stop = _waitFor(function() { return loadStatus == WebEngineView.LoadStoppedStatus }, timeout)
return stop
}
function waitForWindowCloseRequested() {
@@ -55,7 +40,7 @@ WebEngineView {
}
function _waitFor(predicate, timeout) {
if (timeout === undefined)
- timeout = 12000;
+ timeout = 30000;
var i = 0
while (i < timeout && !predicate()) {
testResult.wait(50)
@@ -85,12 +70,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;
}
@@ -101,11 +88,25 @@ WebEngineView {
return textSelection;
}
+ function getElementValue(element) {
+ var elementValue;
+ runJavaScript("document.getElementById('" + element + "').value", function(result) {
+ elementValue = result;
+ });
+ testCase.tryVerify(function() { return elementValue != undefined; });
+ return elementValue;
+ }
+
+ function compareElementValue(element, expected) {
+ testCase.tryVerify(function() { return expected == getElementValue(element); }, 5000,
+ "Value of element \"" + element + "\" is \"" + expected + "\"");
+ }
+
+
TestResult { id: testResult }
- TestCase { id: testCase }
- onLoadingChanged: {
- loadStatus = loadRequest.status
+ onLoadingChanged: function(load) {
+ loadStatus = load.status
}
onWindowCloseRequested: {
@@ -118,5 +119,38 @@ WebEngineView {
testCase.tryVerify(function() { return text !== undefined })
return text
}
+
+ function getItemPixel(item) {
+ var grabImage = Qt.createQmlObject("
+ import QtQuick\n
+ Image { }", testCase)
+ var itemCanvas = Qt.createQmlObject("
+ import QtQuick\n
+ Canvas { }", testCase)
+
+ // Mark QML images with objectName: "image" to be able to check if the image is loaded.
+ if (item.objectName === "image") {
+ testCase.tryVerify(function() { return item.status === Image.Ready });
+ }
+
+ item.grabToImage(function(result) {
+ grabImage.source = result.url
+ });
+ testCase.tryVerify(function() { return grabImage.status === Image.Ready });
+
+ itemCanvas.width = item.width;
+ itemCanvas.height = item.height;
+ var ctx = itemCanvas.getContext("2d");
+ ctx.drawImage(grabImage, 0, 0, grabImage.width, grabImage.height);
+ var imageData = ctx.getImageData(Math.round(itemCanvas.width/2),
+ Math.round(itemCanvas.height/2),
+ itemCanvas.width,
+ itemCanvas.height);
+
+ grabImage.destroy();
+ itemCanvas.destroy();
+
+ return imageData.data;
+ }
}
diff --git a/tests/auto/quick/qmltests/data/favicon-misc.html b/tests/auto/quick/qmltests/data/favicon-misc.html
index 9e788bdf4..03d1086ff 100644
--- a/tests/auto/quick/qmltests/data/favicon-misc.html
+++ b/tests/auto/quick/qmltests/data/favicon-misc.html
@@ -1,8 +1,8 @@
<html>
<head>
<title>Favicon Test</title>
- <link rel="shortcut icon" href="icons/qt32.ico" />
- <link rel="apple-touch-icon" href="icons/qt144.png" />
+ <link rel="shortcut icon" href="icons/qt32.ico" sizes="32x32" />
+ <link rel="apple-touch-icon" href="icons/qt144.png" sizes="144x144"/>
<link rel="shortcut icon" href="icons/unavailable.ico" />
</head>
<body>
diff --git a/tests/auto/quick/qmltests/data/filesystemapi.html b/tests/auto/quick/qmltests/data/filesystemapi.html
new file mode 100644
index 000000000..ab1a33e4d
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/filesystemapi.html
@@ -0,0 +1,66 @@
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<title> Failed to Upload </title>
+</script>
+</head>
+
+<body>
+<button>Request File Picker</button>
+<script>
+ async function handleDirectoryEntry( dirHandle, out ) {
+ for await (const entry of dirHandle.values()) {
+ if (entry.kind === "file"){
+ const file = await entry.getFile();
+ out[ file.name ] = file;
+ }
+ if (entry.kind === "directory") {
+ const newHandle = await dirHandle.getDirectoryHandle( entry.name, { create: false } );
+ const newOut = out[ entry.name ] = {};
+ await handleDirectoryEntry( newHandle, newOut );
+ }
+ }
+ }
+ const button = document.querySelector('button');
+ button.addEventListener('click', async function() {
+ switch(window.dialogType) {
+ case "savePicker":
+ const saveFileHandle = await window.showSaveFilePicker();
+ const writable = await saveFileHandle.createWritable();
+ await writable.write(new Blob(['TEST_CONTENT']));
+ await writable.close();
+ console.log("TEST:DONE")
+ break;
+ case "filePicker":
+ let [openFileHandle] = await window.showOpenFilePicker();
+ const options = {};
+ options.mode = 'readwrite'
+ await openFileHandle.requestPermission(options)
+ const file = await openFileHandle.getFile();
+ const contents = await file.text();
+ console.log("TEST:" + contents)
+ console.log("TEST:DONE")
+ break;
+ case "directoryPicker":
+ console.log("start")
+ const dirHandle = await window.showDirectoryPicker();
+ for await (const entry of dirHandle.values()) {
+ if (entry.kind === "file"){
+ continue
+ }
+ if (entry.kind === "directory") {
+ console.log("TEST:" + entry.name)
+ }
+ }
+ console.log("TEST:DONE")
+ break;
+ default:
+ }
+ });
+ window.onload = function() {
+ window.dialogType = window.location.href.split('=')[1];
+ document.querySelector('button').focus()
+ }
+</script>
+</body>
+</html>
diff --git a/tests/auto/quick/qmltests/data/geolocation.html b/tests/auto/quick/qmltests/data/geolocation.html
index 8b116c8ee..e8c54bc58 100644
--- a/tests/auto/quick/qmltests/data/geolocation.html
+++ b/tests/auto/quick/qmltests/data/geolocation.html
@@ -3,16 +3,21 @@
<title>Geolocation Permission API Test</title>
<script>
+var errorMessage;
+var handled = false;
+
function successHandler(location) {
var message = document.getElementById("message");
message.innerHTML = "Latitude: " + location.coords.latitude +
"<br>Longitude: " + location.coords.longitude;
- console.error("Success");
+ errorMessage = "";
+ handled = true;
}
function errorHandler(error) {
- console.error(error.message);
+ errorMessage = error.message;
+ handled = true;
}
<!-- One shot example -->
diff --git a/tests/auto/quick/qmltests/data/test2.html b/tests/auto/quick/qmltests/data/test2.html
index 629c2a063..06b1c40cb 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"><div style="width:200px; height:200px; background-color:red"></div></a>
</body>
</html>
diff --git a/tests/auto/quick/qmltests/data/test4.html b/tests/auto/quick/qmltests/data/test4.html
index c9b395ee5..82830668a 100644
--- a/tests/auto/quick/qmltests/data/test4.html
+++ b/tests/auto/quick/qmltests/data/test4.html
@@ -9,7 +9,6 @@
font-size: 50px;
}
</style>
- <meta name="viewport" content="initial-scale=2.0"/>
</head>
<body>
<button onclick="scrollWin()" id="scroll">Click me to scroll!</button><br><br>
@@ -24,6 +23,7 @@
}
</script>
<div id="content">
+ <p><a id='anchor' href='#anchor'>anchor</a>
<p>bla00
<p>bla01
<p>bla02
diff --git a/tests/auto/quick/qmltests/data/titleupdate.js b/tests/auto/quick/qmltests/data/titleupdate.js
index c86139c13..720e83676 100644
--- a/tests/auto/quick/qmltests/data/titleupdate.js
+++ b/tests/auto/quick/qmltests/data/titleupdate.js
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
function updateTitle()
{
diff --git a/tests/auto/quick/qmltests/data/tst_action.qml b/tests/auto/quick/qmltests/data/tst_action.qml
index 852d4145a..9e49c2dbf 100644
--- a/tests/auto/quick/qmltests/data/tst_action.qml
+++ b/tests/auto/quick/qmltests/data/tst_action.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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.2
-import QtTest 1.0
-import QtWebEngine 1.8
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
@@ -41,7 +16,7 @@ TestWebEngineView {
}
TestCase {
- id: actionTests
+ id: testCase
name: "WebEngineAction"
when: windowShown
@@ -90,7 +65,9 @@ TestWebEngineView {
{ webAction: WebEngineView.Indent, text: "&Indent", iconName: "", enabled: true },
{ webAction: WebEngineView.Outdent, text: "&Outdent", iconName: "", enabled: true },
{ webAction: WebEngineView.InsertOrderedList, text: "Insert &Ordered List", iconName: "", enabled: true },
- { webAction: WebEngineView.InsertUnorderedList, text: "Insert &Unordered List", iconName: "", enabled: true }
+ { webAction: WebEngineView.InsertUnorderedList, text: "Insert &Unordered List", iconName: "", enabled: true },
+ { webAction: WebEngineView.ChangeTextDirectionLTR, text: "Change text direction left to right", iconName: "", enabled: true },
+ { webAction: WebEngineView.ChangeTextDirectionRTL, text: "Change text direction right to left", iconName: "", enabled: true }
];
}
@@ -116,8 +93,8 @@ TestWebEngineView {
var stopAction = webEngineView.action(WebEngineView.Stop);
verify(stopAction);
- var triggerSpy = createTemporaryObject(signalSpy, actionTests, {target: selectAction, signalName: "triggered"});
- var stopTriggerSpy = createTemporaryObject(signalSpy, actionTests, {target: stopAction, signalName: "triggered"});
+ var triggerSpy = createTemporaryObject(signalSpy, testCase, {target: selectAction, signalName: "triggered"});
+ var stopTriggerSpy = createTemporaryObject(signalSpy, testCase, {target: stopAction, signalName: "triggered"});
verify(selectAction.enabled);
selectAction.trigger();
@@ -148,7 +125,7 @@ TestWebEngineView {
compare(enabledSpy.count, 0);
selectAllAction.trigger();
compare(triggerSpy.count, 0);
- compare(getTextSelection(), "");
+ compare(webEngineView.getTextSelection(), "");
// Focus content by focusing window from JavaScript. Edit actions should be enabled and functional.
webView.runJavaScript("window.focus();");
@@ -157,6 +134,7 @@ TestWebEngineView {
selectAllAction.trigger();
compare(triggerSpy.count, 1);
tryVerify(function() { return webView.getTextSelection() === "foo bar" });
+ webView.destroy();
}
function test_editActionsWithInitialFocus() {
@@ -180,6 +158,7 @@ TestWebEngineView {
selectAllAction.trigger();
compare(triggerSpy.count, 1);
tryVerify(function() { return webView.getTextSelection() === "foo bar" });
+ webView.destroy();
}
}
}
diff --git a/tests/auto/quick/qmltests/data/tst_activeFocusOnPress.qml b/tests/auto/quick/qmltests/data/tst_activeFocusOnPress.qml
index c360a1da2..77968f6b6 100644
--- a/tests/auto/quick/qmltests/data/tst_activeFocusOnPress.qml
+++ b/tests/auto/quick/qmltests/data/tst_activeFocusOnPress.qml
@@ -1,33 +1,8 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-import QtQuick 2.5
-import QtTest 1.0
+import QtQuick
+import QtTest
Item {
id: root
@@ -55,6 +30,7 @@ Item {
}
TestCase {
+ id: testCase
name: "ActiveFocusOnPress"
when:windowShown
diff --git a/tests/auto/quick/qmltests/data/tst_audioMuted.qml b/tests/auto/quick/qmltests/data/tst_audioMuted.qml
index c626d07a0..85f813f0c 100644
--- a/tests/auto/quick/qmltests/data/tst_audioMuted.qml
+++ b/tests/auto/quick/qmltests/data/tst_audioMuted.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-import QtQuick 2.0
-import QtTest 1.0
-import QtWebEngine 1.4
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: view
@@ -42,7 +17,7 @@ TestWebEngineView {
}
TestCase {
- id: test
+ id: testCase
name: "WebEngineViewAudioMuted"
function test_audioMuted() {
diff --git a/tests/auto/quick/qmltests/data/tst_basicProfiles.qml b/tests/auto/quick/qmltests/data/tst_basicProfiles.qml
new file mode 100644
index 000000000..97a25cdd8
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_basicProfiles.qml
@@ -0,0 +1,90 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
+import Qt.labs.platform
+
+Item {
+ WebEngineProfile { id: otrProfile; /* MEMO implicit offTheRecord: true */ }
+ WebEngineProfile { id: nonOtrProfile; offTheRecord: false }
+
+ function getPath(path, offset = 1) { return path.substr(path.indexOf(':') + offset, path.length) }
+ property string appDataLocation: getPath(getPath(StandardPaths.writableLocation(StandardPaths.AppDataLocation).toString(), 3))
+ property string cacheLocation: getPath(getPath(StandardPaths.writableLocation(StandardPaths.CacheLocation).toString(), 3))
+ property string downloadLocation: getPath(getPath(StandardPaths.writableLocation(StandardPaths.DownloadLocation).toString(), 3))
+
+ TestCase {
+ name: "BasicProfiles"
+
+ function test_defaultProfile() {
+ let p = WebEngine.defaultProfile
+ verify(p.offTheRecord)
+
+ compare(p.storageName, '')
+ compare(p.cachePath, '')
+ compare(getPath(p.persistentStoragePath), appDataLocation + '/QtWebEngine/OffTheRecord')
+ compare(p.httpCacheType, WebEngineProfile.MemoryHttpCache)
+ compare(p.httpCacheMaximumSize, 0)
+ compare(p.persistentCookiesPolicy, WebEngineProfile.NoPersistentCookies)
+
+ compare(getPath(p.downloadPath), downloadLocation)
+ compare(p.httpAcceptLanguage, '')
+ verify(p.httpUserAgent !== '')
+ compare(p.spellCheckEnabled, false)
+ compare(p.spellCheckLanguages, [])
+
+ compare(p.userScripts.collection, [])
+ }
+
+ function test_otrProfile() {
+ let p = otrProfile
+ verify(p.offTheRecord)
+
+ compare(p.storageName, '')
+ compare(p.cachePath, '')
+ compare(getPath(p.persistentStoragePath), appDataLocation + '/QtWebEngine/OffTheRecord')
+ compare(p.httpCacheType, WebEngineProfile.MemoryHttpCache)
+ compare(p.httpCacheMaximumSize, 0)
+ compare(p.persistentCookiesPolicy, WebEngineProfile.NoPersistentCookies)
+
+ compare(getPath(p.downloadPath), downloadLocation)
+ compare(p.httpAcceptLanguage, '')
+ verify(p.httpUserAgent !== '')
+ compare(p.spellCheckEnabled, false)
+ compare(p.spellCheckLanguages, [])
+
+ compare(p.userScripts.collection, [])
+ }
+
+ function test_nonOtrProfile() {
+ let p = nonOtrProfile
+ verify(!p.offTheRecord)
+
+ compare(p.storageName, '')
+ compare(p.cachePath, '')
+ compare(getPath(p.persistentStoragePath), appDataLocation + '/QtWebEngine/UnknownProfile')
+ compare(p.httpCacheType, WebEngineProfile.MemoryHttpCache)
+ compare(p.httpCacheMaximumSize, 0)
+ compare(p.persistentCookiesPolicy, WebEngineProfile.NoPersistentCookies)
+
+ compare(getPath(p.downloadPath), downloadLocation)
+ compare(p.httpAcceptLanguage, '')
+ verify(p.httpUserAgent !== '')
+ compare(p.spellCheckEnabled, false)
+ compare(p.spellCheckLanguages, [])
+
+ compare(p.userScripts.collection, [])
+
+ p.storageName = 'Test'
+ compare(p.storageName, 'Test')
+ compare(getPath(p.cachePath), cacheLocation + '/QtWebEngine/' + p.storageName)
+ compare(getPath(p.persistentStoragePath), appDataLocation + '/QtWebEngine/' + p.storageName)
+
+ compare(p.httpCacheType, WebEngineProfile.DiskHttpCache)
+ compare(p.httpCacheMaximumSize, 0)
+ compare(p.persistentCookiesPolicy, WebEngineProfile.AllowPersistentCookies)
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests/data/tst_certificateError.qml b/tests/auto/quick/qmltests/data/tst_certificateError.qml
index 976de88a9..220ef9ac8 100644
--- a/tests/auto/quick/qmltests/data/tst_certificateError.qml
+++ b/tests/auto/quick/qmltests/data/tst_certificateError.qml
@@ -1,36 +1,11 @@
-/****************************************************************************
-**
-** 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.2
-import QtTest 1.0
-import QtWebEngine 1.9
-
-import Test.Shared 1.0 as Shared
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
+
+import Test.Shared as Shared
TestWebEngineView {
id: view; width: 320; height: 320
@@ -45,6 +20,7 @@ TestWebEngineView {
}
TestCase {
+ id: testCase
name: 'CertificateError'
when: windowShown
@@ -89,7 +65,8 @@ TestWebEngineView {
}
view.certificateError.connect(handleCertificateError)
- view.url = Shared.HttpsServer.url()
+ const server_url = Shared.HttpsServer.url()
+ view.url = server_url
if (data.deferError) {
spyError.wait()
@@ -112,23 +89,34 @@ TestWebEngineView {
compare(data.expectedContent, view.getBodyText())
view.certificateError.disconnect(handleCertificateError)
+
+ let error = spyError.signalArguments[0][0]
+ compare(error.url, server_url)
+ verify(error.description.length > 0)
+ verify(error.overridable)
+ compare(error.type, WebEngineCertificateError.CertificateAuthorityInvalid)
}
function test_fatalError() {
- var handleCertificateError = function(error) {
- verify(!error.overrideable);
- // QQuickWebEngineViewPrivate::allowCertificateError() will implicitly reject
- // fatal errors and it should not crash if already rejected in handler.
- error.rejectCertificate();
- }
+ let error = undefined
+ var handleCertificateError = function(e) { error = e; }
view.certificateError.connect(handleCertificateError);
view.url = Qt.resolvedUrl('https://revoked.badssl.com');
- if (!view.waitForLoadFailed(10000))
+ if (!view.waitForLoadResult()) {
+ verify(!error, "There shouldn't be any certificate error if not loaded due to missing internet access!");
skip("Couldn't load page from network, skipping test.");
- compare(spyError.count, 1);
-
+ }
view.certificateError.disconnect(handleCertificateError);
+
+ // revoked certificate might not be reported as invalid by chromium and the load will silently succeed
+ const failed = view.loadStatus == WebEngineView.LoadFailedStatus, hasError = Boolean(error)
+ compare(hasError, failed)
+ if (failed) {
+ verify(!error.overridable);
+ // Fatal certificate errors are implicitly rejected. But second call should not cause crash.
+ error.rejectCertificate();
+ }
}
}
}
diff --git a/tests/auto/quick/qmltests/data/tst_contextMenu.qml b/tests/auto/quick/qmltests/data/tst_contextMenu.qml
index 99450a159..58e27b8ba 100644
--- a/tests/auto/quick/qmltests/data/tst_contextMenu.qml
+++ b/tests/auto/quick/qmltests/data/tst_contextMenu.qml
@@ -1,35 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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 QtQuick.Controls 1.4
-import QtTest 1.0
-import QtWebEngine 1.6
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
+import "../mock-delegates/TestParams"
TestWebEngineView {
id: webEngineView
@@ -40,7 +15,7 @@ TestWebEngineView {
property var mediaType: null
property string selectedText: ""
- onContextMenuRequested: {
+ onContextMenuRequested: function (request) {
linkText = request.linkText;
mediaType = request.mediaType;
selectedText = request.selectedText;
@@ -52,38 +27,20 @@ TestWebEngineView {
signalName: "contextMenuRequested"
}
- function getContextMenus() {
- var data = webEngineView.data;
- var contextMenus = [];
-
- for (var i = 0; i < data.length; i++) {
- if (data[i].type == MenuItemType.Menu) {
- contextMenus.push(data[i]);
- }
- }
- return contextMenus;
- }
-
- function destroyContextMenu() {
- contextMenuTest.keyPress(Qt.Key_Escape);
- return getContextMenus().length == 0;
- }
-
TestCase {
- id: contextMenuTest
+ id: testCase
name: "WebEngineViewContextMenu"
when: windowShown
function init() {
- var contextMenus = getContextMenus();
- compare(contextMenus.length, 0);
+ MenuParams.isMenuOpened = false;
}
function cleanup() {
contextMenuRequestedSpy.clear();
}
- function test_contextMenu_data() {
+ function test_contextMenuRequest_data() {
return [
{ tag: "defaultContextMenu", userHandled: false, accepted: false },
{ tag: "defaultContextMenuWithConnect", userHandled: true, accepted: false },
@@ -91,11 +48,7 @@ TestWebEngineView {
];
}
- function test_contextMenu(row) {
- if (Qt.platform.os == "osx") {
- skip("When the menu pops up on macOS, it does not return and the test fails after time out.");
- }
-
+ function test_contextMenuRequest(row) {
function contextMenuHandler(request) {
request.accepted = row.accepted;
}
@@ -109,22 +62,12 @@ TestWebEngineView {
mouseClick(webEngineView, 20, 20, Qt.RightButton);
contextMenuRequestedSpy.wait();
compare(contextMenuRequestedSpy.count, 1);
+ tryCompare(MenuParams, "isMenuOpened", !row.accepted);
- // There should be maximum one ContextMenu present at a time
- var contextMenus = getContextMenus();
- verify(contextMenus.length <= 1);
- compare(contextMenus[0] != null, !row.accepted);
-
- // FIXME: Sometimes the keyPress(Qt.Key_Escape) event isn't caught so we keep trying
- tryVerify(destroyContextMenu);
webEngineView.contextMenuRequested.disconnect(contextMenuHandler);
}
function test_contextMenuLinkAndSelectedText() {
- if (Qt.platform.os == "osx") {
- skip("When the menu pops up on macOS, it does not return and the test fails after time out.");
- }
-
webEngineView.loadHtml("<html><body>" +
"<span id='text'>Text </span>" +
"<a id='link' href='test1.html'>Link</a>" +
@@ -137,9 +80,6 @@ TestWebEngineView {
contextMenuRequestedSpy.wait();
compare(contextMenuRequestedSpy.count, 1);
- var contextMenus = getContextMenus();
- compare(contextMenus.length, 1);
- verify(contextMenus[0]);
compare(linkText, "Link");
compare(mediaType, ContextMenuRequest.MediaTypeNone);
compare(selectedText, "");
@@ -150,8 +90,6 @@ TestWebEngineView {
verify(webEngineView.action(WebEngineView.CopyLinkToClipboard).enabled);
contextMenuRequestedSpy.clear();
- // FIXME: Sometimes the keyPress(Qt.Key_Escape) event isn't caught so we keep trying
- tryVerify(destroyContextMenu);
// 2. Everything is selected, right click on the link
webEngineView.triggerWebAction(WebEngineView.SelectAll);
@@ -161,16 +99,11 @@ TestWebEngineView {
contextMenuRequestedSpy.wait();
compare(contextMenuRequestedSpy.count, 1);
- contextMenus = getContextMenus();
- compare(contextMenus.length, 1);
- verify(contextMenus[0]);
compare(linkText, "Link");
compare(mediaType, ContextMenuRequest.MediaTypeNone);
compare(selectedText, "Text Link");
contextMenuRequestedSpy.clear();
- // FIXME: Sometimes the keyPress(Qt.Key_Escape) event isn't caught so we keep trying
- tryVerify(destroyContextMenu);
// 3. Everything is selected, right click on the text
var textCenter = getElementCenter("text");
@@ -178,22 +111,12 @@ TestWebEngineView {
contextMenuRequestedSpy.wait();
compare(contextMenuRequestedSpy.count, 1);
- contextMenus = getContextMenus();
- compare(contextMenus.length, 1);
- verify(contextMenus[0]);
compare(linkText, "");
compare(mediaType, ContextMenuRequest.MediaTypeNone);
compare(selectedText, "Text Link");
-
- // FIXME: Sometimes the keyPress(Qt.Key_Escape) event isn't caught so we keep trying
- tryVerify(destroyContextMenu);
}
function test_contextMenuMediaType() {
- if (Qt.platform.os == "osx") {
- skip("When the menu pops up on macOS, it does not return and the test fails after time out.");
- }
-
webEngineView.url = Qt.resolvedUrl("favicon.html");
verify(webEngineView.waitForLoadSucceeded());
// 1. Right click on the image
@@ -202,30 +125,19 @@ TestWebEngineView {
contextMenuRequestedSpy.wait();
compare(contextMenuRequestedSpy.count, 1);
- var contextMenus = getContextMenus();
- compare(contextMenus.length, 1);
- verify(contextMenus[0]);
compare(linkText, "");
compare(mediaType, ContextMenuRequest.MediaTypeImage);
compare(selectedText, "");
contextMenuRequestedSpy.clear();
- // FIXME: Sometimes the keyPress(Qt.Key_Escape) event isn't caught so we keep trying
- tryVerify(destroyContextMenu);
// 2. Right click out of the image
mouseClick(webEngineView, center.x + 30, center.y, Qt.RightButton);
contextMenuRequestedSpy.wait();
compare(contextMenuRequestedSpy.count, 1);
- contextMenus = getContextMenus();
- compare(contextMenus.length, 1);
- verify(contextMenus[0]);
compare(linkText, "");
compare(mediaType, ContextMenuRequest.MediaTypeNone);
compare(selectedText, "");
-
- // FIXME: Sometimes the keyPress(Qt.Key_Escape) event isn't caught so we keep trying
- tryVerify(destroyContextMenu);
}
}
}
diff --git a/tests/auto/quick/qmltests/data/tst_datalist.qml b/tests/auto/quick/qmltests/data/tst_datalist.qml
new file mode 100644
index 000000000..1e5a7ad6b
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_datalist.qml
@@ -0,0 +1,186 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtQuick.Controls
+import QtTest
+import QtWebEngine
+
+TestWebEngineView {
+ id: webEngineView
+ width: 200
+ height: 400
+
+ property string html: "<html><body>" +
+ "<input id='browserInput' list='browserDatalist'>" +
+ "<datalist id='browserDatalist'>" +
+ " <option value='Internet Explorer'>" +
+ " <option value='Firefox'>" +
+ " <option value='Chrome'>" +
+ " <option value='Opera'>" +
+ " <option value='Safari'>" +
+ "</datalist>" +
+ "</body></html>"
+
+ function listView() {
+ if (webEngineView.parent.visibleChildren.length == 1) {
+ // No popup case.
+ return null;
+ }
+
+ let overlay = null;
+ for (let i = 0; i < webEngineView.parent.visibleChildren.length; ++i) {
+ let child = webEngineView.parent.visibleChildren[i];
+ if (child instanceof Overlay) {
+ overlay = child;
+ break;
+ }
+ }
+
+ if (!overlay)
+ return null;
+
+ let popupItem = null;
+ for (let i = 0; i < overlay.visibleChildren[0].visibleChildren.length; ++i) {
+ let child = overlay.visibleChildren[0].visibleChildren[i];
+ if (child.objectName == "QQuickPopupItem") {
+ popupItem = child;
+ }
+ }
+
+ if (!popupItem)
+ return null;
+
+ for (let i = 0; i < popupItem.visibleChildren.length; ++i) {
+ let child = popupItem.visibleChildren[i];
+ if (child instanceof ListView)
+ return child;
+ }
+
+ return null;
+ }
+
+ TestCase {
+ id: testCase
+ name: "WebEngineDatalist"
+ when: windowShown
+
+ function test_showAndHide() {
+ webEngineView.loadHtml(webEngineView.html);
+ verify(webEngineView.waitForLoadSucceeded());
+
+ var values = "";
+ webEngineView.runJavaScript(
+ "(function() {" +
+ " var browserDatalist = document.getElementById('browserDatalist');" +
+ " var options = browserDatalist.options;" +
+ " var result = [];" +
+ " for (let i = 0; i < options.length; ++i) {" +
+ " result.push(options[i].value);" +
+ " }" +
+ " return result;" +
+ "})();", function(result) { values = result; });
+ tryVerify(function() { return values.length != 0; });
+ compare(values, ["Internet Explorer", "Firefox", "Chrome", "Opera", "Safari"]);
+ compareElementValue("browserInput", "");
+
+ // Make sure there is no open popup yet.
+ verify(!listView());
+ // Click in the input field.
+ var browserInputCenter = getElementCenter("browserInput");
+ mouseClick(webEngineView, browserInputCenter.x, browserInputCenter.y, Qt.LeftButton);
+ // Wait for the popup.
+ tryVerify(function() { return listView() != null; });
+
+ // No suggestion is selected.
+ verify(!listView().currentItem);
+ compare(listView().count, 5);
+
+ // Accepting suggestion does nothing.
+ keyClick(Qt.Key_Enter);
+ tryVerify(function() { return listView() != null; });
+ verify(!listView().currentItem);
+
+ // Escape should close popup.
+ keyClick(Qt.Key_Escape);
+ tryVerify(function() { return listView() == null; });
+
+ // The first Key Down opens the popup.
+ keyClick(Qt.Key_Down);
+ tryVerify(function() { return listView() != null; });
+
+ // The second Key Down selects the first suggestion.
+ keyClick(Qt.Key_Down);
+ tryCompare(listView(), "currentIndex", 0);
+ verify(listView().currentItem);
+ }
+
+ function test_keyboardNavigationAndAccept() {
+ webEngineView.loadHtml(html);
+ verify(webEngineView.waitForLoadSucceeded());
+ setFocusToElement("browserInput");
+
+ // Make sure there is no open popup yet.
+ verify(!listView());
+
+ // The first Key Down opens the popup.
+ keyClick(Qt.Key_Down);
+ tryVerify(function() { return listView() != null; });
+
+ // The second Key Down selects the first suggestion.
+ keyClick(Qt.Key_Down);
+ tryCompare(listView(), "currentIndex", 0);
+
+ // Test keyboard navigation in list.
+ keyClick(Qt.Key_Up);
+ compare(listView().currentIndex, 4);
+ keyClick(Qt.Key_Up);
+ compare(listView().currentIndex, 3);
+ keyClick(Qt.Key_PageDown);
+ compare(listView().currentIndex, 4);
+ keyClick(Qt.Key_PageUp);
+ compare(listView().currentIndex, 0);
+ keyClick(Qt.Key_Down);
+ compare(listView().currentIndex, 1);
+ keyClick(Qt.Key_Down);
+ compare(listView().currentIndex, 2);
+
+ // Test accepting suggestion.
+ compare(listView().currentItem.text, "Chrome");
+ keyClick(Qt.Key_Enter);
+ compareElementValue("browserInput", "Chrome");
+ // Accept closes popup.
+ tryVerify(function() { return listView() == null; });
+
+ // Clear input field, should not trigger popup.
+ webEngineView.runJavaScript("document.getElementById('browserInput').value = ''");
+ compareElementValue("browserInput", "");
+ verify(listView() == null);
+ }
+
+ function test_filterSuggestion() {
+ webEngineView.loadHtml(html);
+ verify(webEngineView.waitForLoadSucceeded());
+ setFocusToElement("browserInput");
+
+ // Make sure there is no open popup yet.
+ verify(!listView());
+
+ // Filter suggestions.
+ keyClick(Qt.Key_F);
+ tryVerify(function() { return listView() != null; });
+ compare(listView().count, 2);
+ verify(!listView().currentItem);
+ compare(listView().itemAtIndex(0).text, "Firefox");
+ compare(listView().itemAtIndex(1).text, "Safari");
+ keyClick(Qt.Key_I);
+ tryVerify(function() { return listView().count == 1; });
+ verify(!listView().currentItem);
+ compare(listView().itemAtIndex(0).text, "Firefox");
+ keyClick(Qt.Key_L);
+ // Mismatch should close popup.
+ tryVerify(function() { return listView() == null; });
+ compareElementValue("browserInput", "fil");
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests/data/tst_desktopBehaviorLoadHtml.qml b/tests/auto/quick/qmltests/data/tst_desktopBehaviorLoadHtml.qml
index 780294348..6cb2841ec 100644
--- a/tests/auto/quick/qmltests/data/tst_desktopBehaviorLoadHtml.qml
+++ b/tests/auto/quick/qmltests/data/tst_desktopBehaviorLoadHtml.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-import QtQuick 2.0
-import QtTest 1.0
-import QtWebEngine 1.2
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
@@ -44,7 +19,7 @@ TestWebEngineView {
signalName: "linkHovered"
}
- onLinkHovered: {
+ onLinkHovered: function(hoveredUrl) {
webEngineView.lastUrl = hoveredUrl
}
diff --git a/tests/auto/quick/qmltests/data/tst_download.qml b/tests/auto/quick/qmltests/data/tst_download.qml
index 8607d846d..61a363c39 100644
--- a/tests/auto/quick/qmltests/data/tst_download.qml
+++ b/tests/auto/quick/qmltests/data/tst_download.qml
@@ -1,36 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-import QtQuick 2.0
-import QtTest 1.0
-import QtWebEngine 1.10
-import Qt.labs.platform 1.0
-import Test.util 1.0
+import QtQuick
+import QtTest
+import QtWebEngine
+import Qt.labs.platform
+import Test.util
TestWebEngineView {
id: webEngineView
@@ -51,7 +26,6 @@ TestWebEngineView {
property string downloadedSetPath: ""
property int downloadDirectoryChanged: 0
property int downloadFileNameChanged: 0
- property int downloadPathChanged: 0
property bool setDirectoryFirst: false
TempDir { id: tempDir }
@@ -80,17 +54,24 @@ TestWebEngineView {
Connections {
id: downloadItemConnections
ignoreUnknownSignals: true
- onStateChanged: downloadState.push(target.state)
- onInterruptReasonChanged: downloadInterruptReason = target.interruptReason
- onDownloadDirectoryChanged: downloadDirectoryChanged++
- onDownloadFileNameChanged: downloadFileNameChanged++
- onPathChanged: downloadPathChanged++
+ function onStateChanged() {
+ downloadState.push(target.state);
+ }
+ function onInterruptReasonChanged() {
+ downloadInterruptReason = target.interruptReason;
+ }
+ function onDownloadDirectoryChanged() {
+ downloadDirectoryChanged++;
+ }
+ function onDownloadFileNameChanged() {
+ downloadFileNameChanged++;
+ }
}
WebEngineProfile {
id: testDownloadProfile
- onDownloadRequested: {
+ onDownloadRequested: function(download) {
testDownloadProfile.downloadPath = tempDir.path()
downloadState.push(download.state)
downloadItemConnections.target = download
@@ -120,7 +101,7 @@ TestWebEngineView {
downloadUrl = download.url
suggestedFileName = download.suggestedFileName
}
- onDownloadFinished: {
+ onDownloadFinished: function(download) {
receivedBytes = download.receivedBytes;
}
}
@@ -139,7 +120,6 @@ TestWebEngineView {
downloadInterruptReason = null
downloadDirectoryChanged = 0
downloadFileNameChanged = 0
- downloadPathChanged = 0
downloadDirectory = ""
downloadFileName = ""
downloadedPath = ""
@@ -235,7 +215,6 @@ TestWebEngineView {
compare(downloadedPath, testDownloadProfile.downloadPath + downloadDirectory + downloadFileName);
compare(downloadDirectoryChanged, 1);
compare(downloadFileNameChanged, 1);
- compare(downloadPathChanged, 2);
downloadFinishedSpy.wait();
compare(totalBytes, receivedBytes);
tryCompare(downloadState, "2", WebEngineDownloadRequest.DownloadCompleted);
@@ -258,7 +237,6 @@ TestWebEngineView {
compare(downloadedPath, testDownloadProfile.downloadPath + downloadDirectory + "download.zip");
compare(downloadDirectoryChanged, 1);
compare(downloadFileNameChanged, 0);
- compare(downloadPathChanged, 1);
downloadFinishedSpy.wait();
compare(totalBytes, receivedBytes);
tryCompare(downloadState, "2", WebEngineDownloadRequest.DownloadCompleted);
@@ -270,7 +248,6 @@ TestWebEngineView {
compare(downLoadRequestedSpy.count, 0);
downloadDirectoryChanged = 0;
downloadFileNameChanged = 0;
- downloadPathChanged = 0;
downloadDirectory = "/test_downloadToDirectoryWithSuggestedFileName1/";
webEngineView.url = Qt.resolvedUrl("download.zip");
downLoadRequestedSpy.wait();
@@ -282,7 +259,6 @@ TestWebEngineView {
compare(downloadedPath, testDownloadProfile.downloadPath + downloadDirectory + "download.zip");
compare(downloadDirectoryChanged, 1);
compare(downloadFileNameChanged, 0);
- compare(downloadPathChanged, 1);
downloadFinishedSpy.wait();
compare(totalBytes, receivedBytes);
tryCompare(downloadState, "2", WebEngineDownloadRequest.DownloadCompleted);
@@ -294,7 +270,6 @@ TestWebEngineView {
compare(downLoadRequestedSpy.count, 0);
downloadDirectoryChanged = 0;
downloadFileNameChanged = 0;
- downloadPathChanged = 0;
downloadDirectory = "/test_downloadToDirectoryWithSuggestedFileName1/";
webEngineView.url = Qt.resolvedUrl("download.zip");
downLoadRequestedSpy.wait();
@@ -306,29 +281,6 @@ TestWebEngineView {
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", WebEngineDownloadRequest.DownloadCompleted);
- verify(!downloadInterruptReason);
-}
-
- function test_downloadWithSetPath() {
- compare(downLoadRequestedSpy.count, 0);
- compare(downloadDirectoryChanged, 0);
- compare(downloadFileNameChanged, 0);
- downloadedSetPath = "/test_downloadWithSetPath/test.zip";
- webEngineView.url = Qt.resolvedUrl("download.zip");
- downLoadRequestedSpy.wait();
- compare(downLoadRequestedSpy.count, 1);
- compare(downloadUrl, webEngineView.url);
- compare(suggestedFileName, "download.zip");
- 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", WebEngineDownloadRequest.DownloadCompleted);
diff --git a/tests/auto/quick/qmltests/data/tst_dragHandlerUnderView.qml b/tests/auto/quick/qmltests/data/tst_dragHandlerUnderView.qml
new file mode 100644
index 000000000..c22bd44c2
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_dragHandlerUnderView.qml
@@ -0,0 +1,67 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
+
+Item {
+ id: parentItem
+ width: 400
+ height: 300
+
+ Rectangle {
+ id: draggableDownUnder
+ color: "wheat"
+ width: 350
+ height: 250
+
+ DragHandler { id: dragHandler }
+ }
+
+ TestWebEngineView {
+ id: webEngineView
+ width: 300
+ height: 250
+
+ property var testUrl: Qt.resolvedUrl("test4.html")
+
+ SignalSpy {
+ id: scrollPositionSpy
+ target: webEngineView
+ signalName: "onScrollPositionChanged"
+ }
+
+ SignalSpy {
+ id: dragActiveSpy
+ target: dragHandler
+ signalName: "activeChanged"
+ }
+
+ TestCase {
+ id: testCase
+ name: "KeepMouseGrabDuringScrolling"
+ when: windowShown
+
+ function test_scroll() {
+ webEngineView.url = Qt.resolvedUrl("test4.html");
+ verify(webEngineView.waitForLoadSucceeded());
+
+ mousePress(webEngineView, 295, 20);
+ mouseMove(webEngineView, 295, 200);
+ mouseRelease(webEngineView, 295, 200);
+
+ // WebEngineView scrolled if the scrollbar was visible.
+ // But on macOS, the scrollbar is hidden, so text gets selected.
+ tryVerify(function() {
+ return (scrollPositionSpy.count === 1 && webEngineView.scrollPosition.y > 100)
+ || webEngineView.getTextSelection().length > 0;
+ });
+
+ // DragHandler didn't take over and drag
+ compare(dragActiveSpy.count, 0);
+ compare(draggableDownUnder.y, 0);
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests/data/tst_favicon.qml b/tests/auto/quick/qmltests/data/tst_favicon.qml
index 3f522d91a..15f116e5d 100644
--- a/tests/auto/quick/qmltests/data/tst_favicon.qml
+++ b/tests/auto/quick/qmltests/data/tst_favicon.qml
@@ -1,90 +1,32 @@
-/****************************************************************************
-**
-** 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.0
-import QtWebEngine 1.3
-import QtWebEngine.testsupport 1.0
-import QtQuick.Window 2.0
-import "../../qmltests/data" 1.0
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
+import Test.util
+import "../../qmltests/data"
TestWebEngineView {
id: webEngineView
width: 200
height: 400
- testSupport: WebEngineTestSupport {
- property var errorPageLoadStatus: null
+ TempDir { id: tempDir }
- function waitForErrorPageLoadSucceeded() {
- var success = _waitFor(function() { return testSupport.errorPageLoadStatus == WebEngineView.LoadSucceededStatus })
- testSupport.errorPageLoadStatus = null
- return success
- }
+ property QtObject defaultProfile: WebEngineProfile {
+ offTheRecord: true
+ }
- errorPage.onLoadingChanged: {
- errorPageLoadStatus = loadRequest.status
- }
+ property QtObject nonOTRProfile: WebEngineProfile {
+ persistentStoragePath: tempDir.path() + '/WebEngineFavicon'
+ offTheRecord: false
}
function removeFaviconProviderPrefix(url) {
return url.toString().substring(16)
}
- function getFaviconPixel(faviconImage) {
- var grabImage = Qt.createQmlObject("
- import QtQuick 2.5\n
- Image { }", test)
- var faviconCanvas = Qt.createQmlObject("
- import QtQuick 2.5\n
- Canvas { }", test)
-
- test.tryVerify(function() { return faviconImage.status == Image.Ready });
- faviconImage.grabToImage(function(result) {
- grabImage.source = result.url
- });
- test.tryVerify(function() { return grabImage.status == Image.Ready });
-
- faviconCanvas.width = faviconImage.width;
- faviconCanvas.height = faviconImage.height;
- var ctx = faviconCanvas.getContext("2d");
- ctx.drawImage(grabImage, 0, 0, grabImage.width, grabImage.height);
- var imageData = ctx.getImageData(Math.round(faviconCanvas.width/2),
- Math.round(faviconCanvas.height/2),
- faviconCanvas.width,
- faviconCanvas.height);
-
- grabImage.destroy();
- faviconCanvas.destroy();
-
- return imageData.data;
- }
-
SignalSpy {
id: iconChangedSpy
target: webEngineView
@@ -97,19 +39,29 @@ TestWebEngineView {
}
TestCase {
- id: test
+ id: testCase
name: "WebEngineFavicon"
when: windowShown
function init() {
// It is worth to restore the initial state with loading a blank page before all test functions.
- webEngineView.url = 'about:blank'
- verify(webEngineView.waitForLoadSucceeded())
- iconChangedSpy.clear()
+ webEngineView.url = 'about:blank';
+ verify(webEngineView.waitForLoadSucceeded());
+ iconChangedSpy.clear();
+ webEngineView.settings.touchIconsEnabled = false;
+ webEngineView.settings.autoLoadIconsForPage = true;
}
- function test_faviconLoad() {
+ function test_faviconLoad_data() {
+ return [
+ { tag: "OTR", profile: defaultProfile },
+ { tag: "non-OTR", profile: nonOTRProfile },
+ ];
+ }
+
+ function test_faviconLoad(row) {
+ webEngineView.profile = row.profile
compare(iconChangedSpy.count, 0)
var url = Qt.resolvedUrl("favicon.html")
@@ -119,11 +71,20 @@ TestWebEngineView {
iconChangedSpy.wait()
compare(iconChangedSpy.count, 1)
- compare(favicon.width, 48)
- compare(favicon.height, 48)
+ tryCompare(favicon, "status", Image.Ready)
+ compare(favicon.width, 32)
+ compare(favicon.height, 32)
+ }
+
+ function test_faviconLoadEncodedUrl_data() {
+ return [
+ { tag: "OTR", profile: defaultProfile },
+ { tag: "non-OTR", profile: nonOTRProfile },
+ ];
}
- function test_faviconLoadEncodedUrl() {
+ function test_faviconLoadEncodedUrl(row) {
+ webEngineView.profile = row.profile
compare(iconChangedSpy.count, 0)
var url = Qt.resolvedUrl("favicon2.html?favicon=load should work with#whitespace!")
@@ -133,11 +94,94 @@ TestWebEngineView {
iconChangedSpy.wait()
compare(iconChangedSpy.count, 1)
- compare(favicon.width, 16)
- compare(favicon.height, 16)
+ tryCompare(favicon, "status", Image.Ready)
+ compare(favicon.width, 32)
+ compare(favicon.height, 32)
+ }
+
+ function test_faviconLoadAfterHistoryNavigation_data() {
+ return [
+ { tag: "OTR", profile: defaultProfile },
+ { tag: "non-OTR", profile: nonOTRProfile },
+ ];
+ }
+
+ function test_faviconLoadAfterHistoryNavigation(row) {
+ webEngineView.profile = row.profile
+ compare(iconChangedSpy.count, 0)
+
+ var iconUrl
+
+ webEngineView.url = Qt.resolvedUrl("favicon.html")
+ verify(webEngineView.waitForLoadSucceeded())
+ tryCompare(iconChangedSpy, "count", 1)
+ iconUrl = removeFaviconProviderPrefix(webEngineView.icon)
+ compare(iconUrl, Qt.resolvedUrl("icons/favicon.png"))
+
+ iconChangedSpy.clear()
+ webEngineView.url = Qt.resolvedUrl("favicon-shortcut.html")
+ verify(webEngineView.waitForLoadSucceeded())
+ tryCompare(iconChangedSpy, "count", 2)
+ iconUrl = removeFaviconProviderPrefix(webEngineView.icon)
+ compare(iconUrl, Qt.resolvedUrl("icons/qt32.ico"))
+
+ iconChangedSpy.clear()
+ webEngineView.goBack();
+ verify(webEngineView.waitForLoadSucceeded())
+ tryCompare(iconChangedSpy, "count", 2)
+ iconUrl = removeFaviconProviderPrefix(webEngineView.icon)
+ compare(iconUrl, Qt.resolvedUrl("icons/favicon.png"))
+
+ iconChangedSpy.clear()
+ webEngineView.goForward();
+ verify(webEngineView.waitForLoadSucceeded())
+ tryCompare(iconChangedSpy, "count", 2)
+ iconUrl = removeFaviconProviderPrefix(webEngineView.icon)
+ compare(iconUrl, Qt.resolvedUrl("icons/qt32.ico"))
+ }
+
+ function test_faviconLoadPushState_data() {
+ return [
+ { tag: "OTR", profile: defaultProfile },
+ { tag: "non-OTR", profile: nonOTRProfile },
+ ];
+ }
+
+ function test_faviconLoadPushState(row) {
+ webEngineView.profile = row.profile;
+ compare(iconChangedSpy.count, 0);
+
+ var iconUrl;
+
+ webEngineView.url = Qt.resolvedUrl("favicon.html");
+ verify(webEngineView.waitForLoadSucceeded());
+ tryCompare(iconChangedSpy, "count", 1);
+ iconUrl = removeFaviconProviderPrefix(webEngineView.icon);
+ compare(iconUrl, Qt.resolvedUrl("icons/favicon.png"));
+
+ iconChangedSpy.clear();
+
+ // pushState() is a same document navigation and should not reset or
+ // update favicon.
+ compare(webEngineView.history.items.rowCount(), 1);
+ runJavaScript("history.pushState('', '')");
+ tryVerify(function() { return webEngineView.history.items.rowCount() === 2; });
+
+ // Favicon change is not expected.
+ compare(iconChangedSpy.count, 0);
+ iconUrl = removeFaviconProviderPrefix(webEngineView.icon);
+ compare(iconUrl, Qt.resolvedUrl("icons/favicon.png"));
+ }
+
+ function test_noFavicon_data() {
+ return [
+ { tag: "OTR", profile: defaultProfile },
+ { tag: "non-OTR", profile: nonOTRProfile },
+ ];
}
- function test_noFavicon() {
+ function test_noFavicon(row) {
+ webEngineView.profile = row.profile
compare(iconChangedSpy.count, 0)
var url = Qt.resolvedUrl("test1.html")
@@ -150,7 +194,15 @@ TestWebEngineView {
compare(iconUrl, Qt.resolvedUrl(""))
}
- function test_aboutBlank() {
+ function test_aboutBlank_data() {
+ return [
+ { tag: "OTR", profile: defaultProfile },
+ { tag: "non-OTR", profile: nonOTRProfile },
+ ];
+ }
+
+ function test_aboutBlank(row) {
+ webEngineView.profile = row.profile
compare(iconChangedSpy.count, 0)
var url = Qt.resolvedUrl("about:blank")
@@ -163,7 +215,15 @@ TestWebEngineView {
compare(iconUrl, Qt.resolvedUrl(""))
}
- function test_unavailableFavicon() {
+ function test_unavailableFavicon_data() {
+ return [
+ { tag: "OTR", profile: defaultProfile },
+ { tag: "non-OTR", profile: nonOTRProfile },
+ ];
+ }
+
+ function test_unavailableFavicon(row) {
+ webEngineView.profile = row.profile
compare(iconChangedSpy.count, 0)
var url = Qt.resolvedUrl("favicon-unavailable.html")
@@ -176,15 +236,22 @@ TestWebEngineView {
compare(iconUrl, Qt.resolvedUrl(""))
}
- function test_errorPageEnabled() {
- WebEngine.settings.errorPageEnabled = true
+ function test_errorPageEnabled_data() {
+ return [
+ { tag: "OTR", profile: defaultProfile },
+ { tag: "non-OTR", profile: nonOTRProfile },
+ ];
+ }
+
+ function test_errorPageEnabled(row) {
+ webEngineView.profile = row.profile
+ webEngineView.settings.errorPageEnabled = true
compare(iconChangedSpy.count, 0)
var url = Qt.resolvedUrl("http://url.invalid")
webEngineView.url = url
verify(webEngineView.waitForLoadFailed(20000))
- verify(webEngineView.testSupport.waitForErrorPageLoadSucceeded())
compare(iconChangedSpy.count, 0)
@@ -192,8 +259,16 @@ TestWebEngineView {
compare(iconUrl, Qt.resolvedUrl(""))
}
- function test_errorPageDisabled() {
- WebEngine.settings.errorPageEnabled = false
+ function test_errorPageDisabled_data() {
+ return [
+ { tag: "OTR", profile: defaultProfile },
+ { tag: "non-OTR", profile: nonOTRProfile },
+ ];
+ }
+
+ function test_errorPageDisabled(row) {
+ webEngineView.profile = row.profile
+ webEngineView.settings.errorPageEnabled = false
compare(iconChangedSpy.count, 0)
@@ -207,7 +282,15 @@ TestWebEngineView {
compare(iconUrl, Qt.resolvedUrl(""))
}
- function test_bestFavicon() {
+ function test_bestFavicon_data() {
+ return [
+ { tag: "OTR", profile: defaultProfile },
+ { tag: "non-OTR", profile: nonOTRProfile },
+ ];
+ }
+
+ function test_bestFavicon(row) {
+ webEngineView.profile = row.profile
compare(iconChangedSpy.count, 0)
var url, iconUrl
@@ -221,6 +304,7 @@ TestWebEngineView {
iconUrl = removeFaviconProviderPrefix(webEngineView.icon)
// Touch icon is ignored
compare(iconUrl, Qt.resolvedUrl("icons/qt32.ico"))
+ tryCompare(favicon, "status", Image.Ready)
compare(favicon.width, 32)
compare(favicon.height, 32)
@@ -230,23 +314,25 @@ TestWebEngineView {
webEngineView.url = url
verify(webEngineView.waitForLoadSucceeded())
- iconChangedSpy.wait()
- verify(iconChangedSpy.count >= 1)
+ tryCompare(iconChangedSpy, "count", 2)
iconUrl = removeFaviconProviderPrefix(webEngineView.icon)
- // If the icon URL is empty we have to wait for
- // the second iconChanged signal that propagates the expected URL
- if (iconUrl == Qt.resolvedUrl("")) {
- tryCompare(iconChangedSpy, "count", 2)
- iconUrl = removeFaviconProviderPrefix(webEngineView.icon)
- }
+ // If touch icon is disabled, FaviconHandler propagates the icon closest to size 16x16
+ compare(iconUrl, Qt.resolvedUrl("icons/qt32.ico"))
+ tryCompare(favicon, "status", Image.Ready)
+ compare(favicon.width, 32)
+ compare(favicon.height, 32)
+ }
- compare(iconUrl, Qt.resolvedUrl("icons/qt144.png"))
- compare(favicon.width, 144)
- compare(favicon.height, 144)
+ function test_touchIcon_data() {
+ return [
+ { tag: "OTR", profile: defaultProfile },
+ { tag: "non-OTR", profile: nonOTRProfile },
+ ];
}
- function test_touchIcon() {
+ function test_touchIcon(row) {
+ webEngineView.profile = row.profile
compare(iconChangedSpy.count, 0)
var url = Qt.resolvedUrl("favicon-touch.html")
@@ -260,7 +346,7 @@ TestWebEngineView {
compare(favicon.width, 0)
compare(favicon.height, 0)
- WebEngine.settings.touchIconsEnabled = true
+ webEngineView.settings.touchIconsEnabled = true
url = Qt.resolvedUrl("favicon-touch.html")
webEngineView.url = url
@@ -270,11 +356,20 @@ TestWebEngineView {
iconUrl = removeFaviconProviderPrefix(webEngineView.icon)
compare(iconUrl, Qt.resolvedUrl("icons/qt144.png"))
compare(iconChangedSpy.count, 1)
+ tryCompare(favicon, "status", Image.Ready)
compare(favicon.width, 144)
compare(favicon.height, 144)
}
- function test_multiIcon() {
+ function test_multiIcon_data() {
+ return [
+ { tag: "OTR", profile: defaultProfile },
+ { tag: "non-OTR", profile: nonOTRProfile },
+ ];
+ }
+
+ function test_multiIcon(row) {
+ webEngineView.profile = row.profile
compare(iconChangedSpy.count, 0)
var url = Qt.resolvedUrl("favicon-multi.html")
@@ -283,62 +378,25 @@ TestWebEngineView {
iconChangedSpy.wait()
compare(iconChangedSpy.count, 1)
- compare(favicon.width, 64)
- compare(favicon.height, 64)
+ tryCompare(favicon, "status", Image.Ready)
+ compare(favicon.width, 32)
+ compare(favicon.height, 32)
}
- function test_faviconProvider_data() {
+ function test_dynamicFavicon_data() {
return [
- { tag: "multi 8x8", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 8, value: 16 },
- { tag: "multi 16x16", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 16, value: 16 },
- { tag: "multi 17x17", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 17, value: 32 },
- { tag: "multi 31x31", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 31, value: 32 },
- { tag: "multi 32x32", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 32, value: 32 },
- { tag: "multi 33x33", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 33, value: 64 },
- { tag: "multi 64x64", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 64, value: 64 },
- { tag: "multi 128x128", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 128, value: 128 },
- { tag: "multi 255x255", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 255, value: 255 },
- { tag: "multi 256x256", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 256, value: 255 },
- { tag: "candidate 8x8", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 8, value: 16 },
- { tag: "candidate 16x16", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 16, value: 16 },
- { tag: "candidate 17x17", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 17, value: 32 },
- { tag: "candidate 31x31", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 31, value: 32 },
- { tag: "candidate 32x32", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 32, value: 32 },
- { tag: "candidate 33x33", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 33, value: 64 },
- { tag: "candidate 64x64", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 64, value: 64 },
- { tag: "candidate 128x128", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 128, value: 128 },
- { tag: "candidate 255x255", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 255, value: 255 },
- { tag: "candidate 256x256", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 256, value: 255 },
+ { tag: "OTR", profile: defaultProfile },
+ { tag: "non-OTR", profile: nonOTRProfile },
];
}
- function test_faviconProvider(row) {
- var faviconImage = Qt.createQmlObject("
- import QtQuick 2.5\n
- Image { sourceSize: Qt.size(width, height) }", test)
-
+ function test_dynamicFavicon(row) {
+ webEngineView.profile = row.profile
compare(iconChangedSpy.count, 0)
- webEngineView.url = row.url
- verify(webEngineView.waitForLoadSucceeded())
-
- iconChangedSpy.wait()
- compare(iconChangedSpy.count, 1)
-
- faviconImage.width = row.size / Screen.devicePixelRatio
- faviconImage.height = row.size / Screen.devicePixelRatio
- faviconImage.source = webEngineView.icon
-
- var pixel = getFaviconPixel(faviconImage);
- compare(pixel[0], row.value)
-
- faviconImage.destroy()
- }
-
- function test_dynamicFavicon() {
var faviconImage = Qt.createQmlObject("
- import QtQuick 2.5\n
- Image { width: 16; height: 16; sourceSize: Qt.size(width, height); }", test)
+ import QtQuick\n
+ Image { width: 16; height: 16; sourceSize: Qt.size(width, height); objectName: 'image' }", testCase)
faviconImage.source = Qt.binding(function() { return webEngineView.icon; });
var colors = [
@@ -357,7 +415,7 @@ TestWebEngineView {
verify(webEngineView.waitForLoadSucceeded());
tryCompare(iconChangedSpy, "count", 1);
- pixel = getFaviconPixel(faviconImage);
+ pixel = getItemPixel(faviconImage);
compare(pixel[0], 0);
compare(pixel[1], 0);
compare(pixel[2], 0);
@@ -368,7 +426,7 @@ TestWebEngineView {
tryCompare(faviconImage, "source", "image://favicon/data:image/png;base64," + colors[i]["url"]);
compare(iconChangedSpy.count, 1);
- pixel = getFaviconPixel(faviconImage);
+ pixel = getItemPixel(faviconImage);
compare(pixel[0], colors[i]["r"]);
compare(pixel[1], colors[i]["g"]);
compare(pixel[2], colors[i]["b"]);
@@ -377,9 +435,17 @@ TestWebEngineView {
faviconImage.destroy()
}
- function test_touchIconWithSameURL()
+ function test_touchIconWithSameURL_data() {
+ return [
+ { tag: "OTR", profile: defaultProfile },
+ { tag: "non-OTR", profile: nonOTRProfile },
+ ];
+ }
+
+ function test_touchIconWithSameURL(row)
{
- WebEngine.settings.touchIconsEnabled = false;
+ webEngineView.profile = row.profile;
+ compare(iconChangedSpy.count, 0);
var icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=";
@@ -409,5 +475,53 @@ TestWebEngineView {
tryCompare(iconChangedSpy, "count", 1);
verify(!webEngineView.icon.toString().replace(/^image:\/\/favicon\//, ''));
}
+
+ function test_iconsDisabled_data() {
+ return [
+ { tag: "misc", url: Qt.resolvedUrl("favicon-misc.html") },
+ { tag: "shortcut", url: Qt.resolvedUrl("favicon-shortcut.html") },
+ { tag: "single", url: Qt.resolvedUrl("favicon-single.html") },
+ { tag: "touch", url: Qt.resolvedUrl("favicon-touch.html") },
+ { tag: "unavailable", url: Qt.resolvedUrl("favicon-unavailable.html") },
+ ];
+ }
+
+ function test_iconsDisabled(row) {
+ webEngineView.settings.autoLoadIconsForPage = false
+ webEngineView.profile = defaultProfile
+ compare(iconChangedSpy.count, 0)
+
+ webEngineView.url = row.url
+ verify(webEngineView.waitForLoadSucceeded())
+
+ compare(iconChangedSpy.count, 0)
+
+ var iconUrl = webEngineView.icon
+ compare(iconUrl, Qt.resolvedUrl(""))
+ }
+
+ function test_touchIconsEnabled_data() {
+ return [
+ { tag: "misc", url: Qt.resolvedUrl("favicon-misc.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt144.png") },
+ { tag: "shortcut", url: Qt.resolvedUrl("favicon-shortcut.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt144.png") },
+ { tag: "single", url: Qt.resolvedUrl("favicon-single.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt32.ico") },
+ { tag: "touch", url: Qt.resolvedUrl("favicon-touch.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt144.png") },
+ ];
+ }
+
+ function test_touchIconsEnabled(row) {
+ webEngineView.settings.touchIconsEnabled = true
+ webEngineView.profile = defaultProfile
+ compare(iconChangedSpy.count, 0)
+
+ webEngineView.url = row.url
+ verify(webEngineView.waitForLoadSucceeded())
+
+ iconChangedSpy.wait()
+ compare(iconChangedSpy.count, 1)
+
+ var iconUrl = removeFaviconProviderPrefix(webEngineView.icon)
+ compare(iconUrl, row.expectedIconUrl)
+ }
}
}
diff --git a/tests/auto/quick/qmltests/data/tst_faviconDatabase.qml b/tests/auto/quick/qmltests/data/tst_faviconDatabase.qml
new file mode 100644
index 000000000..284390619
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_faviconDatabase.qml
@@ -0,0 +1,216 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
+import Test.util
+import "../../qmltests/data"
+
+TestWebEngineView {
+ id: webEngineView
+ width: 200
+ height: 400
+
+ TempDir { id: tempDir }
+
+ property QtObject defaultProfile: WebEngineProfile {
+ offTheRecord: true
+ }
+
+ property QtObject nonOTRProfile: WebEngineProfile {
+ persistentStoragePath: tempDir.path() + '/WebEngineFavicon'
+ offTheRecord: false
+ }
+
+ function getFaviconPixel(faviconImage) {
+ var grabImage = Qt.createQmlObject("
+ import QtQuick\n
+ Image { }", testCase)
+ var faviconCanvas = Qt.createQmlObject("
+ import QtQuick\n
+ Canvas { }", testCase)
+
+ testCase.tryVerify(function() { return faviconImage.status == Image.Ready });
+ faviconImage.grabToImage(function(result) {
+ grabImage.source = result.url
+ });
+ testCase.tryVerify(function() { return grabImage.status == Image.Ready });
+
+ faviconCanvas.width = faviconImage.width;
+ faviconCanvas.height = faviconImage.height;
+ var ctx = faviconCanvas.getContext("2d");
+ ctx.drawImage(grabImage, 0, 0, grabImage.width, grabImage.height);
+ var imageData = ctx.getImageData(Math.round(faviconCanvas.width/2),
+ Math.round(faviconCanvas.height/2),
+ faviconCanvas.width,
+ faviconCanvas.height);
+
+ grabImage.destroy();
+ faviconCanvas.destroy();
+
+ return imageData.data;
+ }
+
+ SignalSpy {
+ id: iconChangedSpy
+ target: webEngineView
+ signalName: "iconChanged"
+ }
+
+ TestCase {
+ id: testCase
+ name: "WebEngineFaviconDatabase"
+ when: windowShown
+
+ function init() {
+ // It is worth to restore the initial state with loading a blank page before all test functions.
+ webEngineView.url = 'about:blank';
+ verify(webEngineView.waitForLoadSucceeded());
+ iconChangedSpy.clear();
+ webEngineView.settings.touchIconsEnabled = false;
+ webEngineView.settings.autoLoadIconsForPage = true;
+ }
+
+ function cleanupTestCase() {
+ tempDir.removeRecursive(nonOTRProfile.persistentStoragePath);
+ }
+
+ function test_iconDatabase_data() {
+ return [
+ { tag: "OTR", profile: defaultProfile },
+ { tag: "non-OTR", profile: nonOTRProfile },
+ ];
+ }
+
+ function test_iconDatabase(row)
+ {
+ if (Screen.devicePixelRatio !== 1.0)
+ skip("This test is not supported on High DPI screens.");
+
+ webEngineView.profile = row.profile;
+ compare(iconChangedSpy.count, 0);
+
+ var faviconImage = Qt.createQmlObject("
+ import QtQuick\n
+ Image { width: 16; height: 16; sourceSize: Qt.size(width, height); cache: false; }", testCase);
+
+ var pixel;
+ compare(iconChangedSpy.count, 0);
+
+ webEngineView.url = Qt.resolvedUrl("favicon.html"); // favicon.png -> 165
+ verify(webEngineView.waitForLoadSucceeded());
+
+ iconChangedSpy.wait();
+ compare(iconChangedSpy.count, 1);
+
+ var previousIcon = webEngineView.icon;
+ iconChangedSpy.clear();
+
+ webEngineView.url = Qt.resolvedUrl("favicon-shortcut.html"); // qt32.ico -> 251
+ verify(webEngineView.waitForLoadSucceeded());
+
+ tryCompare(iconChangedSpy, "count", 2);
+
+ // Icon database is not accessible with OTR profile.
+ faviconImage.source = previousIcon;
+ pixel = getFaviconPixel(faviconImage);
+ compare(pixel[0], webEngineView.profile.offTheRecord ? 0 : 165);
+
+ // This should pass with OTR too because icon is requested for the current page.
+ faviconImage.source = "image://favicon/" + Qt.resolvedUrl("favicon-shortcut.html");
+ pixel = getFaviconPixel(faviconImage);
+ compare(pixel[0], 251);
+
+ faviconImage.source = "image://favicon/" + Qt.resolvedUrl("favicon.html");
+ pixel = getFaviconPixel(faviconImage);
+ compare(pixel[0], webEngineView.profile.offTheRecord ? 0 : 165);
+
+ faviconImage.destroy();
+ webEngineView.profile = defaultProfile;
+ }
+
+ function test_iconDatabaseMultiView()
+ {
+ if (Screen.devicePixelRatio !== 1.0)
+ skip("This test is not supported on High DPI screens.");
+
+ var pixel;
+
+ var faviconImage = Qt.createQmlObject("
+ import QtQuick\n
+ Image { width: 16; height: 16; sourceSize: Qt.size(width, height); cache: false; }", testCase);
+
+ var webEngineView1 = Qt.createQmlObject("
+ import QtWebEngine\n
+ import Test.util\n
+ import '../../qmltests/data'\n
+ TestWebEngineView {\n
+ TempDir { id: tempDir }
+ profile: WebEngineProfile {\n
+ persistentStoragePath: tempDir.path() + '/WebEngineFavicon1'\n
+ offTheRecord: false\n
+ }\n
+ }", testCase);
+
+ var webEngineView2 = Qt.createQmlObject("
+ import QtWebEngine\n
+ import Test.util\n
+ import '../../qmltests/data'\n
+ TestWebEngineView {\n
+ TempDir { id: tempDir }
+ profile: WebEngineProfile {\n
+ persistentStoragePath: tempDir.path() + '/WebEngineFavicon2'\n
+ offTheRecord: false\n
+ }\n
+ }", testCase);
+
+ // Moke sure the icons have not been stored in the database yet.
+ var icon1 = "image://favicon/" + Qt.resolvedUrl("icons/favicon.png");
+ faviconImage.source = icon1;
+ pixel = getFaviconPixel(faviconImage);
+ compare(pixel[0], 0);
+
+ var icon2 = "image://favicon/" + Qt.resolvedUrl("icons/qt32.ico");
+ faviconImage.source = icon2;
+ pixel = getFaviconPixel(faviconImage);
+ compare(pixel[0], 0);
+
+ webEngineView1.url = Qt.resolvedUrl("favicon.html"); // favicon.png -> 165
+ verify(webEngineView1.waitForLoadSucceeded());
+ tryCompare(webEngineView1, "icon", icon1);
+ webEngineView1.url = "about:blank";
+ verify(webEngineView1.waitForLoadSucceeded());
+
+ webEngineView2.url = Qt.resolvedUrl("favicon-shortcut.html"); // qt32.ico -> 251
+ verify(webEngineView2.waitForLoadSucceeded());
+ tryCompare(webEngineView2, "icon", icon2);
+ webEngineView2.url = "about:blank";
+ verify(webEngineView2.waitForLoadSucceeded());
+
+ faviconImage.source = "";
+ compare(webEngineView1.icon, "");
+ compare(webEngineView2.icon, "");
+
+ faviconImage.source = icon1;
+ pixel = getFaviconPixel(faviconImage);
+ compare(pixel[0], 165);
+
+ faviconImage.source = icon2;
+ pixel = getFaviconPixel(faviconImage);
+ compare(pixel[0], 251);
+
+ faviconImage.source = "image://favicon/file:///does.not.exist.ico";
+ pixel = getFaviconPixel(faviconImage);
+ compare(pixel[0], 0);
+
+ webEngineView1.destroy();
+ webEngineView2.destroy();
+ faviconImage.destroy();
+
+ tempDir.removeRecursive(webEngineView1.profile.persistentStoragePath)
+ tempDir.removeRecursive(webEngineView2.profile.persistentStoragePath)
+ }
+ }
+}
+
diff --git a/tests/auto/quick/qmltests/data/tst_faviconDownload.qml b/tests/auto/quick/qmltests/data/tst_faviconDownload.qml
deleted file mode 100644
index 9aa32279c..000000000
--- a/tests/auto/quick/qmltests/data/tst_faviconDownload.qml
+++ /dev/null
@@ -1,121 +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.0
-import QtWebEngine 1.3
-import "../../qmltests/data" 1.0
-
-TestWebEngineView {
- id: webEngineView
- width: 200
- height: 400
-
- function removeFaviconProviderPrefix(url) {
- return url.toString().substring(16)
- }
-
- SignalSpy {
- id: iconChangedSpy
- target: webEngineView
- signalName: "iconChanged"
- }
-
- TestCase {
- id: test
- name: "WebEngineFaviconDownload"
-
- function init() {
- WebEngine.settings.autoLoadIconsForPage = true
- WebEngine.settings.touchIconsEnabled = false
-
- if (webEngineView.icon != '') {
- // If this is not the first test, then load a blank page without favicon, restoring the initial state.
- webEngineView.url = 'about:blank'
- verify(webEngineView.waitForLoadSucceeded())
- iconChangedSpy.wait()
- }
-
- iconChangedSpy.clear()
- }
-
- function cleanupTestCase() {
- WebEngine.settings.autoLoadIconsForPage = true
- WebEngine.settings.touchIconsEnabled = false
- }
-
- function test_downloadIconsDisabled_data() {
- return [
- { tag: "misc", url: Qt.resolvedUrl("favicon-misc.html") },
- { tag: "shortcut", url: Qt.resolvedUrl("favicon-shortcut.html") },
- { tag: "single", url: Qt.resolvedUrl("favicon-single.html") },
- { tag: "touch", url: Qt.resolvedUrl("favicon-touch.html") },
- { tag: "unavailable", url: Qt.resolvedUrl("favicon-unavailable.html") },
- ];
- }
-
- function test_downloadIconsDisabled(row) {
- WebEngine.settings.autoLoadIconsForPage = false
-
- compare(iconChangedSpy.count, 0)
-
- webEngineView.url = row.url
- verify(webEngineView.waitForLoadSucceeded())
-
- compare(iconChangedSpy.count, 0)
-
- var iconUrl = webEngineView.icon
- compare(iconUrl, Qt.resolvedUrl(""))
- }
-
- function test_downloadTouchIconsEnabled_data() {
- return [
- { tag: "misc", url: Qt.resolvedUrl("favicon-misc.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt144.png") },
- { tag: "shortcut", url: Qt.resolvedUrl("favicon-shortcut.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt144.png") },
- { tag: "single", url: Qt.resolvedUrl("favicon-single.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt32.ico") },
- { tag: "touch", url: Qt.resolvedUrl("favicon-touch.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt144.png") },
- ];
- }
-
- function test_downloadTouchIconsEnabled(row) {
- WebEngine.settings.touchIconsEnabled = true
-
- compare(iconChangedSpy.count, 0)
-
- webEngineView.url = row.url
- verify(webEngineView.waitForLoadSucceeded())
-
- iconChangedSpy.wait()
- compare(iconChangedSpy.count, 1)
-
- var iconUrl = removeFaviconProviderPrefix(webEngineView.icon)
- compare(iconUrl, row.expectedIconUrl)
- }
- }
-}
-
diff --git a/tests/auto/quick/qmltests/data/tst_filePicker.qml b/tests/auto/quick/qmltests/data/tst_filePicker.qml
index ab30d9e82..a7b59b2e9 100644
--- a/tests/auto/quick/qmltests/data/tst_filePicker.qml
+++ b/tests/auto/quick/qmltests/data/tst_filePicker.qml
@@ -1,42 +1,16 @@
-/****************************************************************************
-**
-** 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.0
-import QtWebEngine 1.2
-import "../../qmltests/data" 1.0
-import "../mock-delegates/TestParams" 1.0
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
+import "../../qmltests/data"
+import "../mock-delegates/TestParams"
TestWebEngineView {
id: webEngineView
width: 400
height: 300
- property var titleChanges: []
function driveLetter() {
if (Qt.platform.os !== "windows")
@@ -55,9 +29,8 @@ TestWebEngineView {
signalName: "renderProcessTerminated"
}
- onTitleChanged: { titleChanges.push(webEngineView.title) }
-
TestCase {
+ id: testCase
name: "WebEngineViewSingleFileUpload"
when: windowShown
@@ -68,7 +41,6 @@ TestWebEngineView {
FilePickerParams.nameFilters = []
titleSpy.clear()
terminationSpy.clear()
- titleChanges = []
}
function cleanup() {
@@ -111,10 +83,10 @@ TestWebEngineView {
keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog.
tryCompare(FilePickerParams, "filePickerOpened", true);
+ tryCompare(webEngineView, "title", row.expected);
webEngineView.url = Qt.resolvedUrl("about:blank");
verify(webEngineView.waitForLoadSucceeded());
tryCompare(webEngineView, "title", "about:blank");
- compare(titleChanges[titleChanges.length-2], row.expected);
// Custom dialog
@@ -122,7 +94,7 @@ TestWebEngineView {
function acceptedFileHandler(request) {
request.accepted = true;
- request.dialogAccept(row.input);
+ request.dialogAccept([row.input]);
finished = true;
}
@@ -132,10 +104,10 @@ TestWebEngineView {
keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog.
tryVerify(function() { return finished; });
+ tryCompare(webEngineView, "title", row.expected);
webEngineView.url = Qt.resolvedUrl("about:blank");
verify(webEngineView.waitForLoadSucceeded());
tryCompare(webEngineView, "title", "about:blank");
- compare(titleChanges[titleChanges.length-2], row.expected);
webEngineView.fileDialogRequested.disconnect(acceptedFileHandler);
}
@@ -156,13 +128,28 @@ TestWebEngineView {
webEngineView.url = Qt.resolvedUrl("directoryupload.html")
verify(webEngineView.waitForLoadSucceeded())
+ webEngineView.runJavaScript(
+ "let relativePathCount = 0;" +
+ "document.getElementById('upfile').addEventListener('change', function(event) {" +
+ " let files = event.target.files;" +
+ " for (let i = 0; i < files.length; i++) {" +
+ " if (files[i].webkitRelativePath != '')" +
+ " relativePathCount++;" +
+ " }" +
+ "}, false);")
+
FilePickerParams.selectFiles = true
FilePickerParams.selectedFilesUrl.push(Qt.resolvedUrl("../data"))
keyClick(Qt.Key_Enter) // Focus is on the button. Open FileDialog.
- tryCompare(FilePickerParams, "filePickerOpened", true)
+ tryCompare(FilePickerParams, "directoryPickerOpened", true)
// Check that the title is a file list (eg. "test1.html,test2.html")
tryVerify(function() { return webEngineView.title.match("^([^,]+,)+[^,]+$"); })
+
+ var relativePathCount = 0;
+ runJavaScript("relativePathCount", function(result) { relativePathCount = result; });
+ // The number of files in data directory may vary
+ tryVerify(function() { return relativePathCount > 0; });
}
function test_reject() {
@@ -226,15 +213,15 @@ TestWebEngineView {
{ tag: "file://applib/products/a%2Db/ abc%5F9/4148.920a/media/test.txt", input: "file://applib/products/a%2Db/ abc%5F9/4148.920a/media/test.txt", expected: "test.txt"},
{ tag: "file://applib/products/a-b/abc_1/t.est/test.txt", input: "file://applib/products/a-b/abc_1/t.est/test.txt", expected: "test.txt"},
{ tag: "file:\\\\applib\\products\\a-b\\abc_1\\t:est\\test.txt", input: "file:\\\\applib\\products\\a-b\\abc_1\\t:est\\test.txt", expected: "test.txt"},
- { tag: "file:C:/test.txt", input: "file:C:/test.txt", expected: "test.tx"},
- { tag: "file:/C:/test.txt", input: "file:/C:/test.txt", expected: "test.tx"},
+ { tag: "file:C:/test.txt", input: "file:C:/test.txt", expected: "test.txt"},
+ { tag: "file:/C:/test.txt", input: "file:/C:/test.txt", expected: "test.txt"},
{ tag: "file://C:/test.txt", input: "file://C:/test.txt", expected: "Failed to Upload"},
{ tag: "file:///C:test.txt", input: "file:///C:test.txt", expected: "Failed to Upload"},
{ tag: "file:///C:/test.txt", input: "file:///C:/test.txt", expected: "test.txt"},
{ tag: "file:///C:\\test.txt", input: "file:///C:\\test.txt", expected: "test.txt"},
{ tag: "file:\\//C:/test.txt", input: "file:\\//C:/test.txt", expected: "test.txt"},
{ tag: "file:\\\\/C:\\test.txt", input: "file:\\\\/C:\\test.txt", expected: "test.txt"},
- { tag: "\\\\?\\C:/test.txt", input: "\\\\?\\C:/test.txt", expected: "test.tx"},
+ { tag: "\\\\?\\C:/test.txt", input: "\\\\?\\C:/test.txt", expected: "test.txt"},
];
}
@@ -251,10 +238,10 @@ TestWebEngineView {
keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog.
tryCompare(FilePickerParams, "filePickerOpened", true);
+ tryCompare(webEngineView, "title", row.expected);
webEngineView.url = Qt.resolvedUrl("about:blank");
verify(webEngineView.waitForLoadSucceeded());
tryCompare(webEngineView, "title", "about:blank");
- compare(titleChanges[titleChanges.length-2], row.expected);
// Custom dialog
@@ -262,7 +249,7 @@ TestWebEngineView {
function acceptedFileHandler(request) {
request.accepted = true;
- request.dialogAccept(row.input);
+ request.dialogAccept([row.input]);
finished = true;
}
@@ -272,10 +259,10 @@ TestWebEngineView {
keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog.
tryVerify(function() { return finished; });
+ tryCompare(webEngineView, "title", row.expected);
webEngineView.url = Qt.resolvedUrl("about:blank");
verify(webEngineView.waitForLoadSucceeded());
tryCompare(webEngineView, "title", "about:blank");
- compare(titleChanges[titleChanges.length-2], row.expected);
webEngineView.fileDialogRequested.disconnect(acceptedFileHandler);
}
diff --git a/tests/auto/quick/qmltests/data/tst_filesystem.qml b/tests/auto/quick/qmltests/data/tst_filesystem.qml
new file mode 100644
index 000000000..fa0da4457
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_filesystem.qml
@@ -0,0 +1,124 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
+import Test.util
+import "../../qmltests/data"
+import "../mock-delegates/TestParams"
+
+
+TestWebEngineView {
+ id: webEngineView
+ width: 400
+ height: 300
+ property var logs: []
+ property bool accessRequested: false
+ property url file: tempDir.pathUrl('file.txt')
+
+ onJavaScriptConsoleMessage: function(level, message, lineNumber, source) {
+ var pair = message.split(':');
+ if (pair.length == 2 && pair[0] == "TEST")
+ logs.push(pair[1]);
+ }
+
+ TempDir { id: tempDir }
+
+ TestCase {
+ id: testCase
+ name: "FileSystemAPI"
+ when: windowShown
+
+ function init() {
+ clearLog()
+ FilePickerParams.filePickerOpened = false
+ FilePickerParams.selectFiles = false
+ FilePickerParams.selectedFilesUrl = []
+ FilePickerParams.nameFilters = []
+ accessRequested = false;
+ }
+
+ function cleanup() {
+ clearLog()
+ }
+
+ function clearLog() {
+ logs = []
+ }
+
+ function logContainsDoneMarker() {
+ if (logs.indexOf("DONE") > -1)
+ return true
+ else
+ return false
+ }
+
+ function result() {
+ return logs[0]
+ }
+
+ function fileAccessRequest(request) {
+ testCase.verify(!accessRequested)
+ accessRequested = true
+ testCase.verify(request.filePath == file)
+ testCase.verify(request.accessFlags == WebEngineFileSystemAccessRequest.Write | WebEngineFileSystemAccessRequest.Read)
+ request.accept()
+ }
+
+ function directoryAccessRequest(request) {
+ testCase.verify(!accessRequested)
+ accessRequested = true
+ testCase.verify(request.filePath == tempDir.pathUrl())
+ testCase.verify(request.accessFlags == WebEngineFileSystemAccessRequest.Read)
+ request.accept()
+ }
+
+ function test_saveFile() {
+ webEngineView.fileSystemAccessRequested.connect(fileAccessRequest);
+ webEngineView.url = Qt.resolvedUrl("filesystemapi.html?dialog=savePicker");
+ verify(webEngineView.waitForLoadSucceeded());
+ FilePickerParams.selectFiles = true;
+ FilePickerParams.selectedFilesUrl.push(file);
+ keyClick(Qt.Key_Enter); // Open SaveDialog.
+ tryCompare(FilePickerParams, "filePickerOpened", true);
+ tryVerify(logContainsDoneMarker,2000)
+ // write access for save dialogs is automatically granted
+ verify(!accessRequested)
+ webEngineView.fileSystemAccessRequested.disconnect(fileAccessRequest);
+ }
+
+ function test_openFile() {
+ // first save the file before open
+ test_saveFile()
+ init()
+ webEngineView.fileSystemAccessRequested.connect(fileAccessRequest);
+ webEngineView.url = Qt.resolvedUrl("filesystemapi.html?dialog=filePicker");
+ verify(webEngineView.waitForLoadSucceeded());
+ FilePickerParams.selectFiles = true;
+ FilePickerParams.selectedFilesUrl.push(file);
+ keyClick(Qt.Key_Enter); // Open FileDialog.
+ tryCompare(FilePickerParams, "filePickerOpened", true);
+ tryVerify(logContainsDoneMarker,2000)
+ verify(logs.indexOf("TEST_CONTENT") > -1)
+ verify(accessRequested)
+ webEngineView.fileSystemAccessRequested.disconnect(fileAccessRequest);
+ }
+
+ function test_selectDirectory() {
+ tempDir.createDirectory("TEST_DIR")
+ webEngineView.fileSystemAccessRequested.connect(directoryAccessRequest);
+ webEngineView.url = Qt.resolvedUrl("filesystemapi.html?dialog=directoryPicker");
+ verify(webEngineView.waitForLoadSucceeded())
+ FilePickerParams.selectFiles = true;
+ FilePickerParams.selectedFilesUrl.push(tempDir.pathUrl());
+ keyClick(Qt.Key_Enter); // Open showDirectoryDialog.
+ tryCompare(FilePickerParams, "directoryPickerOpened", true);
+ tryVerify(logContainsDoneMarker,2000)
+ verify(logs.indexOf("TEST_DIR") > -1)
+ verify(accessRequested)
+ webEngineView.fileSystemAccessRequested.disconnect(directoryAccessRequest);
+ }
+
+ }
+}
diff --git a/tests/auto/quick/qmltests/data/tst_findText.qml b/tests/auto/quick/qmltests/data/tst_findText.qml
index c02a1348e..597cff73e 100644
--- a/tests/auto/quick/qmltests/data/tst_findText.qml
+++ b/tests/auto/quick/qmltests/data/tst_findText.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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.0
-import QtWebEngine 1.2
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
@@ -56,7 +31,7 @@ TestWebEngineView {
// If this starts to fail then either clear was not called before findText
// or unexpected callback was triggered from some search.
// On c++ side callback id can be checked to verify
- testcase.verify(!findCallbackCalled(), 'Unexpected callback call or uncleared state before findText call!')
+ testCase.verify(!findCallbackCalled(), 'Unexpected callback call or uncleared state before findText call!')
webEngineView.matchCount = matchCount
findFailed = matchCount == 0
@@ -64,7 +39,7 @@ TestWebEngineView {
TestCase {
- id: testcase
+ id: testCase
name: "WebViewFindText"
function getBodyInnerHTML() {
@@ -231,8 +206,7 @@ TestWebEngineView {
var listItemText = '';
for (var i = 0; i < 100000; ++i)
- listItemText += "bla ";
- listItemText = listItemText.trim();
+ listItemText += "bla";
webEngineView.loadHtml(
"<html><body>" +
diff --git a/tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml b/tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml
index 93410a727..f070e4bc5 100644
--- a/tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml
+++ b/tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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.5
-import QtTest 1.0
-import QtWebEngine 1.4
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
Item {
id: container
@@ -65,6 +40,7 @@ Item {
}
TestCase {
+ id: testCase
name: "WebEngineViewFocusOnNavigation"
when: windowShown
diff --git a/tests/auto/quick/qmltests/data/tst_fullScreenRequest.qml b/tests/auto/quick/qmltests/data/tst_fullScreenRequest.qml
index 2d9247b26..c7996a11e 100644
--- a/tests/auto/quick/qmltests/data/tst_fullScreenRequest.qml
+++ b/tests/auto/quick/qmltests/data/tst_fullScreenRequest.qml
@@ -1,6 +1,6 @@
-import QtQuick 2.2
-import QtTest 1.0
-import QtWebEngine 1.9
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: view
diff --git a/tests/auto/quick/qmltests/data/tst_geopermission.qml b/tests/auto/quick/qmltests/data/tst_geopermission.qml
index c935ac0b4..e425a82c7 100644
--- a/tests/auto/quick/qmltests/data/tst_geopermission.qml
+++ b/tests/auto/quick/qmltests/data/tst_geopermission.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-import QtQuick 2.2
-import QtTest 1.0
-import QtWebEngine 1.1
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
@@ -37,64 +12,70 @@ TestWebEngineView {
property bool deniedGeolocation: false
property bool geoPermissionRequested: false
- signal consoleErrorMessage(string message)
- SignalSpy {
- id: featurePermissionSpy
- target: webEngineView
- signalName: "featurePermissionRequested"
- }
+ profile.persistentPermissionsPolicy: WebEngineProfile.NoPersistentPermissions
SignalSpy {
- id: consoleErrorMessageSpy
+ id: permissionSpy
target: webEngineView
- signalName: "consoleErrorMessage"
+ signalName: "permissionRequested"
}
- onFeaturePermissionRequested: {
- if (feature === WebEngineView.Geolocation) {
+ onPermissionRequested: function(perm) {
+ if (perm.feature === WebEnginePermission.Geolocation) {
geoPermissionRequested = true
if (deniedGeolocation) {
- webEngineView.grantFeaturePermission(securityOrigin, feature, false)
+ perm.deny()
}
else {
- webEngineView.grantFeaturePermission(securityOrigin, feature, true)
+ perm.grant()
}
}
}
- onJavaScriptConsoleMessage: {
- if (level === WebEngineView.ErrorMessageLevel)
- consoleErrorMessage(message)
- }
-
TestCase {
name: "WebViewGeopermission"
when: windowShown
+ function isHandled() {
+ var handled;
+ runJavaScript("handled", function(result) {
+ handled = result;
+ });
+ tryVerify(function() { return handled != undefined; }, 5000);
+ return handled;
+ }
+
+ function getErrorMessage() {
+ var errorMessage;
+ runJavaScript("errorMessage", function(result) {
+ errorMessage = result;
+ });
+ tryVerify(function() { return errorMessage != undefined; }, 5000);
+ return errorMessage;
+ }
+
function init() {
deniedGeolocation = false
- featurePermissionSpy.clear()
- consoleErrorMessageSpy.clear()
+ permissionSpy.clear()
}
function test_geoPermissionRequest() {
- compare(featurePermissionSpy.count, 0)
+ compare(permissionSpy.count, 0)
webEngineView.url = Qt.resolvedUrl("geolocation.html")
- featurePermissionSpy.wait()
+ permissionSpy.wait()
verify(geoPermissionRequested)
- compare(featurePermissionSpy.count, 1)
- consoleErrorMessageSpy.wait()
- verify(consoleErrorMessageSpy.signalArguments[0][0] === "Success" ||
- consoleErrorMessageSpy.signalArguments[0][0] === "")
+ compare(permissionSpy.count, 1)
+ tryVerify(isHandled, 5000)
+ verify(getErrorMessage() === "")
}
function test_deniedGeolocationByUser() {
deniedGeolocation = true
webEngineView.url = Qt.resolvedUrl("geolocation.html")
- featurePermissionSpy.wait()
- consoleErrorMessageSpy.wait()
- compare(consoleErrorMessageSpy.signalArguments[0][0], "User denied Geolocation")
+ permissionSpy.wait()
+ tryVerify(isHandled, 5000)
+ compare(getErrorMessage(), "User denied Geolocation")
}
}
}
diff --git a/tests/auto/quick/qmltests/data/tst_getUserMedia.qml b/tests/auto/quick/qmltests/data/tst_getUserMedia.qml
index d1c894699..9a876778b 100644
--- a/tests/auto/quick/qmltests/data/tst_getUserMedia.qml
+++ b/tests/auto/quick/qmltests/data/tst_getUserMedia.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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.6
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
@@ -36,6 +11,7 @@ TestWebEngineView {
height: 400
settings.screenCaptureEnabled: true
+ profile.persistentPermissionsPolicy: WebEngineProfile.NoPersistentPermissions
TestCase {
name: "GetUserMedia"
@@ -46,17 +22,17 @@ TestWebEngineView {
{
tag: "device audio",
constraints: { audio: true },
- feature: WebEngineView.MediaAudioCapture,
+ feature: WebEnginePermission.MediaAudioCapture,
},
{
tag: "device video",
constraints: { video: true },
- feature: WebEngineView.MediaVideoCapture,
+ feature: WebEnginePermission.MediaVideoCapture,
},
{
tag: "device audio+video",
constraints: { audio: true, video: true },
- feature: WebEngineView.MediaAudioVideoCapture,
+ feature: WebEnginePermission.MediaAudioVideoCapture,
},
{
tag: "desktop video",
@@ -67,7 +43,7 @@ TestWebEngineView {
}
}
},
- feature: WebEngineView.DesktopVideoCapture,
+ feature: WebEnginePermission.DesktopVideoCapture,
},
{
tag: "desktop audio+video",
@@ -83,7 +59,7 @@ TestWebEngineView {
}
}
},
- feature: WebEngineView.DesktopAudioVideoCapture,
+ feature: WebEnginePermission.DesktopAudioVideoCapture,
}
]
}
@@ -126,8 +102,8 @@ TestWebEngineView {
signalName: "loadFinished"
}
- onLoadingChanged: {
- if (loadRequest.status == WebEngineLoadRequest.LoadSucceededStatus) {
+ onLoadingChanged: function(load) {
+ if (load.status == WebEngineView.LoadSucceededStatus) {
loadFinished()
}
}
@@ -140,28 +116,24 @@ TestWebEngineView {
////
// synchronous permission requests
- property variant requestedFeature
- property variant requestedSecurityOrigin
+ property variant permissionObject
- onFeaturePermissionRequested: {
- requestedFeature = feature
- requestedSecurityOrigin = securityOrigin
+ onPermissionRequested: function(perm) {
+ permissionObject = perm
}
function gotFeatureRequest(expectedFeature) {
- return requestedFeature == expectedFeature
+ return permissionObject && permissionObject.feature == expectedFeature
}
function acceptPendingRequest() {
- webEngineView.grantFeaturePermission(requestedSecurityOrigin, requestedFeature, true)
- requestedFeature = undefined
- requestedSecurityOrigin = undefined
+ permissionObject.grant()
+ permissionObject = undefined
}
function rejectPendingRequest() {
- webEngineView.grantFeaturePermission(requestedSecurityOrigin, requestedFeature, false)
- requestedFeature = undefined
- requestedSecurityOrigin = undefined
+ permissionObject.deny()
+ permissionObject = undefined
}
////
diff --git a/tests/auto/quick/qmltests/data/tst_inputMethod.qml b/tests/auto/quick/qmltests/data/tst_inputMethod.qml
index 0bf9f7eb0..cf79e8a4d 100644
--- a/tests/auto/quick/qmltests/data/tst_inputMethod.qml
+++ b/tests/auto/quick/qmltests/data/tst_inputMethod.qml
@@ -1,54 +1,30 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-import QtQuick 2.0
-import QtTest 1.0
-import QtWebEngine 1.4
-import QtWebEngine.testsupport 1.0
-import "../../qmltests/data" 1.0
+import QtQuick
+import QtTest
+import QtWebEngine
+import Test.util
+import "../../qmltests/data"
TestWebEngineView {
id: webEngineView
width: 200
height: 400
- testSupport: WebEngineTestSupport { }
+ TestInputContext { id: testInputContext }
TestCase {
+ id: testCase
name: "WebEngineViewInputMethod"
when: windowShown
function init() {
- testSupport.testInputContext.create();
+ testInputContext.create();
}
function cleanup() {
- testSupport.testInputContext.release();
+ testInputContext.release();
}
function test_softwareInputPanel() {
diff --git a/tests/auto/quick/qmltests/data/tst_inputTextDirection.qml b/tests/auto/quick/qmltests/data/tst_inputTextDirection.qml
new file mode 100644
index 000000000..2141db4c8
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_inputTextDirection.qml
@@ -0,0 +1,43 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
+
+TestWebEngineView {
+ id: webEngineView
+ width: 400
+ height: 400
+
+ TestCase {
+ id: testCase
+ name: "WebEngineInputTextDirection"
+ when: windowShown
+
+ function getInputTextDirection(element) {
+ var dir;
+ runJavaScript("document.getElementById('" + element + "').dir", function(result) {
+ dir = result;
+ });
+ tryVerify(function() { return dir != undefined; });
+ return dir;
+ }
+
+ function test_changeInputTextDirection() {
+ webEngineView.loadHtml("<html><body><input type='text' id='textfield' value='some text'></body></html>");
+ verify(webEngineView.waitForLoadSucceeded());
+ setFocusToElement("textfield");
+
+ var rtlAction = webEngineView.action(WebEngineView.ChangeTextDirectionRTL);
+ verify(rtlAction);
+ rtlAction.trigger();
+ compare(getInputTextDirection("textfield"), "rtl");
+
+ var ltrAction = webEngineView.action(WebEngineView.ChangeTextDirectionLTR);
+ verify(ltrAction);
+ ltrAction.trigger();
+ compare(getInputTextDirection("textfield"), "ltr");
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml b/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml
index 658071005..6e91b2e77 100644
--- a/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml
+++ b/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml
@@ -1,54 +1,21 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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.2
-import QtWebEngine.testsupport 1.0
-import "../../qmltests/data" 1.0
-import "../mock-delegates/TestParams" 1.0
+// Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
+import "../../qmltests/data"
+import "../mock-delegates/TestParams"
TestWebEngineView {
id: webEngineView
anchors.fill: parent
- testSupport: WebEngineTestSupport {
- property bool windowCloseRejectedSignalEmitted: false
-
- function waitForWindowCloseRejected() {
- return _waitFor(function () {
- return testSupport.windowCloseRejectedSignalEmitted;
- });
- }
+ property bool windowCloseRejectedCalled: false
- onWindowCloseRejected: {
- windowCloseRejectedSignalEmitted = true;
- }
+ // Called by QQuickWebEngineViewPrivate::windowCloseRejected()
+ function windowCloseRejected() {
+ windowCloseRejectedCalled = true;
}
TestCase {
@@ -112,17 +79,32 @@ 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() {
webEngineView.url = Qt.resolvedUrl("confirmclose.html");
verify(webEngineView.waitForLoadSucceeded());
- webEngineView.testSupport.windowCloseRejectedSignalEmitted = false;
+ webEngineView.windowCloseRejectedCalled = false;
JSDialogParams.shouldAcceptDialog = false;
simulateUserGesture()
webEngineView.triggerWebAction(WebEngineView.RequestClose);
- verify(webEngineView.testSupport.waitForWindowCloseRejected());
+ tryVerify(function() { return webEngineView.windowCloseRejectedCalled; });
+
+ // 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/qmltests/data/tst_keyboardEvents.qml b/tests/auto/quick/qmltests/data/tst_keyboardEvents.qml
index 2536f319b..0f69a7e81 100644
--- a/tests/auto/quick/qmltests/data/tst_keyboardEvents.qml
+++ b/tests/auto/quick/qmltests/data/tst_keyboardEvents.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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.0
-import QtWebEngine 1.4
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
@@ -36,6 +11,7 @@ TestWebEngineView {
height: 480
TestCase {
+ id: testCase
name: "WebEngineViewKeyboardEvents"
when: windowShown
@@ -53,20 +29,6 @@ TestWebEngineView {
"Element \"" + element + "\" is " + (expected ? "" : "not") + " checked");
}
- function getElementValue(element) {
- var elementValue;
- runJavaScript("document.getElementById('" + element + "').value", function(result) {
- elementValue = result;
- });
- tryVerify(function() { return elementValue != undefined; });
- return elementValue;
- }
-
- function compareElementValue(element, expected) {
- tryVerify(function() { return expected == getElementValue(element); }, 5000,
- "Value of element \"" + element + "\" is \"" + expected + "\"");
- }
-
function test_keyboardEvents() {
webEngineView.url = Qt.resolvedUrl("keyboardEvents.html");
verify(webEngineView.waitForLoadSucceeded());
diff --git a/tests/auto/quick/qmltests/data/tst_keyboardModifierMapping.qml b/tests/auto/quick/qmltests/data/tst_keyboardModifierMapping.qml
index e0a8c0a41..d0bc75619 100644
--- a/tests/auto/quick/qmltests/data/tst_keyboardModifierMapping.qml
+++ b/tests/auto/quick/qmltests/data/tst_keyboardModifierMapping.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-import QtQuick 2.0
-import QtTest 1.0
-import QtWebEngine 1.2
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
diff --git a/tests/auto/quick/qmltests/data/tst_linkHovered.qml b/tests/auto/quick/qmltests/data/tst_linkHovered.qml
index faf943c55..a11bd2450 100644
--- a/tests/auto/quick/qmltests/data/tst_linkHovered.qml
+++ b/tests/auto/quick/qmltests/data/tst_linkHovered.qml
@@ -1,36 +1,10 @@
-/****************************************************************************
-**
-** 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.0
-import QtWebEngine 1.2
-import QtWebEngine.testsupport 1.0
-import "../../qmltests/data" 1.0
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
+import "../../qmltests/data"
TestWebEngineView {
id: webEngineView
@@ -40,25 +14,29 @@ TestWebEngineView {
property string lastUrl
- testSupport: WebEngineTestSupport { }
-
- SignalSpy {
- id: loadVisuallyCommittedSpy
- target: webEngineView.testSupport
- signalName: "loadVisuallyCommitted"
- }
-
SignalSpy {
id: linkHoveredSpy
target: webEngineView
signalName: "linkHovered"
}
- onLinkHovered: {
+ onLinkHovered: function(hoveredUrl) {
webEngineView.lastUrl = hoveredUrl
}
+ function isViewRendered() {
+ var pixel = getItemPixel(webEngineView);
+
+ // The center pixel is expected to be red.
+ if (pixel[0] !== 255) return false;
+ if (pixel[1] !== 0) return false;
+ if (pixel[2] !== 0) return false;
+
+ return true;
+ }
+
TestCase {
+ id: testCase
name: "DesktopWebEngineViewLinkHovered"
// Delayed windowShown to workaround problems with Qt5 in debug mode.
@@ -72,7 +50,6 @@ TestWebEngineView {
function init() {
webEngineView.lastUrl = "";
- loadVisuallyCommittedSpy.clear();
linkHoveredSpy.clear();
}
@@ -88,7 +65,7 @@ TestWebEngineView {
compare(webEngineView.lastUrl, "")
// Wait for the page to be rendered before trying to test based on input events
- loadVisuallyCommittedSpy.wait();
+ tryVerify(isViewRendered);
mouseMove(webEngineView, 100, 100)
linkHoveredSpy.wait(12000);
@@ -111,7 +88,7 @@ TestWebEngineView {
compare(webEngineView.lastUrl, "")
// Wait for the page to be rendered before trying to test based on input events
- loadVisuallyCommittedSpy.wait();
+ tryVerify(isViewRendered);
for (var i = 0; i < 100; i += 10)
mouseMove(webEngineView, 100, 100 + i)
diff --git a/tests/auto/quick/qmltests/data/tst_loadFail.qml b/tests/auto/quick/qmltests/data/tst_loadFail.qml
index db412f252..8e9224bbf 100644
--- a/tests/auto/quick/qmltests/data/tst_loadFail.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadFail.qml
@@ -1,36 +1,10 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-import QtQuick 2.0
-import QtTest 1.0
-import QtWebEngine 1.2
-import QtWebEngine.testsupport 1.0
-import "../../qmltests/data" 1.0
+import QtQuick
+import QtTest
+import QtWebEngine
+import "../../qmltests/data"
TestWebEngineView {
id: webEngineView
@@ -38,47 +12,21 @@ TestWebEngineView {
height: 300
property var unavailableUrl: Qt.resolvedUrl("file_that_does_not_exist.html")
- property var loadRequestArray: []
- testSupport: WebEngineTestSupport {
- property var errorPageLoadStatus: null
-
- function waitForErrorPageLoadSucceeded() {
- var success = _waitFor(function() { return testSupport.errorPageLoadStatus == WebEngineView.LoadSucceededStatus })
- testSupport.errorPageLoadStatus = null
- return success
- }
-
- errorPage.onLoadingChanged: {
- errorPageLoadStatus = loadRequest.status
-
- loadRequestArray.push({
- "status": loadRequest.status,
- "url": loadRequest.url.toString(),
- "errorDomain": loadRequest.errorDomain,
- "isErrorPage": true
- })
- }
- }
-
- onLoadingChanged: {
- if (loadRequest.status == WebEngineView.LoadFailedStatus) {
- test.compare(loadRequest.url, unavailableUrl)
- test.compare(loadRequest.errorDomain, WebEngineView.InternalErrorDomain)
- }
-
- loadRequestArray.push({
- "status": loadRequest.status,
- "url": loadRequest.url.toString(),
- "errorDomain": loadRequest.errorDomain,
- "isErrorPage": false
- })
+ SignalSpy {
+ id: loadSpy
+ target: webEngineView
+ signalName: 'loadingChanged'
}
TestCase {
id: test
name: "WebEngineViewLoadFail"
+ function cleanup() {
+ loadSpy.clear()
+ }
+
function test_fail() {
WebEngine.settings.errorPageEnabled = false
webEngineView.url = unavailableUrl
@@ -106,38 +54,23 @@ TestWebEngineView {
webEngineView.url = unavailableUrl
// Loading of the error page must be successful
- verify(webEngineView.testSupport.waitForErrorPageLoadSucceeded())
-
- var loadRequest = null
- compare(loadRequestArray.length, 4)
+ verify(webEngineView.waitForLoadFailed())
// Start to load unavailableUrl
- loadRequest = loadRequestArray[0]
- compare(loadRequest.status, WebEngineView.LoadStartedStatus)
- compare(loadRequest.errorDomain, WebEngineView.NoErrorDomain)
- compare(loadRequest.url, unavailableUrl)
- verify(!loadRequest.isErrorPage)
+ let loadStart = loadSpy.signalArguments[0][0]
+ compare(loadStart.status, WebEngineView.LoadStartedStatus)
+ compare(loadStart.errorDomain, WebEngineView.NoErrorDomain)
+ compare(loadStart.errorDomain, WebEngineLoadingInfo.NoErrorDomain)
+ compare(loadStart.url, unavailableUrl)
+ verify(!loadStart.isErrorPage)
// Loading of the unavailableUrl must fail
- loadRequest = loadRequestArray[1]
- compare(loadRequest.status, WebEngineView.LoadFailedStatus)
- compare(loadRequest.errorDomain, WebEngineView.InternalErrorDomain)
- compare(loadRequest.url, unavailableUrl)
- verify(!loadRequest.isErrorPage)
-
- // Start to load error page
- loadRequest = loadRequestArray[2]
- compare(loadRequest.status, WebEngineView.LoadStartedStatus)
- compare(loadRequest.errorDomain, WebEngineView.NoErrorDomain)
- compare(loadRequest.url, "chrome-error://chromewebdata/")
- verify(loadRequest.isErrorPage)
-
- // Loading of the error page must be successful
- loadRequest = loadRequestArray[3]
- compare(loadRequest.status, WebEngineView.LoadSucceededStatus)
- compare(loadRequest.errorDomain, WebEngineView.NoErrorDomain)
- compare(loadRequest.url, "chrome-error://chromewebdata/")
- verify(loadRequest.isErrorPage)
+ let loadFail = loadSpy.signalArguments[1][0]
+ compare(loadFail.status, WebEngineView.LoadFailedStatus)
+ compare(loadFail.errorDomain, WebEngineView.InternalErrorDomain)
+ compare(loadFail.errorDomain, WebEngineLoadingInfo.InternalErrorDomain)
+ compare(loadFail.url, unavailableUrl)
+ verify(loadFail.isErrorPage)
compare(webEngineView.url, unavailableUrl)
compare(webEngineView.title, unavailableUrl)
diff --git a/tests/auto/quick/qmltests/data/tst_loadHtml.qml b/tests/auto/quick/qmltests/data/tst_loadHtml.qml
index ed1de41fd..8f94cd4a2 100644
--- a/tests/auto/quick/qmltests/data/tst_loadHtml.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadHtml.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-import QtQuick 2.0
-import QtTest 1.0
-import QtWebEngine 1.2
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
@@ -42,6 +17,7 @@ TestWebEngineView {
}
TestCase {
+ id: testCase
name: "WebEngineViewLoadHtml"
when: windowShown
diff --git a/tests/auto/quick/qmltests/data/tst_loadProgress.qml b/tests/auto/quick/qmltests/data/tst_loadProgress.qml
index 7bfe1d9e9..2c06a0207 100644
--- a/tests/auto/quick/qmltests/data/tst_loadProgress.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadProgress.qml
@@ -1,36 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-import QtQuick 2.0
-import QtTest 1.0
-import QtWebEngine 1.2
+import QtQuick
+import QtTest
+import QtWebEngine
-import Test.Shared 1.0 as Shared
+import Test.Shared as Shared
TestWebEngineView {
id: webEngineView
diff --git a/tests/auto/quick/qmltests/data/tst_loadRecursionCrash.qml b/tests/auto/quick/qmltests/data/tst_loadRecursionCrash.qml
index 81a0f0904..c0eb5932b 100644
--- a/tests/auto/quick/qmltests/data/tst_loadRecursionCrash.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadRecursionCrash.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-import QtQuick 2.3
-import QtTest 1.0
-import QtWebEngine 1.2
+import QtQuick
+import QtTest
+import QtWebEngine
Item {
width: 300
diff --git a/tests/auto/quick/qmltests/data/tst_loadUrl.qml b/tests/auto/quick/qmltests/data/tst_loadUrl.qml
index 872c46641..25a62c878 100644
--- a/tests/auto/quick/qmltests/data/tst_loadUrl.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadUrl.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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.0
-import QtWebEngine 1.2
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
@@ -37,10 +12,10 @@ TestWebEngineView {
property var loadRequestArray: []
- onLoadingChanged: {
+ onLoadingChanged: function(load) {
loadRequestArray.push({
- "status": loadRequest.status,
- "url": loadRequest.url,
+ "status": load.status,
+ "url": load.url,
"activeUrl": webEngineView.url
});
}
@@ -52,6 +27,7 @@ TestWebEngineView {
}
TestCase {
+ id: testCase
name: "WebEngineViewLoadUrl"
when: windowShown
@@ -79,8 +55,8 @@ TestWebEngineView {
var aboutBlank = "about:blank";
webEngineView.url = aboutBlank;
verify(webEngineView.waitForLoadSucceeded());
- compare(loadRequestArray[0].status, WebEngineView.LoadStartedStatus);
- compare(loadRequestArray[1].status, WebEngineView.LoadSucceededStatus);
+ compare(loadRequestArray[0].status, WebEngineLoadingInfo.LoadStartedStatus);
+ compare(loadRequestArray[1].status, WebEngineLoadingInfo.LoadSucceededStatus);
compare(loadRequestArray.length, 2);
compare(webEngineView.url, aboutBlank);
webEngineView.clear();
@@ -133,6 +109,7 @@ TestWebEngineView {
compare(loadRequest.activeUrl, bogusSite);
loadRequest = loadRequestArray[1];
compare(loadRequest.status, WebEngineView.LoadFailedStatus);
+ compare(loadRequest.status, WebEngineLoadingInfo.LoadFailedStatus);
compare(loadRequest.activeUrl, url);
webEngineView.clear();
@@ -148,10 +125,10 @@ TestWebEngineView {
compare(loadRequest.status, WebEngineView.LoadSucceededStatus);
compare(loadRequest.activeUrl, redirectUrl);
loadRequest = loadRequestArray[2];
- compare(loadRequest.status, WebEngineView.LoadStartedStatus);
+ compare(loadRequest.status, WebEngineLoadingInfo.LoadStartedStatus);
compare(loadRequest.activeUrl, redirectUrl);
loadRequest = loadRequestArray[3];
- compare(loadRequest.status, WebEngineView.LoadSucceededStatus);
+ compare(loadRequest.status, WebEngineLoadingInfo.LoadSucceededStatus);
compare(loadRequest.activeUrl, url);
webEngineView.clear();
@@ -173,11 +150,11 @@ TestWebEngineView {
tryCompare(loadRequestArray, "length", 2);
loadRequest = loadRequestArray[0];
- compare(loadRequest.status, WebEngineView.LoadStartedStatus);
+ compare(loadRequest.status, WebEngineLoadingInfo.LoadStartedStatus);
compare(loadRequest.url, url);
compare(loadRequest.activeUrl, lastUrl);
loadRequest = loadRequestArray[1];
- compare(loadRequest.status, WebEngineView.LoadSucceededStatus);
+ compare(loadRequest.status, WebEngineLoadingInfo.LoadSucceededStatus);
compare(loadRequest.url, url);
compare(loadRequest.activeUrl, url);
webEngineView.clear();
@@ -225,15 +202,16 @@ TestWebEngineView {
compare(loadRequest.activeUrl, bogusSite);
loadRequest = loadRequestArray[1];
compare(loadRequest.status, WebEngineView.LoadFailedStatus);
+ compare(loadRequest.status, WebEngineLoadingInfo.LoadFailedStatus);
// Since the load did not succeed the active url is the
// URL of the previous successful load.
compare(loadRequest.activeUrl, aboutBlank);
loadRequest = loadRequestArray[2];
- compare(loadRequest.status, WebEngineView.LoadStartedStatus);
+ compare(loadRequest.status, WebEngineLoadingInfo.LoadStartedStatus);
compare(loadRequest.activeUrl, bogusSite);
compare(loadRequest.url, "data:text/html;charset=UTF-8,load failed")
loadRequest = loadRequestArray[3];
- compare(loadRequest.status, WebEngineView.LoadSucceededStatus);
+ compare(loadRequest.status, WebEngineLoadingInfo.LoadSucceededStatus);
compare(loadRequest.activeUrl, bogusSite);
compare(loadRequest.url, bogusSite)
webEngineView.clear();
@@ -285,6 +263,7 @@ TestWebEngineView {
compare(loadRequest.activeUrl, stoppedUrl);
loadRequest = loadRequestArray[1];
compare(loadRequest.status, WebEngineView.LoadStoppedStatus);
+ compare(loadRequest.status, WebEngineLoadingInfo.LoadStoppedStatus);
compare(loadRequest.url, stoppedUrl);
compare(loadRequest.activeUrl, initialUrl);
webEngineView.clear();
@@ -298,20 +277,19 @@ TestWebEngineView {
compare(loadRequestArray[0].status, WebEngineView.LoadStartedStatus);
compare(loadRequestArray[1].status, WebEngineView.LoadSucceededStatus);
- // In-page navigation.
- webEngineView.url = Qt.resolvedUrl("test4.html#content");
- // In-page navigation doesn't trigger load succeeded, wait for load progress instead.
- tryCompare(webEngineView, "loadProgress", 100);
- compare(loadRequestArray.length, 3);
- compare(loadRequestArray[2].status, WebEngineView.LoadStartedStatus);
+ // In-page navigation shouldn't trigger load
+ let anchorUrl = Qt.resolvedUrl("test4.html#anchor");
+ let c = webEngineView.getElementCenter('anchor')
+ mouseClick(webEngineView, c.x, c.y)
+ tryCompare(webEngineView, 'url', anchorUrl)
// Load after in-page navigation.
webEngineView.url = Qt.resolvedUrl("test4.html");
verify(webEngineView.waitForLoadSucceeded());
compare(webEngineView.loadProgress, 100);
- compare(loadRequestArray.length, 5);
- compare(loadRequestArray[3].status, WebEngineView.LoadStartedStatus);
- compare(loadRequestArray[4].status, WebEngineView.LoadSucceededStatus);
+ compare(loadRequestArray.length, 4);
+ compare(loadRequestArray[2].status, WebEngineView.LoadStartedStatus);
+ compare(loadRequestArray[3].status, WebEngineView.LoadSucceededStatus);
webEngineView.clear();
}
diff --git a/tests/auto/quick/qmltests/data/tst_mouseClick.qml b/tests/auto/quick/qmltests/data/tst_mouseClick.qml
index eaa012f86..c0c6a6967 100644
--- a/tests/auto/quick/qmltests/data/tst_mouseClick.qml
+++ b/tests/auto/quick/qmltests/data/tst_mouseClick.qml
@@ -1,44 +1,21 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
+import Test.util
+import "../../qmltests/data"
TestWebEngineView {
id: webEngineView
width: 200
height: 200
- testSupport: WebEngineTestSupport {
- function mouseMultiClick(item, x, y, clickCount) {
+ TestInputEvent {
+ id: testInputEvent
+
+ function __mouseMultiClick(item, x, y, clickCount) {
if (!item)
qtest_fail("No item given to mouseMultiClick", 1);
@@ -46,25 +23,26 @@ TestWebEngineView {
x = item.width / 2;
if (y === undefined)
y = item.height / 2;
- if (!testEvent.mouseMultiClick(item, x, y, clickCount))
+ if (!mouseMultiClick(item, x, y, clickCount))
qtest_fail("window not shown", 2);
}
function mouseDoubleClick(item, x, y) {
- mouseMultiClick(item, x, y, 2);
+ __mouseMultiClick(item, x, y, 2);
}
function mouseTripleClick(item, x, y) {
- mouseMultiClick(item, x, y, 3);
+ __mouseMultiClick(item, x, y, 3);
}
function mouseQuadraClick(item, x, y) {
- mouseMultiClick(item, x, y, 4);
+ __mouseMultiClick(item, x, y, 4);
}
}
TestCase {
+ id: testCase
name: "WebEngineViewMouseClick"
when: windowShown
@@ -90,7 +68,7 @@ TestWebEngineView {
verify(webEngineView.waitForLoadSucceeded());
var center = getElementCenter("input");
- webEngineView.testSupport.mouseDoubleClick(webEngineView, center.x, center.y);
+ testInputEvent.mouseDoubleClick(webEngineView, center.x, center.y);
verifyElementHasFocus("input");
tryVerify(function() { return getTextSelection() == "Company" });
@@ -106,7 +84,7 @@ TestWebEngineView {
verify(webEngineView.waitForLoadSucceeded());
var center = getElementCenter("input");
- webEngineView.testSupport.mouseTripleClick(webEngineView, center.x, center.y);
+ testInputEvent.mouseTripleClick(webEngineView, center.x, center.y);
verifyElementHasFocus("input");
tryVerify(function() { return getTextSelection() == "The Qt Company" });
@@ -122,7 +100,7 @@ TestWebEngineView {
verify(webEngineView.waitForLoadSucceeded());
var center = getElementCenter("input");
- webEngineView.testSupport.mouseQuadraClick(webEngineView, center.x, center.y);
+ testInputEvent.mouseQuadraClick(webEngineView, center.x, center.y);
verifyElementHasFocus("input");
tryVerify(function() { return getTextSelection() == "" });
}
diff --git a/tests/auto/quick/qmltests/data/tst_mouseMove.qml b/tests/auto/quick/qmltests/data/tst_mouseMove.qml
index adfa3941c..5ded24c57 100644
--- a/tests/auto/quick/qmltests/data/tst_mouseMove.qml
+++ b/tests/auto/quick/qmltests/data/tst_mouseMove.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-import QtQuick 2.0
-import QtTest 1.0
-import QtWebEngine 1.4
+import QtQuick
+import QtTest
+import QtWebEngine
Rectangle {
id: root
diff --git a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml
index 6ed232589..2ea76c387 100644
--- a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml
+++ b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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.0
-import QtWebEngine 1.2
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
@@ -38,7 +13,7 @@ TestWebEngineView {
ListView {
id: backItemsList
anchors.fill: parent
- model: webEngineView.navigationHistory.backItems
+ model: webEngineView.history.backItems
currentIndex: count - 1
delegate:
Text {
@@ -50,7 +25,7 @@ TestWebEngineView {
ListView {
id: forwardItemsList
anchors.fill: parent
- model: webEngineView.navigationHistory.forwardItems
+ model: webEngineView.history.forwardItems
currentIndex: 0
delegate:
Text {
@@ -59,11 +34,23 @@ TestWebEngineView {
}
}
+ Item { // simple button-like interface to not depend on controls
+ id: backButton
+ enabled: webEngineView.canGoBack
+ function clicked() { if (enabled) webEngineView.goBack() }
+ }
+
+ Item { // simple button-like interface to not depend on controls
+ id: forwardButton
+ enabled: webEngineView.canGoForward
+ function clicked() { if (enabled) webEngineView.goForward() }
+ }
+
TestCase {
- name: "WebEngineViewNavigationHistory"
+ name: "NavigationHistory"
function test_navigationHistory() {
- compare(webEngineView.loadProgress, 0)
+ webEngineView.history.clear()
webEngineView.url = Qt.resolvedUrl("test1.html")
verify(webEngineView.waitForLoadSucceeded())
@@ -135,12 +122,58 @@ TestWebEngineView {
compare(backItemsList.currentItem.text, Qt.resolvedUrl("test1.html"))
compare(forwardItemsList.currentItem.text, Qt.resolvedUrl("javascript.html"))
- webEngineView.navigationHistory.clear()
+ webEngineView.history.clear()
compare(webEngineView.url, Qt.resolvedUrl("test2.html"))
compare(webEngineView.canGoBack, false)
compare(webEngineView.canGoForward, false)
compare(backItemsList.count, 0)
compare(forwardItemsList.count, 0)
}
+
+ function test_navigationButtons() {
+ webEngineView.history.clear()
+
+ const url1 = Qt.resolvedUrl("test1.html")
+ webEngineView.url = url1
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(backButton.enabled, false)
+ compare(forwardButton.enabled, false)
+
+ const url2 = Qt.resolvedUrl("test2.html")
+ webEngineView.url = url2
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(backButton.enabled, true)
+ compare(forwardButton.enabled, false)
+
+ const url3 = Qt.resolvedUrl("test3.html")
+ webEngineView.url = url3
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(backButton.enabled, true)
+ compare(forwardButton.enabled, false)
+
+ backButton.clicked()
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(backButton.enabled, true)
+ compare(forwardButton.enabled, true)
+ compare(webEngineView.url, url2)
+
+ backButton.clicked()
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(backButton.enabled, false)
+ compare(forwardButton.enabled, true)
+ compare(webEngineView.url, url1)
+
+ forwardButton.clicked()
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(backButton.enabled, true)
+ compare(forwardButton.enabled, true)
+ compare(webEngineView.url, url2)
+
+ webEngineView.url = url1
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(backButton.enabled, true)
+ compare(forwardButton.enabled, false)
+ compare(webEngineView.url, url1)
+ }
}
}
diff --git a/tests/auto/quick/qmltests/data/tst_navigationRequested.qml b/tests/auto/quick/qmltests/data/tst_navigationRequested.qml
index 96128574e..31c0cf44e 100644
--- a/tests/auto/quick/qmltests/data/tst_navigationRequested.qml
+++ b/tests/auto/quick/qmltests/data/tst_navigationRequested.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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.0
-import QtWebEngine 1.2
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
@@ -59,26 +34,27 @@ TestWebEngineView {
signalName: "navigationRequested"
}
- onNavigationRequested: {
+ onNavigationRequested: function(request) {
if (request.isMainFrame) {
attributes.mainUrl = request.url
} else {
attributes.iframeUrl = request.url
if (shouldIgnoreSubFrameRequests) {
- request.action = WebEngineView.IgnoreRequest
+ request.reject()
}
}
- if (request.navigationType === WebEngineView.LinkClickedNavigation) {
+ if (request.navigationType === WebEngineNavigationRequest.LinkClickedNavigation) {
attributes.linkClickedNavigationRequested = true
if (shouldIgnoreLinkClicks) {
- request.action = WebEngineView.IgnoreRequest
+ request.reject()
attributes.linkClickedNavigationIgnored = true
}
}
}
TestCase {
+ id: testCase
name: "WebEngineViewNavigationRequested"
when: windowShown
@@ -93,19 +69,17 @@ TestWebEngineView {
// Test if we get notified about main frame and iframe loads
compare(navigationSpy.count, 0)
webEngineView.url = Qt.resolvedUrl("test-iframe.html")
- navigationSpy.wait()
+ verify(webEngineView.waitForLoadSucceeded())
compare(attributes.mainUrl, Qt.resolvedUrl("test-iframe.html"))
- navigationSpy.wait()
compare(attributes.iframeUrl, Qt.resolvedUrl("test1.html"))
compare(navigationSpy.count, 2)
- verify(webEngineView.waitForLoadSucceeded())
// Test if we get notified about clicked links
mouseClick(webEngineView, 100, 100)
- tryCompare(navigationSpy, "count", 3)
+ verify(webEngineView.waitForLoadSucceeded())
compare(attributes.mainUrl, Qt.resolvedUrl("test1.html"))
verify(attributes.linkClickedNavigationRequested)
- verify(webEngineView.waitForLoadSucceeded())
+ compare(navigationSpy.count, 3)
}
function test_ignoreLinkClickedRequest() {
@@ -116,26 +90,28 @@ TestWebEngineView {
shouldIgnoreLinkClicks = true
mouseClick(webEngineView, 100, 100)
- tryCompare(navigationSpy, "count", 3)
- compare(attributes.mainUrl, Qt.resolvedUrl("test1.html"))
- verify(attributes.linkClickedNavigationRequested)
- verify(attributes.linkClickedNavigationIgnored)
// We ignored the main frame request, so we should
// get notified that the load has been stopped.
verify(webEngineView.waitForLoadStopped())
verify(!webEngineView.loading)
+
+ compare(navigationSpy.count, 3)
+ compare(attributes.mainUrl, Qt.resolvedUrl("test1.html"))
+ verify(attributes.linkClickedNavigationRequested)
+ verify(attributes.linkClickedNavigationIgnored)
}
function test_ignoreSubFrameRequest() {
// Test if we can ignore sub frame requests
shouldIgnoreSubFrameRequests = true
webEngineView.url = Qt.resolvedUrl("test-iframe.html")
- tryCompare(navigationSpy, "count", 2)
- compare(attributes.mainUrl, Qt.resolvedUrl("test-iframe.html"))
- compare(attributes.iframeUrl, Qt.resolvedUrl("test1.html"))
// We ignored the sub frame request, so
// the main frame load should still succeed.
verify(webEngineView.waitForLoadSucceeded())
+
+ compare(navigationSpy.count, 2)
+ compare(attributes.mainUrl, Qt.resolvedUrl("test-iframe.html"))
+ compare(attributes.iframeUrl, Qt.resolvedUrl("test1.html"))
}
}
}
diff --git a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
index 80389e9f8..68350d107 100644
--- a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
+++ b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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.0
-import QtWebEngine 1.5
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
@@ -38,14 +13,21 @@ TestWebEngineView {
property var newViewRequest: null
property var dialog: null
property string viewType: ""
+ property var loadRequestArray: []
+
+ onLoadingChanged: function(load) {
+ loadRequestArray.push({
+ "status": load.status,
+ });
+ }
SignalSpy {
id: newViewRequestedSpy
target: webEngineView
- signalName: "newViewRequested"
+ signalName: "newWindowRequested"
}
- onNewViewRequested: {
+ onNewWindowRequested: function(request) {
newViewRequest = {
"destination": request.destination,
"userInitiated": request.userInitiated,
@@ -53,7 +35,7 @@ TestWebEngineView {
};
dialog = Qt.createQmlObject(
- "import QtQuick.Window 2.0\n" +
+ "import QtQuick.Window\n" +
"Window {\n" +
" width: 100; height: 100\n" +
" visible: true; flags: Qt.Dialog\n" +
@@ -70,8 +52,8 @@ TestWebEngineView {
}
TestCase {
- id: test
- name: "NewViewRequest"
+ id: testCase
+ name: "NewWindowRequest"
when: windowShown
function init() {
@@ -81,6 +63,7 @@ TestWebEngineView {
newViewRequestedSpy.clear();
newViewRequest = null;
viewType = "";
+ loadRequestArray = [];
}
function cleanup() {
@@ -88,7 +71,7 @@ TestWebEngineView {
dialog.destroy();
}
- function test_loadNewViewRequest_data() {
+ function test_loadNewWindowRequest_data() {
return [
{ tag: "dialog", viewType: "dialog" },
{ tag: "invalid", viewType: "null" },
@@ -97,7 +80,7 @@ TestWebEngineView {
];
}
- function test_loadNewViewRequest(row) {
+ function test_loadNewWindowRequest(row) {
viewType = row.viewType;
var url = 'data:text/html,%3Chtml%3E%3Cbody%3ETest+Page%3C%2Fbody%3E%3C%2Fhtml%3E';
@@ -110,16 +93,15 @@ TestWebEngineView {
verify(webEngineView.waitForLoadSucceeded());
tryCompare(newViewRequestedSpy, "count", 1);
- compare(newViewRequest.destination, WebEngineView.NewViewInTab);
+ compare(newViewRequest.destination, WebEngineNewWindowRequest.InNewTab);
verify(!newViewRequest.userInitiated);
if (viewType === "dialog") {
- verify(dialog.webEngineView.waitForLoadSucceeded());
- compare(dialog.webEngineView.url, "");
+ tryVerify(dialog.webEngineView.loadSucceeded)
+ compare(dialog.webEngineView.url, Qt.url("about:blank"));
dialog.destroy();
}
- // https://chromium-review.googlesource.com/c/chromium/src/+/1300395
- compare(newViewRequest.requestedUrl, 'about:blank#blocked');
+ compare(newViewRequest.requestedUrl, 'about:blank');
newViewRequestedSpy.clear();
// Open a page in a new dialog
@@ -131,11 +113,11 @@ TestWebEngineView {
verify(webEngineView.waitForLoadSucceeded());
tryCompare(newViewRequestedSpy, "count", 1);
- compare(newViewRequest.destination, WebEngineView.NewViewInDialog);
+ compare(newViewRequest.destination, WebEngineNewWindowRequest.InNewDialog);
compare(newViewRequest.requestedUrl, url);
verify(!newViewRequest.userInitiated);
if (viewType === "dialog") {
- verify(dialog.webEngineView.waitForLoadSucceeded());
+ tryVerify(dialog.webEngineView.loadSucceeded)
dialog.destroy();
}
newViewRequestedSpy.clear();
@@ -150,19 +132,36 @@ TestWebEngineView {
" <button id='popupButton' onclick='popup()'>Pop Up!</button>" +
"</body></html>");
verify(webEngineView.waitForLoadSucceeded());
- verifyElementHasFocus("popupButton");
+ webEngineView.verifyElementHasFocus("popupButton");
keyPress(Qt.Key_Enter);
tryCompare(newViewRequestedSpy, "count", 1);
compare(newViewRequest.requestedUrl, url);
- compare(newViewRequest.destination, WebEngineView.NewViewInDialog);
+ compare(newViewRequest.destination, WebEngineNewWindowRequest.InNewDialog);
verify(newViewRequest.userInitiated);
if (viewType === "dialog") {
- verify(dialog.webEngineView.waitForLoadSucceeded());
+ tryVerify(dialog.webEngineView.loadSucceeded)
dialog.destroy();
}
newViewRequestedSpy.clear();
}
+
+ loadRequestArray = [];
+ compare(loadRequestArray.length, 0);
+ webEngineView.url = Qt.resolvedUrl("test2.html");
+ verify(webEngineView.waitForLoadSucceeded());
+ var center = webEngineView.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, WebEngineNewWindowRequest.InNewBackgroundTab);
+ 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_notification.qml b/tests/auto/quick/qmltests/data/tst_notification.qml
index 773bf4a8e..5defbff4b 100644
--- a/tests/auto/quick/qmltests/data/tst_notification.qml
+++ b/tests/auto/quick/qmltests/data/tst_notification.qml
@@ -1,34 +1,10 @@
-/****************************************************************************
-**
-** 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
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
+import Test.Shared as Shared
TestWebEngineView {
id: view
@@ -37,21 +13,26 @@ TestWebEngineView {
property bool permissionRequested: false
property bool grantPermission: false
- property url securityOrigin: ''
+ property var permissionObject
+
+ profile.persistentPermissionsPolicy: WebEngineProfile.NoPersistentPermissions
signal consoleMessage(string message)
SignalSpy {
id: spyRequest
target: view
- signalName: 'featurePermissionRequested'
+ signalName: 'permissionRequested'
}
- onFeaturePermissionRequested: {
- if (feature === WebEngineView.Notifications) {
+ onPermissionRequested: function(perm) {
+ if (perm.feature === WebEnginePermission.Notifications) {
view.permissionRequested = true
- view.securityOrigin = securityOrigin
- view.grantFeaturePermission(securityOrigin, feature, grantPermission)
+ view.permissionObject = perm
+ if (grantPermission)
+ perm.grant()
+ else
+ perm.deny()
}
}
@@ -60,7 +41,8 @@ TestWebEngineView {
when: windowShown
function resolverUrl(html) {
- return Qt.resolvedUrl('../../../shared/data/' + html)
+ console.log(Shared.HttpServer.sharedDataDir())
+ return Qt.resolvedUrl(Shared.HttpServer.sharedDataDir() + "/" + html)
}
function init() {
@@ -114,7 +96,7 @@ TestWebEngineView {
compare(notification.title, title)
compare(notification.message, message)
compare(notification.direction, Qt.RightToLeft)
- compare(notification.origin, securityOrigin)
+ compare(notification.origin, permissionObject.origin)
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
deleted file mode 100644
index ee7fa4e99..000000000
--- a/tests/auto/quick/qmltests/data/tst_profile.qml
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** 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/data/tst_properties.qml b/tests/auto/quick/qmltests/data/tst_properties.qml
index 89f8af9b8..13d40ed11 100644
--- a/tests/auto/quick/qmltests/data/tst_properties.qml
+++ b/tests/auto/quick/qmltests/data/tst_properties.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-import QtQuick 2.0
-import QtTest 1.0
-import QtWebEngine 1.2
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
diff --git a/tests/auto/quick/qmltests/data/tst_runJavaScript.qml b/tests/auto/quick/qmltests/data/tst_runJavaScript.qml
index beeebc049..f16cd9c41 100644
--- a/tests/auto/quick/qmltests/data/tst_runJavaScript.qml
+++ b/tests/auto/quick/qmltests/data/tst_runJavaScript.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-import QtQuick 2.0
-import QtTest 1.0
-import QtWebEngine 1.2
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
@@ -59,8 +34,7 @@ TestWebEngineView {
compare(result, testTitle2);
callbackCalled = true;
});
- wait(100);
- verify(callbackCalled);
+ tryVerify(function() { return callbackCalled; });
}
}
}
diff --git a/tests/auto/quick/qmltests/data/tst_save.qml b/tests/auto/quick/qmltests/data/tst_save.qml
new file mode 100644
index 000000000..3289dbd8b
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_save.qml
@@ -0,0 +1,185 @@
+import QtQuick
+import QtTest
+import QtWebEngine
+import Test.util
+
+TestWebEngineView {
+ id: webEngineView
+ width: 200
+ height: 200
+ profile: testSaveProfile
+
+ property url downloadUrl: ""
+ property int totalBytes: 0
+ property int receivedBytes: 0
+ property string downloadDir: ""
+ property string downloadFileName: ""
+ property bool isSavePageDownload: false
+ property var downloadState: []
+ property int savePageFormat: WebEngineDownloadRequest.MimeHtmlSaveFormat;
+ property bool autoCancel: false
+
+ TempDir {
+ id: tempDir
+ }
+
+ SignalSpy {
+ id: downLoadRequestedSpy
+ target: testSaveProfile
+ signalName: "downloadRequested"
+ }
+
+ SignalSpy {
+ id: downloadFinishedSpy
+ target: testSaveProfile
+ signalName: "downloadFinished"
+ }
+
+ WebEngineProfile {
+ id: testSaveProfile
+
+ onDownloadRequested: function(download) {
+ downloadState.push(download.state)
+ downloadUrl = download.url
+ savePageFormat = download.savePageFormat
+ downloadDir = download.downloadDirectory;
+ downloadFileName = download.downloadFileName
+ isSavePageDownload = download.isSavePageDownload
+
+ if (autoCancel)
+ download.cancel()
+ }
+ onDownloadFinished: function(download) {
+ receivedBytes = download.receivedBytes
+ totalBytes = download.totalBytes
+ downloadState.push(download.state)
+ }
+ }
+
+ TestCase {
+ name: "WebEngineViewSave"
+
+ function verifyData() {
+ var isDataValid = false
+ webEngineView.runJavaScript("(function() {" +
+ "var title = document.title.toString();" +
+ "var body = document.body.innerText;" +
+ " return title === \"Test page 1\" && body.includes(\"Hello.\")" +
+ "})();", function(result) {
+ isDataValid = result;
+ });
+ tryVerify(function() { return isDataValid });
+ return isDataValid;
+ }
+
+ function init() {
+ downLoadRequestedSpy.clear()
+ downloadFinishedSpy.clear()
+ totalBytes = 0
+ receivedBytes = 0
+ downloadDir = ""
+ downloadFileName = ""
+ isSavePageDownload = false
+ downloadState = []
+ downloadUrl = ""
+ autoCancel = false
+ }
+
+ function test_savePage_data() {
+ return [
+ { tag: "SingleHtmlSaveFormat", savePageFormat: WebEngineDownloadRequest.SingleHtmlSaveFormat },
+ { tag: "CompleteHtmlSaveFormat", savePageFormat: WebEngineDownloadRequest.CompleteHtmlSaveFormat },
+ { tag: "MimeHtmlSaveFormat", savePageFormat: WebEngineDownloadRequest.MimeHtmlSaveFormat },
+ ];
+ }
+
+ function test_savePage(row) {
+ var saveFormat = row.savePageFormat
+
+ var fileDir = tempDir.path()
+ var fileName = "saved_page.html"
+ var filePath = fileDir + "/"+ fileName
+
+ // load data to view
+ webEngineView.url = Qt.resolvedUrl("test1.html")
+ verify(webEngineView.waitForLoadSucceeded())
+ verify(verifyData())
+
+ webEngineView.save(filePath, saveFormat)
+ downLoadRequestedSpy.wait()
+ compare(downLoadRequestedSpy.count, 1)
+ compare(downloadUrl, webEngineView.url)
+ compare(savePageFormat, saveFormat)
+ compare(downloadDir, fileDir)
+ compare(downloadFileName, fileName)
+ compare(isSavePageDownload, true)
+ compare(downloadState[0], WebEngineDownloadRequest.DownloadInProgress)
+ downloadFinishedSpy.wait()
+ compare(downloadFinishedSpy.count, 1)
+ compare(totalBytes, receivedBytes)
+ compare(downloadState[1], WebEngineDownloadRequest.DownloadCompleted)
+
+ // load some other data
+ webEngineView.url = Qt.resolvedUrl("about:blank")
+ verify(webEngineView.waitForLoadSucceeded())
+
+ // load save file to view
+ webEngineView.url = Qt.resolvedUrl(filePath)
+ verify(webEngineView.waitForLoadSucceeded())
+ verify(verifyData())
+ }
+
+ function test_saveImage_data() {
+ return [
+ { tag: "Auto accept", autoCancel: false },
+ { tag: "Cancel", autoCancel: true },
+ ];
+ }
+
+ function test_saveImage(row) {
+ autoCancel = row.autoCancel
+
+ var fileDir = tempDir.path()
+ var fileName = "favicon.png"
+ var filePath = fileDir + "/"+ fileName
+
+ // Load an image
+ webEngineView.url = Qt.resolvedUrl("icons/favicon.png")
+ verify(webEngineView.waitForLoadSucceeded())
+
+ webEngineView.save(filePath)
+ downLoadRequestedSpy.wait()
+ compare(downLoadRequestedSpy.count, 1)
+ compare(downloadUrl, webEngineView.url)
+ compare(downloadDir, fileDir)
+ compare(downloadFileName, fileName)
+ compare(isSavePageDownload, true)
+ compare(downloadState[0], WebEngineDownloadRequest.DownloadInProgress)
+ downloadFinishedSpy.wait()
+ compare(downloadFinishedSpy.count, 1)
+ if (autoCancel) {
+ compare(receivedBytes, 0)
+ compare(downloadState[1], WebEngineDownloadRequest.DownloadCancelled)
+ } else {
+ compare(totalBytes, receivedBytes)
+ compare(downloadState[1], WebEngineDownloadRequest.DownloadCompleted)
+ }
+ }
+
+ function test_saveWebAction() {
+ // Load an image
+ webEngineView.url = Qt.resolvedUrl("icons/favicon.png")
+ verify(webEngineView.waitForLoadSucceeded())
+
+ // Saving without specifying path shouldn't be auto accepted
+ webEngineView.triggerWebAction(WebEngineView.SavePage)
+ downLoadRequestedSpy.wait()
+ compare(downLoadRequestedSpy.count, 1)
+ compare(downloadUrl, webEngineView.url)
+ compare(isSavePageDownload, true)
+ // The initial download request starts from DownloadRequested state,
+ // which means it wasn't automatically accepted.
+ compare(downloadState[0], WebEngineDownloadRequest.DownloadRequested)
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests/data/tst_scrollPosition.qml b/tests/auto/quick/qmltests/data/tst_scrollPosition.qml
index 24b352dde..cc7d15e4c 100644
--- a/tests/auto/quick/qmltests/data/tst_scrollPosition.qml
+++ b/tests/auto/quick/qmltests/data/tst_scrollPosition.qml
@@ -1,35 +1,9 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-import QtQuick 2.2
-import QtQuick.Window 2.0
-import QtTest 1.0
-import QtWebEngine 1.3
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
@@ -61,7 +35,7 @@ TestWebEngineView {
tryCompare(scrollPositionSpy, "count", 1);
compare(webEngineView.scrollPosition.x, 0);
- compare(webEngineView.scrollPosition.y, 600 * Screen.devicePixelRatio);
+ compare(webEngineView.scrollPosition.y, 600);
}
function test_scrollPositionAfterReload() {
@@ -74,13 +48,13 @@ TestWebEngineView {
// Wait for proper scroll position change otherwise we cannot expect
// the new y position after reload.
tryCompare(webEngineView.scrollPosition, "x", 0);
- tryCompare(webEngineView.scrollPosition, "y", 600 * Screen.devicePixelRatio);
+ tryCompare(webEngineView.scrollPosition, "y", 600);
webEngineView.reload();
verify(webEngineView.waitForLoadSucceeded());
tryCompare(webEngineView.scrollPosition, "x", 0);
- tryCompare(webEngineView.scrollPosition, "y", 600 * Screen.devicePixelRatio);
+ tryCompare(webEngineView.scrollPosition, "y", 600);
}
}
}
diff --git a/tests/auto/quick/qmltests/data/tst_settings.qml b/tests/auto/quick/qmltests/data/tst_settings.qml
index 2ff4f9c3c..f47674aa7 100644
--- a/tests/auto/quick/qmltests/data/tst_settings.qml
+++ b/tests/auto/quick/qmltests/data/tst_settings.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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.0
-import QtWebEngine 1.2
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
@@ -36,6 +11,7 @@ TestWebEngineView {
height: 300
TestCase {
+ id: testCase
name: "WebEngineViewSettings"
function test_javascriptEnabled() {
@@ -75,7 +51,7 @@ TestWebEngineView {
}
function test_settingsAffectCurrentViewOnly() {
- var webEngineView2 = Qt.createQmlObject('TestWebEngineView {width: 400; height: 300;}', webEngineView);
+ var webEngineView2 = Qt.createQmlObject('TestWebEngineView {width: 400; height: 300;}', testCase);
webEngineView.settings.javascriptEnabled = true;
webEngineView2.settings.javascriptEnabled = true;
@@ -102,6 +78,68 @@ TestWebEngineView {
webEngineView2.destroy();
}
+
+ function test_disableReadingFromCanvas_data() {
+ return [
+ { tag: 'disabled', disableReadingFromCanvas: false, result: true },
+ { tag: 'enabled', disableReadingFromCanvas: true, result: false },
+ ]
+ }
+
+ function test_disableReadingFromCanvas(data) {
+ webEngineView.settings.readingFromCanvasEnabled = !data.disableReadingFromCanvas;
+ webEngineView.loadHtml("<html><body>" +
+ "<canvas id='myCanvas' width='200' height='40' style='border:1px solid #000000;'></canvas>" +
+ "</body></html>");
+ verify(webEngineView.waitForLoadSucceeded());
+ verify(webEngineView.settings.readingFromCanvasEnabled === !data.disableReadingFromCanvas )
+
+ var jsCode = "(function(){" +
+ " var canvas = document.getElementById(\"myCanvas\");" +
+ " var ctx = canvas.getContext(\"2d\");" +
+ " ctx.fillStyle = \"rgb(255,0,255)\";" +
+ " ctx.fillRect(0, 0, 200, 40);" +
+ " try {" +
+ " src = canvas.toDataURL();" +
+ " }" +
+ " catch(err) {" +
+ " src = \"\";" +
+ " }" +
+ " return src.length ? true : false;" +
+ "})();";
+
+ var isDataRead = false;
+ runJavaScript(jsCode, function(result) {
+ isDataRead = result
+ });
+ tryVerify(function() { return isDataRead === data.result });
+ }
+
+ function test_forceDarkMode() {
+ // based on: https://developer.chrome.com/blog/auto-dark-theme/#detecting-auto-dark-theme
+ webEngineView.loadHtml("<html><body>" +
+ "<div id=\"detection\", style=\"display: none; background-color: canvas; color-scheme: light\"</div>" +
+ "</body></html>");
+ const script = "(() => {"
+ + " const detectionDiv = document.querySelector('#detection');"
+ + " return getComputedStyle(detectionDiv).backgroundColor != 'rgb(255, 255, 255)';"
+ + "})()";
+ verify(webEngineView.waitForLoadSucceeded());
+
+ var isAutoDark = true;
+ runJavaScript(script, result => isAutoDark = result);
+ tryVerify(() => {return !isAutoDark});
+
+ webEngineView.settings.forceDarkMode = true;
+ verify(webEngineView.settings.forceDarkMode == true)
+
+ isAutoDark = false;
+ // the page is not updated immediately
+ tryVerify(function() {
+ runJavaScript(script, result => isAutoDark = result);
+ return isAutoDark;
+ });
+ }
}
}
diff --git a/tests/auto/quick/qmltests/data/tst_titleChanged.qml b/tests/auto/quick/qmltests/data/tst_titleChanged.qml
index 7dda5ce33..66a7c115f 100644
--- a/tests/auto/quick/qmltests/data/tst_titleChanged.qml
+++ b/tests/auto/quick/qmltests/data/tst_titleChanged.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-import QtQuick 2.0
-import QtTest 1.0
-import QtWebEngine 1.2
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
diff --git a/tests/auto/quick/qmltests/data/tst_unhandledKeyEventPropagation.qml b/tests/auto/quick/qmltests/data/tst_unhandledKeyEventPropagation.qml
index 69aa76b77..76363fa71 100644
--- a/tests/auto/quick/qmltests/data/tst_unhandledKeyEventPropagation.qml
+++ b/tests/auto/quick/qmltests/data/tst_unhandledKeyEventPropagation.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-import QtQuick 2.0
-import QtTest 1.0
-import QtWebEngine 1.2
+import QtQuick
+import QtTest
+import QtWebEngine
Item {
id: parentItem
@@ -37,8 +12,12 @@ Item {
property var pressEvents: []
property var releaseEvents: []
- Keys.onPressed: pressEvents.push(event.key)
- Keys.onReleased: releaseEvents.push(event.key)
+ Keys.onPressed: function(event) {
+ pressEvents.push(event.key)
+ }
+ Keys.onReleased: function(event) {
+ releaseEvents.push(event.key)
+ }
TestWebEngineView {
id: webEngineView
@@ -46,6 +25,7 @@ Item {
focus: true
}
TestCase {
+ id: testCase
name: "WebEngineViewUnhandledKeyEventPropagation"
when: false
diff --git a/tests/auto/quick/qmltests/data/tst_userScriptCollection.qml b/tests/auto/quick/qmltests/data/tst_userScriptCollection.qml
new file mode 100644
index 000000000..94c993771
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_userScriptCollection.qml
@@ -0,0 +1,127 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
+
+Item {
+
+ WebEngineProfile { id: testProfile }
+
+ TestWebEngineView {
+ id: webEngineView
+ width: 400
+ height: 300
+ }
+
+ TestCase {
+ name: "UserScriptCollection"
+
+ function cleanup() {
+ webEngineView.url = ""
+ webEngineView.userScripts.collection = []
+ compare(webEngineView.userScripts.collection.length, 0)
+ }
+
+ function test_collection() {
+ let scriptFoo = { name: "Foo",
+ sourceUrl: Qt.resolvedUrl("foo.js"),
+ injectionPoint: WebEngineScript.DocumentReady
+ }
+ let scriptBar = WebEngine.script()
+
+ scriptBar.name = "Bar"
+ scriptBar.sourceUrl = Qt.resolvedUrl("bar.js")
+ scriptBar.injectionPoint = WebEngineScript.DocumentReady
+
+ compare(webEngineView.userScripts.collection.length, 0)
+ webEngineView.userScripts.collection = [ scriptFoo, scriptBar ]
+ compare(webEngineView.userScripts.collection.length, 2)
+ compare(webEngineView.userScripts.collection[0].name, scriptFoo.name)
+ compare(webEngineView.userScripts.collection[0].sourceUrl, scriptFoo.sourceUrl)
+ compare(webEngineView.userScripts.collection[1].name, scriptBar.name)
+ compare(webEngineView.userScripts.collection[1].sourceUrl, scriptBar.sourceUrl)
+ webEngineView.userScripts.collection = []
+ compare(webEngineView.userScripts.collection.length, 0)
+ }
+
+ function test_insert() {
+ let scriptFoo = WebEngine.script()
+ scriptFoo.name = "Foo"
+ scriptFoo.sourceUrl = Qt.resolvedUrl("foo.js")
+ scriptFoo.injectionPoint = WebEngineScript.DocumentReady
+ let scriptBar = WebEngine.script()
+ scriptBar.name = "Bar"
+ scriptBar.sourceUrl = Qt.resolvedUrl("bar.js")
+ scriptBar.injectionPoint = WebEngineScript.DocumentReady
+
+ compare(webEngineView.userScripts.collection.length, 0)
+ webEngineView.userScripts.insert(scriptFoo)
+ webEngineView.userScripts.insert(scriptBar)
+ compare(webEngineView.userScripts.collection.length, 2)
+ compare(webEngineView.userScripts.collection[0].name, scriptFoo.name)
+ compare(webEngineView.userScripts.collection[1].name, scriptBar.name)
+ webEngineView.userScripts.collection = []
+ compare(webEngineView.userScripts.collection.length, 0)
+
+ var list = [ scriptFoo , scriptBar]
+ webEngineView.userScripts.insert(list)
+ compare(webEngineView.userScripts.collection.length, 2)
+ compare(webEngineView.userScripts.collection[0].name, scriptFoo.name)
+ compare(webEngineView.userScripts.collection[1].name, scriptBar.name)
+ }
+
+ function test_find() {
+ let scriptA = WebEngine.script()
+ scriptA.name = "A"
+ scriptA.sourceUrl = Qt.resolvedUrl("A.js")
+ let scriptB = WebEngine.script()
+ scriptB.name = "A"
+ scriptB.sourceUrl = Qt.resolvedUrl("B.js")
+ let scriptC = WebEngine.script()
+ scriptC.name = "C"
+ scriptC.sourceUrl = Qt.resolvedUrl("C.js")
+
+ compare(webEngineView.userScripts.collection.length, 0)
+ webEngineView.userScripts.collection = [ scriptA, scriptB, scriptC ];
+ compare(webEngineView.userScripts.collection.length, 3)
+ let scriptsA = webEngineView.userScripts.find("A")
+ let scriptsB = webEngineView.userScripts.find("B")
+ let scriptsC = webEngineView.userScripts.find("C")
+ compare(scriptsA.length, 2)
+ compare(scriptsB.length, 0)
+ compare(scriptsC.length, 1)
+ compare(scriptsA[0].name, scriptA.name)
+ compare(scriptsA[0].sourceUrl, scriptA.sourceUrl)
+ compare(scriptsA[1].name, scriptB.name)
+ compare(scriptsA[1].sourceUrl, scriptB.sourceUrl)
+ compare(scriptsC[0].name, scriptC.name)
+ compare(scriptsC[0].sourceUrl, scriptC.sourceUrl)
+ }
+
+ function test_contains() {
+ let scriptFoo = WebEngine.script()
+ scriptFoo.name = "Foo"
+ let scriptBar = WebEngine.script()
+ scriptBar.name = "Bar"
+ compare(webEngineView.userScripts.collection.length, 0)
+ webEngineView.userScripts.collection = [ scriptFoo ]
+ compare(webEngineView.userScripts.collection.length, 1)
+ verify(webEngineView.userScripts.contains(scriptFoo))
+ verify(!webEngineView.userScripts.contains(scriptBar))
+ }
+
+ function test_clear() {
+ let scriptFoo = WebEngine.script()
+ scriptFoo.name = "Foo"
+ let scriptBar = WebEngine.script()
+ scriptBar.name = "Bar"
+ compare(webEngineView.userScripts.collection.length, 0)
+ webEngineView.userScripts.collection = [ scriptFoo ];
+ compare(webEngineView.userScripts.collection.length, 1)
+ webEngineView.userScripts.clear()
+ compare(webEngineView.userScripts.collection.length, 0)
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests/data/tst_userScripts.qml b/tests/auto/quick/qmltests/data/tst_userScripts.qml
index 4d0bd28bf..30704f47b 100644
--- a/tests/auto/quick/qmltests/data/tst_userScripts.qml
+++ b/tests/auto/quick/qmltests/data/tst_userScripts.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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.0
-import QtWebEngine 1.2
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
Item {
@@ -60,6 +35,8 @@ Item {
return script
}
+ WebEngineProfile { id: testProfile }
+
TestWebEngineView {
id: webEngineView
width: 400
@@ -77,7 +54,7 @@ Item {
width: 400
height: 300
- onNavigationRequested: {
+ onNavigationRequested: function(request) {
var urlString = request.url.toString();
if (urlString.indexOf("test1.html") !== -1)
userScripts.collection = [ changeDocumentTitleScript() ];
@@ -89,13 +66,28 @@ Item {
}
TestCase {
- name: "WebEngineViewUserScripts"
+ name: "UserScripts"
-
- function init() {
+ function cleanup() {
webEngineView.url = "";
webEngineView.userScripts.collection = [];
+ compare(webEngineView.userScripts.collection.length, 0)
webEngineView.profile.userScripts.collection = [];
+ compare(webEngineView.profile.userScripts.collection.length, 0)
+ }
+
+ function test_profileScripts() {
+ // assusme it is the same type as in View
+ let t1 = String(testProfile.userScripts), t2 = String(webEngineView.userScripts)
+ compare(t1.substr(0, t1.indexOf('(')), t2.substr(0, t2.indexOf('(')))
+
+ // ... and just test basic things like access
+ compare(testProfile.userScripts.collection, [])
+ let script = changeDocumentTitleScript()
+ testProfile.userScripts.collection = [ script ]
+
+ compare(testProfile.userScripts.collection.length, 1)
+ compare(testProfile.userScripts.collection[0].name, script.name)
}
function test_oneScript() {
@@ -103,8 +95,10 @@ Item {
webEngineView.waitForLoadSucceeded();
tryCompare(webEngineView, "title", "Test page 1");
- webEngineView.userScripts.collection = [ changeDocumentTitleScript() ]
-
+ let script = changeDocumentTitleScript()
+ webEngineView.userScripts.collection = [ script ]
+ compare(webEngineView.userScripts.collection.length, 1)
+ compare(webEngineView.userScripts.collection[0].name, script.name)
compare(webEngineView.title, "Test page 1");
webEngineView.reload();
@@ -116,6 +110,7 @@ Item {
tryCompare(webEngineView, "title", "New title");
webEngineView.userScripts.collection = [];
+ compare(webEngineView.userScripts.collection.length, 0)
compare(webEngineView.title, "New title");
webEngineView.reload();
@@ -131,6 +126,7 @@ Item {
var script2 = appendDocumentTitleScript();
script2.injectionPoint = WebEngineScript.Deferred;
webEngineView.userScripts.collection = [ script1, script2 ];
+ compare(webEngineView.userScripts.collection.length, 2)
// Make sure the scripts are loaded in order.
webEngineView.reload();
@@ -140,12 +136,14 @@ Item {
script2.injectionPoint = WebEngineScript.DocumentReady
script1.injectionPoint = WebEngineScript.Deferred
webEngineView.userScripts.collection = [ script1, script2 ];
+ compare(webEngineView.userScripts.collection.length, 2)
webEngineView.reload();
webEngineView.waitForLoadSucceeded();
tryCompare(webEngineView, "title", "New title");
// Make sure we can remove scripts from the preload list.
webEngineView.userScripts.collection = [ script2 ];
+ compare(webEngineView.userScripts.collection.length, 1)
webEngineView.reload();
webEngineView.waitForLoadSucceeded();
tryCompare(webEngineView, "title", "Test page 1 with appendix");
@@ -169,6 +167,7 @@ Item {
function test_bigScript() {
webEngineView.userScripts.collection = [ bigUserScript() ];
+ compare(webEngineView.userScripts.collection.length, 1)
webEngineView.url = Qt.resolvedUrl("test1.html");
webEngineView.waitForLoadSucceeded();
tryCompare(webEngineView , "title", "Big user script changed title");
@@ -180,6 +179,8 @@ Item {
compare(script.injectionPoint, WebEngineScript.DocumentReady);
webEngineView.userScripts.collection = [ script ];
+ compare(webEngineView.userScripts.collection.length, 1)
+ compare(webEngineView.userScripts.collection[0].name, script.name)
// @include *data/test*.html
webEngineView.url = Qt.resolvedUrl("test1.html");
@@ -208,6 +209,7 @@ Item {
compare(script.injectionPoint, WebEngineScript.DocumentReady);
webEngineView.userScripts.collection = [ script ];
+ compare(webEngineView.userScripts.collection.length, 1)
// @match some:junk
webEngineView.url = Qt.resolvedUrl("test2.html");
@@ -216,7 +218,10 @@ Item {
}
function test_profileWideScript() {
- webEngineView.profile.userScripts.collection = [ changeDocumentTitleScript() ];
+ let script = changeDocumentTitleScript()
+ webEngineView.profile.userScripts.collection = [ script ];
+ compare(webEngineView.profile.userScripts.collection.length, 1)
+ compare(webEngineView.profile.userScripts.collection[0].name, script.name)
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..d4449f7de 100644
--- a/tests/auto/quick/qmltests/data/tst_viewSource.qml
+++ b/tests/auto/quick/qmltests/data/tst_viewSource.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** 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.0
-import QtWebEngine 1.4
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
@@ -38,9 +13,15 @@ TestWebEngineView {
property var viewRequest: null
SignalSpy {
+ id: loadSpy
+ target: webEngineView
+ signalName: 'loadingChanged'
+ }
+
+ SignalSpy {
id: newViewRequestedSpy
target: webEngineView
- signalName: "newViewRequested"
+ signalName: "newWindowRequested"
}
SignalSpy {
@@ -49,13 +30,13 @@ TestWebEngineView {
signalName: "titleChanged"
}
- onNewViewRequested: {
+ onNewWindowRequested: function(request) {
viewRequest = {
"destination": request.destination,
"userInitiated": request.userInitiated
};
- request.openIn(webEngineView);
+ webEngineView.acceptAsNewWindow(request);
}
TestCase {
@@ -68,6 +49,7 @@ TestWebEngineView {
tryCompare(webEngineView, "loadStatus", WebEngineView.LoadSucceededStatus);
webEngineView.loadStatus = null;
+ loadSpy.clear();
newViewRequestedSpy.clear();
titleChangedSpy.clear();
viewRequest = null;
@@ -86,7 +68,7 @@ TestWebEngineView {
// The first titleChanged signal is emitted by adoptWebContents()
tryVerify(function() { return titleChangedSpy.count >= 2; });
- compare(viewRequest.destination, WebEngineView.NewViewInTab);
+ compare(viewRequest.destination, WebEngineNewWindowRequest.InNewTab);
verify(viewRequest.userInitiated);
verify(!webEngineView.action(WebEngineView.ViewSource).enabled);
@@ -94,36 +76,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";
@@ -145,12 +97,46 @@ TestWebEngineView {
// The first titleChanged signal is emitted by adoptWebContents()
tryVerify(function() { return titleChangedSpy.count >= 2; });
- compare(viewRequest.destination, WebEngineView.NewViewInTab);
+ compare(viewRequest.destination, WebEngineNewWindowRequest.InNewTab);
verify(viewRequest.userInitiated);
tryCompare(webEngineView, "url", "view-source:" + url.replace("user:passwd@", ""));
tryCompare(webEngineView, "title", "view-source:" + url.replace("http://user:passwd@", ""));
}
+
+ 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) {
+ WebEngine.settings.errorPageEnabled = true
+ webEngineView.url = row.userInputUrl;
+
+ tryCompare(loadSpy, 'count', 2, 12000);
+ let load = loadSpy.signalArguments[1][0]
+ let expectedStatus = row.loadSucceed ? WebEngineView.LoadSucceededStatus : WebEngineView.LoadFailedStatus
+ compare(load.status, expectedStatus);
+ compare(load.isErrorPage, !row.loadSucceed);
+ 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/qmltests/data/tst_webchannel.qml b/tests/auto/quick/qmltests/data/tst_webchannel.qml
index 3ca3ccce1..780b55934 100644
--- a/tests/auto/quick/qmltests/data/tst_webchannel.qml
+++ b/tests/auto/quick/qmltests/data/tst_webchannel.qml
@@ -1,35 +1,11 @@
-/*********************************************************************
-** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Milian Wolff <milian.wolff@kdab.com>
-** 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.2
-
-import QtWebChannel 1.0
+// Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Milian Wolff <milian.wolff@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
+
+import QtWebChannel
Item {
id: test
@@ -81,6 +57,12 @@ Item {
}
function test_basic() {
+ webView.userScripts.collection = [ {
+ name: "qtwebchanneljs",
+ sourceUrl: Qt.resolvedUrl("qrc:/qtwebchannel/qwebchannel.js"),
+ injectionPoint: WebEngineScript.DocumentCreation,
+ worldId: WebEngineScript.MainWorld
+ }]
webView.url = testUrl;
verify(webView.waitForLoadSucceeded());
diff --git a/tests/auto/quick/qmltests/data/webchannel-test.html b/tests/auto/quick/qmltests/data/webchannel-test.html
index 92966b24a..d8c3b1305 100644
--- a/tests/auto/quick/qmltests/data/webchannel-test.html
+++ b/tests/auto/quick/qmltests/data/webchannel-test.html
@@ -2,7 +2,6 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script>
<script type="text/javascript">
//BEGIN SETUP
var channel = new QWebChannel(qt.webChannelTransport, function(channel) {
diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/AlertDialog.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/AlertDialog.qml
deleted file mode 100644
index 4ba3be4b9..000000000
--- a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/AlertDialog.qml
+++ /dev/null
@@ -1,32 +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$
-**
-****************************************************************************/
-
-// Both dialogs are basically expected to behave in the same way from an API point of view
-ConfirmDialog
-{
-}
diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/ConfirmDialog.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/ConfirmDialog.qml
deleted file mode 100644
index 9933fc2f7..000000000
--- a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/ConfirmDialog.qml
+++ /dev/null
@@ -1,49 +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 QtQml 2.0
-import QtTest 1.0
-import "../../TestParams" 1.0
-
-QtObject {
- property string text;
- property string title;
- signal accepted();
- signal rejected();
-
- function open() {
- JSDialogParams.dialogTitle = title;
- JSDialogParams.dialogMessage = text;
- JSDialogParams.dialogCount++;
- if (JSDialogParams.shouldAcceptDialog)
- accepted()
- else
- rejected()
- }
-}
-
diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/FilePicker.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/FilePicker.qml
deleted file mode 100644
index 745f533f5..000000000
--- a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/FilePicker.qml
+++ /dev/null
@@ -1,49 +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.2
-import "../../TestParams" 1.0
-
-QtObject {
- property bool selectMultiple: false;
- property bool selectExisting: false;
- property bool selectFolder: false;
- property var nameFilters: [];
-
- signal filesSelected(var fileList);
- signal rejected();
-
- function open() {
- FilePickerParams.filePickerOpened = true;
- FilePickerParams.nameFilters = nameFilters;
- if (FilePickerParams.selectFiles)
- filesSelected(FilePickerParams.selectedFilesUrl)
- else
- rejected()
- }
-}
diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/Menu.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/Menu.qml
deleted file mode 100644
index 36efa7680..000000000
--- a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/Menu.qml
+++ /dev/null
@@ -1,57 +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:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** 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-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-import QtQuick.Controls 1.4 as Controls
-
-Controls.Menu {
- id: menu
- signal done()
-
- // Use private API for now
- onAboutToHide: doneTimer.start()
-
- // WORKAROUND On Mac the Menu may be destroyed before the MenuItem
- // is actually triggered (see qtbase commit 08cc9b9991ae9ab51)
- Timer {
- id: doneTimer
- interval: 100
- onTriggered: menu.done()
- }
-}
diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/MenuItem.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/MenuItem.qml
deleted file mode 100644
index e61f4c230..000000000
--- a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/MenuItem.qml
+++ /dev/null
@@ -1,44 +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:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** 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-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-import QtQuick.Controls 1.4 as Controls
-
-Controls.MenuItem { }
-
diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/PromptDialog.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/PromptDialog.qml
deleted file mode 100644
index 7c5b16eab..000000000
--- a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/PromptDialog.qml
+++ /dev/null
@@ -1,52 +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 QtQml 2.0
-import QtTest 1.0
-import "../../TestParams" 1.0
-
-QtObject {
- property string text;
- property string title;
- signal accepted();
- signal rejected();
- signal input(string text);
- signal closing();
-
- function open() {
- JSDialogParams.dialogTitle = title;
- JSDialogParams.dialogMessage = text;
- JSDialogParams.dialogCount++;
- if (JSDialogParams.shouldAcceptDialog) {
- input(JSDialogParams.inputForPrompt)
- accepted()
- } else {
- rejected()
- }
- }
-}
diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/qmldir b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/qmldir
deleted file mode 100644
index cf8ac0512..000000000
--- a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/qmldir
+++ /dev/null
@@ -1,5 +0,0 @@
-module QtWebEngine.UIDelegates
-AlertDialog 1.0 AlertDialog.qml
-ConfirmDialog 1.0 ConfirmDialog.qml
-FilePicker 1.0 FilePicker.qml
-PromptDialog 1.0 PromptDialog.qml
diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/AlertDialog.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/AlertDialog.qml
new file mode 100644
index 000000000..7d7efda0c
--- /dev/null
+++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/AlertDialog.qml
@@ -0,0 +1,5 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+// Both dialogs are basically expected to behave in the same way from an API point of view
+ConfirmDialog { }
diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/ConfirmDialog.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/ConfirmDialog.qml
new file mode 100644
index 000000000..6125d0b98
--- /dev/null
+++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/ConfirmDialog.qml
@@ -0,0 +1,24 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQml
+import QtTest
+import "../../TestParams"
+
+QtObject {
+ property string text
+ property string title
+ signal accepted()
+ signal rejected()
+
+ function open() {
+ JSDialogParams.dialogTitle = title;
+ JSDialogParams.dialogMessage = text;
+ JSDialogParams.dialogCount++;
+ if (JSDialogParams.shouldAcceptDialog)
+ accepted();
+ else
+ rejected();
+ }
+}
+
diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/DirectoryPicker.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/DirectoryPicker.qml
new file mode 100644
index 000000000..71da28843
--- /dev/null
+++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/DirectoryPicker.qml
@@ -0,0 +1,18 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import "../../TestParams"
+
+QtObject {
+ signal folderSelected(var folder)
+ signal rejected()
+
+ function open() {
+ FilePickerParams.directoryPickerOpened = true;
+ if (FilePickerParams.selectFiles)
+ folderSelected(FilePickerParams.selectedFilesUrl);
+ else
+ rejected();
+ }
+}
diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/FilePicker.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/FilePicker.qml
new file mode 100644
index 000000000..247088bcb
--- /dev/null
+++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/FilePicker.qml
@@ -0,0 +1,24 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import "../../TestParams"
+
+QtObject {
+ property bool selectMultiple: false
+ property bool selectExisting: false
+ property bool selectFolder: false
+ property var nameFilters: []
+
+ signal filesSelected(var fileList)
+ signal rejected()
+
+ function open() {
+ FilePickerParams.filePickerOpened = true;
+ FilePickerParams.nameFilters = nameFilters;
+ if (FilePickerParams.selectFiles)
+ filesSelected(FilePickerParams.selectedFilesUrl);
+ else
+ rejected();
+ }
+}
diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/Menu.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/Menu.qml
new file mode 100644
index 000000000..cd7ed4821
--- /dev/null
+++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/Menu.qml
@@ -0,0 +1,18 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQml
+import "../../TestParams"
+
+QtObject {
+ id: menu
+ property string linkText: ""
+ property var mediaType: null
+ property string selectedText: ""
+
+ signal done()
+
+ function open() {
+ MenuParams.isMenuOpened = true;
+ }
+}
diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/MenuItem.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/MenuItem.qml
new file mode 100644
index 000000000..67dab1bba
--- /dev/null
+++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/MenuItem.qml
@@ -0,0 +1,8 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQml
+
+QtObject {
+ signal triggered()
+}
diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/PromptDialog.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/PromptDialog.qml
new file mode 100644
index 000000000..81a63d918
--- /dev/null
+++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/PromptDialog.qml
@@ -0,0 +1,27 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQml
+import QtTest
+import "../../TestParams"
+
+QtObject {
+ property string text
+ property string title
+ signal accepted()
+ signal rejected()
+ signal input(string text)
+ signal closing()
+
+ function open() {
+ JSDialogParams.dialogTitle = title;
+ JSDialogParams.dialogMessage = text;
+ JSDialogParams.dialogCount++;
+ if (JSDialogParams.shouldAcceptDialog) {
+ input(JSDialogParams.inputForPrompt)
+ accepted();
+ } else {
+ rejected();
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests/mock-delegates/TestParams/FilePickerParams.qml b/tests/auto/quick/qmltests/mock-delegates/TestParams/FilePickerParams.qml
index 02b0da1d4..67d67dc40 100644
--- a/tests/auto/quick/qmltests/mock-delegates/TestParams/FilePickerParams.qml
+++ b/tests/auto/quick/qmltests/mock-delegates/TestParams/FilePickerParams.qml
@@ -1,37 +1,13 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
pragma Singleton
-import QtQuick 2.0
+import QtQuick
QtObject {
property var selectedFilesUrl: [];
property bool selectFiles: false;
property bool filePickerOpened: false;
+ property bool directoryPickerOpened: false;
property var nameFilters: [];
}
diff --git a/tests/auto/quick/qmltests/mock-delegates/TestParams/JSDialogParams.qml b/tests/auto/quick/qmltests/mock-delegates/TestParams/JSDialogParams.qml
index 70696803c..1033b509e 100644
--- a/tests/auto/quick/qmltests/mock-delegates/TestParams/JSDialogParams.qml
+++ b/tests/auto/quick/qmltests/mock-delegates/TestParams/JSDialogParams.qml
@@ -1,32 +1,7 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
pragma Singleton
-import QtQml 2.0
+import QtQml
QtObject {
property string dialogMessage: "";
diff --git a/tests/auto/quick/qmltests/mock-delegates/TestParams/MenuParams.qml b/tests/auto/quick/qmltests/mock-delegates/TestParams/MenuParams.qml
new file mode 100644
index 000000000..d8a01764c
--- /dev/null
+++ b/tests/auto/quick/qmltests/mock-delegates/TestParams/MenuParams.qml
@@ -0,0 +1,9 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+pragma Singleton
+import QtQml
+
+QtObject {
+ property bool isMenuOpened: false;
+}
diff --git a/tests/auto/quick/qmltests/mock-delegates/TestParams/qmldir b/tests/auto/quick/qmltests/mock-delegates/TestParams/qmldir
index 5807f1e6e..2702ad30f 100644
--- a/tests/auto/quick/qmltests/mock-delegates/TestParams/qmldir
+++ b/tests/auto/quick/qmltests/mock-delegates/TestParams/qmldir
@@ -2,3 +2,4 @@
module TestParams
singleton FilePickerParams 1.0 FilePickerParams.qml
singleton JSDialogParams 1.0 JSDialogParams.qml
+singleton MenuParams 1.0 MenuParams.qml
diff --git a/tests/auto/quick/qmltests/qmltests.pro b/tests/auto/quick/qmltests/qmltests.pro
deleted file mode 100644
index eb53a98bb..000000000
--- a/tests/auto/quick/qmltests/qmltests.pro
+++ /dev/null
@@ -1,155 +0,0 @@
-include($$QTWEBENGINE_OUT_ROOT/src/webengine/qtwebengine-config.pri) # workaround for QTBUG-68093
-QT_FOR_CONFIG += webengine-private
-
-include(../tests.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
- 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 \
- $$PWD/data/link.html \
- $$PWD/data/localStorage.html \
- $$PWD/data/multifileupload.html \
- $$PWD/data/redirect.html \
- $$PWD/data/script-with-metadata.js \
- $$PWD/data/singlefileupload.html \
- $$PWD/data/test1.html \
- $$PWD/data/test2.html \
- $$PWD/data/test3.html \
- $$PWD/data/test4.html \
- $$PWD/data/test-iframe.html \
- $$PWD/data/keyboardModifierMapping.html \
- $$PWD/data/keyboardEvents.html \
- $$PWD/data/titleupdate.js \
- $$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)
-
diff --git a/tests/auto/quick/qmltests/resources/server.key b/tests/auto/quick/qmltests/resources/server.key
new file mode 100644
index 000000000..9bf87aee3
--- /dev/null
+++ b/tests/auto/quick/qmltests/resources/server.key
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEpQIBAAKCAQEAqAygFPG5ILLb3G51D0OIN4Kpm5t3Oh1nByTnvi1kMz+sCBBd
+CSugt4NnKkB6kiGtMEsrEm1/xg8Bkfbpet3v3+jAidRpjvCISqy3Z9D1cgCFM46h
+iob/AvLZpqITiAgsU4fJ4auuIKhFplIGrIKMv2gK8haoBGBoRUD1RM+irwjEr6TN
+XTQt2Ap+Ouxs53NLPhAOgumpfzzRR8/Umbhen+G5MhH+XTzzreiClz2V6A79ePJj
+y1uQ8NJ79feOOWBDRizRDWwxsnNd24GjkpvcaTwafiK6Vdqeub+XTtiB5RPal2on
+Cj0TQDcnaacecl/zmUWsIFNkNJWDcd3/vEdyOQIDAQABAoIBAQCW93icOCdim6tu
+FIDu7HEjxSsPUpPCToWu4lWaAHcinxGx0NlzkpD4K4DzcSdrvfszBmQ0UtBVokd7
+1IAdU+HZmePWLk+CDM2zoAPHrO3Cs3r2PS0cIHhZMsearcG0E/uWMseHB08PoXuo
+lcnPEhzVGueyYe4guGcTx+5PGeUBLf+fJcEc3rIQnT2LYulM2aqBZSQM3jRUaPYs
+F0awDpCNwajW/Bt2VB14Pr+H5MJ+WSznFCqW7SolBkqDGfKckXPSHgX6xZ0y7VCI
+MM8vwlVI4mPkaHvSQMSI8vS4Qh+SGQCSs/AuuNLjjPoz1YotV3Ih4YbLj6BjFP2g
+CrqzT6VNAoGBANOHmsqE0nRkLzonTDrMdla5b0TjTxwtNM5DjLgJa6UBBqPe+1Lv
+JFoBP9bIfYDRWZOZrxXItfMmM43nK/ST6Xqgx1IpHUCLKVr2pA9RXrP+m4oawfgn
+frW212fHibeOYiLy+DaQXQ0VRFxsc/VbwKVyVlMEcNg3N93x2E67M7vjAoGBAMtg
+7wDa+5gjwuyNr7LKkp5VDTmtKQhoDtg4sw6MSQSMF6fJT9Z4kGTZ23+G85/LsM/k
+iXbceabGJ0CQJvGn6oW4dI2Ut2c2nCNVbQCxJ6Nyn/yW7bRLShMnwXvbGAVxVUax
+5ohJPZGJ8ar2CP76A0bkvm2Nwylq2gp6Y8h7+iwzAoGBAKizwfQ6sk45iKDsrpNG
+dir8gY2DbJigRTksDpLIkJ1skAspz295YpiV3oBCLjYKwVJCg6zwAo0FrqBB+oB5
+ZwByMgWI3NeZJUZy5q2Ay/Lp4MroRELR3PC3/lu6fE90szgEZ4m84TmJ+Jdtt527
+q41H/yj+pbELePb95vIDw2LZAoGBAJBZ+MmupCzUFSI5Xp+UUIS48W4ijaE92mt1
+swF8aMcleBTLOjOL11D9oGHfs0OUG6czGq6WxnGs62dT6ZBUEo1e4rsq9xH3HNOn
+anq3Qt8sGIn7xjPVzHnUGeyDEYWrb0+CLZJGCcEnG7SwdKolYfYLnW281Oysvp35
+SKGf/W0pAoGAa2+sZmhb1mpGAf6Bi4z+uym/6qOJmG6CnrBSM9e/r8nujwFVkCYF
+3iz48qx3GbuliO6za8aM1drX2u8KWp1uP5KzwYvtW5SfpQ1eusFblHEYQQNRcKLT
+j/wZBXnU961eMKkkTe2XsPirO8rVhVmxuFLqT/aEPffcragQFFIGOEQ=
+-----END RSA PRIVATE KEY-----
diff --git a/tests/auto/quick/qmltests/resources/server.pem b/tests/auto/quick/qmltests/resources/server.pem
new file mode 100644
index 000000000..a201ed08e
--- /dev/null
+++ b/tests/auto/quick/qmltests/resources/server.pem
@@ -0,0 +1,41 @@
+-----BEGIN CERTIFICATE-----
+MIIDezCCAmOgAwIBAgIUFZEIIzeR7lEA10rb14w7MfhP87MwDQYJKoZIhvcNAQEL
+BQAwWjELMAkGA1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjEPMA0GA1UEBwwGQmVy
+bGluMRUwEwYDVQQKDAxUaGVRdENvbXBhbnkxEjAQBgNVBAsMCXdlYmVuZ2luZTAe
+Fw0yMTA1MTAyMTM1MTJaFw0yMjA1MTAyMTM1MTJaMGAxCzAJBgNVBAYTAkRFMQ8w
+DQYDVQQIDAZCZXJsaW4xDzANBgNVBAcMBkJlcmxpbjEVMBMGA1UECgwMVGhlUXRD
+b21wYW55MRgwFgYDVQQDDA93ZWJlbmdpbmUucXQuaW8wggEiMA0GCSqGSIb3DQEB
+AQUAA4IBDwAwggEKAoIBAQCoDKAU8bkgstvcbnUPQ4g3gqmbm3c6HWcHJOe+LWQz
+P6wIEF0JK6C3g2cqQHqSIa0wSysSbX/GDwGR9ul63e/f6MCJ1GmO8IhKrLdn0PVy
+AIUzjqGKhv8C8tmmohOICCxTh8nhq64gqEWmUgasgoy/aAryFqgEYGhFQPVEz6Kv
+CMSvpM1dNC3YCn467Gznc0s+EA6C6al/PNFHz9SZuF6f4bkyEf5dPPOt6IKXPZXo
+Dv148mPLW5Dw0nv19445YENGLNENbDGyc13bgaOSm9xpPBp+IrpV2p65v5dO2IHl
+E9qXaicKPRNANydppx5yX/OZRawgU2Q0lYNx3f+8R3I5AgMBAAGjMzAxMBoGA1Ud
+EQQTMBGCD3dlYmVuZ2luZS5xdC5pbzATBgNVHSUEDDAKBggrBgEFBQcDATANBgkq
+hkiG9w0BAQsFAAOCAQEAjThKpP0sBv1vEmaqBc1wTu//7RHmFcoStTt3scADzb2C
+9gjOVC4NzxBneLkv01444Z1p/Iiu/ZZ+VKu7aJElJgnBWEisYwJ09t3cdZRA0UY7
+XRvTVAqV0OlsB1Jn0afE+aTLGjWo+jSYzua0O+NK74e23p9jkdSmXxH9w0FB/oyM
+FGIOFnnfP0+QR4ZVvAGk2H60tBHQKmCM6b87TiD4GQIfOghCQWH+qJYSuyGu4hkE
+uis+n1KHHhed3GIJOHpm7gt1C9qtjcp1nOpv0ycQjfc9CGvr02BcQjhMeO65hX0A
+TvCgKN9/XMFv5jwwjjPCL12GBhwnN2k9hM/tEYpe2A==
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIDOzCCAiMCFDwWg4NZxCplj3qyBxAUTi1wmj4jMA0GCSqGSIb3DQEBCwUAMFox
+CzAJBgNVBAYTAkRFMQ8wDQYDVQQIDAZCZXJsaW4xDzANBgNVBAcMBkJlcmxpbjEV
+MBMGA1UECgwMVGhlUXRDb21wYW55MRIwEAYDVQQLDAl3ZWJlbmdpbmUwHhcNMjEw
+NTEwMjEzMTE4WhcNMjIwNTEwMjEzMTE4WjBaMQswCQYDVQQGEwJERTEPMA0GA1UE
+CAwGQmVybGluMQ8wDQYDVQQHDAZCZXJsaW4xFTATBgNVBAoMDFRoZVF0Q29tcGFu
+eTESMBAGA1UECwwJd2ViZW5naW5lMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
+CgKCAQEAuc/8xVrfSzOsI6kYul+o1QIPBh1I86eQm1PhTBDMAAPHuzyPaEMgBkn2
+XAUmvkynGpNioaJDU2ndV2fBHvsoeQCdNNmjFTe1rKYjrN6U2X5KoYSzN93TOYzK
+aR38fEFx+w4qV76nnxSjYtGNe9z74GrfWFMdDQ0NJKzvaO4gaZ+OOg0OzWy4MJQ0
+aINo3UV55Y7Nt92AxFweiuHucKu+rjf3BX7n0Af/Tcs2c84f0R3HA7euReSibVvX
+f33eHLRKwu2bvDjXiUzOdkxBn9GTo6Q09LyY6wDG0ZdWnyCKj3NBQKBVrq+bs3Q0
+ATsWhj/PvYlZhhZh4EOlqYOhCpwv4wIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQCC
+pLSFGJcG0zhHW+2A6ogmpn2tA8gKUZx7f0J1nwgPEoAXQqWQv/299ZtmWfMKHUkk
+ygG4u80C87wWPH42XWXo/KDrP9iYzoqAvtqbRuPG9PAxefQ/JUSnuhikA51g9+Mu
+IDKKKSI+y/JW9u0Qo77fp/5n2DaFn5B+pBYvn/xLfaEa9bRdJMTEMsElGbPBzMZd
+I/7X6B78X6Ow5TuRKSeZA7E1AZ/+e5A4Hj65bLAugoSKz3zaS0dV26LwAo18c2zP
+TqtwHyIVj4QCoI6Z694q9KH4Pkml3fz8VSkk+MvZMWapvUhHu/DneTgqGbp9POYg
+nx6oWME6idhnvN6DljxB
+-----END CERTIFICATE-----
diff --git a/tests/auto/quick/qmltests/tst_qmltests.cpp b/tests/auto/quick/qmltests/tst_qmltests.cpp
index 8423df1bd..9e928157e 100644
--- a/tests/auto/quick/qmltests/tst_qmltests.cpp
+++ b/tests/auto/quick/qmltests/tst_qmltests.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <httpserver.h>
@@ -32,12 +7,17 @@
#include <httpsserver.h>
#endif
-#include <QtCore/QScopedPointer>
-#include <QTemporaryDir>
+#include <QtCore/qscopedpointer.h>
+#include <QtCore/qtemporarydir.h>
+#include <QtGui/private/qinputmethod_p.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickwindow.h>
#include <QtQuickTest/quicktest.h>
-#include <QtWebEngine/QQuickWebEngineProfile>
-#include <QQmlEngine>
-#include "qt_webengine_quicktest.h"
+#include <QtTest/qtest.h>
+#include <QtWebEngineQuick/qquickwebengineprofile.h>
+#include <QtWebEngineQuick/qtwebenginequickglobal.h>
+#include <qt_webengine_quicktest.h>
#if defined(Q_OS_LINUX) && defined(QT_DEBUG)
#include <fcntl.h>
@@ -45,6 +25,19 @@
#include <unistd.h>
#endif
+class Setup : public QObject
+{
+ Q_OBJECT
+public:
+ Setup() { }
+
+public slots:
+ void qmlEngineAvailable(QQmlEngine *engine)
+ {
+ engine->addImportPath(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + "/mock-delegates");
+ }
+};
+
#if defined(Q_OS_LINUX) && defined(QT_DEBUG)
static bool debuggerPresent()
{
@@ -112,10 +105,125 @@ public:
return tempDir.isValid() ? tempDir.path() : QString();
}
+ Q_INVOKABLE QUrl pathUrl(const QString &filename = QString())
+ {
+ Q_ASSERT(tempDir.isValid());
+ return filename.isEmpty() ? QUrl::fromLocalFile(tempDir.path())
+ : QUrl::fromLocalFile(tempDir.filePath(filename));
+ }
+
+ Q_INVOKABLE void removeRecursive(const QString dirname)
+ {
+ QDir dir(dirname);
+ QFileInfoList entries(dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot));
+ for (int i = 0; i < entries.size(); ++i) {
+ if (entries[i].isDir())
+ removeRecursive(entries[i].filePath());
+ else
+ dir.remove(entries[i].fileName());
+ }
+ QDir().rmdir(dirname);
+ }
+
+ Q_INVOKABLE void createDirectory(const QString dirname) { QDir(tempDir.path()).mkdir(dirname); }
+
private:
QTemporaryDir tempDir;
};
+class TestInputContext : public QPlatformInputContext {
+ Q_OBJECT
+
+public:
+ TestInputContext() = default;
+ ~TestInputContext() { release(); }
+
+ Q_INVOKABLE void create()
+ {
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = this;
+ }
+
+ Q_INVOKABLE void release()
+ {
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = nullptr;
+ }
+
+ void showInputPanel() override { m_visible = true; }
+ void hideInputPanel() override { m_visible = false; }
+ bool isInputPanelVisible() const override { return m_visible; }
+
+private:
+ bool m_visible = false;
+};
+
+QT_BEGIN_NAMESPACE
+namespace QTest {
+ int Q_TESTLIB_EXPORT defaultMouseDelay();
+}
+QT_END_NAMESPACE
+
+class TestInputEvent : public QObject {
+ Q_OBJECT
+
+public:
+ TestInputEvent() = default;
+
+ Q_INVOKABLE bool mouseMultiClick(QObject *item, qreal x, qreal y, int clickCount)
+ {
+ QTEST_ASSERT(item);
+
+ QWindow *view = eventWindow(item);
+ if (!view)
+ return false;
+
+ for (int i = 0; i < clickCount; ++i) {
+ mouseEvent(QMouseEvent::MouseButtonPress, view, item, QPointF(x, y));
+ mouseEvent(QMouseEvent::MouseButtonRelease, view, item, QPointF(x, y));
+ }
+ QTest::lastMouseTimestamp += QTest::mouseDoubleClickInterval;
+
+ return true;
+ }
+
+private:
+ QWindow *eventWindow(QObject *item = nullptr)
+ {
+ QWindow *window = qobject_cast<QWindow *>(item);
+ if (window)
+ return window;
+
+ QQuickItem *quickItem = qobject_cast<QQuickItem *>(item);
+ if (quickItem)
+ return quickItem->window();
+
+ QQuickItem *testParentItem = qobject_cast<QQuickItem *>(parent());
+ if (testParentItem)
+ return testParentItem->window();
+
+ return nullptr;
+ }
+
+ void mouseEvent(QEvent::Type type, QWindow *window, QObject *item, const QPointF &_pos)
+ {
+ QTest::qWait(QTest::defaultMouseDelay());
+ QTest::lastMouseTimestamp += QTest::defaultMouseDelay();
+
+ QPoint pos;
+ QQuickItem *sgitem = qobject_cast<QQuickItem *>(item);
+ if (sgitem)
+ pos = sgitem->mapToScene(_pos).toPoint();
+
+ QMouseEvent me(type, pos, window->mapFromGlobal(pos), Qt::LeftButton, Qt::LeftButton, {});
+ me.setTimestamp(++QTest::lastMouseTimestamp);
+
+ QSpontaneKeyEvent::setSpontaneous(&me);
+ if (!qApp->notify(window, &me))
+ qWarning("Mouse click event not accepted by receiving window");
+ }
+};
+
int main(int argc, char **argv)
{
#if defined(Q_OS_LINUX) && defined(QT_DEBUG)
@@ -127,41 +235,41 @@ int main(int argc, char **argv)
sigaction(SIGSEGV, &sigAction, 0);
#endif
-
- QScopedPointer<Application> app;
-
+ QtWebEngineQuick::initialize();
// 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")};
- 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) \
- w_argv.append(params[i].data()); \
- int w_argc = w_argv.size(); \
+ static QByteArrayList params = {QByteArrayLiteral("--webEngineArgs"),QByteArrayLiteral("--use-fake-device-for-media-stream")};
+ 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) w_argv.append(params[i].data());
+ int w_argc = w_argv.size();
+ Application app(w_argc, const_cast<char **>(w_argv.data()));
- 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");
+ qmlRegisterType<TestInputContext>("Test.util", 1, 0, "TestInputContext");
+ qmlRegisterType<TestInputEvent>("Test.util", 1, 0, "TestInputEvent");
QTEST_SET_MAIN_SOURCE_PATH
qmlRegisterSingletonType<HttpServer>("Test.Shared", 1, 0, "HttpServer", [&] (QQmlEngine *, QJSEngine *) {
auto server = new HttpServer;
- server->setResourceDirs({ TESTS_SHARED_DATA_DIR, QUICK_TEST_SOURCE_DIR });
+ server->setResourceDirs(
+ { server->sharedDataDir(),
+ QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + QLatin1String("/data") });
return server;
});
#if QT_CONFIG(ssl)
qmlRegisterSingletonType<HttpsServer>(
- "Test.Shared", 1, 0, "HttpsServer",
- [&](QQmlEngine *, QJSEngine *) { return new HttpsServer; });
+ "Test.Shared", 1, 0, "HttpsServer", [&](QQmlEngine *, QJSEngine *) {
+ return new HttpsServer(":/resources/server.pem", ":/resources/server.key", "");
+ });
#endif
-
- int i = quick_test_main(argc, argv, "qmltests", QUICK_TEST_SOURCE_DIR);
+ Setup setup;
+ int i = quick_test_main_with_setup(
+ argc, argv, "qmltests",
+ qPrintable(QT_TESTCASE_BUILDDIR + QLatin1String("/webengine.qmltests")), &setup);
return i;
}
diff --git a/tests/auto/quick/qquickwebenginedefaultsurfaceformat/CMakeLists.txt b/tests/auto/quick/qquickwebenginedefaultsurfaceformat/CMakeLists.txt
new file mode 100644
index 000000000..9856ed513
--- /dev/null
+++ b/tests/auto/quick/qquickwebenginedefaultsurfaceformat/CMakeLists.txt
@@ -0,0 +1,13 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_qquickwebenginedefaultsurfaceformat
+ SOURCES
+ tst_qquickwebenginedefaultsurfaceformat.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::WebEngineQuickPrivate
+ Test::Util
+)
diff --git a/tests/auto/quick/qquickwebenginedefaultsurfaceformat/html/basic_page.html b/tests/auto/quick/qquickwebenginedefaultsurfaceformat/html/basic_page.html
new file mode 100644
index 000000000..53726e4a6
--- /dev/null
+++ b/tests/auto/quick/qquickwebenginedefaultsurfaceformat/html/basic_page.html
@@ -0,0 +1,6 @@
+<html>
+<head>
+<title> Basic Page </title>
+</head>
+<h1>Basic page</h1>
+</html>
diff --git a/tests/auto/quick/qquickwebenginedefaultsurfaceformat/qquickwebenginedefaultsurfaceformat.pro b/tests/auto/quick/qquickwebenginedefaultsurfaceformat/qquickwebenginedefaultsurfaceformat.pro
deleted file mode 100644
index 699186741..000000000
--- a/tests/auto/quick/qquickwebenginedefaultsurfaceformat/qquickwebenginedefaultsurfaceformat.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-include(../tests.pri)
-
-exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc
-QT_PRIVATE += core-private webengine-private webenginecore-private
-
-HEADERS += ../shared/util.h
diff --git a/tests/auto/quick/qquickwebenginedefaultsurfaceformat/tst_qquickwebenginedefaultsurfaceformat.cpp b/tests/auto/quick/qquickwebenginedefaultsurfaceformat/tst_qquickwebenginedefaultsurfaceformat.cpp
index 734c4ff7a..b4c95d671 100644
--- a/tests/auto/quick/qquickwebenginedefaultsurfaceformat/tst_qquickwebenginedefaultsurfaceformat.cpp
+++ b/tests/auto/quick/qquickwebenginedefaultsurfaceformat/tst_qquickwebenginedefaultsurfaceformat.cpp
@@ -1,33 +1,8 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "testwindow.h"
-#include "util.h"
+#include "quickutil.h"
#include <QGuiApplication>
#include <QtQml/QQmlEngine>
@@ -63,8 +38,8 @@ void tst_QQuickWebEngineDefaultSurfaceFormat::initEngineAndViewComponent() {
m_engine = new QQmlEngine(this);
QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true);
m_component.reset(new QQmlComponent(m_engine, this));
- m_component->setData(QByteArrayLiteral("import QtQuick 2.0\n"
- "import QtWebEngine 1.2\n"
+ m_component->setData(QByteArrayLiteral("import QtQuick\n"
+ "import QtWebEngine\n"
"WebEngineView {}")
, QUrl());
}
@@ -93,7 +68,7 @@ inline QQuickWebEngineView *tst_QQuickWebEngineDefaultSurfaceFormat::webEngineVi
QUrl tst_QQuickWebEngineDefaultSurfaceFormat::urlFromTestPath(const char *localFilePath)
{
- QString testSourceDirPath = QString::fromLocal8Bit(TESTS_SOURCE_DIR);
+ QString testSourceDirPath = QDir(QT_TESTCASE_SOURCEDIR).canonicalPath();
if (!testSourceDirPath.endsWith(QLatin1Char('/')))
testSourceDirPath.append(QLatin1Char('/'));
@@ -116,7 +91,7 @@ void tst_QQuickWebEngineDefaultSurfaceFormat::customDefaultSurfaceFormat()
QSurfaceFormat::setDefaultFormat( format );
QGuiApplication app(argc, argv);
- QtWebEngine::initialize();
+ QtWebEngineQuick::initialize();
initEngineAndViewComponent();
initWindow();
@@ -126,10 +101,10 @@ void tst_QQuickWebEngineDefaultSurfaceFormat::customDefaultSurfaceFormat()
QObject::connect(
view,
- &QQuickWebEngineView::loadingChanged, [](QQuickWebEngineLoadRequest* request)
+ &QQuickWebEngineView::loadingChanged, [](const QWebEngineLoadingInfo &info)
{
- if (request->status() == QQuickWebEngineView::LoadSucceededStatus
- || request->status() == QQuickWebEngineView::LoadFailedStatus)
+ if (info.status() == QWebEngineLoadingInfo::LoadSucceededStatus
+ || info.status() == QWebEngineLoadingInfo::LoadFailedStatus)
QTimer::singleShot(100, qApp, &QCoreApplication::quit);
}
);
diff --git a/tests/auto/quick/qquickwebengineprofile/qquickwebengineprofile.pro b/tests/auto/quick/qquickwebengineprofile/qquickwebengineprofile.pro
deleted file mode 100644
index e99c7f493..000000000
--- a/tests/auto/quick/qquickwebengineprofile/qquickwebengineprofile.pro
+++ /dev/null
@@ -1 +0,0 @@
-include(../tests.pri)
diff --git a/tests/auto/quick/qquickwebengineprofile/tst_qquickwebengineprofile.cpp b/tests/auto/quick/qquickwebengineprofile/tst_qquickwebengineprofile.cpp
deleted file mode 100644
index db7c2ad6e..000000000
--- a/tests/auto/quick/qquickwebengineprofile/tst_qquickwebengineprofile.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** 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 <QtQml/QQmlEngine>
-#include <QtTest/QtTest>
-#include <QtWebEngine/QQuickWebEngineProfile>
-
-class tst_QQuickWebEngineProfile : public QObject {
- Q_OBJECT
-public:
- tst_QQuickWebEngineProfile();
-
- // TODO: Many tests missings
- void usedForGlobalCertificateVerification();
-
-private Q_SLOTS:
- void init();
- void cleanup();
-};
-
-tst_QQuickWebEngineProfile::tst_QQuickWebEngineProfile()
-{
- QtWebEngine::initialize();
- QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true);
-}
-
-
-void tst_QQuickWebEngineProfile::init()
-{
-}
-
-void tst_QQuickWebEngineProfile::cleanup()
-{
-}
-
-void tst_QQuickWebEngineProfile::usedForGlobalCertificateVerification()
-{
- QQuickWebEngineProfile *profile1 = new QQuickWebEngineProfile();
- QQuickWebEngineProfile *profile2 = new QQuickWebEngineProfile();
- QVERIFY(!profile1->isUsedForGlobalVerification());
- QVERIFY(!profile2->isUsedForGlobalVerification());
-
-
-}
-
-
-QTEST_MAIN(tst_QQuickWebEngineProfile)
-#include "tst_qquickwebengineprofile.moc"
diff --git a/tests/auto/quick/qquickwebengineview/CMakeLists.txt b/tests/auto/quick/qquickwebengineview/CMakeLists.txt
new file mode 100644
index 000000000..307ea36c9
--- /dev/null
+++ b/tests/auto/quick/qquickwebengineview/CMakeLists.txt
@@ -0,0 +1,16 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_qquickwebengineview
+ SOURCES
+ tst_qquickwebengineview.cpp
+ LIBRARIES
+ Qt::WebEngineCorePrivate
+ Qt::WebEngineQuick
+ Qt::GuiPrivate
+ Qt::WebEngineQuickPrivate
+ Qt::TestPrivate
+ Test::Util
+)
diff --git a/tests/auto/quick/qquickwebengineview/html/basic_page.html b/tests/auto/quick/qquickwebengineview/html/basic_page.html
new file mode 100644
index 000000000..53726e4a6
--- /dev/null
+++ b/tests/auto/quick/qquickwebengineview/html/basic_page.html
@@ -0,0 +1,6 @@
+<html>
+<head>
+<title> Basic Page </title>
+</head>
+<h1>Basic page</h1>
+</html>
diff --git a/tests/auto/quick/html/basic_page2.html b/tests/auto/quick/qquickwebengineview/html/basic_page2.html
index f8cff2969..f8cff2969 100644
--- a/tests/auto/quick/html/basic_page2.html
+++ b/tests/auto/quick/qquickwebengineview/html/basic_page2.html
diff --git a/tests/auto/quick/html/direct-image-compositing.html b/tests/auto/quick/qquickwebengineview/html/direct-image-compositing.html
index 53a4ca137..53a4ca137 100644
--- a/tests/auto/quick/html/direct-image-compositing.html
+++ b/tests/auto/quick/qquickwebengineview/html/direct-image-compositing.html
diff --git a/tests/auto/quick/html/inputmethod.html b/tests/auto/quick/qquickwebengineview/html/inputmethod.html
index dc9140f9d..dc9140f9d 100644
--- a/tests/auto/quick/html/inputmethod.html
+++ b/tests/auto/quick/qquickwebengineview/html/inputmethod.html
diff --git a/tests/auto/quick/html/resources/simple_image.png b/tests/auto/quick/qquickwebengineview/html/resources/simple_image.png
index 4685399ca..4685399ca 100644
--- a/tests/auto/quick/html/resources/simple_image.png
+++ b/tests/auto/quick/qquickwebengineview/html/resources/simple_image.png
Binary files differ
diff --git a/tests/auto/quick/html/scroll.html b/tests/auto/quick/qquickwebengineview/html/scroll.html
index ce2193b6c..ce2193b6c 100644
--- a/tests/auto/quick/html/scroll.html
+++ b/tests/auto/quick/qquickwebengineview/html/scroll.html
diff --git a/tests/auto/quick/qquickwebengineview/qquickwebengineview.pro b/tests/auto/quick/qquickwebengineview/qquickwebengineview.pro
deleted file mode 100644
index 38c130aa3..000000000
--- a/tests/auto/quick/qquickwebengineview/qquickwebengineview.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-include(../tests.pri)
-
-exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc
-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 189eead04..dbfa1cb33 100644
--- a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
+++ b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
@@ -1,32 +1,10 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
#include "testwindow.h"
+#include "quickutil.h"
#include "util.h"
#include <QScopedPointer>
@@ -37,13 +15,15 @@
#include <QtGui/qpa/qwindowsysteminterface.h>
#include <QtQml/QQmlEngine>
#include <QtTest/QtTest>
-#include <QtWebEngine/QQuickWebEngineProfile>
-#include <QtWebEngine/QQuickWebEngineScriptCollection>
+#include <QtWebEngineQuick/QQuickWebEngineProfile>
#include <QtGui/private/qinputmethod_p.h>
-#include <QtWebEngine/private/qquickwebengineview_p.h>
-#include <QtWebEngine/private/qquickwebenginesettings_p.h>
+#include <QtWebEngineQuick/private/qquickwebenginescriptcollection_p.h>
+#include <QtWebEngineQuick/private/qquickwebenginesettings_p.h>
+#include <QtWebEngineQuick/private/qquickwebenginedownloadrequest_p.h>
+#include <QtWebEngineQuick/private/qquickwebengineview_p.h>
#include <QtWebEngineCore/private/qtwebenginecore-config_p.h>
#include <qpa/qplatforminputcontext.h>
+#include <QtTest/private/qemulationdetector_p.h>
#include <functional>
@@ -93,8 +73,13 @@ private Q_SLOTS:
void javascriptClipboard_data();
void javascriptClipboard();
void setProfile();
- void focusChild();
+#if QT_CONFIG(accessibility)
void focusChild_data();
+ void focusChild();
+#endif
+ void htmlSelectPopup();
+ void savePage_data();
+ void savePage();
private:
inline QQuickWebEngineView *newWebEngineView();
@@ -104,21 +89,26 @@ private:
QString m_testSourceDirPath;
QScopedPointer<TestWindow> m_window;
QScopedPointer<QQmlComponent> m_component;
+
+ QPointingDevice *touchDevice() {
+ static auto d = QScopedPointer<QPointingDevice>(QTest::createTouchDevice());
+ return d.get();
+ }
};
tst_QQuickWebEngineView::tst_QQuickWebEngineView()
{
- QtWebEngine::initialize();
+ QtWebEngineQuick::initialize();
QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true);
- m_testSourceDirPath = QString::fromLocal8Bit(TESTS_SOURCE_DIR);
+ m_testSourceDirPath = QDir(QT_TESTCASE_SOURCEDIR).canonicalPath();
if (!m_testSourceDirPath.endsWith(QLatin1Char('/')))
m_testSourceDirPath.append(QLatin1Char('/'));
static QQmlEngine *engine = new QQmlEngine(this);
m_component.reset(new QQmlComponent(engine, this));
- m_component->setData(QByteArrayLiteral("import QtQuick 2.0\n"
- "import QtWebEngine 1.2\n"
+ m_component->setData(QByteArrayLiteral("import QtQuick\n"
+ "import QtWebEngine\n"
"WebEngineView {}")
, QUrl());
}
@@ -198,7 +188,7 @@ void tst_QQuickWebEngineView::loadEmptyPageViewVisible()
void tst_QQuickWebEngineView::loadEmptyPageViewHidden()
{
- QSignalSpy loadSpy(webEngineView(), SIGNAL(loadingChanged(QQuickWebEngineLoadRequest*)));
+ QSignalSpy loadSpy(webEngineView(), SIGNAL(loadingChanged(QWebEngineLoadingInfo)));
webEngineView()->setUrl(urlFromTestPath("html/basic_page.html"));
QVERIFY(waitForLoadSucceeded(webEngineView()));
@@ -208,7 +198,7 @@ void tst_QQuickWebEngineView::loadEmptyPageViewHidden()
void tst_QQuickWebEngineView::loadNonexistentFileUrl()
{
- QSignalSpy loadSpy(webEngineView(), SIGNAL(loadingChanged(QQuickWebEngineLoadRequest*)));
+ QSignalSpy loadSpy(webEngineView(), SIGNAL(loadingChanged(QWebEngineLoadingInfo)));
webEngineView()->setUrl(urlFromTestPath("html/file_that_does_not_exist.html"));
QVERIFY(waitForLoadFailed(webEngineView()));
@@ -369,6 +359,9 @@ QImage tryToGrabWindowUntil(QQuickWindow *window, std::function<bool(const QImag
void tst_QQuickWebEngineView::basicRenderingSanity()
{
+ if (QTestPrivate::isRunningArmOnX86())
+ QSKIP("Grab does not work with QEMU.");
+
showWebEngineView();
webEngineView()->setUrl(QUrl(QString::fromUtf8("data:text/html,<html><body bgcolor=\"%2300ff00\"></body></html>")));
@@ -408,6 +401,9 @@ void tst_QQuickWebEngineView::titleUpdate()
void tst_QQuickWebEngineView::transparentWebEngineViews()
{
+ if (QTestPrivate::isRunningArmOnX86())
+ QSKIP("Grab does not work with QEMU.");
+
showWebEngineView();
// This should not crash.
@@ -435,10 +431,10 @@ void tst_QQuickWebEngineView::transparentWebEngineViews()
for (int i = 0; i < image.width(); i++)
for (int j = 0; j < image.height(); j++)
colors.insert(image.pixel(i, j));
- return colors.count() > 1;
+ return colors.size() > 1;
});
- QVERIFY(colors.count() > 1);
+ QVERIFY(colors.size() > 1);
QVERIFY(colors.contains(qRgb(0, 0, 0))); // black
QVERIFY(colors.contains(qRgb(255, 0, 0))); // red
for (auto color : colors) {
@@ -450,7 +446,6 @@ void tst_QQuickWebEngineView::transparentWebEngineViews()
void tst_QQuickWebEngineView::inputMethod()
{
m_window->show();
- QTRY_VERIFY(qApp->focusObject());
QQuickItem *input;
QQuickWebEngineView *view = webEngineView();
@@ -458,18 +453,21 @@ void tst_QQuickWebEngineView::inputMethod()
view->setUrl(urlFromTestPath("html/inputmethod.html"));
QVERIFY(waitForLoadSucceeded(view));
+ QTRY_VERIFY(qobject_cast<QQuickItem *>(qApp->focusObject()));
input = qobject_cast<QQuickItem *>(qApp->focusObject());
QVERIFY(!input->flags().testFlag(QQuickItem::ItemAcceptsInputMethod));
QVERIFY(!view->flags().testFlag(QQuickItem::ItemAcceptsInputMethod));
runJavaScript("document.getElementById('inputField').focus();");
QTRY_COMPARE(activeElementId(view), QStringLiteral("inputField"));
+ QTRY_VERIFY(qobject_cast<QQuickItem *>(qApp->focusObject()));
input = qobject_cast<QQuickItem *>(qApp->focusObject());
QTRY_VERIFY(input->flags().testFlag(QQuickItem::ItemAcceptsInputMethod));
QVERIFY(view->flags().testFlag(QQuickItem::ItemAcceptsInputMethod));
runJavaScript("document.getElementById('inputField').blur();");
QTRY_VERIFY(activeElementId(view).isEmpty());
+ QTRY_VERIFY(qobject_cast<QQuickItem *>(qApp->focusObject()));
input = qobject_cast<QQuickItem *>(qApp->focusObject());
QTRY_VERIFY(!input->flags().testFlag(QQuickItem::ItemAcceptsInputMethod));
QVERIFY(!view->flags().testFlag(QQuickItem::ItemAcceptsInputMethod));
@@ -510,15 +508,10 @@ public:
inputMethodPrivate->testContext = 0;
}
- virtual void commit() {
- commitCallCount++;
- }
-
- virtual void reset() {
- resetCallCount++;
- }
+ void commit() override { commitCallCount++; }
+ void reset() override { resetCallCount++; }
- virtual void update(Qt::InputMethodQueries queries)
+ void update(Qt::InputMethodQueries queries) override
{
if (!qApp->focusObject())
return;
@@ -585,9 +578,8 @@ void tst_QQuickWebEngineView::interruptImeTextComposition()
QTest::mouseClick(view->window(), Qt::LeftButton, {}, textInputCenter);
} else if (eventType == "Touch") {
QPoint textInputCenter = elementCenter(view, QStringLiteral("input2"));
- QPointingDevice *touchDevice = QTest::createTouchDevice();
- QTest::touchEvent(view->window(), touchDevice).press(0, textInputCenter, view->window());
- QTest::touchEvent(view->window(), touchDevice).release(0, textInputCenter, view->window());
+ QTest::touchEvent(view->window(), touchDevice()).press(0, textInputCenter, view->window());
+ QTest::touchEvent(view->window(), touchDevice()).release(0, textInputCenter, view->window());
}
QTRY_COMPARE(evaluateJavaScriptSync(view, "document.activeElement.id").toString(), QStringLiteral("input2"));
#ifndef Q_OS_WIN
@@ -615,12 +607,12 @@ void tst_QQuickWebEngineView::inputContextQueryInput()
" <input type='text' id='input1' />"
"</body></html>");
QVERIFY(waitForLoadSucceeded(view));
- QCOMPARE(testContext.infos.count(), 0);
+ QCOMPARE(testContext.infos.size(), 0);
// Set focus on an input field.
QPoint textInputCenter = elementCenter(view, "input1");
QTest::mouseClick(view->window(), Qt::LeftButton, {}, textInputCenter);
- QTRY_COMPARE(testContext.infos.count(), 2);
+ QTRY_COMPARE(testContext.infos.size(), 2);
QCOMPARE(evaluateJavaScriptSync(view, "document.activeElement.id").toString(), QStringLiteral("input1"));
foreach (const InputMethodInfo &info, testContext.infos) {
QCOMPARE(info.cursorPosition, 0);
@@ -632,7 +624,7 @@ void tst_QQuickWebEngineView::inputContextQueryInput()
// Change content of an input field from JavaScript.
evaluateJavaScriptSync(view, "document.getElementById('input1').value='QtWebEngine';");
- QTRY_COMPARE(testContext.infos.count(), 1);
+ QTRY_COMPARE(testContext.infos.size(), 1);
QCOMPARE(testContext.infos[0].cursorPosition, 11);
QCOMPARE(testContext.infos[0].anchorPosition, 11);
QCOMPARE(testContext.infos[0].surroundingText, QStringLiteral("QtWebEngine"));
@@ -641,7 +633,7 @@ void tst_QQuickWebEngineView::inputContextQueryInput()
// Change content of an input field by key press.
QTest::keyClick(view->window(), Qt::Key_Exclam);
- QTRY_COMPARE(testContext.infos.count(), 1);
+ QTRY_COMPARE(testContext.infos.size(), 1);
QCOMPARE(testContext.infos[0].cursorPosition, 12);
QCOMPARE(testContext.infos[0].anchorPosition, 12);
QCOMPARE(testContext.infos[0].surroundingText, QStringLiteral("QtWebEngine!"));
@@ -650,7 +642,7 @@ void tst_QQuickWebEngineView::inputContextQueryInput()
// Change cursor position.
QTest::keyClick(view->window(), Qt::Key_Left);
- QTRY_COMPARE(testContext.infos.count(), 1);
+ QTRY_COMPARE(testContext.infos.size(), 1);
QCOMPARE(testContext.infos[0].cursorPosition, 11);
QCOMPARE(testContext.infos[0].anchorPosition, 11);
QCOMPARE(testContext.infos[0].surroundingText, QStringLiteral("QtWebEngine!"));
@@ -665,7 +657,7 @@ void tst_QQuickWebEngineView::inputContextQueryInput()
QInputMethodEvent event("", attributes);
QGuiApplication::sendEvent(qApp->focusObject(), &event);
}
- QTRY_COMPARE(testContext.infos.count(), 2);
+ QTRY_COMPARE(testContext.infos.size(), 2);
// As a first step, Chromium moves the cursor to the start of the selection.
// We don't filter this in QtWebEngine because we don't know yet if this is part of a selection.
@@ -689,7 +681,7 @@ void tst_QQuickWebEngineView::inputContextQueryInput()
QInputMethodEvent event("", attributes);
QGuiApplication::sendEvent(qApp->focusObject(), &event);
}
- QTRY_COMPARE(testContext.infos.count(), 1);
+ QTRY_COMPARE(testContext.infos.size(), 1);
QCOMPARE(testContext.infos[0].cursorPosition, 0);
QCOMPARE(testContext.infos[0].anchorPosition, 0);
QCOMPARE(testContext.infos[0].surroundingText, QStringLiteral("QtWebEngine!"));
@@ -702,9 +694,9 @@ void tst_QQuickWebEngineView::inputContextQueryInput()
QInputMethodEvent event("123", attributes);
QGuiApplication::sendEvent(qApp->focusObject(), &event);
}
- QTRY_COMPARE(testContext.infos.count(), 1);
- QCOMPARE(testContext.infos[0].cursorPosition, 3);
- QCOMPARE(testContext.infos[0].anchorPosition, 3);
+ QTRY_COMPARE(testContext.infos.size(), 1);
+ QCOMPARE(testContext.infos[0].cursorPosition, 0);
+ QCOMPARE(testContext.infos[0].anchorPosition, 0);
QCOMPARE(testContext.infos[0].surroundingText, QStringLiteral("QtWebEngine!"));
QCOMPARE(testContext.infos[0].selectedText, QStringLiteral(""));
QCOMPARE(evaluateJavaScriptSync(view, "document.getElementById('input1').value").toString(), QStringLiteral("123QtWebEngine!"));
@@ -716,7 +708,7 @@ void tst_QQuickWebEngineView::inputContextQueryInput()
QInputMethodEvent event("", attributes);
QGuiApplication::sendEvent(qApp->focusObject(), &event);
}
- QTRY_COMPARE(testContext.infos.count(), 2);
+ QTRY_COMPARE(testContext.infos.size(), 2);
foreach (const InputMethodInfo &info, testContext.infos) {
QCOMPARE(info.cursorPosition, 0);
QCOMPARE(info.anchorPosition, 0);
@@ -733,7 +725,7 @@ void tst_QQuickWebEngineView::inputContextQueryInput()
event.setCommitString(QStringLiteral("123"), 0, 0);
QGuiApplication::sendEvent(qApp->focusObject(), &event);
}
- QTRY_COMPARE(testContext.infos.count(), 1);
+ QTRY_COMPARE(testContext.infos.size(), 1);
QCOMPARE(testContext.infos[0].cursorPosition, 3);
QCOMPARE(testContext.infos[0].anchorPosition, 3);
QCOMPARE(testContext.infos[0].surroundingText, QStringLiteral("123QtWebEngine!"));
@@ -743,7 +735,7 @@ void tst_QQuickWebEngineView::inputContextQueryInput()
// Focus out.
QTest::keyPress(view->window(), Qt::Key_Tab);
- QTRY_COMPARE(testContext.infos.count(), 1);
+ QTRY_COMPARE(testContext.infos.size(), 1);
QTRY_COMPARE(evaluateJavaScriptSync(view, "document.activeElement.id").toString(), QStringLiteral(""));
testContext.infos.clear();
}
@@ -771,9 +763,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
@@ -784,28 +780,56 @@ 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()
{
QQuickWebEngineView *view = webEngineView();
+ m_window->show();
+ view->setSize(QSizeF(320, 240));
- QVERIFY(qFuzzyCompare(view->zoomFactor(), 1.0));
+ QCOMPARE(view->zoomFactor(), 1.0);
view->setZoomFactor(2.5);
- QVERIFY(qFuzzyCompare(view->zoomFactor(), 2.5));
+ QCOMPARE(view->zoomFactor(), 2.5);
- view->setUrl(urlFromTestPath("html/basic_page.html"));
+ const QUrl url1 = urlFromTestPath("html/basic_page.html"), url2 = urlFromTestPath("html/basic_page2.html");
+
+ view->setUrl(url1);
QVERIFY(waitForLoadSucceeded(view));
- QVERIFY(qFuzzyCompare(view->zoomFactor(), 2.5));
+ QCOMPARE(view->zoomFactor(), 2.5);
view->setZoomFactor(0.1);
- QVERIFY(qFuzzyCompare(view->zoomFactor(), 2.5));
+ QCOMPARE(view->zoomFactor(), 2.5);
view->setZoomFactor(5.5);
- QVERIFY(qFuzzyCompare(view->zoomFactor(), 2.5));
+ QCOMPARE(view->zoomFactor(), 2.5);
+
+ QScopedPointer<QQuickWebEngineView> view2(newWebEngineView());
+ view2->setSize(QSizeF(320, 240));
+ view2->setParentItem(m_window->contentItem());
+
+ // try loading different url and check new values after load
+ for (auto &&p : {
+ qMakePair(view, 2.5), // navigating away to different url should keep zoom
+ qMakePair(view2.get(), 1.0), // same url navigation in diffent page shouldn't be affected
+ }) {
+ auto &&view = p.first; auto zoomFactor = p.second;
+ view->setUrl(url2);
+ QVERIFY(waitForLoadSucceeded(view));
+ QCOMPARE(view->zoomFactor(), zoomFactor);
+ }
+
+ // should have no influence on first page
+ view2->setZoomFactor(3.5);
+ for (auto &&p : { qMakePair(view, 2.5), qMakePair(view2.get(), 3.5), })
+ QCOMPARE(p.first->zoomFactor(), p.second);
}
void tst_QQuickWebEngineView::printToPdf()
@@ -822,7 +846,7 @@ void tst_QQuickWebEngineView::printToPdf()
QSignalSpy savePdfSpy(view, SIGNAL(pdfPrintingFinished(const QString&, bool)));
QString path = tempDir.path() + "/print_success.pdf";
view->printToPdf(path, QQuickWebEngineView::A4, QQuickWebEngineView::Portrait);
- QTRY_VERIFY2(savePdfSpy.count() == 1, "Printing to PDF file failed without signal");
+ QTRY_VERIFY2(savePdfSpy.size() == 1, "Printing to PDF file failed without signal");
QList<QVariant> successArguments = savePdfSpy.takeFirst();
QVERIFY2(successArguments.at(0).toString() == path, "File path for first saved PDF does not match arguments");
QVERIFY2(successArguments.at(1).toBool() == true, "Printing to PDF file failed though it should succeed");
@@ -833,7 +857,7 @@ void tst_QQuickWebEngineView::printToPdf()
path = tempDir.path() + "/print_|fail.pdf";
#endif // #if !defined(Q_OS_WIN)
view->printToPdf(path, QQuickWebEngineView::A4, QQuickWebEngineView::Portrait);
- QTRY_VERIFY2(savePdfSpy.count() == 1, "Printing to PDF file failed without signal");
+ QTRY_VERIFY2(savePdfSpy.size() == 1, "Printing to PDF file failed without signal");
QList<QVariant> failedArguments = savePdfSpy.takeFirst();
QVERIFY2(failedArguments.at(0).toString() == path, "File path for second saved PDF does not match arguments");
QVERIFY2(failedArguments.at(1).toBool() == false, "Printing to PDF file succeeded though it should fail");
@@ -876,6 +900,7 @@ public:
QQuickItem(parent), m_eventCounter(0), m_child(child) {
setFlag(ItemHasContents);
setAcceptedMouseButtons(Qt::AllButtons);
+ setAcceptTouchEvents(true);
setAcceptHoverEvents(true);
}
@@ -976,11 +1001,9 @@ void tst_QQuickWebEngineView::inputEventForwardingDisabledWhenActiveFocusOnPress
QTest::mousePress(view->window(), Qt::LeftButton);
QTest::mouseRelease(view->window(), Qt::LeftButton);
- 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());
- QTest::touchEvent(view->window(), device).release(0, QPoint(1, 1), view->window());
+ QTest::touchEvent(view->window(), touchDevice()).press(0, QPoint(0,0), view->window());
+ QTest::touchEvent(view->window(), touchDevice()).move(0, QPoint(1, 1), view->window());
+ QTest::touchEvent(view->window(), touchDevice()).release(0, QPoint(1, 1), view->window());
// We expect to catch 7 events - click = 2, press + release = 2, touches = 3.
QCOMPARE(item.eventCount(), 7);
@@ -992,6 +1015,9 @@ void tst_QQuickWebEngineView::inputEventForwardingDisabledWhenActiveFocusOnPress
void tst_QQuickWebEngineView::changeLocale()
{
+ if (QTestPrivate::isRunningArmOnX86())
+ QSKIP("Does not work with QEMU. (QTBUG-94911)");
+
QStringList errorLines;
QUrl url("http://non.existent/");
@@ -1099,7 +1125,7 @@ void tst_QQuickWebEngineView::javascriptClipboard()
// - return value of queryCommandEnabled and
// - return value of execCommand
// - comparing the clipboard / input field
- QGuiApplication::clipboard()->clear();
+ QGuiApplication::clipboard()->setText(QString());
QCOMPARE(evaluateJavaScriptSync(view, "document.queryCommandEnabled('copy')").toBool(),
copyResult);
QCOMPARE(evaluateJavaScriptSync(view, "document.execCommand('copy')").toBool(), copyResult);
@@ -1126,9 +1152,9 @@ void tst_QQuickWebEngineView::javascriptClipboard()
"if (result.state == 'prompt') accessPrompt = true;"
"})"));
- QTRY_COMPARE(evaluateJavaScriptSync(view, "accessGranted").toBool(), copyResult);
- QTRY_COMPARE(evaluateJavaScriptSync(view, "accessDenied").toBool(), !javascriptCanAccessClipboard);
- QTRY_COMPARE(evaluateJavaScriptSync(view, "accessPrompt").toBool(), false);
+ QTRY_COMPARE(evaluateJavaScriptSync(view, "accessGranted").toBool(), javascriptCanAccessClipboard && javascriptCanPaste);
+ QTRY_COMPARE(evaluateJavaScriptSync(view, "accessDenied").toBool(), false);
+ QTRY_COMPARE(evaluateJavaScriptSync(view, "accessPrompt").toBool(), !javascriptCanAccessClipboard || !javascriptCanPaste);
evaluateJavaScriptSync(view,
QStringLiteral(
@@ -1142,13 +1168,13 @@ void tst_QQuickWebEngineView::javascriptClipboard()
"if (result.state == 'prompt') accessPrompt = true;"
"})"));
- QTRY_COMPARE(evaluateJavaScriptSync(view, "accessGranted").toBool(), pasteResult);
- QTRY_COMPARE(evaluateJavaScriptSync(view, "accessDenied").toBool(), !javascriptCanAccessClipboard || !javascriptCanPaste);
- QTRY_COMPARE(evaluateJavaScriptSync(view, "accessPrompt").toBool(), false);
+ QTRY_COMPARE(evaluateJavaScriptSync(view, "accessGranted").toBool(), javascriptCanAccessClipboard && javascriptCanPaste);
+ QTRY_COMPARE(evaluateJavaScriptSync(view, "accessDenied").toBool(), false);
+ QTRY_COMPARE(evaluateJavaScriptSync(view, "accessPrompt").toBool(), !javascriptCanAccessClipboard || !javascriptCanPaste);
}
void tst_QQuickWebEngineView::setProfile() {
- QSignalSpy loadSpy(webEngineView(), SIGNAL(loadingChanged(QQuickWebEngineLoadRequest*)));
+ QSignalSpy loadSpy(webEngineView(), SIGNAL(loadingChanged(QWebEngineLoadingInfo)));
webEngineView()->setUrl(urlFromTestPath("html/basic_page.html"));
QVERIFY(waitForLoadSucceeded(webEngineView()));
QCOMPARE(loadSpy.size(), 2);
@@ -1156,10 +1182,13 @@ void tst_QQuickWebEngineView::setProfile() {
QVERIFY(waitForLoadSucceeded(webEngineView()));
QCOMPARE(loadSpy.size(), 4);
QQuickWebEngineProfile *profile = new QQuickWebEngineProfile();
+ auto oldProfile = webEngineView()->profile();
+ auto sc = qScopeGuard([&] () { webEngineView()->setProfile(oldProfile); delete profile; });
webEngineView()->setProfile(profile);
QTRY_COMPARE(webEngineView()->url() ,urlFromTestPath("html/basic_page2.html"));
}
+#if QT_CONFIG(accessibility)
void tst_QQuickWebEngineView::focusChild_data()
{
QTest::addColumn<QString>("interfaceName");
@@ -1222,9 +1251,122 @@ void tst_QQuickWebEngineView::focusChild()
// <html> -> <body> -> <input>
QCOMPARE(traverseToWebDocumentAccessibleInterface(iface)->child(0)->child(0), iface->focusChild());
}
+#endif // QT_CONFIG(accessibility)
+void tst_QQuickWebEngineView::htmlSelectPopup()
+{
+ m_window->show();
+ QQuickWebEngineView &view = *webEngineView();
+ view.settings()->setFocusOnNavigationEnabled(true);
+ view.setSize(QSizeF(640, 480));
+ view.loadHtml("<html><body>"
+ "<select id='select' onchange='console.log(\"option changed to: \" + this.value)'>"
+ "<option value='O1'>O1</option><option value='O2'>O2</option><option value='O3'>O3</option></select>"
+ "</body></html>");
+ QVERIFY(waitForLoadSucceeded(&view));
+
+ auto makeTouch = [this] (QWindow *w, const QPoint &p) {
+ QTest::touchEvent(w, touchDevice()).press(1, p);
+ QTest::touchEvent(w, touchDevice()).release(1, p);
+ };
+
+ makeTouch(view.window(), elementCenter(&view, "select"));
+ QPointer<QQuickWindow> popup;
+ QTRY_VERIFY((popup = m_window->findChild<QQuickWindow *>()));
+ QCOMPARE(activeElementId(&view), QStringLiteral("select"));
+
+ makeTouch(popup, QPoint(popup->width() / 2, popup->height() / 2));
+ QTRY_VERIFY(!popup);
+ QCOMPARE(evaluateJavaScriptSync(&view, "document.getElementById('select').value").toString(), QStringLiteral("O2"));
+}
+
+void tst_QQuickWebEngineView::savePage_data()
+{
+ QTest::addColumn<QWebEngineDownloadRequest::SavePageFormat>("savePageFormat");
+
+ QTest::newRow("SingleHtmlSaveFormat") << QWebEngineDownloadRequest::SingleHtmlSaveFormat;
+ QTest::newRow("CompleteHtmlSaveFormat") << QWebEngineDownloadRequest::CompleteHtmlSaveFormat;
+ QTest::newRow("MimeHtmlSaveFormat") << QWebEngineDownloadRequest::MimeHtmlSaveFormat;
+}
+
+void tst_QQuickWebEngineView::savePage()
+{
+ QFETCH(QWebEngineDownloadRequest::SavePageFormat, savePageFormat);
+
+ QTemporaryDir tempDir(QDir::tempPath() + "/tst_QQuickWebEngineView-XXXXXX");
+ QVERIFY(tempDir.isValid());
+ const QString filePath = tempDir.path() + "/saved_page.html";
+
+ QQuickWebEngineView *view = webEngineView();
+ int acceptedCount = 0;
+ int finishedCount = 0;
+ ScopedConnection sc1 = connect(
+ view->profile(), &QQuickWebEngineProfile::downloadRequested,
+ [&](QQuickWebEngineDownloadRequest *downloadRequest) {
+ QCOMPARE(downloadRequest->state(),
+ QQuickWebEngineDownloadRequest::DownloadInProgress);
+ QCOMPARE(downloadRequest->isSavePageDownload(), true);
+ QCOMPARE(downloadRequest->savePageFormat(), savePageFormat);
+ QCOMPARE(QDir(downloadRequest->downloadDirectory())
+ .filePath(downloadRequest->downloadFileName()),
+ filePath);
+ QCOMPARE(downloadRequest->url(), view->url());
+
+ connect(downloadRequest, &QQuickWebEngineDownloadRequest::isFinishedChanged,
+ [&, downloadRequest]() {
+ QCOMPARE(downloadRequest->state(),
+ QQuickWebEngineDownloadRequest::DownloadCompleted);
+ QCOMPARE(downloadRequest->isSavePageDownload(), true);
+ QCOMPARE(downloadRequest->isFinished(), true);
+ QCOMPARE(downloadRequest->savePageFormat(), savePageFormat);
+ QCOMPARE(downloadRequest->totalBytes(),
+ downloadRequest->receivedBytes());
+ QVERIFY(downloadRequest->receivedBytes() > 0);
+ QCOMPARE(QDir(downloadRequest->downloadDirectory())
+ .filePath(downloadRequest->downloadFileName()),
+ filePath);
+ QCOMPARE(downloadRequest->url(), view->url());
+ finishedCount++;
+ });
+ acceptedCount++;
+ });
+
+ const QString originalData = QStringLiteral("Basic page");
+ view->setUrl(urlFromTestPath("html/basic_page.html"));
+ QVERIFY(waitForLoadSucceeded(view));
+ QCOMPARE(evaluateJavaScriptSync(view, "document.getElementsByTagName('h1')[0].innerText")
+ .toString(),
+ originalData);
+
+ // Save the loaded page as HTML.
+ view->save(filePath, savePageFormat);
+ QTRY_COMPARE(acceptedCount, 1);
+ QTRY_COMPARE(finishedCount, 1);
+ QFile file(filePath);
+ QVERIFY(file.exists());
+
+ // Load something else.
+ view->setUrl(urlFromTestPath("html/basic_page2.html"));
+ QVERIFY(waitForLoadSucceeded(view));
+ QVERIFY(evaluateJavaScriptSync(view, "document.getElementsByTagName('h1')[0].innerText")
+ .toString()
+ != originalData);
+
+ // Load the saved page and compare the contents.
+ view->setUrl(QUrl::fromLocalFile(filePath));
+ QVERIFY(waitForLoadSucceeded(view));
+ QCOMPARE(evaluateJavaScriptSync(view, "document.getElementsByTagName('h1')[0].innerText")
+ .toString(),
+ originalData);
+}
+
+#if QT_CONFIG(accessibility)
static QByteArrayList params = QByteArrayList()
<< "--force-renderer-accessibility";
+#else
+static QByteArrayList params;
+#endif
W_QTEST_MAIN(tst_QQuickWebEngineView, params)
#include "tst_qquickwebengineview.moc"
+#include "moc_quickutil.cpp"
diff --git a/tests/auto/quick/qquickwebengineviewgraphics/CMakeLists.txt b/tests/auto/quick/qquickwebengineviewgraphics/CMakeLists.txt
new file mode 100644
index 000000000..f22408d15
--- /dev/null
+++ b/tests/auto/quick/qquickwebengineviewgraphics/CMakeLists.txt
@@ -0,0 +1,13 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+include(../../util/util.cmake)
+qt_internal_add_test(tst_qquickwebengineviewgraphics
+ SOURCES
+ tst_qquickwebengineviewgraphics.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::WebEngineQuickPrivate
+ Qt::Test
+ Test::Util
+)
diff --git a/tests/auto/quick/qquickwebengineviewgraphics/qquickwebengineviewgraphics.pro b/tests/auto/quick/qquickwebengineviewgraphics/qquickwebengineviewgraphics.pro
deleted file mode 100644
index a0ee3fd89..000000000
--- a/tests/auto/quick/qquickwebengineviewgraphics/qquickwebengineviewgraphics.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-include(../tests.pri)
-CONFIG -= testcase # remove, once this passes in the CI
-exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc
-QT_PRIVATE += webengine-private gui-private webenginecore-private
diff --git a/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp b/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp
index 518ddaa0d..3644ac481 100644
--- a/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp
+++ b/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp
@@ -1,40 +1,14 @@
-/****************************************************************************
-**
-** 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 "util.h"
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#include <quickutil.h>
#include <QtTest/QtTest>
#include <QQmlContext>
#include <QQuickView>
#include <QQuickItem>
#include <QPainter>
-#include <qtwebengineglobal.h>
-#include <private/qquickwebengineview_p.h>
+#include <QtWebEngineQuick/qtwebenginequickglobal.h>
+#include <QtWebEngineQuick/private/qquickwebengineview_p.h>
#include <map>
@@ -98,6 +72,8 @@ static void verifyGreenSquare(QQuickWindow *window)
bool ok = QTest::qWaitFor([&](){
actual = window->grabWindow();
expected = getGreenSquare(actual.format());
+ if (actual.height() > 150)
+ actual = actual.scaledToHeight(150);
return actual == expected;
}, 10000);
if (!ok) {
@@ -110,7 +86,9 @@ static void verifyGreenSquare(QQuickWindow *window)
void tst_QQuickWebEngineViewGraphics::simpleGraphics()
{
setHtml(greenSquare);
+ m_view->show();
verifyGreenSquare(m_view.data());
+ m_view->hide();
}
void tst_QQuickWebEngineViewGraphics::showHideShow()
@@ -126,12 +104,15 @@ void tst_QQuickWebEngineViewGraphics::showHideShow()
m_view->show();
QVERIFY(exposeSpy.wait());
verifyGreenSquare(m_view.data());
+ m_view->hide();
}
void tst_QQuickWebEngineViewGraphics::simpleAcceleratedLayer()
{
+ m_view->show();
setHtml(acLayerGreenSquare);
verifyGreenSquare(m_view.data());
+ m_view->hide();
}
void tst_QQuickWebEngineViewGraphics::reparentToOtherWindow()
@@ -142,21 +123,24 @@ void tst_QQuickWebEngineViewGraphics::reparentToOtherWindow()
window.create();
m_view->rootObject()->setParentItem(window.contentItem());
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
verifyGreenSquare(&window);
}
void tst_QQuickWebEngineViewGraphics::setHtml(const QString &html)
{
QString htmlData = QUrl::toPercentEncoding(html);
- QString qmlData = QUrl::toPercentEncoding(QStringLiteral("import QtQuick 2.0; import QtWebEngine 1.2; WebEngineView { width: 150; height: 150 }"));
+ QString qmlData = QUrl::toPercentEncoding(QStringLiteral("import QtQuick; import QtWebEngine; WebEngineView { width: 150; height: 150 }"));
m_view->setSource(QUrl(QStringLiteral("data:text/plain,%1").arg(qmlData)));
m_view->create();
QQuickWebEngineView *webEngineView = static_cast<QQuickWebEngineView *>(m_view->rootObject());
- webEngineView->setProperty("url", QUrl(QStringLiteral("data:text/html,%1").arg(htmlData)));
- QTRY_COMPARE_WITH_TIMEOUT(m_view->rootObject()->property("loading"), QVariant(false), 30000);
+ webEngineView->setUrl(QUrl(QStringLiteral("data:text/html,%1").arg(htmlData)));
+ QVERIFY(waitForLoadSucceeded(webEngineView));
}
static QByteArrayList params;
W_QTEST_MAIN(tst_QQuickWebEngineViewGraphics, params)
#include "tst_qquickwebengineviewgraphics.moc"
+#include "moc_quickutil.cpp"
diff --git a/tests/auto/quick/qtbug-70248/CMakeLists.txt b/tests/auto/quick/qtbug-70248/CMakeLists.txt
new file mode 100644
index 000000000..b177c5309
--- /dev/null
+++ b/tests/auto/quick/qtbug-70248/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_test(tst_qtbug-70248
+ SOURCES
+ tst_qtbug-70248.cpp
+ LIBRARIES
+ Qt::WebEngineQuickPrivate
+)
+
+set(test_resource_files
+ "test.qml"
+)
+
+qt_internal_add_resource(tst_qtbug-70248 "test"
+ PREFIX
+ "/"
+ FILES
+ ${test_resource_files}
+)
diff --git a/tests/auto/quick/qtbug-70248/qtbug-70248.pro b/tests/auto/quick/qtbug-70248/qtbug-70248.pro
deleted file mode 100644
index e1b18bc16..000000000
--- a/tests/auto/quick/qtbug-70248/qtbug-70248.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-include(../tests.pri)
-QT += webengine webengine-private
-
-RESOURCES += \
- test.qrc
diff --git a/tests/auto/quick/qtbug-70248/test.qml b/tests/auto/quick/qtbug-70248/test.qml
index 35962aff5..5870f593e 100644
--- a/tests/auto/quick/qtbug-70248/test.qml
+++ b/tests/auto/quick/qtbug-70248/test.qml
@@ -1,6 +1,6 @@
-import QtQuick 2.9
-import QtQuick.Window 2.2
-import QtWebEngine 1.3
+import QtQuick
+import QtQuick.Window
+import QtWebEngine
Window {
visible: true
diff --git a/tests/auto/quick/qtbug-70248/test.qrc b/tests/auto/quick/qtbug-70248/test.qrc
deleted file mode 100644
index 83fea5eb0..000000000
--- a/tests/auto/quick/qtbug-70248/test.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>test.qml</file>
- </qresource>
-</RCC>
diff --git a/tests/auto/quick/qtbug-70248/tst_qtbug-70248.cpp b/tests/auto/quick/qtbug-70248/tst_qtbug-70248.cpp
index 3dffa1d84..cf5c187c3 100644
--- a/tests/auto/quick/qtbug-70248/tst_qtbug-70248.cpp
+++ b/tests/auto/quick/qtbug-70248/tst_qtbug-70248.cpp
@@ -1,32 +1,7 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-#include "qtwebengineglobal.h"
+#include "qtwebenginequickglobal.h"
#include <QQuickWebEngineProfile>
#include <QQmlApplicationEngine>
#include <QQuickWindow>
@@ -43,7 +18,7 @@ private slots:
void tst_qtbug_70248::test()
{
- QtWebEngine::initialize();
+ QtWebEngineQuick::initialize();
QScopedPointer<QQmlApplicationEngine> engine;
QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true);
engine.reset(new QQmlApplicationEngine());
diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro
deleted file mode 100644
index 4648b2f64..000000000
--- a/tests/auto/quick/quick.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-include($$QTWEBENGINE_OUT_ROOT/src/webengine/qtwebengine-config.pri) # workaround for QTBUG-68093
-QT_FOR_CONFIG += webengine-private
-
-TEMPLATE = subdirs
-
-SUBDIRS += \
- dialogs \
- inspectorserver \
- qmltests \
- publicapi \
- qquickwebenginedefaultsurfaceformat \
- qquickwebengineview \
- qtbug-70248 \
- certificateerror
-
-qtConfig(webengine-testsupport) {
- SUBDIRS += qquickwebengineviewgraphics
-}
-
-boot2qt: SUBDIRS -= inspectorserver qquickwebengineview qmltests
diff --git a/tests/auto/quick/shared/qt_webengine_quicktest.h b/tests/auto/quick/shared/qt_webengine_quicktest.h
deleted file mode 100644
index 3adc9d459..000000000
--- a/tests/auto/quick/shared/qt_webengine_quicktest.h
+++ /dev/null
@@ -1,57 +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$
-**
-****************************************************************************/
-
-#ifndef QT_WEBENGINE_QUICKTEST_H
-#define QT_WEBENGINE_QUICKTEST_H
-
-#include <QtQuickTest/quicktestglobal.h>
-
-#ifdef QT_WIDGETS_LIB
-#include <QtWidgets/QApplication>
-#else
-#include <QtGui/QGuiApplication>
-#endif
-
-#include "qopenglcontext.h"
-#include <qtwebengineglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QUICK_TEST_SOURCE_DIR
-#define QUICK_TEST_SOURCE_DIR 0
-#endif
-
-#ifdef QT_WIDGETS_LIB
-#define Application QApplication
-#else
-#define Application QGuiApplication
-#endif
-
-QT_END_NAMESPACE
-
-#endif // QT_WEBENGINE_QUICKTEST_H
diff --git a/tests/auto/quick/shared/testwindow.h b/tests/auto/quick/shared/testwindow.h
deleted file mode 100644
index b57443c69..000000000
--- a/tests/auto/quick/shared/testwindow.h
+++ /dev/null
@@ -1,68 +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$
-**
-****************************************************************************/
-
-#ifndef TESTWINDOW_H
-#define TESTWINDOW_H
-
-#if 0
-#pragma qt_no_master_include
-#endif
-
-#include <QResizeEvent>
-#include <QScopedPointer>
-#include <QtQuick/qquickitem.h>
-#include <QtQuick/qquickview.h>
-
-// TestWindow: Utility class to ignore QQuickView details.
-class TestWindow : public QQuickView {
-public:
- inline TestWindow(QQuickItem *webEngineView);
- QScopedPointer<QQuickItem> webEngineView;
-
-protected:
- inline void resizeEvent(QResizeEvent*);
-};
-
-inline TestWindow::TestWindow(QQuickItem *webEngineView)
- : webEngineView(webEngineView)
-{
- Q_ASSERT(webEngineView);
- webEngineView->setParentItem(contentItem());
- resize(300, 400);
-}
-
-inline void TestWindow::resizeEvent(QResizeEvent *event)
-{
- QQuickView::resizeEvent(event);
- webEngineView->setX(0);
- webEngineView->setY(0);
- webEngineView->setWidth(event->size().width());
- webEngineView->setHeight(event->size().height());
-}
-
-#endif /* TESTWINDOW_H */
diff --git a/tests/auto/quick/shared/util.h b/tests/auto/quick/shared/util.h
deleted file mode 100644
index 132c353ca..000000000
--- a/tests/auto/quick/shared/util.h
+++ /dev/null
@@ -1,190 +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$
-**
-****************************************************************************/
-
-#ifndef UTIL_H
-#define UTIL_H
-
-#include <QEventLoop>
-#include <QQmlEngine>
-#include <QSignalSpy>
-#include <QTimer>
-#include <QtTest/QtTest>
-#include <QtWebEngine/private/qquickwebengineview_p.h>
-#include <QtWebEngine/private/qquickwebengineloadrequest_p.h>
-#include <QGuiApplication>
-
-#if !defined(TESTS_SOURCE_DIR)
-#define TESTS_SOURCE_DIR ""
-#endif
-
-class LoadSpy : public QEventLoop {
- Q_OBJECT
-
-public:
- LoadSpy(QQuickWebEngineView *webEngineView)
- {
- connect(webEngineView, SIGNAL(loadingChanged(QQuickWebEngineLoadRequest*)), SLOT(onLoadingChanged(QQuickWebEngineLoadRequest*)));
- }
-
- ~LoadSpy() { }
-
-Q_SIGNALS:
- void loadSucceeded();
- void loadFailed();
-
-private Q_SLOTS:
- void onLoadingChanged(QQuickWebEngineLoadRequest *loadRequest)
- {
- if (loadRequest->status() == QQuickWebEngineView::LoadSucceededStatus)
- emit loadSucceeded();
- else if (loadRequest->status() == QQuickWebEngineView::LoadFailedStatus)
- emit loadFailed();
- }
-};
-
-class LoadStartedCatcher : public QObject {
- Q_OBJECT
-
-public:
- LoadStartedCatcher(QQuickWebEngineView *webEngineView)
- : m_webEngineView(webEngineView)
- {
- connect(m_webEngineView, SIGNAL(loadingChanged(QQuickWebEngineLoadRequest*)), this, SLOT(onLoadingChanged(QQuickWebEngineLoadRequest*)));
- }
-
- virtual ~LoadStartedCatcher() { }
-
-public Q_SLOTS:
- void onLoadingChanged(QQuickWebEngineLoadRequest *loadRequest)
- {
- if (loadRequest->status() == QQuickWebEngineView::LoadStartedStatus)
- QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
- }
-
-Q_SIGNALS:
- void finished();
-
-private:
- QQuickWebEngineView *m_webEngineView;
-};
-
-inline bool waitForLoadSucceeded(QQuickWebEngineView *webEngineView, int timeout = 10000)
-{
- LoadSpy loadSpy(webEngineView);
- QSignalSpy spy(&loadSpy, &LoadSpy::loadSucceeded);
- return spy.wait(timeout);
-}
-
-inline bool waitForLoadFailed(QQuickWebEngineView *webEngineView, int timeout = 20000)
-{
- LoadSpy loadSpy(webEngineView);
- QSignalSpy spy(&loadSpy, &LoadSpy::loadFailed);
- return spy.wait(timeout);
-}
-
-inline QVariant evaluateJavaScriptSync(QQuickWebEngineView *view, const QString &script)
-{
- QQmlEngine *engine = qmlEngine(view);
- engine->globalObject().setProperty("called", false);
- engine->globalObject().setProperty("result", QJSValue());
- QJSValue callback = engine->evaluate(
- "(function callback(r) {"
- " called = true;"
- " result = r;"
- "})"
- );
- view->runJavaScript(script, callback);
- QTRY_LOOP_IMPL(engine->globalObject().property("called").toBool(), 5000, 50);
- if (!engine->globalObject().property("called").toBool()) {
- qWarning("JavaScript wasn't evaluated");
- return QVariant();
- }
-
- return engine->globalObject().property("result").toVariant();
-}
-
-inline QPoint elementCenter(QQuickWebEngineView *view, 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(view, jsCode).toList();
-
- if (rectList.count() != 2) {
- qWarning("elementCenter failed.");
- return QPoint();
- }
-
- return QPoint(rectList.at(0).toInt(), rectList.at(1).toInt());
-}
-
-inline QString activeElementId(QQuickWebEngineView *webEngineView)
-{
- qRegisterMetaType<QQuickWebEngineView::JavaScriptConsoleMessageLevel>("JavaScriptConsoleMessageLevel");
- QSignalSpy consoleMessageSpy(webEngineView, &QQuickWebEngineView::javaScriptConsoleMessage);
-
- webEngineView->runJavaScript(
- "if (document.activeElement == null)"
- " console.log('');"
- "else"
- " console.log(document.activeElement.id);"
- );
-
- if (!consoleMessageSpy.wait())
- return QString();
-
- QList<QVariant> arguments = consoleMessageSpy.takeFirst();
- if (static_cast<QQuickWebEngineView::JavaScriptConsoleMessageLevel>(arguments.at(0).toInt()) != QQuickWebEngineView::InfoMessageLevel)
- return QString();
-
- return arguments.at(1).toString();
-}
-
-#define W_QTEST_MAIN(TestObject, params) \
-int main(int argc, char *argv[]) \
-{ \
- QtWebEngine::initialize(); \
- \
- 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) \
- w_argv.append(params[i].data()); \
- int w_argc = w_argv.size(); \
- \
- QGuiApplication app(w_argc, const_cast<char **>(w_argv.data())); \
- app.setAttribute(Qt::AA_Use96Dpi, true); \
- TestObject tc; \
- QTEST_SET_MAIN_SOURCE_PATH \
- return QTest::qExec(&tc, argc, argv); \
-}
-#endif /* UTIL_H */
-
diff --git a/tests/auto/quick/tests.pri b/tests/auto/quick/tests.pri
deleted file mode 100644
index 1bf69da43..000000000
--- a/tests/auto/quick/tests.pri
+++ /dev/null
@@ -1,20 +0,0 @@
-include($$QTWEBENGINE_OUT_ROOT/src/webengine/qtwebengine-config.pri) # workaround for QTBUG-68093
-QT_FOR_CONFIG += webengine-private
-
-TEMPLATE = app
-
-CONFIG += testcase
-
-VPATH += $$_PRO_FILE_PWD_
-TARGET = tst_$$TARGET
-
-SOURCES += $${TARGET}.cpp
-INCLUDEPATH += \
- $$PWD \
- ../shared
-
-QT += testlib network quick webengine
-
-# This define is used by some tests to look up resources in the source tree
-DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD/\\\"
-include(../embed_info_plist.pri)
diff --git a/tests/auto/quick/uidelegates/CMakeLists.txt b/tests/auto/quick/uidelegates/CMakeLists.txt
new file mode 100644
index 000000000..bdf041e04
--- /dev/null
+++ b/tests/auto/quick/uidelegates/CMakeLists.txt
@@ -0,0 +1,17 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+include(../../httpserver/httpserver.cmake)
+include(../../util/util.cmake)
+
+qt_internal_add_test(tst_uidelegates
+ SOURCES
+ tst_uidelegates.cpp
+ LIBRARIES
+ Qt::WebEngineCorePrivate
+ Qt::WebEngineQuick
+ Qt::GuiPrivate
+ Qt::WebEngineQuickPrivate
+ Test::HttpServer
+ Test::Util
+)
diff --git a/tests/auto/quick/uidelegates/tst_uidelegates.cpp b/tests/auto/quick/uidelegates/tst_uidelegates.cpp
new file mode 100644
index 000000000..fb8734f83
--- /dev/null
+++ b/tests/auto/quick/uidelegates/tst_uidelegates.cpp
@@ -0,0 +1,228 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include "testwindow.h"
+#include "quickutil.h"
+
+#include <QScopedPointer>
+#include <QtQml/QQmlEngine>
+#include <QtTest/QtTest>
+#include <QtWebEngineQuick/private/qquickwebengineview_p.h>
+#include <httpserver.h>
+#include <QNetworkProxy>
+#include <QObject>
+
+class tst_UIDelegates : public QObject
+{
+ Q_OBJECT
+public:
+ tst_UIDelegates();
+
+private Q_SLOTS:
+ void init();
+ void initTestCase();
+ void cleanup();
+ void javaScriptDialog();
+ void javaScriptDialog_data();
+ void fileDialog();
+ void contextMenu();
+ void tooltip();
+ void colorDialog();
+ void authenticationDialog_data();
+ void authenticationDialog();
+
+private:
+ inline QQuickWebEngineView *newWebEngineView();
+ inline QQuickWebEngineView *webEngineView() const;
+ void runJavaScript(const QString &script);
+ QScopedPointer<TestWindow> m_window;
+ QScopedPointer<QQmlComponent> m_component;
+};
+
+tst_UIDelegates::tst_UIDelegates()
+{
+ QtWebEngineQuick::initialize();
+ static QQmlEngine *engine = new QQmlEngine(this);
+ m_component.reset(new QQmlComponent(engine, this));
+ m_component->setData(QByteArrayLiteral("import QtQuick\n"
+ "import QtWebEngine\n"
+ "WebEngineView {}"),
+ QUrl());
+}
+
+QQuickWebEngineView *tst_UIDelegates::newWebEngineView()
+{
+ QObject *viewInstance = m_component->create();
+ QQuickWebEngineView *webEngineView = qobject_cast<QQuickWebEngineView *>(viewInstance);
+ return webEngineView;
+}
+
+void tst_UIDelegates::init()
+{
+ m_window.reset(new TestWindow(newWebEngineView()));
+}
+
+void tst_UIDelegates::initTestCase()
+{
+ QNetworkProxy proxy;
+ proxy.setType(QNetworkProxy::HttpProxy);
+ proxy.setHostName("localhost");
+ proxy.setPort(5555);
+ QNetworkProxy::setApplicationProxy(proxy);
+}
+
+void tst_UIDelegates::cleanup()
+{
+ m_window.reset();
+}
+
+inline QQuickWebEngineView *tst_UIDelegates::webEngineView() const
+{
+ return static_cast<QQuickWebEngineView *>(m_window->webEngineView.data());
+}
+
+void tst_UIDelegates::runJavaScript(const QString &script)
+{
+ webEngineView()->runJavaScript(script);
+}
+
+void tst_UIDelegates::javaScriptDialog_data()
+{
+ QTest::addColumn<QString>("javaScriptCode");
+ QTest::addColumn<QString>("expectedObjectName");
+
+ QTest::newRow("AlertDialog") << QString("alert('This is the Alert Dialog!');")
+ << QString("alertDialog");
+ QTest::newRow("ConfirmDialog") << QString("confirm('This is the Confirm Dialog.');")
+ << QString("confirmDialog");
+ QTest::newRow("PromptDialog") << QString("prompt('Is this the Prompt Dialog?', 'Yes');")
+ << QString("promptDialog");
+}
+
+void tst_UIDelegates::javaScriptDialog()
+{
+ QFETCH(QString, javaScriptCode);
+ QFETCH(QString, expectedObjectName);
+
+ m_window->show();
+ QTRY_VERIFY(qApp->focusObject());
+ QQuickWebEngineView *view = webEngineView();
+
+ view->loadHtml("<html><body>"
+ "</body></html>");
+ QVERIFY(waitForLoadSucceeded(view));
+
+ runJavaScript(javaScriptCode);
+ QTRY_VERIFY(view->findChild<QObject *>(expectedObjectName));
+}
+
+void tst_UIDelegates::fileDialog()
+{
+ m_window->show();
+ QTRY_VERIFY(qApp->focusObject());
+ QQuickWebEngineView *view = webEngineView();
+
+ view->loadHtml("<html><body>"
+ "<input type='file' id='filePicker'/>"
+ "</body></html>");
+ QVERIFY(waitForLoadSucceeded(view));
+
+ QPoint filePickerCenter = elementCenter(view, QStringLiteral("filePicker"));
+ QTest::mouseClick(view->window(), Qt::LeftButton, {}, filePickerCenter);
+ QTRY_VERIFY(view->findChild<QObject *>(QStringLiteral("fileDialog")));
+}
+
+void tst_UIDelegates::contextMenu()
+{
+ m_window->show();
+ QTRY_VERIFY(qApp->focusObject());
+ QQuickWebEngineView *view = webEngineView();
+
+ view->loadHtml("<html><body>"
+ "</body></html>");
+ QVERIFY(waitForLoadSucceeded(view));
+
+ QTest::mouseClick(view->window(), Qt::RightButton);
+ QTRY_VERIFY(view->findChild<QObject *>(QStringLiteral("menu")));
+}
+
+void tst_UIDelegates::tooltip()
+{
+ m_window->show();
+ QTRY_VERIFY(qApp->focusObject());
+ QQuickWebEngineView *view = webEngineView();
+
+ view->loadHtml("<html><body>"
+ "<p id='toolTip' title='I'm a tooltip.'>Hover this text to display a tooltip</p>"
+ "</body></html>");
+ QVERIFY(waitForLoadSucceeded(view));
+ QString toolTipStr = QStringLiteral("toolTip");
+
+ QPoint tooltipCenter = elementCenter(view, toolTipStr);
+ QPoint windowCenter = QPoint(view->window()->width() / 2, view->window()->height() / 2);
+ QVERIFY(tooltipCenter.x() == windowCenter.x());
+
+ int distance = windowCenter.y() - tooltipCenter.y();
+ for (int i = 3; i > 0; i--) {
+ QTest::mouseMove(view->window(), QPoint(windowCenter.x(), windowCenter.y() - distance / i));
+ }
+ QTRY_VERIFY(view->findChild<QObject *>(toolTipStr));
+}
+
+void tst_UIDelegates::colorDialog()
+{
+ m_window->show();
+ QTRY_VERIFY(qApp->focusObject());
+ QQuickWebEngineView *view = webEngineView();
+
+ view->loadHtml("<html><body>"
+ "<input type='color' id='colorPicker'>"
+ "</body></html>");
+ QVERIFY(waitForLoadSucceeded(view));
+
+ QPoint filePickerCenter = elementCenter(view, QStringLiteral("colorPicker"));
+ QTest::mouseClick(view->window(), Qt::LeftButton, {}, filePickerCenter);
+ QTRY_VERIFY(view->findChild<QObject *>(QStringLiteral("colorDialog")));
+}
+
+void tst_UIDelegates::authenticationDialog_data()
+{
+ QTest::addColumn<QUrl>("url");
+ QTest::addColumn<QByteArray>("response");
+
+ QTest::newRow("Http Authentication Dialog")
+ << QUrl("http://localhost:5555/")
+ << 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/")
+ << 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_UIDelegates::authenticationDialog()
+{
+ QFETCH(QUrl, url);
+ QFETCH(QByteArray, response);
+
+ HttpServer server(QHostAddress::LocalHost, 5555);
+ connect(&server, &HttpServer::newRequest,
+ [url, response](HttpReqRep *rr) { rr->sendResponse(response); });
+ QVERIFY(server.start());
+
+ m_window->show();
+ QTRY_VERIFY(qApp->focusObject());
+ QQuickWebEngineView *view = webEngineView();
+ view->loadHtml("<html><body>"
+ "</body></html>");
+ QVERIFY(waitForLoadSucceeded(view));
+
+ view->setUrl(url);
+ QTRY_VERIFY(view->findChild<QObject *>(QStringLiteral("authenticationDialog")));
+ QVERIFY(server.stop());
+}
+
+QTEST_MAIN(tst_UIDelegates)
+#include "tst_uidelegates.moc"
+#include "moc_quickutil.cpp"