summaryrefslogtreecommitdiffstats
path: root/src/webengine
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/api/qquickwebenginetestsupport.cpp75
-rw-r--r--src/webengine/api/qquickwebenginetestsupport_p.h76
-rw-r--r--src/webengine/api/qquickwebengineview.cpp43
-rw-r--r--src/webengine/api/qquickwebengineview_p.h15
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h11
-rw-r--r--src/webengine/plugin/testsupport/plugin.cpp63
-rw-r--r--src/webengine/plugin/testsupport/qmldir3
-rw-r--r--src/webengine/plugin/testsupport/testsupport.pro13
-rw-r--r--src/webengine/webengine.pro7
9 files changed, 302 insertions, 4 deletions
diff --git a/src/webengine/api/qquickwebenginetestsupport.cpp b/src/webengine/api/qquickwebenginetestsupport.cpp
new file mode 100644
index 000000000..d85e56e59
--- /dev/null
+++ b/src/webengine/api/qquickwebenginetestsupport.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** 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: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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickwebenginetestsupport_p.h"
+
+#include "qquickwebengineloadrequest_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QQuickWebEngineErrorPage::QQuickWebEngineErrorPage()
+{
+}
+
+void QQuickWebEngineErrorPage::loadFinished(bool success, const QUrl &url)
+{
+ // Loading of the error page should not fail.
+ Q_ASSERT(success);
+
+ QQuickWebEngineLoadRequest loadRequest(url, QQuickWebEngineView::LoadSucceededStatus);
+ Q_EMIT loadingChanged(&loadRequest);
+ return;
+}
+
+void QQuickWebEngineErrorPage::loadStarted(const QUrl &provisionalUrl)
+{
+ QQuickWebEngineLoadRequest loadRequest(provisionalUrl, QQuickWebEngineView::LoadStartedStatus);
+ Q_EMIT loadingChanged(&loadRequest);
+}
+
+QQuickWebEngineTestSupport::QQuickWebEngineTestSupport()
+ : m_errorPage(new QQuickWebEngineErrorPage())
+{
+}
+
+QQuickWebEngineErrorPage *QQuickWebEngineTestSupport::errorPage() const
+{
+ return m_errorPage.data();
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qquickwebenginetestsupport_p.cpp"
diff --git a/src/webengine/api/qquickwebenginetestsupport_p.h b/src/webengine/api/qquickwebenginetestsupport_p.h
new file mode 100644
index 000000000..832ac2803
--- /dev/null
+++ b/src/webengine/api/qquickwebenginetestsupport_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** 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: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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKWEBENGINETESTSUPPORT_P_H
+#define QQUICKWEBENGINETESTSUPPORT_P_H
+
+#include <private/qtwebengineglobal_p.h>
+
+#include <QObject>
+#include <QUrl>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickWebEngineLoadRequest;
+
+class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineErrorPage : public QObject {
+ Q_OBJECT
+
+public:
+ QQuickWebEngineErrorPage();
+
+ void loadFinished(bool success, const QUrl &url);
+ void loadStarted(const QUrl &provisionalUrl);
+
+Q_SIGNALS:
+ void loadingChanged(QQuickWebEngineLoadRequest *loadRequest);
+};
+
+class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineTestSupport : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QQuickWebEngineErrorPage *errorPage READ errorPage)
+
+public:
+ QQuickWebEngineTestSupport();
+ QQuickWebEngineErrorPage *errorPage() const;
+
+private:
+ QScopedPointer<QQuickWebEngineErrorPage> m_errorPage;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKWEBENGINETESTSUPPORT_P_H
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 6fa3798c2..2fbf0ecb2 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -49,6 +49,11 @@
#include "qquickwebengineprofile_p_p.h"
#include "qquickwebenginesettings_p.h"
#include "qquickwebenginescript_p_p.h"
+
+#ifdef ENABLE_QML_TESTSUPPORT_API
+#include "qquickwebenginetestsupport_p.h"
+#endif
+
#include "render_widget_host_view_qt_delegate_quick.h"
#include "render_widget_host_view_qt_delegate_quickwindow.h"
#include "ui_delegates_manager.h"
@@ -90,6 +95,9 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
, m_history(new QQuickWebEngineHistory(this))
, m_profile(QQuickWebEngineProfile::defaultProfile())
, m_settings(new QQuickWebEngineSettings(m_profile->settings()))
+#ifdef ENABLE_QML_TESTSUPPORT_API
+ , m_testSupport(0)
+#endif
, contextMenuExtraItems(0)
, loadProgress(0)
, m_isFullScreen(false)
@@ -301,9 +309,17 @@ qreal QQuickWebEngineViewPrivate::dpiScale() const
return m_dpiScale;
}
-void QQuickWebEngineViewPrivate::loadStarted(const QUrl &provisionalUrl)
+void QQuickWebEngineViewPrivate::loadStarted(const QUrl &provisionalUrl, bool isErrorPage)
{
Q_Q(QQuickWebEngineView);
+ if (isErrorPage) {
+#ifdef ENABLE_QML_TESTSUPPORT_API
+ if (m_testSupport)
+ m_testSupport->errorPage()->loadStarted(provisionalUrl);
+#endif
+ return;
+ }
+
isLoading = true;
m_history->reset();
m_certificateErrorControllers.clear();
@@ -325,9 +341,18 @@ Q_STATIC_ASSERT(static_cast<int>(WebEngineError::NoErrorDomain) == static_cast<i
Q_STATIC_ASSERT(static_cast<int>(WebEngineError::CertificateErrorDomain) == static_cast<int>(QQuickWebEngineView::CertificateErrorDomain));
Q_STATIC_ASSERT(static_cast<int>(WebEngineError::DnsErrorDomain) == static_cast<int>(QQuickWebEngineView::DnsErrorDomain));
-void QQuickWebEngineViewPrivate::loadFinished(bool success, const QUrl &url, int errorCode, const QString &errorDescription)
+void QQuickWebEngineViewPrivate::loadFinished(bool success, const QUrl &url, bool isErrorPage, int errorCode, const QString &errorDescription)
{
Q_Q(QQuickWebEngineView);
+
+ if (isErrorPage) {
+#ifdef ENABLE_QML_TESTSUPPORT_API
+ if (m_testSupport)
+ m_testSupport->errorPage()->loadFinished(success, url);
+#endif
+ return;
+ }
+
isLoading = false;
m_history->reset();
if (errorCode == WebEngineError::UserAbortedError) {
@@ -703,6 +728,20 @@ void QQuickWebEngineViewPrivate::setProfile(QQuickWebEngineProfile *profile)
}
}
+#ifdef ENABLE_QML_TESTSUPPORT_API
+QQuickWebEngineTestSupport *QQuickWebEngineView::testSupport() const
+{
+ Q_D(const QQuickWebEngineView);
+ return d->m_testSupport;
+}
+
+void QQuickWebEngineView::setTestSupport(QQuickWebEngineTestSupport *testSupport)
+{
+ Q_D(QQuickWebEngineView);
+ d->m_testSupport = testSupport;
+}
+#endif
+
void QQuickWebEngineViewPrivate::didRunJavaScript(quint64 requestId, const QVariant &result)
{
Q_Q(QQuickWebEngineView);
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index 3ff6ab66b..d4a492efb 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -54,6 +54,11 @@ class QQuickWebEngineSettings;
class QQuickWebEngineViewExperimental;
class QQuickWebEngineViewPrivate;
+#ifdef ENABLE_QML_TESTSUPPORT_API
+class QQuickWebEngineTestSupport;
+#endif
+
+
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_OBJECT
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
@@ -69,6 +74,11 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(QQuickWebEngineHistory *navigationHistory READ navigationHistory CONSTANT FINAL REVISION 1)
Q_PROPERTY(QQmlWebChannel *webChannel READ webChannel WRITE setWebChannel NOTIFY webChannelChanged REVISION 1)
Q_PROPERTY(QQmlListProperty<QQuickWebEngineScript> userScripts READ userScripts FINAL)
+
+#ifdef ENABLE_QML_TESTSUPPORT_API
+ Q_PROPERTY(QQuickWebEngineTestSupport *testSupport READ testSupport WRITE setTestSupport FINAL)
+#endif
+
Q_ENUMS(NavigationRequestAction);
Q_ENUMS(NavigationType);
Q_ENUMS(LoadStatus);
@@ -161,6 +171,11 @@ public:
void setWebChannel(QQmlWebChannel *);
QQuickWebEngineHistory *navigationHistory() const;
+#ifdef ENABLE_QML_TESTSUPPORT_API
+ QQuickWebEngineTestSupport *testSupport() const;
+ void setTestSupport(QQuickWebEngineTestSupport *testSupport);
+#endif
+
public Q_SLOTS:
void runJavaScript(const QString&, const QJSValue & = QJSValue());
void loadHtml(const QString &html, const QUrl &baseUrl = QUrl());
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 7a33605de..6d9b16d70 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -57,6 +57,10 @@ class QQmlComponent;
class QQmlContext;
class QQuickWebEngineSettings;
+#ifdef ENABLE_QML_TESTSUPPORT_API
+class QQuickWebEngineTestSupport;
+#endif
+
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineViewport : public QObject {
Q_OBJECT
Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio WRITE setDevicePixelRatio NOTIFY devicePixelRatioChanged)
@@ -137,10 +141,10 @@ public:
virtual void selectionChanged() Q_DECL_OVERRIDE { }
virtual QRectF viewportRect() const Q_DECL_OVERRIDE;
virtual qreal dpiScale() const Q_DECL_OVERRIDE;
- virtual void loadStarted(const QUrl &provisionalUrl) Q_DECL_OVERRIDE;
+ virtual void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) Q_DECL_OVERRIDE;
virtual void loadCommitted() Q_DECL_OVERRIDE;
virtual void loadVisuallyCommitted() Q_DECL_OVERRIDE;
- virtual void loadFinished(bool success, const QUrl &url, int errorCode = 0, const QString &errorDescription = QString()) Q_DECL_OVERRIDE;
+ virtual void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) Q_DECL_OVERRIDE;
virtual void focusContainer() Q_DECL_OVERRIDE;
virtual void unhandledKeyEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
virtual void adoptNewWindow(QtWebEngineCore::WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &) Q_DECL_OVERRIDE;
@@ -186,6 +190,9 @@ public:
QScopedPointer<QQuickWebEngineHistory> m_history;
QQuickWebEngineProfile *m_profile;
QScopedPointer<QQuickWebEngineSettings> m_settings;
+#ifdef ENABLE_QML_TESTSUPPORT_API
+ QQuickWebEngineTestSupport *m_testSupport;
+#endif
QQmlComponent *contextMenuExtraItems;
QUrl explicitUrl;
QUrl icon;
diff --git a/src/webengine/plugin/testsupport/plugin.cpp b/src/webengine/plugin/testsupport/plugin.cpp
new file mode 100644
index 000000000..60e56062c
--- /dev/null
+++ b/src/webengine/plugin/testsupport/plugin.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** 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: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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQml>
+
+#include "qquickwebenginetestsupport_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QtWebEngineTestSupportPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
+public:
+ virtual void registerTypes(const char *uri)
+ {
+ qWarning("\nWARNING: This project is using the testsupport QML API extensions for QtWebEngine and is therefore tied to a specific QtWebEngine release.\n"
+ "WARNING: The testsupport API will change from version to version, or even be removed. You have been warned!\n");
+
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebEngine.testsupport"));
+
+ qmlRegisterType<QQuickWebEngineTestSupport>(uri, 1, 0, "WebEngineTestSupport");
+ qmlRegisterUncreatableType<QQuickWebEngineErrorPage>(uri, 1, 0, "WebEngineErrorPage",
+ QObject::tr("Cannot create a separate instance of WebEngineErrorPage"));
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "plugin.moc"
diff --git a/src/webengine/plugin/testsupport/qmldir b/src/webengine/plugin/testsupport/qmldir
new file mode 100644
index 000000000..588c9d2d4
--- /dev/null
+++ b/src/webengine/plugin/testsupport/qmldir
@@ -0,0 +1,3 @@
+module QtWebEngine.testsupport
+plugin qtwebenginetestsupportplugin
+typeinfo plugins.qmltypes
diff --git a/src/webengine/plugin/testsupport/testsupport.pro b/src/webengine/plugin/testsupport/testsupport.pro
new file mode 100644
index 000000000..1a45ad56a
--- /dev/null
+++ b/src/webengine/plugin/testsupport/testsupport.pro
@@ -0,0 +1,13 @@
+CXX_MODULE = qml
+TARGET = qtwebenginetestsupportplugin
+TARGETPATH = QtWebEngine/testsupport
+IMPORT_VERSION = 1.0
+
+QT += webengine qml quick
+QT_PRIVATE += webengine-private
+
+INCLUDEPATH += $$QTWEBENGINE_ROOT/src/core $$QTWEBENGINE_ROOT/src/webengine $$QTWEBENGINE_ROOT/src/webengine/api
+
+SOURCES = plugin.cpp
+
+load(qml_plugin)
diff --git a/src/webengine/webengine.pro b/src/webengine/webengine.pro
index 154286e9e..6cba9c5d9 100644
--- a/src/webengine/webengine.pro
+++ b/src/webengine/webengine.pro
@@ -48,4 +48,11 @@ HEADERS = \
render_widget_host_view_qt_delegate_quickwindow.h \
ui_delegates_manager.h
+isQMLTestSupportApiEnabled() {
+ SOURCES += api/qquickwebenginetestsupport.cpp
+ HEADERS += api/qquickwebenginetestsupport_p.h
+
+ DEFINES += ENABLE_QML_TESTSUPPORT_API
+}
+
load(qt_module)