WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
0001-GTK-Allow-WebKitTestServer-to-run-non-loopback-addre.patch (text/plain), 5.25 KB, created by
Frédéric Wang Nélar
on 2021-02-24 07:44:18 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Frédéric Wang Nélar
Created:
2021-02-24 07:44:18 PST
Size:
5.25 KB
patch
obsolete
>From c01c3ca3f4fca8057bf3e32eee47f4e30170e251 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= <fwang@igalia.com> >Date: Wed, 24 Feb 2021 16:41:31 +0100 >Subject: [PATCH] [GTK] Allow WebKitTestServer to run non-loopback addresses > for API tests > >--- > .../Tests/WebKitGLib/TestDownloads.cpp | 7 +++++- > .../Tests/WebKitGLib/TestSSL.cpp | 1 + > .../glib/WebKitGLib/WebKitTestServer.cpp | 25 ++++++++++++++----- > .../glib/WebKitGLib/WebKitTestServer.h | 5 +++- > 4 files changed, 30 insertions(+), 8 deletions(-) > >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp >index c7456772b9..5722b4b6b8 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp >@@ -879,7 +879,12 @@ static void testBlobDownload(WebViewDownloadTest* test, gconstpointer) > > void beforeAll() > { >- kServer = new WebKitTestServer(); >+ WebKitTestServer::ServerOptionsBitSet serverOptions; >+ // TODO: remove this change from the patch! >+ serverOptions.set(WebKitTestServer::ServerNonLoopback); >+ serverOptions.set(WebKitTestServer::ServerRunInThread); >+ // serverOptions.set(WebKitTestServer::ServerHTTPS); >+ kServer = new WebKitTestServer(serverOptions); > kServer->run(serverCallback); > > DownloadTest::add("Downloads", "local-file", testDownloadLocalFile); >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestSSL.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestSSL.cpp >index c5611073c6..0f91e6a44c 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestSSL.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestSSL.cpp >@@ -562,6 +562,7 @@ static void httpServerCallback(SoupServer* server, SoupServerMessage* message, c > > void beforeAll() > { >+ // TODO: use non-loopback. > kHttpsServer = new WebKitTestServer(WebKitTestServer::ServerHTTPS); > kHttpsServer->run(httpsServerCallback); > >diff --git a/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.cpp b/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.cpp >index ed855eefc9..61c9eaccbe 100644 >--- a/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.cpp >+++ b/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.cpp >@@ -40,25 +40,38 @@ WebKitTestServer::WebKitTestServer(ServerOptionsBitSet options) > GUniquePtr<char> sslKeyFile(g_build_filename(resourcesDir.data(), "test-key.pem", nullptr)); > g_assert_true(soup_server_set_ssl_cert_file(m_soupServer.get(), sslCertificateFile.get(), sslKeyFile.get(), nullptr)); > } >+ >+ if (options[ServerNonLoopback]) { >+ m_address = adoptGRef(soup_address_new("localhost", SOUP_ADDRESS_ANY_PORT)); >+ soup_address_resolve_sync(m_address.get(), nullptr); >+ } >+} >+ >+gboolean WebKitTestServer::listen() { >+ unsigned options = 0; >+ if (!m_address) >+ options |= SOUP_SERVER_LISTEN_IPV4_ONLY; >+ if (soup_server_is_https(m_soupServer.get())) >+ options |= SOUP_SERVER_LISTEN_HTTPS; >+ >+ if (m_address) >+ return soup_server_listen(m_soupServer.get(), soup_address_get_gsockaddr(m_address.get()), static_cast<SoupServerListenOptions>(options), nullptr); >+ return soup_server_listen_local(m_soupServer.get(), SOUP_ADDRESS_ANY_PORT, static_cast<SoupServerListenOptions>(options), nullptr); > } > > void WebKitTestServer::run(SoupServerCallback serverCallback) > { > soup_server_add_handler(m_soupServer.get(), nullptr, serverCallback, nullptr, nullptr); > >- unsigned options = SOUP_SERVER_LISTEN_IPV4_ONLY; >- if (soup_server_is_https(m_soupServer.get())) >- options |= SOUP_SERVER_LISTEN_HTTPS; >- > if (m_queue) { > BinarySemaphore semaphore; > m_queue->dispatch([&] { >- g_assert_true(soup_server_listen_local(m_soupServer.get(), 0, static_cast<SoupServerListenOptions>(options), nullptr)); >+ g_assert_true(listen()); > semaphore.signal(); > }); > semaphore.wait(); > } else >- g_assert_true(soup_server_listen_local(m_soupServer.get(), 0, static_cast<SoupServerListenOptions>(options), nullptr)); >+ g_assert_true(listen()); > > GSList* uris = soup_server_get_uris(m_soupServer.get()); > g_assert_nonnull(uris); >diff --git a/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.h b/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.h >index dd3ceedd35..9f04aff8b9 100644 >--- a/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.h >+++ b/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.h >@@ -33,8 +33,9 @@ public: > enum ServerOptions { > ServerHTTPS = 0, > ServerRunInThread = 1, >+ ServerNonLoopback = 2, > }; >- using ServerOptionsBitSet = std::bitset<2>; >+ using ServerOptionsBitSet = std::bitset<3>; > > WebKitTestServer(ServerOptionsBitSet = 0); > WebKitTestServer(ServerOptions option) >@@ -44,6 +45,7 @@ public: > unsigned port() const; > CString getURIForPath(const char* path) const; > void run(SoupServerCallback); >+ gboolean listen(); > > #if SOUP_CHECK_VERSION(2, 50, 0) > void addWebSocketHandler(SoupServerWebsocketCallback, gpointer userData); >@@ -54,6 +56,7 @@ public: > > private: > GRefPtr<SoupServer> m_soupServer; >+ GRefPtr<SoupAddress> m_address; > URL m_baseURL; > #if SOUP_CHECK_VERSION(2, 50, 0) > URL m_baseWebSocketURL; >-- >2.25.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 219257
:
414801
|
414835
| 421409