Changeset 270170 in webkit
- Timestamp:
- Nov 26, 2020 4:40:58 PM (3 years ago)
- Location:
- trunk/Tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r270168 r270170 1 2020-11-26 Frederic Wang <fwang@igalia.com> 2 3 [GTK] Allow WebKitTestServer to run non-loopback addresses for API tests 4 https://bugs.webkit.org/show_bug.cgi?id=219257 5 6 GTK API tests currently assumes that loopback IP addresses can be treated as mixed content 7 in order to test WEBKIT_INSECURE_CONTENT_RUN and WEBKIT_INSECURE_CONTENT_DISPLAYED APIs. 8 After bug 218623, this will no longer be true so this patch adds an option to 9 WebKitTestServer so that it can run a server listening to "localhost" instead. This approach 10 will work until bug 171934 is fixed, but we might add a way to launch a server listening to 11 non-localhost addresses (bug 219198) or review the whole mixed content handling in the 12 future (bug 140625). This patch also tweaks a bit WebKitTestServer options, so they use a 13 bitset instead. 14 15 Reviewed by Michael Catanzaro. 16 17 * TestWebKitAPI/Tests/WebKitGLib/TestSSL.cpp: 18 (beforeAll): Add a ServerNonLoopback bit to the HTTPS server used by the tests, so that 19 insecure content APIs will still work after bug 218623. Also remove explicit options for the 20 HTTP server since it just uses the default (no bits set). 21 * TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.cpp: 22 (WebKitTestServer::WebKitTestServer): Use the new bitset syntax. Starts a server listening to 23 "localhost" if the ServerNonLoopback bit is set. 24 * TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.h: Make the enum a list of bit positions 25 and the parameter a bitset of options. Add the new ServerNonLoopback option and remove 26 ServerHTTP, which corresponds to the default value (no bits set). 27 1 28 2020-11-26 Michael Catanzaro <mcatanzaro@gnome.org> 2 29 -
trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestSSL.cpp
r267524 r270170 555 555 void beforeAll() 556 556 { 557 kHttpsServer = new WebKitTestServer(WebKitTestServer::ServerHTTPS); 557 // FIXME(https://webkit.org/b/219198): This should really be a non-localhost domain but 558 // relying on a non-loopback IP address is enough until bug 171934 is fixed. 559 kHttpsServer = new WebKitTestServer(WebKitTestServer::ServerHTTPS | WebKitTestServer::ServerNonLoopback); 558 560 kHttpsServer->run(httpsServerCallback); 559 561 560 kHttpServer = new WebKitTestServer( WebKitTestServer::ServerHTTP);562 kHttpServer = new WebKitTestServer(); 561 563 kHttpServer->run(httpServerCallback); 562 564 -
trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.cpp
r270074 r270170 25 25 #include <wtf/glib/GUniquePtr.h> 26 26 27 WebKitTestServer::WebKitTestServer(ServerOptions options)27 WebKitTestServer::WebKitTestServer(ServerOptionsBitSet options) 28 28 { 29 if (options & ServerRunInThread) {29 if (options[ServerRunInThread]) { 30 30 WTF::initialize(); 31 31 m_queue = WorkQueue::create("WebKitTestServer"); … … 34 34 GUniquePtr<char> sslCertificateFile; 35 35 GUniquePtr<char> sslKeyFile; 36 if (options & ServerHTTPS) {36 if (options[ServerHTTPS]) { 37 37 CString resourcesDir = Test::getResourcesDir(); 38 38 sslCertificateFile.reset(g_build_filename(resourcesDir.data(), "test-cert.pem", NULL)); … … 46 46 47 47 GUniqueOutPtr<GError> error; 48 SoupServerListenOptions serverOptions = static_cast<SoupServerListenOptions>(options & ServerHTTPS ? SOUP_SERVER_LISTEN_IPV4_ONLY : SOUP_SERVER_LISTEN_IPV4_ONLY | SOUP_SERVER_LISTEN_HTTPS); 49 if (!soup_server_listen_local(m_soupServer.get(), SOUP_ADDRESS_ANY_PORT, serverOptions, &error.outPtr())) { 48 SoupServerListenOptions serverOptions = static_cast<SoupServerListenOptions>(options[ServerHTTPS] ? SOUP_SERVER_LISTEN_IPV4_ONLY : SOUP_SERVER_LISTEN_IPV4_ONLY | SOUP_SERVER_LISTEN_HTTPS); 49 bool serverStarted = false; 50 if (options[ServerNonLoopback]) { 51 GRefPtr<SoupAddress> address = adoptGRef(soup_address_new("localhost", SOUP_ADDRESS_ANY_PORT)); 52 soup_address_resolve_sync(address.get(), nullptr); 53 serverStarted = soup_server_listen(m_soupServer.get(), soup_address_get_gsockaddr(address.get()), serverOptions, &error.outPtr()); 54 } else 55 serverStarted = soup_server_listen_local(m_soupServer.get(), SOUP_ADDRESS_ANY_PORT, serverOptions, &error.outPtr()); 56 if (!serverStarted) { 50 57 WTFLogAlways("Failed to start HTTP server: %s", error->message); 51 58 CRASH(); -
trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.h
r248762 r270170 20 20 #pragma once 21 21 22 #include <bitset> 22 23 #include <libsoup/soup.h> 23 24 #include <wtf/WorkQueue.h> … … 30 31 31 32 enum ServerOptions { 32 ServerHTTP = 0,33 Server HTTPS = 1 <<1,34 Server RunInThread = 1 <<2,33 ServerHTTPS = 0, 34 ServerRunInThread = 1, 35 ServerNonLoopback = 2, 35 36 }; 37 using ServerOptionsBitSet = std::bitset<3>; 36 38 37 WebKitTestServer(ServerOptions = ServerHTTP);39 WebKitTestServer(ServerOptionsBitSet = 0); 38 40 virtual ~WebKitTestServer(); 39 41
Note: See TracChangeset
for help on using the changeset viewer.