From ed3a0f052910b09edc393dfb6c6940f118b267ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Fri, 15 Dec 2017 15:19:28 +0100 Subject: 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 --- .../widgets/qwebenginepage/tst_qwebenginepage.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests') 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 #include #include +#include #include #include #include @@ -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" -- cgit v1.2.3