summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2018-10-04 17:36:51 +0200
committerJüri Valdmann <juri.valdmann@qt.io>2018-10-12 14:30:33 +0000
commit75f6f4d3178d9356aff9a5a14f8601ebc8b70c95 (patch)
tree9893a14227ac10b1a5741ccba8b299d4474023d9
parentbd7051912f1f75d89bb2a0ddd35987d71be1f2c6 (diff)
Disable error pages for external URLsv5.12.0-beta2
Failing to launch an external URL triggers a navigation to "chrome-error://chromewebdata". Navigating to "chrome-error://chromewebdata" results in a failed attempt to launch it as an external URL. The cycle repeats until the computer becomes bored. Match Chromium and disable error pages for external URL load failures. Fixes: QTBUG-63378 Change-Id: I6c401532d658744edc56921b55efd0d040a12b1a Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/core/web_contents_delegate_qt.cpp10
-rw-r--r--tests/auto/widgets/schemes/tst_schemes.cpp5
2 files changed, 6 insertions, 9 deletions
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 11f64c5a..569b939d 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -602,14 +602,12 @@ void WebContentsDelegateQt::launchExternalURL(const QUrl &url, ui::PageTransitio
}
if (!navigationAllowedByPolicy || !navigationRequestAccepted) {
+ QString errorDescription;
if (!navigationAllowedByPolicy)
- didFailLoad(url, 420, QStringLiteral("Launching external protocol forbidden by WebEngineSettings::UnknownUrlSchemePolicy"));
+ errorDescription = QStringLiteral("Launching external protocol forbidden by WebEngineSettings::UnknownUrlSchemePolicy");
else
- didFailLoad(url, 420, QStringLiteral("Launching external protocol suppressed by WebContentsAdapterClient::navigationRequested"));
- if (settings->testAttribute(WebEngineSettings::ErrorPageEnabled)) {
- EmitLoadStarted(toQt(GURL(content::kUnreachableWebDataURL)), true);
- m_viewClient->webContentsAdapter()->load(toQt(GURL(content::kUnreachableWebDataURL)));
- }
+ errorDescription = QStringLiteral("Launching external protocol suppressed by WebContentsAdapterClient::navigationRequested");
+ didFailLoad(url, net::Error::ERR_ABORTED, errorDescription);
}
}
diff --git a/tests/auto/widgets/schemes/tst_schemes.cpp b/tests/auto/widgets/schemes/tst_schemes.cpp
index 2097120e..6da34efd 100644
--- a/tests/auto/widgets/schemes/tst_schemes.cpp
+++ b/tests/auto/widgets/schemes/tst_schemes.cpp
@@ -68,7 +68,7 @@ void tst_Schemes::unknownUrlSchemePolicy()
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
QWebEngineSettings *settings = view.page()->profile()->settings();
- settings->setAttribute(QWebEngineSettings::ErrorPageEnabled, false);
+ settings->setAttribute(QWebEngineSettings::ErrorPageEnabled, true);
settings->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, true);
QWebEngineSettings::UnknownUrlSchemePolicy policies[6] = {QWebEngineSettings::DisallowUnknownUrlSchemes,
@@ -103,8 +103,7 @@ void tst_Schemes::unknownUrlSchemePolicy()
});
}
- bool errorPageEnabled = settings->testAttribute(QWebEngineSettings::ErrorPageEnabled);
- QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.size(), 2 + (errorPageEnabled ? 1 : 0), 15000);
+ QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.size(), 2, 15000);
QCOMPARE(page.acceptNavigationRequestCalls, shouldAccept ? 1 : 0);
}
}