diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-01-16 13:09:44 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-01-16 17:01:24 +0100 |
commit | 819e00f71e37f5230b9b2c2ff756db4cc4cfda5e (patch) | |
tree | ed8f247651f06581c462c6cbefde4fa097000946 | |
parent | 9ed734bfdd7b70f4f7f8e78529ead40031607f99 (diff) | |
parent | 2620f6baa55dc13d65ea0d4b09a23ddfae580279 (diff) |
Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
src/3rdparty
src/core/web_contents_adapter.cpp
src/webengine/api/qquickwebengineprofile.cpp
src/webenginewidgets/api/qwebengineprofile.cpp
tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp
tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
Change-Id: I56c093ebab5ee8b577783ce71761719159cd3ddd
-rw-r--r-- | dist/changes-5.9.4 | 68 | ||||
m--------- | src/3rdparty | 0 | ||||
-rw-r--r-- | src/core/api/core_api.pro | 2 | ||||
-rw-r--r-- | src/core/api/qwebenginebrowsercontext.cpp | 73 | ||||
-rw-r--r-- | src/core/api/qwebenginebrowsercontext_p.h | 83 | ||||
-rw-r--r-- | src/core/proxy_config_service_qt.cpp | 14 | ||||
-rw-r--r-- | src/core/web_contents_adapter.cpp | 4 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineprofile.cpp | 20 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineprofile_p.h | 7 | ||||
-rw-r--r-- | src/webengine/ui_delegates_manager.cpp | 5 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginedownloaditem.cpp | 7 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineprofile.cpp | 29 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineprofile_p.h | 18 | ||||
-rw-r--r-- | tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp | 21 | ||||
-rw-r--r-- | tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 19 |
15 files changed, 302 insertions, 68 deletions
diff --git a/dist/changes-5.9.4 b/dist/changes-5.9.4 new file mode 100644 index 000000000..e80c7fcb8 --- /dev/null +++ b/dist/changes-5.9.4 @@ -0,0 +1,68 @@ +Qt 5.9.4 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.9.0. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +http://doc.qt.io/qt-5/index.html + +The Qt version 5.9 series is binary compatible with the 5.8.x series. +Applications compiled for 5.8 will continue to run with 5.9. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Qt 5.9.4 changes * +**************************************************************************** + +Chromium +-------- + + * Security fixes from Chromium up to version 63.0.3239.132. + Including: CVE-2017-15407, CVE-2017-15409, CVE-2017-15410, + CVE-2017-15411, CVE-2017-15415, CVE-2017-15416, CVE-2017-15418, + CVE-2017-15419, CVE-2017-15422, CVE-2017-15423, CVE-2017-15424, + CVE-2017-15425 and CVE-2017-15426 + * Mitigation of SPECTRE. + +General +------- + + - [QTBUG-64265] JavaScript MouseLeave events are now always raised + when mouse is leaving view. + - [QTBUG-63266] JavaScript PointerEvent.pointerType property is now + properly set. + - [QTBUG-64560] Fixed rendering glitches after renderProcessTerminated + signal was emitted. + - [QTBUG-47206] Fixed incorrect layouting due to bug in HTML5 viewport + support. + - [QTBUG-57206] Fixed Favicon not updating if URL gets changed from + JavaScript. + - [QTBUG-58400] Printing does now use less memory, avoiding OOM situations + with very large documents. + - [QTBUG-65239] Fixed hanging of process if application is closed too + fast after startup. + +QtWebEngineWidgets +------------------ + + - [QTBUG-64436] Fixed crash when exiting fullscreen mode using the context + menu. + - [QTBUG-64933] Fixed tooltips that did still show after mouse was moved + away. + +Platform Specific Changes +------------------------- + + - Linux: + * [QTBUG-65174] Fixed regression from Qt 5.9.2 where the official + QtWebEngine binary did not use the installed + certificates via libnss. + * [QTBUG-57761] Fixed hardcoded lookup of library libGLES2.so.2 in + the system. diff --git a/src/3rdparty b/src/3rdparty -Subproject 44b6c003b1e3ab8ef4ce9d516fd24d7a8eefb2f +Subproject 17e4aafb6fe894047b46abeb3c3b8290de4094c diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro index 270595378..93eebbc45 100644 --- a/src/core/api/core_api.pro +++ b/src/core/api/core_api.pro @@ -33,6 +33,7 @@ HEADERS = \ qwebenginecallback_p.h \ qtwebenginecoreglobal.h \ qtwebenginecoreglobal_p.h \ + qwebenginebrowsercontext_p.h \ qwebenginecookiestore.h \ qwebenginecookiestore_p.h \ qwebenginehttprequest.h \ @@ -44,6 +45,7 @@ HEADERS = \ SOURCES = \ qtwebenginecoreglobal.cpp \ + qwebenginebrowsercontext.cpp \ qwebenginecookiestore.cpp \ qwebenginehttprequest.cpp \ qwebengineurlrequestinfo.cpp \ diff --git a/src/core/api/qwebenginebrowsercontext.cpp b/src/core/api/qwebenginebrowsercontext.cpp new file mode 100644 index 000000000..c3ab16460 --- /dev/null +++ b/src/core/api/qwebenginebrowsercontext.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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: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$ +** +****************************************************************************/ + +#include "qwebenginebrowsercontext_p.h" + +#include "browser_context_adapter.h" +#include <qtwebenginecoreglobal.h> + +QT_BEGIN_NAMESPACE + +QWebEngineBrowserContext::QWebEngineBrowserContext(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext, + QtWebEngineCore::BrowserContextAdapterClient *profile) + : QObject(QtWebEngineCore::BrowserContextAdapter::globalQObjectRoot()) + , browserContextRef(browserContext) + , m_profile(profile) +{ + browserContextRef->addClient(m_profile); +} + +QWebEngineBrowserContext::~QWebEngineBrowserContext() +{ + if (m_profile) + shutdown(); +} + +void QWebEngineBrowserContext::shutdown() +{ + Q_ASSERT(m_profile); + // In the case the user sets this profile as the parent of the interceptor + // it can be deleted before the browser-context still referencing it is. + browserContextRef->setRequestInterceptor(nullptr); + browserContextRef->removeClient(m_profile); + m_profile = 0; + deleteLater(); +} + +QT_END_NAMESPACE diff --git a/src/core/api/qwebenginebrowsercontext_p.h b/src/core/api/qwebenginebrowsercontext_p.h new file mode 100644 index 000000000..713ab730e --- /dev/null +++ b/src/core/api/qwebenginebrowsercontext_p.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** 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: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$ +** +****************************************************************************/ + +#ifndef QWEBENGINEBROWSERCONTEXT_P_H +#define QWEBENGINEBROWSERCONTEXT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// +#include "qtwebenginecoreglobal_p.h" + +#include <QObject> +#include <QSharedPointer> + +namespace QtWebEngineCore { +class BrowserContextAdapter; +class BrowserContextAdapterClient; +} + +QT_BEGIN_NAMESPACE + +// This is a wrapper class for BrowserContextAdapter. BrowserContextAdapter must be destructed before WebEngineContext +// is destructed. Therefore access it via the QWebEngineBrowserContext which parent is the WebEngineContext::globalQObject. +// This guarantees the destruction together with the WebEngineContext. +class QWEBENGINE_PRIVATE_EXPORT QWebEngineBrowserContext : public QObject { +public: + QWebEngineBrowserContext(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext, QtWebEngineCore::BrowserContextAdapterClient *profile); + ~QWebEngineBrowserContext(); + + void shutdown(); + + QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextRef; + +private: + QtWebEngineCore::BrowserContextAdapterClient *m_profile; +}; + +QT_END_NAMESPACE + +#endif // QWEBENGINEBROWSERCONTEXT_P_H diff --git a/src/core/proxy_config_service_qt.cpp b/src/core/proxy_config_service_qt.cpp index cd8f4c0fe..7fca18eb6 100644 --- a/src/core/proxy_config_service_qt.cpp +++ b/src/core/proxy_config_service_qt.cpp @@ -52,22 +52,20 @@ using content::BrowserThread; net::ProxyServer ProxyConfigServiceQt::fromQNetworkProxy(const QNetworkProxy &qtProxy) { - net::ProxyServer::Scheme proxyScheme = net::ProxyServer::SCHEME_INVALID; + net::HostPortPair hostPortPair(qtProxy.hostName().toStdString(), qtProxy.port()); switch (qtProxy.type()) { case QNetworkProxy::Socks5Proxy: - proxyScheme = net::ProxyServer::SCHEME_SOCKS5; - break; + return net::ProxyServer(net::ProxyServer::SCHEME_SOCKS5, hostPortPair); case QNetworkProxy::HttpProxy: case QNetworkProxy::HttpCachingProxy: case QNetworkProxy::FtpCachingProxy: - proxyScheme = net::ProxyServer::SCHEME_HTTP; - break; + return net::ProxyServer(net::ProxyServer::SCHEME_HTTP, hostPortPair); case QNetworkProxy::NoProxy: case QNetworkProxy::DefaultProxy: - proxyScheme = net::ProxyServer::SCHEME_DIRECT; - break; + return net::ProxyServer(net::ProxyServer::SCHEME_DIRECT, net::HostPortPair()); + default: + return net::ProxyServer(net::ProxyServer::SCHEME_INVALID, net::HostPortPair()); } - return net::ProxyServer(proxyScheme, net::HostPortPair(qtProxy.hostName().toStdString(), qtProxy.port())); } ProxyConfigServiceQt::ProxyConfigServiceQt(std::unique_ptr<ProxyConfigService> baseService) diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 0592e36fb..5850b07b5 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -1320,7 +1320,11 @@ bool WebContentsAdapter::handleDropDataFileContents(const content::DropData &dro const auto maybeFilename = dropData.GetSafeFilenameForImageFileContents(); const QString fileName = maybeFilename ? toQt(maybeFilename->AsUTF16Unsafe()) : QString(); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) const QString &filePath = d->dndTmpDir->filePath(fileName); +#else + const QString &filePath = d->dndTmpDir->path() + QLatin1Char('/') + fileName; +#endif QFile file(filePath); if (!file.open(QIODevice::WriteOnly)) { qWarning("Cannot write temporary file %s.", qUtf8Printable(filePath)); diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index 57ad009b7..7f591efe3 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -142,9 +142,8 @@ ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineC QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(QSharedPointer<BrowserContextAdapter> browserContext) : m_settings(new QQuickWebEngineSettings()) - , m_browserContextRef(browserContext) + , m_browserContext(new QWebEngineBrowserContext(browserContext, this)) { - m_browserContextRef->addClient(this); m_settings->d_ptr->initDefaults(); // Fullscreen API was implemented before the supported setting, so we must // make it default true to avoid change in default API behavior. @@ -153,21 +152,26 @@ QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(QSharedPointer<Brow QQuickWebEngineProfilePrivate::~QQuickWebEngineProfilePrivate() { - m_browserContextRef->setRequestInterceptor(nullptr); - - m_browserContextRef->removeClient(this); - - Q_FOREACH (QQuickWebEngineDownloadItem* download, m_ongoingDownloads) { + Q_FOREACH (QQuickWebEngineDownloadItem *download, m_ongoingDownloads) { if (download) download->cancel(); } m_ongoingDownloads.clear(); + + if (m_browserContext) + m_browserContext->shutdown(); +} + +QSharedPointer<QtWebEngineCore::BrowserContextAdapter> QQuickWebEngineProfilePrivate::browserContext() const +{ + return m_browserContext ? m_browserContext->browserContextRef : nullptr; } void QQuickWebEngineProfilePrivate::cancelDownload(quint32 downloadId) { - browserContext()->cancelDownload(downloadId); + if (m_browserContext) + m_browserContext->browserContextRef->cancelDownload(downloadId); } void QQuickWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId) diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h index 1828f8085..660433fd9 100644 --- a/src/webengine/api/qquickwebengineprofile_p.h +++ b/src/webengine/api/qquickwebengineprofile_p.h @@ -52,8 +52,9 @@ // #include "browser_context_adapter_client.h" -#include "qquickwebengineprofile_p.h" #include "browser_context_adapter.h" +#include "qwebenginebrowsercontext_p.h" +#include "qquickwebengineprofile_p.h" #include <QExplicitlySharedDataPointer> #include <QMap> @@ -71,7 +72,7 @@ public: QQuickWebEngineProfilePrivate(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext); ~QQuickWebEngineProfilePrivate(); - QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext() const { return m_browserContextRef; } + QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext() const; QQuickWebEngineSettings *settings() const { return m_settings.data(); } void cancelDownload(quint32 downloadId); @@ -90,7 +91,7 @@ private: friend class QQuickWebEngineViewPrivate; QQuickWebEngineProfile *q_ptr; QScopedPointer<QQuickWebEngineSettings> m_settings; - QSharedPointer<QtWebEngineCore::BrowserContextAdapter> m_browserContextRef; + QPointer<QWebEngineBrowserContext> m_browserContext; QMap<quint32, QPointer<QQuickWebEngineDownloadItem> > m_ongoingDownloads; QList<QQuickWebEngineScript *> m_userScripts; }; diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp index fb23f5db7..046affbf4 100644 --- a/src/webengine/ui_delegates_manager.cpp +++ b/src/webengine/ui_delegates_manager.cpp @@ -504,7 +504,12 @@ public: if (pos.isNull() || !item->contains(pos)) return; const QPoint oldPos = QCursor::pos(); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)) const QPoint globalPos = item->mapToGlobal(QPointF(pos)).toPoint(); +#else + const QPoint posInWindow = item->mapToItem(item->window()->contentItem(), QPointF(pos)).toPoint(); + const QPoint globalPos = item->window()->mapToGlobal(posInWindow); +#endif if (oldPos == globalPos) return; m_oldCursorPos = oldPos; diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp index a5569e408..dc1a48360 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp +++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp @@ -195,9 +195,10 @@ void QWebEngineDownloadItem::cancel() // We directly cancel the download request if the user cancels // before it even started, so no need to notify the profile here. - if (state == QWebEngineDownloadItem::DownloadInProgress) - d->profile->browserContext()->cancelDownload(d->downloadId); - else { + if (state == QWebEngineDownloadItem::DownloadInProgress) { + if (auto browserContext = d->profile->browserContext()) + browserContext->cancelDownload(d->downloadId); + } else { d->downloadState = QWebEngineDownloadItem::DownloadCancelled; Q_EMIT stateChanged(d->downloadState); } diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index 5a6c0e18a..2897d9798 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -47,8 +47,9 @@ #include "qwebenginesettings.h" #include "qwebenginescriptcollection_p.h" +#include "qwebenginebrowsercontext_p.h" +#include "qtwebenginecoreglobal.h" #include "browser_context_adapter.h" -#include <qtwebenginecoreglobal.h> #include "visited_links_manager_qt.h" #include "web_engine_settings.h" @@ -145,30 +146,6 @@ using QtWebEngineCore::BrowserContextAdapter; \sa QWebEngineDownloadItem, QWebEnginePage::download() */ -QWebEngineBrowserContext::QWebEngineBrowserContext(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext, QWebEngineProfilePrivate *profile) - : QObject(BrowserContextAdapter::globalQObjectRoot()) - , browserContextRef(browserContext) - , m_profile(profile) -{ - browserContextRef->addClient(m_profile); -} - -QWebEngineBrowserContext::~QWebEngineBrowserContext() -{ - if (m_profile) - shutdown(); -} - -void QWebEngineBrowserContext::shutdown() -{ - Q_ASSERT(m_profile); - // In the case the user sets this profile as the parent of the interceptor - // it can be deleted before the browser-context still referencing it is. - browserContextRef->setRequestInterceptor(nullptr); - browserContextRef->removeClient(m_profile); - m_profile = 0; -} - QWebEngineProfilePrivate::QWebEngineProfilePrivate(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext) : m_settings(new QWebEngineSettings()) , m_scriptCollection(new QWebEngineScriptCollection(new QWebEngineScriptCollectionPrivate(browserContext->userResourceController()))) @@ -194,7 +171,7 @@ QWebEngineProfilePrivate::~QWebEngineProfilePrivate() QSharedPointer<QtWebEngineCore::BrowserContextAdapter> QWebEngineProfilePrivate::browserContext() const { - return m_browserContext->browserContextRef; + return m_browserContext ? m_browserContext->browserContextRef : nullptr; } void QWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId) diff --git a/src/webenginewidgets/api/qwebengineprofile_p.h b/src/webenginewidgets/api/qwebengineprofile_p.h index 07aad9176..8d9e5011f 100644 --- a/src/webenginewidgets/api/qwebengineprofile_p.h +++ b/src/webenginewidgets/api/qwebengineprofile_p.h @@ -54,6 +54,7 @@ #include "browser_context_adapter_client.h" #include "qwebengineprofile.h" #include "qwebenginescriptcollection.h" + #include <QMap> #include <QPointer> #include <QScopedPointer> @@ -65,25 +66,10 @@ class BrowserContextAdapter; QT_BEGIN_NAMESPACE +class QWebEngineBrowserContext; class QWebEngineProfilePrivate; class QWebEngineSettings; -// This is a wrapper class for BrowserContextAdapter. BrowserContextAdapter must be destructed before WebEngineContext -// is destructed. Therefore access it via the QWebEngineBrowserContext which parent is the WebEngineContext::globalQObject. -// This guarantees the destruction together with the WebEngineContext. -class QWebEngineBrowserContext : public QObject { -public: - QWebEngineBrowserContext(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext, QWebEngineProfilePrivate *profile); - ~QWebEngineBrowserContext(); - - void shutdown(); - - QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextRef; - -private: - QWebEngineProfilePrivate *m_profile; -}; - class QWebEngineProfilePrivate : public QtWebEngineCore::BrowserContextAdapterClient { public: Q_DECLARE_PUBLIC(QWebEngineProfile) diff --git a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp index 7094c8e4b..83e8d1101 100644 --- a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp +++ b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp @@ -431,6 +431,13 @@ void tst_QWebEngineDownloads::downloadLink() void tst_QWebEngineDownloads::downloadTwoLinks() { HttpServer server; + QSignalSpy requestSpy(&server, &HttpServer::newRequest); + QList<HttpReqRep*> results; + connect(&server, &HttpServer::newRequest, [&](HttpReqRep *rr) { + rr->setParent(nullptr); + results.append(rr); + }); + QWebEngineProfile profile; QWebEnginePage page(&profile); QWebEngineView view; @@ -438,7 +445,8 @@ void tst_QWebEngineDownloads::downloadTwoLinks() view.load(server.url()); view.show(); - auto indexRR = waitForRequest(&server); + QTRY_COMPARE(requestSpy.count(), 1); + std::unique_ptr<HttpReqRep> indexRR(results.takeFirst()); QVERIFY(indexRR); QCOMPARE(indexRR->requestMethod(), QByteArrayLiteral("GET")); QCOMPARE(indexRR->requestPath(), QByteArrayLiteral("/")); @@ -449,19 +457,24 @@ void tst_QWebEngineDownloads::downloadTwoLinks() QVERIFY(waitForSignal(&page, &QWebEnginePage::loadFinished, [&](bool ok){ loadOk = ok; })); QVERIFY(loadOk); - auto favIconRR = waitForFaviconRequest(&server); + QTRY_COMPARE(requestSpy.count(), 2); + std::unique_ptr<HttpReqRep> favIconRR(results.takeFirst()); QVERIFY(favIconRR); + favIconRR->setResponseStatus(404); + favIconRR->sendResponse(); QTRY_VERIFY(view.focusWidget()); QWidget *renderWidget = view.focusWidget(); QTest::mouseClick(renderWidget, Qt::LeftButton, {}, QPoint(10, 10)); QTest::mouseClick(renderWidget, Qt::LeftButton, {}, QPoint(10, 30)); - auto file1RR = waitForRequest(&server); + QTRY_VERIFY(requestSpy.count() >= 3); + std::unique_ptr<HttpReqRep> file1RR(results.takeFirst()); QVERIFY(file1RR); QCOMPARE(file1RR->requestMethod(), QByteArrayLiteral("GET")); QCOMPARE(file1RR->requestPath(), QByteArrayLiteral("/file1")); - auto file2RR = waitForRequest(&server); + QTRY_COMPARE(requestSpy.count(), 4); + std::unique_ptr<HttpReqRep> file2RR(results.takeFirst()); QVERIFY(file2RR); QCOMPARE(file2RR->requestMethod(), QByteArrayLiteral("GET")); QCOMPARE(file2RR->requestPath(), QByteArrayLiteral("/file2")); diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 1c9b668ae..54cf27066 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -29,6 +29,7 @@ #include <QMainWindow> #include <QMenu> #include <QMimeDatabase> +#include <QNetworkProxy> #include <QOpenGLWidget> #include <QPaintEngine> #include <QPushButton> @@ -215,6 +216,7 @@ private Q_SLOTS: void viewSource(); void viewSourceURL_data(); void viewSourceURL(); + void proxyConfigWithUnexpectedHostPortPair(); private: static QPoint elementCenter(QWebEnginePage *page, const QString &id); @@ -4528,6 +4530,23 @@ void tst_QWebEnginePage::viewSourceURL() QVERIFY(!page.action(QWebEnginePage::ViewSource)->isEnabled()); } +Q_DECLARE_METATYPE(QNetworkProxy::ProxyType); + +void tst_QWebEnginePage::proxyConfigWithUnexpectedHostPortPair() +{ + // Chromium expects a proxy of type NoProxy to not have a host or port set. + + QNetworkProxy proxy; + proxy.setType(QNetworkProxy::NoProxy); + proxy.setHostName(QStringLiteral("127.0.0.1")); + proxy.setPort(244); + QNetworkProxy::setApplicationProxy(proxy); + + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + m_page->load(QStringLiteral("http://127.0.0.1:245/")); + QTRY_COMPARE(loadFinishedSpy.count(), 1); +} + static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")}; W_QTEST_MAIN(tst_QWebEnginePage, params) |