Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: fix WebKit socks proxy tests (#19035)

Max Schmittb84a7a9e575b
diff --git a/tests/config/serverFixtures.ts b/tests/config/serverFixtures.ts
index b779c224d5..0d73a84ac8 100644
--- a/tests/config/serverFixtures.ts
+++ b/tests/config/serverFixtures.ts
@@ -49,9 +49,11 @@ export const serverFixtures: Fixtures<ServerFixtures, ServerWorkerOptions> = {
const socksServer = socks.createServer((info, accept, deny) => {
const socket = accept(true);
- if (socket) {
- // Catch and ignore ECONNRESET errors.
- socket.on('error', () => {});
+ if (!socket)
+ return;
+ socket.on('data', data => {
+ if (!data.toString().includes('\r\n\r\n'))
+ return;
const body = '<html><title>Served by the SOCKS proxy</title></html>';
socket.end([
'HTTP/1.1 200 OK',
@@ -61,7 +63,10 @@ export const serverFixtures: Fixtures<ServerFixtures, ServerWorkerOptions> = {
'',
body
].join('\r\n'));
- }
+ });
+ // Catch and ignore ECONNRESET errors.
+ socket.on('error', () => {});
+ setTimeout(() => socket.end(), 1000);
});
const socksPort = port + 2;
socksServer.listen(socksPort, 'localhost');