From b27edd025dbe6ef2d1e302b8be0e0993ef3d645d Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Wed, 2 Dec 2020 12:49:13 +0100 Subject: Suppress error pages also for http errors if they are disabled Load with client or server http error results in successful navigation, which leads to 'true' loadFinished result, and subsequent chromium's error page load and display with second set of loadStarted/loadFinished signals. This effectively ignores QWebEngineSettings::ErrorPageEnabled. Fixing it requires submodule change to ask embedder if error pages should also be suppressed for http errors. Also update chromium for required change, which pulls in the following changes: * e71010069b4 Fix embedded builds with printing enabled * f5a93d251cc Allow the embedder to suppress an error page for http errors Change-Id: I731678575439a6dad90dfb89e79b0083c63b49c2 Reviewed-by: Allan Sandfeld Jensen --- src/3rdparty | 2 +- src/core/web_contents_delegate_qt.cpp | 10 ++++------ src/webenginewidgets/api/qwebenginepage.cpp | 1 - 3 files changed, 5 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/3rdparty b/src/3rdparty index 25db271c9..f5a93d251 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit 25db271c9b53e576cbb2cdc84d2c56ca5e8633a8 +Subproject commit f5a93d251cca15cb24a3acacd2fc0f645513c56d diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index fb3eb2ab3..532d9653b 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -374,8 +374,6 @@ void WebContentsDelegateQt::DidStartNavigation(content::NavigationHandle *naviga if (!navigation_handle->IsInMainFrame()) return; - // Error-pages are not reported as separate started navigations. - Q_ASSERT(!navigation_handle->IsErrorPage()); m_loadingErrorFrameList.clear(); m_faviconManager->resetCandidates(); @@ -384,6 +382,8 @@ void WebContentsDelegateQt::DidStartNavigation(content::NavigationHandle *naviga void WebContentsDelegateQt::EmitLoadFinished(bool success, const QUrl &url, bool isErrorPage, int errorCode, const QString &errorDescription) { + Q_ASSERT(!isErrorPage || webEngineSettings()->testAttribute(WebEngineSettings::ErrorPageEnabled)); + // When error page enabled we don't need to send the error page load finished signal if (m_loadProgressMap[url] == 100) return; @@ -538,10 +538,8 @@ void WebContentsDelegateQt::DidFinishLoad(content::RenderFrameHost* render_frame m_viewClient->iconChanged(QUrl()); content::NavigationEntry *entry = web_contents()->GetController().GetActiveEntry(); - int http_statuscode = 0; - if (entry) - http_statuscode = entry->GetHttpStatusCode(); - EmitLoadFinished(true /* success */ , toQt(validated_url), false /* isErrorPage */, http_statuscode); + int http_statuscode = entry ? http_statuscode = entry->GetHttpStatusCode() : 0; + EmitLoadFinished(http_statuscode < 400, toQt(validated_url), false /* isErrorPage */, http_statuscode); } void WebContentsDelegateQt::DidUpdateFaviconURL(const std::vector &candidates) diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 828a1ca79..72311f1a8 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -290,7 +290,6 @@ void QWebEnginePagePrivate::loadFinished(bool success, const QUrl &url, bool isE Q_UNUSED(errorDescription); if (isErrorPage) { - Q_ASSERT(settings->testAttribute(QWebEngineSettings::ErrorPageEnabled)); QTimer::singleShot(0, q, [q](){ emit q->loadFinished(false); }); -- cgit v1.2.1