diff --git a/tests/config/proxy.ts b/tests/config/proxy.ts index f9672cfb1b..782dfc7814 100644 --- a/tests/config/proxy.ts +++ b/tests/config/proxy.ts @@ -114,7 +114,7 @@ export async function setupSocksForwardingServer({ const socksProxy = new SocksProxy(); socksProxy.setPattern('*'); socksProxy.addListener(SocksProxy.Events.SocksRequested, async (payload: SocksSocketRequestedPayload) => { - if (!['127.0.0.1', 'fake-localhost-127-0-0-1.nip.io', 'localhost'].includes(payload.host) || payload.port !== allowedTargetPort) { + if (!['127.0.0.1', '0:0:0:0:0:0:0:1', 'fake-localhost-127-0-0-1.nip.io', 'localhost'].includes(payload.host) || payload.port !== allowedTargetPort) { socksProxy.sendSocketError({ uid: payload.uid, error: 'ECONNREFUSED' }); return; } diff --git a/tests/config/serverFixtures.ts b/tests/config/serverFixtures.ts index a156f2ac5f..2bff8e6369 100644 --- a/tests/config/serverFixtures.ts +++ b/tests/config/serverFixtures.ts @@ -51,7 +51,7 @@ export const serverFixtures: Fixtures = { const socksServer = new MockSocksServer(); const socksPort = port + 2; - await socksServer.listen(socksPort, 'localhost'); + await socksServer.listen(socksPort, loopback); const proxyPort = port + 3; const proxyServer = await TestProxy.create(proxyPort); diff --git a/tests/library/client-certificates.spec.ts b/tests/library/client-certificates.spec.ts index 10c8a52235..8e0a4cdf47 100644 --- a/tests/library/client-certificates.spec.ts +++ b/tests/library/client-certificates.spec.ts @@ -390,7 +390,7 @@ test.describe('browser', () => { }); expect(connectHosts).toEqual([]); await page.goto(serverURL); - const host = browserName === 'webkit' && isMac ? 'localhost' : '127.0.0.1'; + const host = browserName === 'webkit' && isMac ? '0:0:0:0:0:0:0:1' : '127.0.0.1'; expect(connectHosts).toEqual([`${host}:${serverPort}`]); await expect(page.getByTestId('message')).toHaveText('Hello Alice, your certificate was issued by localhost!'); await page.close(); diff --git a/tests/library/har.spec.ts b/tests/library/har.spec.ts index 3a10347825..a5d4a6fa0e 100644 --- a/tests/library/har.spec.ts +++ b/tests/library/har.spec.ts @@ -862,7 +862,7 @@ it('should include timings when using http proxy', async ({ contextFactory, serv proxyServer.forwardTo(server.PORT, { allowConnectRequests: true }); const { page, getLog } = await pageWithHar(contextFactory, testInfo, { proxy: { server: `localhost:${proxyServer.PORT}` } }); const response = await page.request.get(server.EMPTY_PAGE); - await response.body(); + expect(proxyServer.connectHosts).toEqual([`localhost:${server.PORT}`]); await expect(response).toBeOK(); const log = await getLog(); expect(log.entries[0].timings.connect).toBeGreaterThan(0); @@ -871,7 +871,7 @@ it('should include timings when using http proxy', async ({ contextFactory, serv it('should include timings when using socks proxy', async ({ contextFactory, server, socksPort }, testInfo) => { const { page, getLog } = await pageWithHar(contextFactory, testInfo, { proxy: { server: `socks5://localhost:${socksPort}` } }); const response = await page.request.get(server.EMPTY_PAGE); - await response.body(); + expect(await response.text()).toContain('Served by the SOCKS proxy'); await expect(response).toBeOK(); const log = await getLog(); expect(log.entries[0].timings.connect).toBeGreaterThan(0);