summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2017-12-15 15:19:28 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-01-15 12:18:11 +0000
commited3a0f052910b09edc393dfb6c6940f118b267ea (patch)
treed12ab56156dda7fb884c8394e8650a4e62f1d48b
parent3d0de6eff785f657346435efdefbcde55a03a3f4 (diff)
ProxyConfigServiceQt: Use default HostPortPair for SCHEME_DIRECT
Unlike QNetworkProxy, Chromium's net::ProxyServer expects the hostname and port to be at default values for special schemes (DIRECT and INVALID). Otherwise, a DCHECK is triggered at proxy_server.cc:73. Change-Id: I1ac6c425ea03fcbfe084d25c2fd05bf174c753d6 Reviewed-by: Viktor Engelmann <viktor.engelmann@qt.io>
-rw-r--r--src/core/proxy_config_service_qt.cpp14
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp19
2 files changed, 25 insertions, 8 deletions
diff --git a/src/core/proxy_config_service_qt.cpp b/src/core/proxy_config_service_qt.cpp
index cd8f4c0fe..7fca18eb6 100644
--- a/src/core/proxy_config_service_qt.cpp
+++ b/src/core/proxy_config_service_qt.cpp
@@ -52,22 +52,20 @@ using content::BrowserThread;
net::ProxyServer ProxyConfigServiceQt::fromQNetworkProxy(const QNetworkProxy &qtProxy)
{
- net::ProxyServer::Scheme proxyScheme = net::ProxyServer::SCHEME_INVALID;
+ net::HostPortPair hostPortPair(qtProxy.hostName().toStdString(), qtProxy.port());
switch (qtProxy.type()) {
case QNetworkProxy::Socks5Proxy:
- proxyScheme = net::ProxyServer::SCHEME_SOCKS5;
- break;
+ return net::ProxyServer(net::ProxyServer::SCHEME_SOCKS5, hostPortPair);
case QNetworkProxy::HttpProxy:
case QNetworkProxy::HttpCachingProxy:
case QNetworkProxy::FtpCachingProxy:
- proxyScheme = net::ProxyServer::SCHEME_HTTP;
- break;
+ return net::ProxyServer(net::ProxyServer::SCHEME_HTTP, hostPortPair);
case QNetworkProxy::NoProxy:
case QNetworkProxy::DefaultProxy:
- proxyScheme = net::ProxyServer::SCHEME_DIRECT;
- break;
+ return net::ProxyServer(net::ProxyServer::SCHEME_DIRECT, net::HostPortPair());
+ default:
+ return net::ProxyServer(net::ProxyServer::SCHEME_INVALID, net::HostPortPair());
}
- return net::ProxyServer(proxyScheme, net::HostPortPair(qtProxy.hostName().toStdString(), qtProxy.port()));
}
ProxyConfigServiceQt::ProxyConfigServiceQt(std::unique_ptr<ProxyConfigService> baseService)
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index e3d6a7435..182094a11 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -29,6 +29,7 @@
#include <QMainWindow>
#include <QMenu>
#include <QMimeDatabase>
+#include <QNetworkProxy>
#include <QOpenGLWidget>
#include <QPaintEngine>
#include <QPushButton>
@@ -210,6 +211,7 @@ private Q_SLOTS:
void viewSource();
void viewSourceURL_data();
void viewSourceURL();
+ void proxyConfigWithUnexpectedHostPortPair();
private:
static QPoint elementCenter(QWebEnginePage *page, const QString &id);
@@ -4353,5 +4355,22 @@ void tst_QWebEnginePage::viewSourceURL()
QVERIFY(!page.action(QWebEnginePage::ViewSource)->isEnabled());
}
+Q_DECLARE_METATYPE(QNetworkProxy::ProxyType);
+
+void tst_QWebEnginePage::proxyConfigWithUnexpectedHostPortPair()
+{
+ // Chromium expects a proxy of type NoProxy to not have a host or port set.
+
+ QNetworkProxy proxy;
+ proxy.setType(QNetworkProxy::NoProxy);
+ proxy.setHostName(QStringLiteral("127.0.0.1"));
+ proxy.setPort(244);
+ QNetworkProxy::setApplicationProxy(proxy);
+
+ QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool)));
+ m_page->load(QStringLiteral("http://127.0.0.1:245/"));
+ QTRY_COMPARE(loadFinishedSpy.count(), 1);
+}
+
QTEST_MAIN(tst_QWebEnginePage)
#include "tst_qwebenginepage.moc"