diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-10-24 17:14:28 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-10-24 17:14:28 +0200 |
commit | 5907f31e472b04553eb44cbec54c98bd06c3fee9 (patch) | |
tree | 218417007620698bc48f75c9bab9bd56b4385c10 | |
parent | 0de715dec80620482f051f7f29cf6844c0bbf008 (diff) | |
parent | bcf346057daa0ababa322c0fe657619bf238d77c (diff) |
Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I85903c77f4c68f4b945cfdac9ce3cea4041c2b37
50 files changed, 760 insertions, 180 deletions
diff --git a/examples/webengine/customdialogs/main.cpp b/examples/webengine/customdialogs/main.cpp index 82a3eca63..5aad8affb 100644 --- a/examples/webengine/customdialogs/main.cpp +++ b/examples/webengine/customdialogs/main.cpp @@ -67,9 +67,10 @@ int main(int argc, char *argv[]) { QCoreApplication::setOrganizationName("QtExamples"); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - Application app(argc, argv); QtWebEngine::initialize(); + Application app(argc, argv); + QQmlApplicationEngine engine; Server *server = new Server(&engine); diff --git a/examples/webengine/minimal/main.cpp b/examples/webengine/minimal/main.cpp index 8bcd0e0e9..86109f97a 100644 --- a/examples/webengine/minimal/main.cpp +++ b/examples/webengine/minimal/main.cpp @@ -57,9 +57,8 @@ int main(int argc, char *argv[]) QCoreApplication::setOrganizationName("QtExamples"); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); - QGuiApplication app(argc, argv); - QtWebEngine::initialize(); + QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); diff --git a/examples/webengine/quicknanobrowser/BrowserWindow.qml b/examples/webengine/quicknanobrowser/BrowserWindow.qml index 39a13df59..2d3168382 100644 --- a/examples/webengine/quicknanobrowser/BrowserWindow.qml +++ b/examples/webengine/quicknanobrowser/BrowserWindow.qml @@ -57,7 +57,7 @@ import QtQuick.Controls.Styles 1.0 import QtQuick.Dialogs 1.2 import QtQuick.Layouts 1.0 import QtQuick.Window 2.1 -import QtWebEngine 1.11 +import QtWebEngine 1.10 ApplicationWindow { id: browserWindow @@ -580,7 +580,7 @@ ApplicationWindow { findBar.visible = true; findBar.numberOfMatches = result.numberOfMatches; - findBar.activeMatchOrdinal = result.activeMatchOrdinal; + findBar.activeMatch = result.activeMatch; } onLoadingChanged: function(loadRequest) { diff --git a/examples/webengine/quicknanobrowser/FindBar.qml b/examples/webengine/quicknanobrowser/FindBar.qml index 2d673592a..de407ac33 100644 --- a/examples/webengine/quicknanobrowser/FindBar.qml +++ b/examples/webengine/quicknanobrowser/FindBar.qml @@ -57,12 +57,12 @@ Rectangle { id: root property int numberOfMatches: 0 - property int activeMatchOrdinal: 0 + property int activeMatch: 0 property alias text: findTextField.text function reset() { numberOfMatches = 0; - activeMatchOrdinal = 0; + activeMatch = 0; visible = false; } @@ -113,7 +113,7 @@ Rectangle { } Label { - text: activeMatchOrdinal + "/" + numberOfMatches + text: activeMatch + "/" + numberOfMatches visible: findTextField.text != "" } diff --git a/examples/webengine/quicknanobrowser/main.cpp b/examples/webengine/quicknanobrowser/main.cpp index 8d032f5d8..d09abba3c 100644 --- a/examples/webengine/quicknanobrowser/main.cpp +++ b/examples/webengine/quicknanobrowser/main.cpp @@ -80,11 +80,10 @@ int main(int argc, char **argv) { QCoreApplication::setOrganizationName("QtExamples"); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QtWebEngine::initialize(); Application app(argc, argv); - QtWebEngine::initialize(); - QQmlApplicationEngine appEngine; Utils utils; appEngine.rootContext()->setContextProperty("utils", &utils); diff --git a/examples/webengine/recipebrowser/main.cpp b/examples/webengine/recipebrowser/main.cpp index 6e6d69804..e61b9e0f5 100644 --- a/examples/webengine/recipebrowser/main.cpp +++ b/examples/webengine/recipebrowser/main.cpp @@ -58,9 +58,10 @@ int main(int argc, char *argv[]) { QCoreApplication::setOrganizationName("QtExamples"); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QGuiApplication app(argc, argv); QtWebEngine::initialize(); + QGuiApplication app(argc, argv); + QQuickStyle::setStyle(QStringLiteral("Material")); QQmlApplicationEngine engine; diff --git a/examples/webengine/webengineaction/main.cpp b/examples/webengine/webengineaction/main.cpp index ce723a99b..f2dec9655 100644 --- a/examples/webengine/webengineaction/main.cpp +++ b/examples/webengine/webengineaction/main.cpp @@ -56,10 +56,10 @@ int main(int argc, char *argv[]) { QCoreApplication::setOrganizationName("QtExamples"); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QGuiApplication app(argc, argv); - QtWebEngine::initialize(); + QGuiApplication app(argc, argv); + QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); diff --git a/examples/webenginewidgets/simplebrowser/browserwindow.cpp b/examples/webenginewidgets/simplebrowser/browserwindow.cpp index 7b167ded7..c1d0ea359 100644 --- a/examples/webenginewidgets/simplebrowser/browserwindow.cpp +++ b/examples/webenginewidgets/simplebrowser/browserwindow.cpp @@ -532,7 +532,7 @@ void BrowserWindow::handleFindTextFinished(const QWebEngineFindTextResult &resul statusBar()->showMessage(tr("\"%1\" not found.").arg(m_lastSearch)); } else { statusBar()->showMessage(tr("\"%1\" found: %2/%3").arg(m_lastSearch, - QString::number(result.activeMatchOrdinal()), + QString::number(result.activeMatch()), QString::number(result.numberOfMatches()))); } } diff --git a/src/3rdparty b/src/3rdparty -Subproject dc5221146d665f5634fab11fb4c9b5515c1ab07 +Subproject 88a931558e2e960eacccb32483713fcc4bbaf43 diff --git a/src/buildtools/config/common.pri b/src/buildtools/config/common.pri index 23a134774..97d39535c 100644 --- a/src/buildtools/config/common.pri +++ b/src/buildtools/config/common.pri @@ -137,3 +137,5 @@ qtConfig(webengine-kerberos) { ccache { gn_args += cc_wrapper=\"ccache\" } + +qtConfig(force_asserts): gn_args += dcheck_always_on=true diff --git a/src/buildtools/configure.json b/src/buildtools/configure.json index 535d8358b..a36d05320 100644 --- a/src/buildtools/configure.json +++ b/src/buildtools/configure.json @@ -150,9 +150,9 @@ ] }, "webengine-icu": { - "label": "icu >= 63", + "label": "icu >= 64", "sources": [ - { "type": "pkgConfig", "args": "icu-uc >= 63 icu-i18n >= 63" } + { "type": "pkgConfig", "args": "icu-uc >= 64 icu-i18n >= 64" } ] }, "webengine-webp": { diff --git a/src/core/api/qtwebenginecoreglobal.cpp b/src/core/api/qtwebenginecoreglobal.cpp index 0fddacb15..b27de4c23 100644 --- a/src/core/api/qtwebenginecoreglobal.cpp +++ b/src/core/api/qtwebenginecoreglobal.cpp @@ -108,7 +108,7 @@ Q_WEBENGINECORE_PRIVATE_EXPORT void initialize() QCoreApplication *app = QCoreApplication::instance(); if (!app) { - qFatal("QtWebEngine::initialize() must be called after the construction of the application object."); + qFatal("QtWebEngine::initialize() but no core application instance."); return; } diff --git a/src/core/api/qwebenginefindtextresult.cpp b/src/core/api/qwebenginefindtextresult.cpp index ce1be359e..c0adc6177 100644 --- a/src/core/api/qwebenginefindtextresult.cpp +++ b/src/core/api/qwebenginefindtextresult.cpp @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE class QWebEngineFindTextResultPrivate : public QSharedData { public: int numberOfMatches = 0; - int activeMatchOrdinal = 0; + int activeMatch = 0; }; /*! @@ -54,6 +54,18 @@ public: \inmodule QtWebEngineCore + The string search can be initiated by the \l QWebEnginePage::findText() or + \l{WebEngineView::findText()}{WebEngineView.findText()} method. The results of the search + are highlighted in the view. The details of this result are passed as a + QWebEngineFindTextResult object that can be used to show a status message, + such as "2 of 2 matches". For example: + + \code + QObject::connect(view.page(), &QWebEnginePage::findTextFinished, [](const QWebEngineFindTextResult &result) { + qInfo() << result.activeMatch() << "of" << result.numberOfMatches() << "matches"; + }); + \endcode + Results are passed to the user in the \l QWebEnginePage::findTextFinished() and \l{WebEngineView::findTextFinished()}{WebEngineView.findTextFinished()} signals. @@ -67,11 +79,11 @@ QWebEngineFindTextResult::QWebEngineFindTextResult() /*! \internal */ -QWebEngineFindTextResult::QWebEngineFindTextResult(int numberOfMatches, int activeMatchOrdinal) +QWebEngineFindTextResult::QWebEngineFindTextResult(int numberOfMatches, int activeMatch) : d(new QWebEngineFindTextResultPrivate) { d->numberOfMatches = numberOfMatches; - d->activeMatchOrdinal = activeMatchOrdinal; + d->activeMatch = activeMatch; } /*! \internal @@ -103,12 +115,12 @@ int QWebEngineFindTextResult::numberOfMatches() const } /*! - \property QWebEngineFindTextResult::activeMatchOrdinal + \property QWebEngineFindTextResult::activeMatch \brief The index of the currently highlighted match. */ -int QWebEngineFindTextResult::activeMatchOrdinal() const +int QWebEngineFindTextResult::activeMatch() const { - return d->activeMatchOrdinal; + return d->activeMatch; } QT_END_NAMESPACE diff --git a/src/core/api/qwebenginefindtextresult.h b/src/core/api/qwebenginefindtextresult.h index 073a8135f..246e689c3 100644 --- a/src/core/api/qwebenginefindtextresult.h +++ b/src/core/api/qwebenginefindtextresult.h @@ -55,11 +55,11 @@ class QWebEngineFindTextResultPrivate; class Q_WEBENGINECORE_EXPORT QWebEngineFindTextResult { Q_GADGET Q_PROPERTY(int numberOfMatches READ numberOfMatches CONSTANT FINAL) - Q_PROPERTY(int activeMatchOrdinal READ activeMatchOrdinal CONSTANT FINAL) + Q_PROPERTY(int activeMatch READ activeMatch CONSTANT FINAL) public: int numberOfMatches() const; - int activeMatchOrdinal() const; + int activeMatch() const; QWebEngineFindTextResult(); QWebEngineFindTextResult(const QWebEngineFindTextResult &other); @@ -67,7 +67,7 @@ public: ~QWebEngineFindTextResult(); private: - QWebEngineFindTextResult(int numberOfMatches, int activeMatchOrdinal); + QWebEngineFindTextResult(int numberOfMatches, int activeMatch); QSharedDataPointer<QWebEngineFindTextResultPrivate> d; diff --git a/src/core/browser_message_filter_qt.cpp b/src/core/browser_message_filter_qt.cpp index c8fc88017..a4b75f075 100644 --- a/src/core/browser_message_filter_qt.cpp +++ b/src/core/browser_message_filter_qt.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** 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. @@ -40,19 +40,19 @@ #include "browser_message_filter_qt.h" #include "chrome/browser/profiles/profile.h" -#include "common/qt_messages.h" #include "content/public/browser/plugin_service.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" -#include "type_conversion.h" -#include "net/network_delegate_qt.h" +#include "common/qt_messages.h" +#include "profile_io_data_qt.h" +#include "type_conversion.h" namespace QtWebEngineCore { BrowserMessageFilterQt::BrowserMessageFilterQt(int /*render_process_id*/, Profile *profile) : BrowserMessageFilter(QtMsgStart) - , m_profile(profile) + , m_profileData(ProfileIODataQt::FromBrowserContext(profile)) { } @@ -81,8 +81,7 @@ void BrowserMessageFilterQt::OnAllowDatabase(int /*render_frame_id*/, const GURL &top_origin_url, bool* allowed) { - NetworkDelegateQt *networkDelegate = static_cast<NetworkDelegateQt *>(m_profile->GetRequestContext()->GetURLRequestContext()->network_delegate()); - *allowed = networkDelegate->canGetCookies(top_origin_url, origin_url); + *allowed = m_profileData->canGetCookies(toQt(top_origin_url), toQt(origin_url)); } void BrowserMessageFilterQt::OnAllowDOMStorage(int /*render_frame_id*/, @@ -91,8 +90,7 @@ void BrowserMessageFilterQt::OnAllowDOMStorage(int /*render_frame_id*/, bool /*local*/, bool *allowed) { - NetworkDelegateQt *networkDelegate = static_cast<NetworkDelegateQt *>(m_profile->GetRequestContext()->GetURLRequestContext()->network_delegate()); - *allowed = networkDelegate->canGetCookies(top_origin_url, origin_url); + *allowed = m_profileData->canGetCookies(toQt(top_origin_url), toQt(origin_url)); } void BrowserMessageFilterQt::OnAllowIndexedDB(int /*render_frame_id*/, @@ -100,8 +98,7 @@ void BrowserMessageFilterQt::OnAllowIndexedDB(int /*render_frame_id*/, const GURL &top_origin_url, bool *allowed) { - NetworkDelegateQt *networkDelegate = static_cast<NetworkDelegateQt *>(m_profile->GetRequestContext()->GetURLRequestContext()->network_delegate()); - *allowed = networkDelegate->canGetCookies(top_origin_url, origin_url); + *allowed = m_profileData->canGetCookies(toQt(top_origin_url), toQt(origin_url)); } void BrowserMessageFilterQt::OnRequestFileSystemAccessSync(int render_frame_id, @@ -153,9 +150,7 @@ void BrowserMessageFilterQt::OnRequestFileSystemAccess(int /*render_frame_id*/, base::Callback<void(bool)> callback) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - - NetworkDelegateQt *networkDelegate = static_cast<NetworkDelegateQt *>(m_profile->GetRequestContext()->GetURLRequestContext()->network_delegate()); - bool allowed = networkDelegate->canGetCookies(top_origin_url, origin_url); + bool allowed = m_profileData->canGetCookies(toQt(top_origin_url), toQt(origin_url)); callback.Run(allowed); } diff --git a/src/core/browser_message_filter_qt.h b/src/core/browser_message_filter_qt.h index 3963fb9d5..4abc612f8 100644 --- a/src/core/browser_message_filter_qt.h +++ b/src/core/browser_message_filter_qt.h @@ -49,6 +49,8 @@ class Profile; namespace QtWebEngineCore { +class ProfileIODataQt; + class BrowserMessageFilterQt : public content::BrowserMessageFilter { public: @@ -91,7 +93,7 @@ private: const GURL &top_origin_url, base::Callback<void(bool)> callback); - Profile *m_profile; + ProfileIODataQt *m_profileData; }; } // namespace QtWebEngineCore diff --git a/src/core/certificate_error_controller.cpp b/src/core/certificate_error_controller.cpp index bc83ed802..f3b16357b 100644 --- a/src/core/certificate_error_controller.cpp +++ b/src/core/certificate_error_controller.cpp @@ -93,7 +93,7 @@ CertificateErrorControllerPrivate::CertificateErrorControllerPrivate(int cert_er if (auto cert = ssl_info.cert.get()) { validStart = toQt(cert->valid_start()); validExpiry = toQt(cert->valid_expiry()); - chain = toCertificateChain(cert); + certificateChain = toCertificateChain(cert); } } @@ -187,9 +187,9 @@ QString CertificateErrorController::errorString() const return getQStringForMessageId(IDS_CERT_ERROR_UNKNOWN_ERROR_DESCRIPTION); } -QList<QSslCertificate> CertificateErrorController::chain() const +QList<QSslCertificate> CertificateErrorController::certificateChain() const { - return d->chain; + return d->certificateChain; } QT_END_NAMESPACE diff --git a/src/core/certificate_error_controller.h b/src/core/certificate_error_controller.h index 7f5300dc8..d7e057adf 100644 --- a/src/core/certificate_error_controller.h +++ b/src/core/certificate_error_controller.h @@ -96,7 +96,7 @@ public: QString errorString() const; QDateTime validStart() const; QDateTime validExpiry() const; - QList<QSslCertificate> chain() const; + QList<QSslCertificate> certificateChain() const; void accept(bool); diff --git a/src/core/certificate_error_controller_p.h b/src/core/certificate_error_controller_p.h index a11f2b6f0..ceae99853 100644 --- a/src/core/certificate_error_controller_p.h +++ b/src/core/certificate_error_controller_p.h @@ -71,7 +71,7 @@ public: bool fatalError; bool strictEnforcement; const base::Callback<void(content::CertificateRequestResultType)> callback; - QList<QSslCertificate> chain; + QList<QSslCertificate> certificateChain; }; QT_END_NAMESPACE diff --git a/src/core/compositor/delegated_frame_node.cpp b/src/core/compositor/delegated_frame_node.cpp index 2a0df3acd..4d74937d9 100644 --- a/src/core/compositor/delegated_frame_node.cpp +++ b/src/core/compositor/delegated_frame_node.cpp @@ -858,7 +858,7 @@ void DelegatedFrameNode::handleQuad( const viz::TextureDrawQuad *tquad = viz::TextureDrawQuad::MaterialCast(quad); const CompositorResource *resource = findAndHoldResource(tquad->resource_id(), resourceTracker); QSGTexture *texture = - initAndHoldTexture(resource, quad->ShouldDrawWithBlending(), apiDelegate); + initAndHoldTexture(resource, quad->ShouldDrawWithBlending(true), apiDelegate); QSizeF textureSize; if (texture) textureSize = texture->textureSize(); @@ -909,7 +909,7 @@ void DelegatedFrameNode::handleQuad( const viz::TileDrawQuad *tquad = viz::TileDrawQuad::MaterialCast(quad); const CompositorResource *resource = findAndHoldResource(tquad->resource_id(), resourceTracker); nodeHandler->setupTextureContentNode( - initAndHoldTexture(resource, quad->ShouldDrawWithBlending(), apiDelegate), + initAndHoldTexture(resource, quad->ShouldDrawWithBlending(true), apiDelegate), toQt(quad->rect), toQt(tquad->tex_coord_rect), QSGImageNode::NoTransform, currentLayerChain); break; @@ -930,10 +930,10 @@ void DelegatedFrameNode::handleQuad( aResource = findAndHoldResource(vquad->a_plane_resource_id(), resourceTracker); nodeHandler->setupYUVVideoNode( - initAndHoldTexture(yResource, quad->ShouldDrawWithBlending()), - initAndHoldTexture(uResource, quad->ShouldDrawWithBlending()), - initAndHoldTexture(vResource, quad->ShouldDrawWithBlending()), - aResource ? initAndHoldTexture(aResource, quad->ShouldDrawWithBlending()) : 0, + initAndHoldTexture(yResource, quad->ShouldDrawWithBlending(true)), + initAndHoldTexture(uResource, quad->ShouldDrawWithBlending(true)), + initAndHoldTexture(vResource, quad->ShouldDrawWithBlending(true)), + aResource ? initAndHoldTexture(aResource, quad->ShouldDrawWithBlending(true)) : 0, toQt(vquad->ya_tex_coord_rect), toQt(vquad->uv_tex_coord_rect), toQt(vquad->ya_tex_size), toQt(vquad->uv_tex_size), vquad->video_color_space, vquad->resource_multiplier, vquad->resource_offset, toQt(quad->rect), @@ -945,7 +945,7 @@ void DelegatedFrameNode::handleQuad( const viz::StreamVideoDrawQuad *squad = viz::StreamVideoDrawQuad::MaterialCast(quad); const CompositorResource *resource = findAndHoldResource(squad->resource_id(), resourceTracker); MailboxTexture *texture = static_cast<MailboxTexture *>( - initAndHoldTexture(resource, quad->ShouldDrawWithBlending(), apiDelegate, GL_TEXTURE_EXTERNAL_OES)); + initAndHoldTexture(resource, quad->ShouldDrawWithBlending(true), apiDelegate, GL_TEXTURE_EXTERNAL_OES)); QMatrix4x4 qMatrix; // convertToQt(squad->matrix.matrix(), qMatrix); diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 6fcd9ad5b..29b6e09ed 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -252,7 +252,7 @@ void ShareGroupQtQuick::AboutToAddFirstContext() // This currently has to be setup by ::main in all applications using QQuickWebEngineView with delegated rendering. QOpenGLContext *shareContext = qt_gl_global_share_context(); if (!shareContext) { - qFatal("QWebEngine: OpenGL resource sharing is not set up in QtQuick. Please make sure to call QtWebEngine::initialize() in your main() function."); + qFatal("QWebEngine: OpenGL resource sharing is not set up in QtQuick. Please make sure to call QtWebEngine::initialize() in your main() function before QCoreApplication is created."); } m_shareContextQtQuick = new QtShareGLContext(shareContext); #endif diff --git a/src/core/find_text_helper.cpp b/src/core/find_text_helper.cpp index effda529f..065fed38f 100644 --- a/src/core/find_text_helper.cpp +++ b/src/core/find_text_helper.cpp @@ -135,7 +135,7 @@ bool FindTextHelper::isFindTextInProgress() const } void FindTextHelper::handleFindReply(content::WebContents *source, int requestId, int numberOfMatches, - const gfx::Rect &selectionRect, int activeMatchOrdinal, bool finalUpdate) + const gfx::Rect &selectionRect, int activeMatch, bool finalUpdate) { Q_UNUSED(selectionRect); @@ -146,7 +146,7 @@ void FindTextHelper::handleFindReply(content::WebContents *source, int requestId Q_ASSERT(m_currentFindRequestId == requestId); m_lastCompletedFindRequestId = requestId; - m_viewClient->findTextFinished(QWebEngineFindTextResult(numberOfMatches, activeMatchOrdinal)); + m_viewClient->findTextFinished(QWebEngineFindTextResult(numberOfMatches, activeMatch)); invokeResultCallback(requestId, numberOfMatches); } diff --git a/src/core/find_text_helper.h b/src/core/find_text_helper.h index e8f186272..9843dc8b5 100644 --- a/src/core/find_text_helper.h +++ b/src/core/find_text_helper.h @@ -78,7 +78,7 @@ public: void startFinding(const QString &findText, bool caseSensitively, bool findBackward); void stopFinding(); bool isFindTextInProgress() const; - void handleFindReply(content::WebContents *source, int requestId, int numberOfMatches, const gfx::Rect &selectionRect, int activeMatchOrdinal, bool finalUpdate); + void handleFindReply(content::WebContents *source, int requestId, int numberOfMatches, const gfx::Rect &selectionRect, int activeMatch, bool finalUpdate); void handleLoadCommitted(); private: diff --git a/src/core/net/url_request_custom_job.cpp b/src/core/net/url_request_custom_job.cpp index 56ba79f35..8f0fada57 100644 --- a/src/core/net/url_request_custom_job.cpp +++ b/src/core/net/url_request_custom_job.cpp @@ -41,6 +41,7 @@ #include "url_request_custom_job_proxy.h" #include "api/qwebengineurlscheme.h" + #include "base/strings/stringprintf.h" #include "base/task/post_task.h" #include "content/public/browser/browser_task_traits.h" @@ -146,17 +147,28 @@ void URLRequestCustomJob::GetResponseInfo(HttpResponseInfo* info) { // Based on net::URLRequestRedirectJob::StartAsync() - if (!m_corsEnabled) + if (m_error) return; std::string headers; - headers += base::StringPrintf("HTTP/1.1 %i OK\n", m_httpStatusCode); - if (m_redirect.is_valid()) + if (m_redirect.is_valid()) { + headers += "HTTP/1.1 303 See Other\n"; headers += base::StringPrintf("Location: %s\n", m_redirect.spec().c_str()); - std::string origin; - if (request_->extra_request_headers().GetHeader("Origin", &origin)) { - headers += base::StringPrintf("Access-Control-Allow-Origin: %s\n", origin.c_str()); - headers += "Access-Control-Allow-Credentials: true\n"; + } else { + headers += base::StringPrintf("HTTP/1.1 %i OK\n", m_httpStatusCode); + if (m_mimeType.size() > 0) { + headers += base::StringPrintf("Content-Type: %s", m_mimeType.c_str()); + if (m_charset.size() > 0) + headers += base::StringPrintf("; charset=%s", m_charset.c_str()); + headers += "\n"; + } + } + if (m_corsEnabled) { + std::string origin; + if (request_->extra_request_headers().GetHeader("Origin", &origin)) { + headers += base::StringPrintf("Access-Control-Allow-Origin: %s\n", origin.c_str()); + headers += "Access-Control-Allow-Credentials: true\n"; + } } info->headers = new HttpResponseHeaders(HttpUtil::AssembleRawHeaders(headers)); diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 7633aa44c..e86f05d60 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -1009,15 +1009,22 @@ QSGNode *RenderWidgetHostViewQt::updatePaintNode(QSGNode *oldNode) void RenderWidgetHostViewQt::notifyShown() { if (m_enableViz) { + // Handle possible frame eviction: + if (!m_dfhLocalSurfaceIdAllocator.HasValidLocalSurfaceIdAllocation()) + m_dfhLocalSurfaceIdAllocator.GenerateId(); if (m_visible) return; m_visible = true; + } + + host()->WasShown(base::nullopt); + + if (m_enableViz) { m_delegatedFrameHost->AttachToCompositor(m_uiCompositor.get()); m_delegatedFrameHost->WasShown(GetLocalSurfaceIdAllocation().local_surface_id(), m_viewRectInDips.size(), base::nullopt); } - host()->WasShown(base::nullopt); } void RenderWidgetHostViewQt::notifyHidden() diff --git a/src/core/type_conversion.h b/src/core/type_conversion.h index dfd8e8fef..2275ae82e 100644 --- a/src/core/type_conversion.h +++ b/src/core/type_conversion.h @@ -217,7 +217,7 @@ inline QDateTime toQt(base::Time time) } inline base::Time toTime(const QDateTime &dateTime) { - return base::Time::FromInternalValue(dateTime.toMSecsSinceEpoch()); + return base::Time::FromJavaTime(dateTime.toMSecsSinceEpoch()); } inline QNetworkCookie toQt(const net::CanonicalCookie & cookie) diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index 9bc1279ba..49006ec20 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -53,7 +53,9 @@ #include "content/public/common/webrtc_ip_handling_policy.h" #include "media/base/media_switches.h" #include "third_party/blink/public/mojom/renderer_preferences.mojom.h" +#include "ui/base/ui_base_switches.h" #include "ui/events/event_switches.h" +#include "ui/native_theme/native_theme.h" #include <QFont> #include <QTimer> @@ -399,6 +401,50 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p prefs->minimum_font_size = fontSize(MinimumFontSize); prefs->minimum_logical_font_size = fontSize(MinimumLogicalFontSize); prefs->default_encoding = defaultTextEncoding().toStdString(); + + // Set the theme colors. Based on chrome_content_browser_client.cc: + const ui::NativeTheme *webTheme = ui::NativeTheme::GetInstanceForWeb(); + if (webTheme) { +#if !defined(OS_MACOSX) + // Mac has a concept of high contrast that does not relate to forced colors. + prefs->forced_colors = webTheme->UsesHighContrastColors() + ? blink::ForcedColors::kActive + : blink::ForcedColors::kNone; +#endif // !defined(OS_MACOSX) + switch (webTheme->GetPreferredColorScheme()) { + case ui::NativeTheme::PreferredColorScheme::kDark: + prefs->preferred_color_scheme = blink::PreferredColorScheme::kDark; + break; + case ui::NativeTheme::PreferredColorScheme::kLight: + prefs->preferred_color_scheme = blink::PreferredColorScheme::kLight; + break; + case ui::NativeTheme::PreferredColorScheme::kNoPreference: + prefs->preferred_color_scheme = blink::PreferredColorScheme::kNoPreference; + } + } + + // Apply native CaptionStyle parameters. + base::Optional<ui::CaptionStyle> style; + if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kForceCaptionStyle)) { + style = ui::CaptionStyle::FromSpec( + base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kForceCaptionStyle)); + } + + // Apply system caption style. + if (!style && webTheme) + style = webTheme->GetSystemCaptionStyle(); + + if (style) { + prefs->text_track_background_color = style->background_color; + prefs->text_track_text_color = style->text_color; + prefs->text_track_text_size = style->text_size; + prefs->text_track_text_shadow = style->text_shadow; + prefs->text_track_font_family = style->font_family; + prefs->text_track_font_variant = style->font_variant; + prefs->text_track_window_color = style->window_color; + prefs->text_track_window_padding = style->window_padding; + prefs->text_track_window_radius = style->window_radius; + } } bool WebEngineSettings::applySettingsToRendererPreferences(blink::mojom::RendererPreferences *prefs) diff --git a/src/webengine/api/qquickwebenginedownloaditem_p.h b/src/webengine/api/qquickwebenginedownloaditem_p.h index 96ef0daf0..beb359622 100644 --- a/src/webengine/api/qquickwebenginedownloaditem_p.h +++ b/src/webengine/api/qquickwebenginedownloaditem_p.h @@ -137,10 +137,10 @@ public: Q_PROPERTY(bool isPaused READ isPaused NOTIFY isPausedChanged REVISION 5 FINAL) Q_PROPERTY(bool isSavePageDownload READ isSavePageDownload CONSTANT REVISION 6 FINAL) Q_PROPERTY(QQuickWebEngineView *view READ view CONSTANT REVISION 7 FINAL) - Q_PROPERTY(QUrl url READ url CONSTANT REVISION 8 FINAL) - Q_PROPERTY(QString suggestedFileName READ suggestedFileName CONSTANT REVISION 8 FINAL) - Q_PROPERTY(QString downloadDirectory READ downloadDirectory WRITE setDownloadDirectory NOTIFY downloadDirectoryChanged REVISION 8 FINAL) - Q_PROPERTY(QString downloadFileName READ downloadFileName WRITE setDownloadFileName NOTIFY downloadFileNameChanged REVISION 8 FINAL) + Q_PROPERTY(QUrl url READ url CONSTANT REVISION 10 FINAL) + Q_PROPERTY(QString suggestedFileName READ suggestedFileName CONSTANT REVISION 10 FINAL) + Q_PROPERTY(QString downloadDirectory READ downloadDirectory WRITE setDownloadDirectory NOTIFY downloadDirectoryChanged REVISION 10 FINAL) + Q_PROPERTY(QString downloadFileName READ downloadFileName WRITE setDownloadFileName NOTIFY downloadFileNameChanged REVISION 10 FINAL) Q_INVOKABLE void accept(); Q_INVOKABLE void cancel(); @@ -181,8 +181,8 @@ Q_SIGNALS: Q_REVISION(4) void interruptReasonChanged(); Q_REVISION(5) void isFinishedChanged(); Q_REVISION(5) void isPausedChanged(); - Q_REVISION(8) void downloadDirectoryChanged(); - Q_REVISION(8) void downloadFileNameChanged(); + Q_REVISION(10) void downloadDirectoryChanged(); + Q_REVISION(10) void downloadFileNameChanged(); private: QQuickWebEngineDownloadItem(QQuickWebEngineDownloadItemPrivate*, QObject *parent = 0); diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h index 4a88e3c28..618f9407e 100644 --- a/src/webengine/api/qquickwebengineview_p.h +++ b/src/webengine/api/qquickwebengineview_p.h @@ -139,8 +139,8 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem { Q_PROPERTY(QQuickWebEngineTestSupport *testSupport READ testSupport WRITE setTestSupport NOTIFY testSupportChanged FINAL) #endif - Q_PROPERTY(LifecycleState lifecycleState READ lifecycleState WRITE setLifecycleState NOTIFY lifecycleStateChanged REVISION 11 FINAL) - Q_PROPERTY(LifecycleState recommendedState READ recommendedState NOTIFY recommendedStateChanged REVISION 11 FINAL) + Q_PROPERTY(LifecycleState lifecycleState READ lifecycleState WRITE setLifecycleState NOTIFY lifecycleStateChanged REVISION 10 FINAL) + Q_PROPERTY(LifecycleState recommendedState READ recommendedState NOTIFY recommendedStateChanged REVISION 10 FINAL) public: QQuickWebEngineView(QQuickItem *parent = 0); @@ -573,9 +573,9 @@ Q_SIGNALS: Q_REVISION(8) void printRequested(); Q_REVISION(9) void selectClientCertificate(QQuickWebEngineClientCertificateSelection *clientCertSelection); Q_REVISION(10) void tooltipRequested(QQuickWebEngineTooltipRequest *request); - Q_REVISION(11) void lifecycleStateChanged(LifecycleState state); - Q_REVISION(11) void recommendedStateChanged(LifecycleState state); - Q_REVISION(11) void findTextFinished(const QWebEngineFindTextResult &result); + Q_REVISION(10) void lifecycleStateChanged(LifecycleState state); + Q_REVISION(10) void recommendedStateChanged(LifecycleState state); + Q_REVISION(10) void findTextFinished(const QWebEngineFindTextResult &result); #if QT_CONFIG(webengine_testsupport) void testSupportChanged(); diff --git a/src/webengine/api/qtwebengineglobal.cpp b/src/webengine/api/qtwebengineglobal.cpp index a11618dba..4346832c9 100644 --- a/src/webengine/api/qtwebengineglobal.cpp +++ b/src/webengine/api/qtwebengineglobal.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qtwebengineglobal.h" +#include <QCoreApplication> namespace QtWebEngineCore { @@ -62,8 +63,8 @@ namespace QtWebEngine { /*! \fn QtWebEngine::initialize() - Sets up an OpenGL Context that can be shared between threads. This has to be done after - QGuiApplication is created, but before a Qt Quick window is created. + Sets up an OpenGL Context that can be shared between threads. This has to be done before + QGuiApplication is created and before window's QPlatformOpenGLContext is created. This has the same effect as setting the Qt::AA_ShareOpenGLContexts attribute with QCoreApplication::setAttribute before constructing @@ -71,7 +72,15 @@ namespace QtWebEngine { */ void initialize() { - QtWebEngineCore::initialize(); + QCoreApplication *app = QCoreApplication::instance(); + if (app) { + qWarning("QtWebEngine::initialize() called with QCoreApplication object already created and should be call before. "\ + "This is depreciated and may fail in the future."); + QtWebEngineCore::initialize(); + return; + } + // call initialize the same way as widgets do + qAddPreRoutine(QtWebEngineCore::initialize); } } // namespace QtWebEngine diff --git a/src/webengine/doc/src/webengineview_lgpl.qdoc b/src/webengine/doc/src/webengineview_lgpl.qdoc index 3a7717bd2..df956f03e 100644 --- a/src/webengine/doc/src/webengineview_lgpl.qdoc +++ b/src/webengine/doc/src/webengineview_lgpl.qdoc @@ -1599,7 +1599,7 @@ */ /*! - \qmlproperty int FindTextResult::activeMatchOrdinal + \qmlproperty int FindTextResult::activeMatch \readonly \brief The index of the currently highlighted match. @@ -1607,7 +1607,7 @@ /*! \qmlsignal WebEngineView::findTextFinished(FindTextResult result) - \since QtWebEngine 1.11 + \since QtWebEngine 1.10 This signal is emitted when a string search on a page is completed. \a result is the result of the string search. diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp index 5fb48d867..3acf7d058 100644 --- a/src/webengine/plugin/plugin.cpp +++ b/src/webengine/plugin/plugin.cpp @@ -97,7 +97,6 @@ public: qmlRegisterType<QQuickWebEngineView, 8>(uri, 1, 8, "WebEngineView"); qmlRegisterType<QQuickWebEngineView, 9>(uri, 1, 9, "WebEngineView"); qmlRegisterType<QQuickWebEngineView, 10>(uri, 1, 10, "WebEngineView"); - qmlRegisterType<QQuickWebEngineView, 11>(uri, 1, 11, "WebEngineView"); qmlRegisterType<QQuickWebEngineProfile>(uri, 1, 1, "WebEngineProfile"); qmlRegisterType<QQuickWebEngineProfile, 1>(uri, 1, 2, "WebEngineProfile"); qmlRegisterType<QQuickWebEngineProfile, 2>(uri, 1, 3, "WebEngineProfile"); @@ -122,7 +121,7 @@ public: msgUncreatableType("WebEngineDownloadItem")); qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 7>(uri, 1, 8, "WebEngineDownloadItem", msgUncreatableType("WebEngineDownloadItem")); - qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 8>(uri, 1, 10, "WebEngineDownloadItem", + qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 10>(uri, 1, 10, "WebEngineDownloadItem", msgUncreatableType("WebEngineDownloadItem")); qmlRegisterUncreatableType<QQuickWebEngineNewViewRequest>(uri, 1, 1, "WebEngineNewViewRequest", msgUncreatableType("WebEngineNewViewRequest")); qmlRegisterUncreatableType<QQuickWebEngineNewViewRequest, 1>(uri, 1, 5, "WebEngineNewViewRequest", tr("Cannot create separate instance of WebEngineNewViewRequest")); @@ -174,7 +173,7 @@ public: qmlRegisterUncreatableType<QQuickWebEngineTooltipRequest>(uri, 1, 10, "TooltipRequest", msgUncreatableType("TooltipRequest")); qRegisterMetaType<QWebEngineFindTextResult>(); - qmlRegisterUncreatableType<QWebEngineFindTextResult>(uri, 1, 11, "FindTextResult", msgUncreatableType("FindTextResult")); + qmlRegisterUncreatableType<QWebEngineFindTextResult>(uri, 1, 10, "FindTextResult", msgUncreatableType("FindTextResult")); } private: diff --git a/src/webengine/plugin/plugins.qmltypes b/src/webengine/plugin/plugins.qmltypes index 0037861e5..a23d1c3c0 100644 --- a/src/webengine/plugin/plugins.qmltypes +++ b/src/webengine/plugin/plugins.qmltypes @@ -4,11 +4,285 @@ import QtQuick.tooling 1.2 // It is used for QML tooling purposes only. // // This file was auto-generated by: -// 'qmlplugindump -nonrelocatable -defaultplatform -dependencies dependencies.json QtWebEngine 1.9' +// 'qmlplugindump -nonrelocatable -defaultplatform -dependencies dependencies.json QtWebEngine 1.10' Module { dependencies: ["QtQuick 2.8"] Component { + name: "QAbstractItemModel" + prototype: "QObject" + Enum { + name: "LayoutChangeHint" + values: { + "NoLayoutChangeHint": 0, + "VerticalSortHint": 1, + "HorizontalSortHint": 2 + } + } + Enum { + name: "CheckIndexOption" + values: { + "NoOption": 0, + "IndexIsValid": 1, + "DoNotUseParent": 2, + "ParentIsInvalid": 4 + } + } + Signal { + name: "dataChanged" + Parameter { name: "topLeft"; type: "QModelIndex" } + Parameter { name: "bottomRight"; type: "QModelIndex" } + Parameter { name: "roles"; type: "QVector<int>" } + } + Signal { + name: "dataChanged" + Parameter { name: "topLeft"; type: "QModelIndex" } + Parameter { name: "bottomRight"; type: "QModelIndex" } + } + Signal { + name: "headerDataChanged" + Parameter { name: "orientation"; type: "Qt::Orientation" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "layoutChanged" + Parameter { name: "parents"; type: "QList<QPersistentModelIndex>" } + Parameter { name: "hint"; type: "QAbstractItemModel::LayoutChangeHint" } + } + Signal { + name: "layoutChanged" + Parameter { name: "parents"; type: "QList<QPersistentModelIndex>" } + } + Signal { name: "layoutChanged" } + Signal { + name: "layoutAboutToBeChanged" + Parameter { name: "parents"; type: "QList<QPersistentModelIndex>" } + Parameter { name: "hint"; type: "QAbstractItemModel::LayoutChangeHint" } + } + Signal { + name: "layoutAboutToBeChanged" + Parameter { name: "parents"; type: "QList<QPersistentModelIndex>" } + } + Signal { name: "layoutAboutToBeChanged" } + Signal { + name: "rowsAboutToBeInserted" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "rowsInserted" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "rowsAboutToBeRemoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "rowsRemoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "columnsAboutToBeInserted" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "columnsInserted" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "columnsAboutToBeRemoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "columnsRemoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { name: "modelAboutToBeReset" } + Signal { name: "modelReset" } + Signal { + name: "rowsAboutToBeMoved" + Parameter { name: "sourceParent"; type: "QModelIndex" } + Parameter { name: "sourceStart"; type: "int" } + Parameter { name: "sourceEnd"; type: "int" } + Parameter { name: "destinationParent"; type: "QModelIndex" } + Parameter { name: "destinationRow"; type: "int" } + } + Signal { + name: "rowsMoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "start"; type: "int" } + Parameter { name: "end"; type: "int" } + Parameter { name: "destination"; type: "QModelIndex" } + Parameter { name: "row"; type: "int" } + } + Signal { + name: "columnsAboutToBeMoved" + Parameter { name: "sourceParent"; type: "QModelIndex" } + Parameter { name: "sourceStart"; type: "int" } + Parameter { name: "sourceEnd"; type: "int" } + Parameter { name: "destinationParent"; type: "QModelIndex" } + Parameter { name: "destinationColumn"; type: "int" } + } + Signal { + name: "columnsMoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "start"; type: "int" } + Parameter { name: "end"; type: "int" } + Parameter { name: "destination"; type: "QModelIndex" } + Parameter { name: "column"; type: "int" } + } + Method { name: "submit"; type: "bool" } + Method { name: "revert" } + Method { + name: "hasIndex" + type: "bool" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { + name: "hasIndex" + type: "bool" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + } + Method { + name: "index" + type: "QModelIndex" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { + name: "index" + type: "QModelIndex" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + } + Method { + name: "parent" + type: "QModelIndex" + Parameter { name: "child"; type: "QModelIndex" } + } + Method { + name: "sibling" + type: "QModelIndex" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + Parameter { name: "idx"; type: "QModelIndex" } + } + Method { + name: "rowCount" + type: "int" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { name: "rowCount"; type: "int" } + Method { + name: "columnCount" + type: "int" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { name: "columnCount"; type: "int" } + Method { + name: "hasChildren" + type: "bool" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { name: "hasChildren"; type: "bool" } + Method { + name: "data" + type: "QVariant" + Parameter { name: "index"; type: "QModelIndex" } + Parameter { name: "role"; type: "int" } + } + Method { + name: "data" + type: "QVariant" + Parameter { name: "index"; type: "QModelIndex" } + } + Method { + name: "setData" + type: "bool" + Parameter { name: "index"; type: "QModelIndex" } + Parameter { name: "value"; type: "QVariant" } + Parameter { name: "role"; type: "int" } + } + Method { + name: "setData" + type: "bool" + Parameter { name: "index"; type: "QModelIndex" } + Parameter { name: "value"; type: "QVariant" } + } + Method { + name: "headerData" + type: "QVariant" + Parameter { name: "section"; type: "int" } + Parameter { name: "orientation"; type: "Qt::Orientation" } + Parameter { name: "role"; type: "int" } + } + Method { + name: "headerData" + type: "QVariant" + Parameter { name: "section"; type: "int" } + Parameter { name: "orientation"; type: "Qt::Orientation" } + } + Method { + name: "fetchMore" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { + name: "canFetchMore" + type: "bool" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { + name: "flags" + type: "Qt::ItemFlags" + Parameter { name: "index"; type: "QModelIndex" } + } + Method { + name: "match" + type: "QModelIndexList" + Parameter { name: "start"; type: "QModelIndex" } + Parameter { name: "role"; type: "int" } + Parameter { name: "value"; type: "QVariant" } + Parameter { name: "hits"; type: "int" } + Parameter { name: "flags"; type: "Qt::MatchFlags" } + } + Method { + name: "match" + type: "QModelIndexList" + Parameter { name: "start"; type: "QModelIndex" } + Parameter { name: "role"; type: "int" } + Parameter { name: "value"; type: "QVariant" } + Parameter { name: "hits"; type: "int" } + } + Method { + name: "match" + type: "QModelIndexList" + Parameter { name: "start"; type: "QModelIndex" } + Parameter { name: "role"; type: "int" } + Parameter { name: "value"; type: "QVariant" } + } + } + Component { name: "QAbstractListModel"; prototype: "QAbstractItemModel" } + Component { name: "QQuickWebEngineAction" prototype: "QObject" exports: ["QtWebEngine/WebEngineAction 1.8"] @@ -202,6 +476,7 @@ Module { prototype: "QObject" exports: [ "QtWebEngine/WebEngineDownloadItem 1.1", + "QtWebEngine/WebEngineDownloadItem 1.10", "QtWebEngine/WebEngineDownloadItem 1.2", "QtWebEngine/WebEngineDownloadItem 1.3", "QtWebEngine/WebEngineDownloadItem 1.4", @@ -211,7 +486,7 @@ Module { "QtWebEngine/WebEngineDownloadItem 1.8" ] isCreatable: false - exportMetaObjectRevisions: [0, 1, 2, 3, 4, 5, 6, 7] + exportMetaObjectRevisions: [0, 10, 1, 2, 3, 4, 5, 6, 7] Enum { name: "DownloadState" values: { @@ -294,12 +569,18 @@ Module { isReadonly: true isPointer: true } + Property { name: "url"; revision: 10; type: "QUrl"; isReadonly: true } + Property { name: "suggestedFileName"; revision: 10; type: "string"; isReadonly: true } + Property { name: "downloadDirectory"; revision: 10; type: "string" } + Property { name: "downloadFileName"; revision: 10; type: "string" } Signal { name: "savePageFormatChanged"; revision: 2 } Signal { name: "mimeTypeChanged"; revision: 1 } Signal { name: "typeChanged"; revision: 3 } Signal { name: "interruptReasonChanged"; revision: 4 } Signal { name: "isFinishedChanged"; revision: 5 } Signal { name: "isPausedChanged"; revision: 5 } + Signal { name: "downloadDirectoryChanged"; revision: 10 } + Signal { name: "downloadFileNameChanged"; revision: 10 } Method { name: "accept" } Method { name: "cancel" } Method { name: "pause" } @@ -625,10 +906,11 @@ Module { "QtWebEngine/WebEngineSettings 1.5", "QtWebEngine/WebEngineSettings 1.6", "QtWebEngine/WebEngineSettings 1.7", - "QtWebEngine/WebEngineSettings 1.8" + "QtWebEngine/WebEngineSettings 1.8", + "QtWebEngine/WebEngineSettings 1.9" ] isCreatable: false - exportMetaObjectRevisions: [0, 1, 2, 3, 4, 5, 6, 7] + exportMetaObjectRevisions: [0, 1, 2, 3, 4, 5, 6, 7, 8] Enum { name: "UnknownUrlSchemePolicy" values: { @@ -704,12 +986,32 @@ Module { } } Component { + name: "QQuickWebEngineTooltipRequest" + prototype: "QObject" + exports: ["QtWebEngine/TooltipRequest 1.10"] + isCreatable: false + exportMetaObjectRevisions: [0] + Enum { + name: "RequestType" + values: { + "Show": 0, + "Hide": 1 + } + } + Property { name: "x"; type: "int"; isReadonly: true } + Property { name: "y"; type: "int"; isReadonly: true } + Property { name: "text"; type: "string"; isReadonly: true } + Property { name: "type"; type: "RequestType"; isReadonly: true } + Property { name: "accepted"; type: "bool" } + } + Component { name: "QQuickWebEngineView" defaultProperty: "data" prototype: "QQuickItem" exports: [ "QtWebEngine/WebEngineView 1.0", "QtWebEngine/WebEngineView 1.1", + "QtWebEngine/WebEngineView 1.10", "QtWebEngine/WebEngineView 1.2", "QtWebEngine/WebEngineView 1.3", "QtWebEngine/WebEngineView 1.4", @@ -719,7 +1021,7 @@ Module { "QtWebEngine/WebEngineView 1.8", "QtWebEngine/WebEngineView 1.9" ] - exportMetaObjectRevisions: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + exportMetaObjectRevisions: [0, 1, 10, 2, 3, 4, 5, 6, 7, 8, 9] Enum { name: "NavigationRequestAction" values: { @@ -735,7 +1037,8 @@ Module { "FormSubmittedNavigation": 2, "BackForwardNavigation": 3, "ReloadNavigation": 4, - "OtherNavigation": 5 + "OtherNavigation": 5, + "RedirectNavigation": 6 } } Enum { @@ -994,6 +1297,14 @@ Module { "Landscape": 1 } } + Enum { + name: "LifecycleState" + values: { + "Active": 0, + "Frozen": 1, + "Discarded": 2 + } + } Property { name: "url"; type: "QUrl" } Property { name: "icon"; type: "QUrl"; isReadonly: true } Property { name: "loading"; type: "bool"; isReadonly: true } @@ -1035,7 +1346,8 @@ Module { Property { name: "webChannelWorld"; revision: 3; type: "uint" } Property { name: "inspectedView"; revision: 7; type: "QQuickWebEngineView"; isPointer: true } Property { name: "devToolsView"; revision: 7; type: "QQuickWebEngineView"; isPointer: true } - Property { name: "testSupport"; type: "QQuickWebEngineTestSupport"; isPointer: true } + Property { name: "lifecycleState"; revision: 10; type: "LifecycleState" } + Property { name: "recommendedState"; revision: 10; type: "LifecycleState"; isReadonly: true } Signal { name: "loadingChanged" Parameter { name: "loadRequest"; type: "QQuickWebEngineLoadRequest"; isPointer: true } @@ -1194,6 +1506,26 @@ Module { isPointer: true } } + Signal { + name: "tooltipRequested" + revision: 10 + Parameter { name: "request"; type: "QQuickWebEngineTooltipRequest"; isPointer: true } + } + Signal { + name: "lifecycleStateChanged" + revision: 10 + Parameter { name: "state"; type: "LifecycleState" } + } + Signal { + name: "recommendedStateChanged" + revision: 10 + Parameter { name: "state"; type: "LifecycleState" } + } + Signal { + name: "findTextFinished" + revision: 10 + Parameter { name: "result"; type: "QWebEngineFindTextResult" } + } Method { name: "runJavaScript" Parameter { type: "string" } @@ -1320,26 +1652,25 @@ Module { } } Component { + name: "QWebEngineFindTextResult" + exports: ["QtWebEngine/FindTextResult 1.10"] + isCreatable: false + exportMetaObjectRevisions: [0] + Property { name: "numberOfMatches"; type: "int"; isReadonly: true } + Property { name: "activeMatchOrdinal"; type: "int"; isReadonly: true } + } + Component { name: "QWebEngineNotification" prototype: "QObject" exports: ["QtWebEngine/WebEngineNotification 1.9"] isCreatable: false exportMetaObjectRevisions: [0] - Enum { - name: "Direction" - values: { - "LeftToRight": 0, - "RightToLeft": 1, - "DirectionAuto": 2 - } - } Property { name: "origin"; type: "QUrl"; isReadonly: true } - Property { name: "icon"; type: "QIcon"; isReadonly: true } Property { name: "title"; type: "string"; isReadonly: true } Property { name: "message"; type: "string"; isReadonly: true } Property { name: "tag"; type: "string"; isReadonly: true } Property { name: "language"; type: "string"; isReadonly: true } - Property { name: "direction"; type: "Direction"; isReadonly: true } + Property { name: "direction"; type: "Qt::LayoutDirection"; isReadonly: true } Signal { name: "closed" } Method { name: "show" } Method { name: "click" } diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.cpp b/src/webenginewidgets/api/qwebenginecertificateerror.cpp index 45277e19d..3f20b6483 100644 --- a/src/webenginewidgets/api/qwebenginecertificateerror.cpp +++ b/src/webenginewidgets/api/qwebenginecertificateerror.cpp @@ -79,7 +79,7 @@ public: QUrl url; bool overridable; QString errorDescription; - QList<QSslCertificate> chain; + QList<QSslCertificate> certificateChain; bool answered = false, deferred = false; QWeakPointer<CertificateErrorController> controller; @@ -107,7 +107,7 @@ QWebEngineCertificateError::QWebEngineCertificateError(const QSharedPointer<Cert controller->overridable(), controller->errorString())) { d->controller = controller; - d->chain = controller->chain(); + d->certificateChain = controller->certificateChain(); } QWebEngineCertificateError::QWebEngineCertificateError(const QWebEngineCertificateError &) = default; @@ -255,9 +255,9 @@ bool QWebEngineCertificateError::answered() const Chain starts with the peer's immediate certificate and ending with the CA's certificate. */ -QList<QSslCertificate> QWebEngineCertificateError::chain() const +QList<QSslCertificate> QWebEngineCertificateError::certificateChain() const { - return d->chain; + return d->certificateChain; } QT_END_NAMESPACE diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.h b/src/webenginewidgets/api/qwebenginecertificateerror.h index b2dd65a9f..d3a19edfc 100644 --- a/src/webenginewidgets/api/qwebenginecertificateerror.h +++ b/src/webenginewidgets/api/qwebenginecertificateerror.h @@ -90,7 +90,7 @@ public: void ignoreCertificateError(); bool answered() const; - QList<QSslCertificate> chain() const; + QList<QSslCertificate> certificateChain() const; private: friend class QWebEnginePagePrivate; diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index db3efa521..524df0425 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -2671,16 +2671,13 @@ void QContextMenuBuilder::addMenuItem(ContextMenuItem menuItem) switch (menuItem) { case ContextMenuItem::Back: - action = new QAction(QIcon::fromTheme(QStringLiteral("go-previous")), QWebEnginePage::tr("&Back"), m_menu); - QObject::connect(action, &QAction::triggered, thisRef->d_ptr->view, &QWebEngineView::back); + action = thisRef->action(QWebEnginePage::Back); break; case ContextMenuItem::Forward: - action = new QAction(QIcon::fromTheme(QStringLiteral("go-next")), QWebEnginePage::tr("&Forward"), m_menu); - QObject::connect(action, &QAction::triggered, thisRef->d_ptr->view, &QWebEngineView::forward); + action = thisRef->action(QWebEnginePage::Forward); break; case ContextMenuItem::Reload: - action = new QAction(QIcon::fromTheme(QStringLiteral("view-refresh")), QWebEnginePage::tr("&Reload"), m_menu); - QObject::connect(action, &QAction::triggered, thisRef->d_ptr->view, &QWebEngineView::reload); + action = thisRef->action(QWebEnginePage::Reload); break; case ContextMenuItem::Cut: action = thisRef->action(QWebEnginePage::Cut); diff --git a/tests/auto/quick/dialogs/tst_dialogs.cpp b/tests/auto/quick/dialogs/tst_dialogs.cpp index eee6b2bb6..82ea3be37 100644 --- a/tests/auto/quick/dialogs/tst_dialogs.cpp +++ b/tests/auto/quick/dialogs/tst_dialogs.cpp @@ -28,6 +28,7 @@ #include "testhandler.h" #include "server.h" +#include "util.h" #include <QtWebEngine/private/qquickwebenginedialogrequests_p.h> #include <QtWebEngine/private/qquickwebenginecontextmenurequest_p.h> #include <QQuickWebEngineProfile> @@ -43,6 +44,7 @@ class tst_Dialogs : public QObject { public: tst_Dialogs(){} + private slots: void initTestCase(); void init(); @@ -64,7 +66,6 @@ private: void tst_Dialogs::initTestCase() { - QtWebEngine::initialize(); QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true); qmlRegisterType<TestHandler>("io.qt.tester", 1, 0, "TestHandler"); m_engine.reset(new QQmlApplicationEngine()); @@ -230,5 +231,5 @@ void tst_Dialogs::javaScriptDialogRequested() } #include "tst_dialogs.moc" -QTEST_MAIN(tst_Dialogs) +W_QTEST_MAIN(tst_Dialogs) diff --git a/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp b/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp index 922c7769e..224814f7e 100644 --- a/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp +++ b/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp @@ -167,7 +167,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 -"), 20000); + QTRY_VERIFY_WITH_TIMEOUT(inspectorWebView->title().startsWith("DevTools -"), 30000); } QTEST_MAIN(tst_InspectorServer) diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp index 9f7dfa8ad..321972057 100644 --- a/tests/auto/quick/publicapi/tst_publicapi.cpp +++ b/tests/auto/quick/publicapi/tst_publicapi.cpp @@ -279,7 +279,7 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineFileDialogRequest.dialogReject() --> void" << "QQuickWebEngineFileDialogRequest.mode --> FileMode" << "QWebEngineFindTextResult.numberOfMatches --> int" - << "QWebEngineFindTextResult.activeMatchOrdinal --> int" + << "QWebEngineFindTextResult.activeMatch --> int" << "QQuickWebEngineFormValidationMessageRequest.Hide --> RequestType" << "QQuickWebEngineFormValidationMessageRequest.Move --> RequestType" << "QQuickWebEngineFormValidationMessageRequest.Show --> RequestType" diff --git a/tests/auto/quick/qmltests/data/tst_findText.qml b/tests/auto/quick/qmltests/data/tst_findText.qml index 040d324e6..c02a1348e 100644 --- a/tests/auto/quick/qmltests/data/tst_findText.qml +++ b/tests/auto/quick/qmltests/data/tst_findText.qml @@ -113,7 +113,7 @@ TestWebEngineView { verify(!findFailed) tryCompare(findTextSpy, "count", 1) compare(findTextSpy.signalArguments[0][0].numberOfMatches, 1) - compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1) + compare(findTextSpy.signalArguments[0][0].activeMatch, 1) } function test_findTextCaseInsensitive() { @@ -127,7 +127,7 @@ TestWebEngineView { verify(!findFailed) tryCompare(findTextSpy, "count", 1) compare(findTextSpy.signalArguments[0][0].numberOfMatches, 1) - compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1) + compare(findTextSpy.signalArguments[0][0].activeMatch, 1) } function test_findTextManyMatches() { @@ -141,7 +141,7 @@ TestWebEngineView { verify(!findFailed) tryCompare(findTextSpy, "count", 1) compare(findTextSpy.signalArguments[0][0].numberOfMatches, 100) - compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1) + compare(findTextSpy.signalArguments[0][0].activeMatch, 1) } @@ -156,7 +156,7 @@ TestWebEngineView { verify(findFailed) tryCompare(findTextSpy, "count", 1) compare(findTextSpy.signalArguments[0][0].numberOfMatches, 0) - compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 0) + compare(findTextSpy.signalArguments[0][0].activeMatch, 0) } function test_findTextNotFound() { @@ -170,7 +170,7 @@ TestWebEngineView { verify(findFailed) tryCompare(findTextSpy, "count", 1) compare(findTextSpy.signalArguments[0][0].numberOfMatches, 0) - compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 0) + compare(findTextSpy.signalArguments[0][0].activeMatch, 0) } function test_findTextAfterNotFound() { @@ -184,7 +184,7 @@ TestWebEngineView { verify(findFailed) tryCompare(findTextSpy, "count", 1) compare(findTextSpy.signalArguments[0][0].numberOfMatches, 0) - compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 0) + compare(findTextSpy.signalArguments[0][0].activeMatch, 0) webEngineView.url = Qt.resolvedUrl("test1.html") verify(webEngineView.waitForLoadSucceeded()) @@ -195,7 +195,7 @@ TestWebEngineView { verify(!findFailed) tryCompare(findTextSpy, "count", 1) compare(findTextSpy.signalArguments[0][0].numberOfMatches, 1) - compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1) + compare(findTextSpy.signalArguments[0][0].activeMatch, 1) } function test_findTextInModifiedDOMAfterNotFound() { @@ -212,7 +212,7 @@ TestWebEngineView { verify(findFailed) tryCompare(findTextSpy, "count", 1) compare(findTextSpy.signalArguments[0][0].numberOfMatches, 0) - compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 0) + compare(findTextSpy.signalArguments[0][0].activeMatch, 0) runJavaScript("document.body.innerHTML = 'blahellobla'"); tryVerify(function() { return getBodyInnerHTML() == "blahellobla"; }, 20000); @@ -223,7 +223,7 @@ TestWebEngineView { verify(!findFailed) tryCompare(findTextSpy, "count", 1) compare(findTextSpy.signalArguments[0][0].numberOfMatches, 1) - compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1) + compare(findTextSpy.signalArguments[0][0].activeMatch, 1) } function test_findTextInterruptedByLoad() { @@ -276,7 +276,7 @@ TestWebEngineView { findTextSpy.wait(); compare(findTextSpy.count, i); compare(findTextSpy.signalArguments[i-1][0].numberOfMatches, 3); - compare(findTextSpy.signalArguments[i-1][0].activeMatchOrdinal, i); + compare(findTextSpy.signalArguments[i-1][0].activeMatch, i); } // The last match is followed by the fist one. @@ -285,7 +285,7 @@ TestWebEngineView { findTextSpy.wait(); compare(findTextSpy.count, 1); compare(findTextSpy.signalArguments[0][0].numberOfMatches, 3); - compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1); + compare(findTextSpy.signalArguments[0][0].activeMatch, 1); // The first match is preceded by the last one. webEngineView.clear(); @@ -293,23 +293,23 @@ TestWebEngineView { findTextSpy.wait(); compare(findTextSpy.count, 1); compare(findTextSpy.signalArguments[0][0].numberOfMatches, 3); - compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 3); + compare(findTextSpy.signalArguments[0][0].activeMatch, 3); - // Finding another word resets the activeMatchOrdinal. + // Finding another word resets the activeMatch. webEngineView.clear(); webEngineView.findText("bar"); findTextSpy.wait(); compare(findTextSpy.count, 1); compare(findTextSpy.signalArguments[0][0].numberOfMatches, 2); - compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1); + compare(findTextSpy.signalArguments[0][0].activeMatch, 1); - // If no match activeMatchOrdinal is 0. + // If no match activeMatch is 0. webEngineView.clear(); webEngineView.findText("bla"); findTextSpy.wait(); compare(findTextSpy.count, 1); compare(findTextSpy.signalArguments[0][0].numberOfMatches, 0); - compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 0); + compare(findTextSpy.signalArguments[0][0].activeMatch, 0); } } } diff --git a/tests/auto/quick/shared/util.h b/tests/auto/quick/shared/util.h index c2e7d3e19..bc5ae445b 100644 --- a/tests/auto/quick/shared/util.h +++ b/tests/auto/quick/shared/util.h @@ -36,6 +36,7 @@ #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 "" @@ -182,4 +183,15 @@ inline QString activeElementId(QQuickWebEngineView *webEngineView) return arguments.at(1).toString(); } +#define W_QTEST_MAIN(TestObject) \ +int main(int argc, char *argv[]) \ +{ \ + QtWebEngine::initialize(); \ + QGuiApplication app(argc, argv); \ + 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/widgets/certificateerror/tst_certificateerror.cpp b/tests/auto/widgets/certificateerror/tst_certificateerror.cpp index 5fd765ed5..f11d9236c 100644 --- a/tests/auto/widgets/certificateerror/tst_certificateerror.cpp +++ b/tests/auto/widgets/certificateerror/tst_certificateerror.cpp @@ -48,13 +48,13 @@ private Q_SLOTS: struct PageWithCertificateErrorHandler : QWebEnginePage { PageWithCertificateErrorHandler(bool defer, bool accept, QObject *p = nullptr) - : QWebEnginePage(p), deferError(defer), acceptCertificate(accept) { - connect(this, &QWebEnginePage::loadFinished, [&] (bool result) { spyLoad(result); }); + : QWebEnginePage(p), deferError(defer), acceptCertificate(accept) + , loadSpy(this, &QWebEnginePage::loadFinished) { } bool deferError, acceptCertificate; - CallbackSpy<bool> spyLoad; + QSignalSpy loadSpy; QScopedPointer<QWebEngineCertificateError> error; bool certificateError(const QWebEngineCertificateError &e) override { @@ -96,7 +96,7 @@ void tst_CertificateError::handleError() page.setUrl(server.url()); QTRY_VERIFY(page.error); QVERIFY(page.error->isOverridable()); - auto chain = page.error->chain(); + auto chain = page.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"); @@ -104,7 +104,7 @@ void tst_CertificateError::handleError() if (deferError) { QVERIFY(page.error->deferred()); QVERIFY(!page.error->answered()); - QVERIFY(!page.spyLoad.wasCalled()); + QCOMPARE(page.loadSpy.count(), 0); QCOMPARE(toPlainTextSync(&page), QString()); if (acceptCertificate) @@ -115,10 +115,8 @@ void tst_CertificateError::handleError() QVERIFY(page.error->answered()); page.error.reset(); } - - bool loadResult = page.spyLoad.waitForResult(); - QVERIFY(page.spyLoad.wasCalled()); - QCOMPARE(loadResult, acceptCertificate); + QTRY_COMPARE_WITH_TIMEOUT(page.loadSpy.count(), 1, 30000); + QCOMPARE(page.loadSpy.takeFirst().value(0).toBool(), acceptCertificate); QCOMPARE(toPlainTextSync(&page), expectedContent); } diff --git a/tests/auto/widgets/devtools/tst_devtools.cpp b/tests/auto/widgets/devtools/tst_devtools.cpp index 8f3b90a14..3026b3931 100644 --- a/tests/auto/widgets/devtools/tst_devtools.cpp +++ b/tests/auto/widgets/devtools/tst_devtools.cpp @@ -46,7 +46,7 @@ void tst_DevTools::attachAndDestroyPageFirst() QSignalSpy spy(page, &QWebEnginePage::loadFinished); page->load(QUrl("data:text/plain,foobarbaz")); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 12000); inspector->setInspectedPage(page); page->triggerAction(QWebEnginePage::InspectElement); @@ -67,7 +67,7 @@ void tst_DevTools::attachAndDestroyInspectorFirst() QSignalSpy spy(page, &QWebEnginePage::loadFinished); page->setHtml(QStringLiteral("<body><h1>FOO BAR!</h1></body>")); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 12000); page->triggerAction(QWebEnginePage::InspectElement); diff --git a/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp b/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp index 540c8d505..1469ddb15 100644 --- a/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp +++ b/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp @@ -107,7 +107,7 @@ void tst_FaviconManager::faviconLoad() QUrl url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/favicon-single.html")); m_page->load(url); - QTRY_COMPARE(loadFinishedSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); QTRY_COMPARE(iconUrlChangedSpy.count(), 1); QTRY_COMPARE(iconChangedSpy.count(), 1); @@ -132,7 +132,7 @@ void tst_FaviconManager::faviconLoadFromResources() QUrl url("qrc:/resources/favicon-single.html"); m_page->load(url); - QTRY_COMPARE(loadFinishedSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); QTRY_COMPARE(iconUrlChangedSpy.count(), 1); QTRY_COMPARE(iconChangedSpy.count(), 1); @@ -161,7 +161,7 @@ void tst_FaviconManager::faviconLoadEncodedUrl() QUrl url(urlString + QLatin1String("?favicon=load should work with#whitespace!")); m_page->load(url); - QTRY_COMPARE(loadFinishedSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); QTRY_COMPARE(iconUrlChangedSpy.count(), 1); QTRY_COMPARE(iconChangedSpy.count(), 1); @@ -189,7 +189,7 @@ void tst_FaviconManager::noFavicon() QUrl url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/test1.html")); m_page->load(url); - QTRY_COMPARE(loadFinishedSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); QCOMPARE(iconUrlChangedSpy.count(), 0); QCOMPARE(iconChangedSpy.count(), 0); @@ -206,7 +206,7 @@ void tst_FaviconManager::aboutBlank() QUrl url("about:blank"); m_page->load(url); - QTRY_COMPARE(loadFinishedSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); QCOMPARE(iconUrlChangedSpy.count(), 0); QCOMPARE(iconChangedSpy.count(), 0); @@ -226,7 +226,7 @@ void tst_FaviconManager::unavailableFavicon() QUrl url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/favicon-unavailable.html")); m_page->load(url); - QTRY_COMPARE(loadFinishedSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); QCOMPARE(iconUrlChangedSpy.count(), 0); QCOMPARE(iconChangedSpy.count(), 0); @@ -245,7 +245,7 @@ void tst_FaviconManager::errorPageEnabled() QUrl url("http://url.invalid"); m_page->load(url); - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 20000); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); QCOMPARE(iconUrlChangedSpy.count(), 0); QCOMPARE(iconChangedSpy.count(), 0); @@ -264,7 +264,7 @@ void tst_FaviconManager::errorPageDisabled() QUrl url("http://url.invalid"); m_page->load(url); - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 12000); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); QCOMPARE(iconUrlChangedSpy.count(), 0); QCOMPARE(iconChangedSpy.count(), 0); @@ -288,7 +288,7 @@ void tst_FaviconManager::bestFavicon() url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/favicon-misc.html")); m_page->load(url); - QTRY_COMPARE(loadFinishedSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); QTRY_COMPARE(iconUrlChangedSpy.count(), 1); QTRY_COMPARE(iconChangedSpy.count(), 1); @@ -311,7 +311,7 @@ void tst_FaviconManager::bestFavicon() url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/favicon-shortcut.html")); m_page->load(url); - QTRY_COMPARE(loadFinishedSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); QTRY_VERIFY(iconUrlChangedSpy.count() >= 1); QTRY_VERIFY(iconChangedSpy.count() >= 1); @@ -347,7 +347,7 @@ void tst_FaviconManager::touchIcon() QUrl url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/favicon-touch.html")); m_page->load(url); - QTRY_COMPARE(loadFinishedSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); QCOMPARE(iconUrlChangedSpy.count(), 0); QCOMPARE(iconChangedSpy.count(), 0); @@ -367,7 +367,7 @@ void tst_FaviconManager::multiIcon() QUrl url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/favicon-multi.html")); m_page->load(url); - QTRY_COMPARE(loadFinishedSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); QTRY_COMPARE(iconUrlChangedSpy.count(), 1); QTRY_COMPARE(iconChangedSpy.count(), 1); @@ -395,7 +395,7 @@ void tst_FaviconManager::candidateIcon() QUrl url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("faviconmanager/resources/favicon-shortcut.html")); m_page->load(url); - QTRY_COMPARE(loadFinishedSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); QTRY_COMPARE(iconUrlChangedSpy.count(), 1); QTRY_COMPARE(iconChangedSpy.count(), 1); @@ -432,7 +432,7 @@ void tst_FaviconManager::downloadIconsDisabled() m_page->load(url); - QTRY_COMPARE(loadFinishedSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); QCOMPARE(iconUrlChangedSpy.count(), 0); QCOMPARE(iconChangedSpy.count(), 0); @@ -465,7 +465,7 @@ void tst_FaviconManager::downloadTouchIconsEnabled() m_page->load(url); - QTRY_COMPARE(loadFinishedSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); QTRY_COMPARE(iconUrlChangedSpy.count(), 1); QTRY_COMPARE(iconChangedSpy.count(), 1); @@ -494,7 +494,7 @@ void tst_FaviconManager::dynamicFavicon() m_page->setHtml("<html>" "<link rel='icon' type='image/png' href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII='/>" "</html>"); - QTRY_COMPARE(loadFinishedSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); QTRY_COMPARE(iconUrlChangedSpy.count(), 1); QTRY_COMPARE(iconChangedSpy.count(), 1); @@ -525,7 +525,7 @@ void tst_FaviconManager::touchIconWithSameURL() QTRY_COMPARE(loadFinishedSpy.count(), 1); // The default favicon has to be loaded even if its URL is also set as a touch icon while touch icons are disabled. - QTRY_COMPARE(iconUrlChangedSpy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); QCOMPARE(m_page->iconUrl().toString(), icon); QTRY_COMPARE(iconChangedSpy.count(), 1); diff --git a/tests/auto/widgets/origins/tst_origins.cpp b/tests/auto/widgets/origins/tst_origins.cpp index 02d5bfba3..990ca70a7 100644 --- a/tests/auto/widgets/origins/tst_origins.cpp +++ b/tests/auto/widgets/origins/tst_origins.cpp @@ -134,6 +134,13 @@ void registerSchemes() scheme.setFlags(QWebEngineUrlScheme::CorsEnabled); QWebEngineUrlScheme::registerScheme(scheme); } + + { + QWebEngineUrlScheme scheme(QBAL("cors")); + scheme.setFlags(QWebEngineUrlScheme::CorsEnabled); + QWebEngineUrlScheme::registerScheme(scheme); + } + } Q_CONSTRUCTOR_FUNCTION(registerSchemes) @@ -159,6 +166,7 @@ public: profile->installUrlSchemeHandler(QBAL("HostPortAndUserInformationSyntax"), this); profile->installUrlSchemeHandler(QBAL("redirect1"), this); profile->installUrlSchemeHandler(QBAL("redirect2"), this); + profile->installUrlSchemeHandler(QBAL("cors"), this); } QVector<QUrl> &requests() { return m_requests; } @@ -569,7 +577,9 @@ void tst_Origins::mixedSchemesWithCsp() // Load the main page over one scheme, then make an XMLHttpRequest to a // different scheme. // -// XMLHttpRequests can only be made to http, https, data, and chrome. +// Cross-origin XMLHttpRequests can only be made to CORS-enabled schemes. These +// include the builtin schemes http, https, data, and chrome, as well as custom +// schemes with the CorsEnabled flag. void tst_Origins::mixedXHR() { QVERIFY(load(QSL("file:" THIS_DIR "resources/mixedXHR.html"))); @@ -581,6 +591,8 @@ void tst_Origins::mixedXHR() QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("error"))); eval(QSL("sendXHR('data:,ok')")); QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok"))); + eval(QSL("sendXHR('cors:/resources/mixedXHR.txt')")); + QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok"))); QVERIFY(load(QSL("qrc:/resources/mixedXHR.html"))); eval(QSL("sendXHR('file:" THIS_DIR "resources/mixedXHR.txt')")); @@ -591,6 +603,8 @@ void tst_Origins::mixedXHR() QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("error"))); eval(QSL("sendXHR('data:,ok')")); QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok"))); + eval(QSL("sendXHR('cors:/resources/mixedXHR.txt')")); + QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok"))); QVERIFY(load(QSL("tst:/resources/mixedXHR.html"))); eval(QSL("sendXHR('file:" THIS_DIR "resources/mixedXHR.txt')")); @@ -601,6 +615,8 @@ void tst_Origins::mixedXHR() QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok"))); eval(QSL("sendXHR('data:,ok')")); QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok"))); + eval(QSL("sendXHR('cors:/resources/mixedXHR.txt')")); + QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok"))); } #if defined(WEBSOCKETS) diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 5edd778e2..1b3295abb 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -999,7 +999,7 @@ void tst_QWebEnginePage::findTextResult() if (findTextSpy.count() != 1) return QVector<int>({-1, -1}); auto r = findTextSpy.takeFirst().value(0).value<QWebEngineFindTextResult>(); - return QVector<int>({ r.numberOfMatches(), r.activeMatchOrdinal() }); + return QVector<int>({ r.numberOfMatches(), r.activeMatch() }); }; // findText will abort in blink if the view has an empty size. @@ -1104,7 +1104,7 @@ void tst_QWebEnginePage::findTextActiveMatchOrdinal() QTRY_COMPARE(findTextSpy.count(), 1); result = findTextSpy.takeFirst().value(0).value<QWebEngineFindTextResult>(); QCOMPARE(result.numberOfMatches(), 3); - QCOMPARE(result.activeMatchOrdinal(), i); + QCOMPARE(result.activeMatch(), i); } // The last match is followed by the fist one. @@ -1112,28 +1112,28 @@ void tst_QWebEnginePage::findTextActiveMatchOrdinal() QTRY_COMPARE(findTextSpy.count(), 1); result = findTextSpy.takeFirst().value(0).value<QWebEngineFindTextResult>(); QCOMPARE(result.numberOfMatches(), 3); - QCOMPARE(result.activeMatchOrdinal(), 1); + QCOMPARE(result.activeMatch(), 1); // The first match is preceded by the last one. m_view->page()->findText("foo", QWebEnginePage::FindBackward); QTRY_COMPARE(findTextSpy.count(), 1); result = findTextSpy.takeFirst().value(0).value<QWebEngineFindTextResult>(); QCOMPARE(result.numberOfMatches(), 3); - QCOMPARE(result.activeMatchOrdinal(), 3); + QCOMPARE(result.activeMatch(), 3); - // Finding another word resets the activeMatchOrdinal. + // Finding another word resets the activeMatch. m_view->page()->findText("bar", 0); QTRY_COMPARE(findTextSpy.count(), 1); result = findTextSpy.takeFirst().value(0).value<QWebEngineFindTextResult>(); QCOMPARE(result.numberOfMatches(), 2); - QCOMPARE(result.activeMatchOrdinal(), 1); + QCOMPARE(result.activeMatch(), 1); - // If no match activeMatchOrdinal is 0. + // If no match activeMatch is 0. m_view->page()->findText("bla", 0); QTRY_COMPARE(findTextSpy.count(), 1); result = findTextSpy.takeFirst().value(0).value<QWebEngineFindTextResult>(); QCOMPARE(result.numberOfMatches(), 0); - QCOMPARE(result.activeMatchOrdinal(), 0); + QCOMPARE(result.activeMatch(), 0); } static QWindow *findNewTopLevelWindow(const QWindowList &oldTopLevelWindows) @@ -1190,6 +1190,8 @@ void tst_QWebEnginePage::comboBoxPopupPositionAfterMove() QTRY_VERIFY(QGuiApplication::topLevelWindows().contains(popup)); QTRY_VERIFY(!popup->position().isNull()); QCOMPARE(popupPos + offset, popup->position()); + QTest::mouseClick(window, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(1, 1)); + QTRY_VERIFY(!QGuiApplication::topLevelWindows().contains(popup)); } void tst_QWebEnginePage::comboBoxPopupPositionAfterChildMove() diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp index 25afa5849..a7a5ba62a 100644 --- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp +++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp @@ -40,6 +40,11 @@ #include <QtWebEngineWidgets/qwebengineview.h> #include <QtWebEngineWidgets/qwebenginedownloaditem.h> +#if QT_CONFIG(webengine_webchannel) +#include <QWebChannel> +#endif + +#include <map> #include <mutex> class tst_QWebEngineProfile : public QObject @@ -60,6 +65,8 @@ private Q_SLOTS: void urlSchemeHandlerStreaming(); void urlSchemeHandlerRequestHeaders(); void urlSchemeHandlerInstallation(); + void urlSchemeHandlerXhrStatus(); + void urlSchemeHandlerScriptModule(); void customUserAgent(); void httpAcceptLanguage(); void downloadItem(); @@ -80,6 +87,7 @@ void tst_QWebEngineProfile::initTestCase() stream.setDefaultPort(8080); letterto.setSyntax(QWebEngineUrlScheme::Syntax::Path); aviancarrier.setSyntax(QWebEngineUrlScheme::Syntax::Path); + aviancarrier.setFlags(QWebEngineUrlScheme::CorsEnabled); QWebEngineUrlScheme::registerScheme(foo); QWebEngineUrlScheme::registerScheme(stream); QWebEngineUrlScheme::registerScheme(letterto); @@ -575,6 +583,137 @@ void tst_QWebEngineProfile::urlSchemeHandlerInstallation() profile.removeUrlScheme("tst"); } +#if QT_CONFIG(webengine_webchannel) +class XhrStatusHost : public QObject +{ + Q_OBJECT +public: + std::map<QUrl, int> requests; + + bool isReady() + { + static const auto sig = QMetaMethod::fromSignal(&XhrStatusHost::load); + return isSignalConnected(sig); + } + +Q_SIGNALS: + void load(QUrl url); + +public Q_SLOTS: + void loadFinished(QUrl url, int status) + { + requests[url] = status; + } + +private: +}; + +class XhrStatusUrlSchemeHandler : public QWebEngineUrlSchemeHandler +{ +public: + void requestStarted(QWebEngineUrlRequestJob *job) + { + QString path = job->requestUrl().path(); + if (path == "/") { + QBuffer *buffer = new QBuffer(job); + buffer->open(QBuffer::ReadWrite); + buffer->write(QByteArrayLiteral(R"( +<html> + <body> + <script src="qwebchannel.js"></script> + <script> + new QWebChannel(qt.webChannelTransport, (channel) => { + const host = channel.objects.host; + host.load.connect((url) => { + const xhr = new XMLHttpRequest(); + xhr.onload = () => { host.loadFinished(url, xhr.status); }; + xhr.onerror = () => { host.loadFinished(url, -1); }; + xhr.open("GET", url, true); + xhr.send(); + }); + }); + </script> + </body> +</html> +)")); + buffer->seek(0); + job->reply("text/html", buffer); + } else if (path == "/qwebchannel.js") { + QFile *file = new QFile(":/qtwebchannel/qwebchannel.js", job); + file->open(QFile::ReadOnly); + job->reply("application/javascript", file); + } else if (path == "/ok") { + QBuffer *buffer = new QBuffer(job); + buffer->buffer() = QByteArrayLiteral("ok"); + job->reply("text/plain", buffer); + } else if (path == "/redirect") { + QUrl url = job->requestUrl(); + url.setPath("/ok"); + job->redirect(url); + } else if (path == "/fail") { + job->fail(QWebEngineUrlRequestJob::RequestFailed); + } else { + job->fail(QWebEngineUrlRequestJob::UrlNotFound); + } + } +}; +#endif + +void tst_QWebEngineProfile::urlSchemeHandlerXhrStatus() +{ +#if QT_CONFIG(webengine_webchannel) + XhrStatusUrlSchemeHandler handler; + XhrStatusHost host; + QWebEngineProfile profile; + QWebEnginePage page(&profile); + QWebChannel channel; + channel.registerObject("host", &host); + profile.installUrlSchemeHandler("aviancarrier", &handler); + page.setWebChannel(&channel); + page.load(QUrl("aviancarrier:/")); + QTRY_VERIFY(host.isReady()); + host.load(QUrl("aviancarrier:/ok")); + host.load(QUrl("aviancarrier:/redirect")); + host.load(QUrl("aviancarrier:/fail")); + host.load(QUrl("aviancarrier:/notfound")); + QTRY_COMPARE(host.requests.size(), 4u); + QCOMPARE(host.requests[QUrl("aviancarrier:/ok")], 200); + QCOMPARE(host.requests[QUrl("aviancarrier:/redirect")], 200); + QCOMPARE(host.requests[QUrl("aviancarrier:/fail")], -1); + QCOMPARE(host.requests[QUrl("aviancarrier:/notfound")], -1); +#else + QSKIP("No QtWebChannel"); +#endif +} + +class ScriptsUrlSchemeHandler : public QWebEngineUrlSchemeHandler +{ +public: + void requestStarted(QWebEngineUrlRequestJob *job) + { + auto *script = new QBuffer(job); + script->setData(QByteArrayLiteral("window.test = 'SUCCESS';")); + job->reply("text/javascript", script); + } +}; + +void tst_QWebEngineProfile::urlSchemeHandlerScriptModule() +{ + ScriptsUrlSchemeHandler handler; + QWebEngineProfile profile; + profile.installUrlSchemeHandler("aviancarrier", &handler); + QWebEnginePage page(&profile); + QSignalSpy loadFinishedSpy(&page, SIGNAL(loadFinished(bool))); + page.setHtml(QStringLiteral("<html><head><script src=\"aviancarrier:///\"></script></head><body>Test1</body></html>")); + QTRY_COMPARE(loadFinishedSpy.count(), 1); + QCOMPARE(evaluateJavaScriptSync(&page, QStringLiteral("test")).toString(), QStringLiteral("SUCCESS")); + + loadFinishedSpy.clear(); + page.setHtml(QStringLiteral("<html><head><script type=\"module\" src=\"aviancarrier:///\"></script></head><body>Test2</body></html>")); + QTRY_COMPARE(loadFinishedSpy.count(), 1); + QCOMPARE(evaluateJavaScriptSync(&page, QStringLiteral("test")).toString(), QStringLiteral("SUCCESS")); +} + void tst_QWebEngineProfile::customUserAgent() { QString defaultUserAgent = QWebEngineProfile::defaultProfile()->httpUserAgent(); diff --git a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp index 2e8687d9b..2044f0df4 100644 --- a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp +++ b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp @@ -180,23 +180,23 @@ void tst_QWebEngineScript::loadEvents() // Single frame / setHtml page.setHtml(QStringLiteral("<!DOCTYPE html><html><head><title>mr</title></head><body></body></html>")); - QTRY_COMPARE(page.spy.count(), 1); - QCOMPARE(page.spy.takeFirst().value(0).toBool(), true); + QTRY_COMPARE_WITH_TIMEOUT(page.spy.count(), 1, 20000); + QVERIFY(page.spy.takeFirst().value(0).toBool()); QVERIFY(verifyOrder(page.eval("window.log", QWebEngineScript::MainWorld).toStringList())); QVERIFY(verifyOrder(page.eval("window.log", QWebEngineScript::ApplicationWorld).toStringList())); // After discard page.setLifecycleState(QWebEnginePage::LifecycleState::Discarded); page.setLifecycleState(QWebEnginePage::LifecycleState::Active); - QTRY_COMPARE(page.spy.count(), 1); - QCOMPARE(page.spy.takeFirst().value(0).toBool(), true); + QTRY_COMPARE_WITH_TIMEOUT(page.spy.count(), 1, 20000); + QVERIFY(page.spy.takeFirst().value(0).toBool()); QVERIFY(verifyOrder(page.eval("window.log", QWebEngineScript::MainWorld).toStringList())); QVERIFY(verifyOrder(page.eval("window.log", QWebEngineScript::ApplicationWorld).toStringList())); // Multiple frames page.load(QUrl("qrc:/resources/test_iframe_main.html")); - QTRY_COMPARE(page.spy.count(), 1); - QCOMPARE(page.spy.takeFirst().value(0).toBool(), true); + QTRY_COMPARE_WITH_TIMEOUT(page.spy.count(), 1, 20000); + QVERIFY(page.spy.takeFirst().value(0).toBool()); QVERIFY(verifyOrder(page.eval("window.log", QWebEngineScript::MainWorld).toStringList())); QVERIFY(verifyOrder(page.eval("window.log", QWebEngineScript::ApplicationWorld).toStringList())); QVERIFY(verifyOrder(page.eval("window[0].log", QWebEngineScript::MainWorld).toStringList())); @@ -207,14 +207,14 @@ void tst_QWebEngineScript::loadEvents() // Cross-process navigation page.load(QUrl("chrome://gpu")); QTRY_COMPARE_WITH_TIMEOUT(page.spy.count(), 1, 20000); - QCOMPARE(page.spy.takeFirst().value(0).toBool(), true); + QVERIFY(page.spy.takeFirst().value(0).toBool()); QVERIFY(verifyOrder(page.eval("window.log", QWebEngineScript::MainWorld).toStringList())); QVERIFY(verifyOrder(page.eval("window.log", QWebEngineScript::ApplicationWorld).toStringList())); // Using window.open from JS QVERIFY(profile.pages.size() == 1); page.load(QUrl("qrc:/resources/test_window_open.html")); - QTRY_VERIFY(profile.pages.size() == 2); + QTRY_COMPARE(profile.pages.size(), 2); QTRY_COMPARE(profile.pages.front().spy.count(), 1); QTRY_COMPARE(profile.pages.back().spy.count(), 1); QVERIFY(verifyOrder(profile.pages.front().eval("window.log", QWebEngineScript::MainWorld).toStringList())); diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp index 71c4aa9b5..abf414eb9 100644 --- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp +++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp @@ -3125,7 +3125,7 @@ void tst_QWebEngineView::webUIURLs() view.settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false); QSignalSpy loadFinishedSpy(&view, SIGNAL(loadFinished(bool))); view.load(url); - QVERIFY(loadFinishedSpy.wait()); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 12000); QCOMPARE(loadFinishedSpy.takeFirst().at(0).toBool(), supported); } diff --git a/tests/auto/widgets/util.h b/tests/auto/widgets/util.h index f27466225..eba974f33 100644 --- a/tests/auto/widgets/util.h +++ b/tests/auto/widgets/util.h @@ -85,7 +85,7 @@ public: T waitForResult() { if (!called) { - timeoutTimer.start(10000); + timeoutTimer.start(20000); eventLoop.exec(); } return result; |