Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test(proxy): use a hostname that is exempt from https upgrades (#43454)
Dmitry Gozman3757bb1ec5c3
diff --git a/tests/android/browser.spec.ts b/tests/android/browser.spec.tsindex 61595a8795..4564ece8a7 100644--- a/tests/android/browser.spec.ts+++ b/tests/android/browser.spec.ts@@ -59,7 +59,7 @@ test('androidDevice.launchBrowser should pass proxy config', async ({ androidDev});const context = await androidDevice.launchBrowser({ proxy: { server: `${loopback}:${server.PORT}` } });const page = await context.newPage();- await page.goto('http://non-existent.com/target.html');+ await page.goto('http://non-existent.test/target.html');expect(await page.title()).toBe('Served by the proxy');await context.close();});diff --git a/tests/library/browsercontext-proxy.spec.ts b/tests/library/browsercontext-proxy.spec.tsindex c0861471a6..358f8d9016 100644--- a/tests/library/browsercontext-proxy.spec.ts+++ b/tests/library/browsercontext-proxy.spec.ts@@ -34,8 +34,8 @@ it('should work when passing the proxy only on the context level', async ({ brow});const page = await context.newPage();- await page.goto('http://non-existent.com/target.html');- expect(proxyServer.requestUrls).toContain('http://non-existent.com/target.html');+ await page.goto('http://non-existent.test/target.html');+ expect(proxyServer.requestUrls).toContain('http://non-existent.test/target.html');expect(await page.title()).toBe('Served by the proxy');} finally {await browser.close();@@ -49,11 +49,11 @@ for (const launchProxy of ['per-context', 'http://per-context']) {try {const context = await browser.newContext({ proxy: { server: proxyServer.HOST } });const page = await context.newPage();- await page.goto('http://non-existent.com/target.html');+ await page.goto('http://non-existent.test/target.html');expect(await page.title()).toBe('Served by the proxy');- const response = await context.request.get('http://non-existent.com/target.html');+ const response = await context.request.get('http://non-existent.test/target.html');expect(await response.text()).toContain('Served by the proxy');- expect(proxyServer.connectHosts).toContain('non-existent.com:80');+ expect(proxyServer.connectHosts).toContain('non-existent.test:80');const directContext = await browser.newContext();const directPage = await directContext.newPage();@@ -81,8 +81,8 @@ it('should use proxy', async ({ contextFactory, server, proxyServer }) => {proxy: { server: proxyServer.HOST }});const page = await context.newPage();- await page.goto('http://non-existent.com/target.html');- expect(proxyServer.requestUrls).toContain('http://non-existent.com/target.html');+ await page.goto('http://non-existent.test/target.html');+ expect(proxyServer.requestUrls).toContain('http://non-existent.test/target.html');expect(await page.title()).toBe('Served by the proxy');await context.close();});@@ -203,8 +203,8 @@ it('should use ipv6 proxy', async ({ contextFactory, server, proxyServer, browseproxy: { server: `[0:0:0:0:0:0:0:1]:${proxyServer.PORT}` }});const page = await context.newPage();- await page.goto('http://non-existent.com/target.html');- expect(proxyServer.requestUrls).toContain('http://non-existent.com/target.html');+ await page.goto('http://non-existent.test/target.html');+ expect(proxyServer.requestUrls).toContain('http://non-existent.test/target.html');expect(await page.title()).toBe('Served by the proxy');await context.close();});@@ -215,10 +215,10 @@ it('should use proxy twice', async ({ contextFactory, server, proxyServer }) =>proxy: { server: proxyServer.HOST }});const page = await context.newPage();- await page.goto('http://non-existent.com/target.html');- expect(proxyServer.requestUrls).toContain('http://non-existent.com/target.html');- await page.goto('http://non-existent-2.com/target.html');- expect(proxyServer.requestUrls).toContain('http://non-existent-2.com/target.html');+ await page.goto('http://non-existent.test/target.html');+ expect(proxyServer.requestUrls).toContain('http://non-existent.test/target.html');+ await page.goto('http://non-existent-2.test/target.html');+ expect(proxyServer.requestUrls).toContain('http://non-existent-2.test/target.html');expect(await page.title()).toBe('Served by the proxy');await context.close();});@@ -230,14 +230,14 @@ it('should use proxy for second page', async ({ contextFactory, server, proxySer});const page = await context.newPage();- await page.goto('http://non-existent.com/target.html');- expect(proxyServer.requestUrls).toContain('http://non-existent.com/target.html');+ await page.goto('http://non-existent.test/target.html');+ expect(proxyServer.requestUrls).toContain('http://non-existent.test/target.html');expect(await page.title()).toBe('Served by the proxy');const page2 = await context.newPage();proxyServer.requestUrls = [];- await page2.goto('http://non-existent.com/target.html');- expect(proxyServer.requestUrls).toContain('http://non-existent.com/target.html');+ await page2.goto('http://non-existent.test/target.html');+ expect(proxyServer.requestUrls).toContain('http://non-existent.test/target.html');expect(await page2.title()).toBe('Served by the proxy');await context.close();@@ -253,8 +253,8 @@ it('should use proxy for https urls', async ({ contextFactory, httpsServer, proxproxy: { server: proxyServer.HOST }});const page = await context.newPage();- await page.goto('https://non-existent.com/target.html');- expect(proxyServer.connectHosts).toContain('non-existent.com:443');+ await page.goto('https://non-existent.test/target.html');+ expect(proxyServer.connectHosts).toContain('non-existent.test:443');expect(await page.title()).toBe('Served by https server via proxy');await context.close();});@@ -265,8 +265,8 @@ it('should work with IP:PORT notion', async ({ contextFactory, server, proxyServproxy: { server: `127.0.0.1:${proxyServer.PORT}` }});const page = await context.newPage();- await page.goto('http://non-existent.com/target.html');- expect(proxyServer.requestUrls).toContain('http://non-existent.com/target.html');+ await page.goto('http://non-existent.test/target.html');+ expect(proxyServer.requestUrls).toContain('http://non-existent.test/target.html');expect(await page.title()).toBe('Served by the proxy');await context.close();});@@ -296,8 +296,8 @@ it('should authenticate', async ({ contextFactory, server, proxyServer }) => {proxy: { server: proxyServer.HOST, username: 'user', password: 'secret' }});const page = await context.newPage();- await page.goto('http://non-existent.com/target.html');- expect(proxyServer.requestUrls).toContain('http://non-existent.com/target.html');+ await page.goto('http://non-existent.test/target.html');+ expect(proxyServer.requestUrls).toContain('http://non-existent.test/target.html');expect(auth).toBe('Basic ' + Buffer.from('user:secret').toString('base64'));expect(await page.title()).toBe('Served by the proxy');await context.close();@@ -314,7 +314,7 @@ it('should authenticate with empty password', async ({ contextFactory, server, pproxy: { server: proxyServer.HOST, username: 'user', password: '' }});const page = await context.newPage();- await page.goto('http://non-existent.com/target.html');+ await page.goto('http://non-existent.test/target.html');expect(auth).toBe('Basic ' + Buffer.from('user:').toString('base64'));expect(await page.title()).toBe('Served by the proxy');await context.close();@@ -332,7 +332,7 @@ it('should isolate proxy credentials between contexts', async ({ contextFactory,proxy: { server: proxyServer.HOST, username: 'user1', password: 'secret1' }});const page = await context.newPage();- await page.goto('http://non-existent.com/target.html');+ await page.goto('http://non-existent.test/target.html');expect(auth).toBe('Basic ' + Buffer.from('user1:secret1').toString('base64'));expect(await page.title()).toBe('Served by the proxy');await context.close();@@ -343,7 +343,7 @@ it('should isolate proxy credentials between contexts', async ({ contextFactory,proxy: { server: proxyServer.HOST, username: 'user2', password: 'secret2' }});const page = await context.newPage();- await page.goto('http://non-existent.com/target.html');+ await page.goto('http://non-existent.test/target.html');expect(await page.title()).toBe('Served by the proxy');expect(auth).toBe('Basic ' + Buffer.from('user2:secret2').toString('base64'));await context.close();@@ -417,7 +417,7 @@ it('should use socks proxy', async ({ contextFactory, socksPort }) => {proxy: { server: `socks5://localhost:${socksPort}` }});const page = await context.newPage();- await page.goto('http://non-existent.com');+ await page.goto('http://non-existent.test');expect(await page.title()).toBe('Served by the SOCKS proxy');await context.close();});@@ -428,11 +428,11 @@ it('should use socks proxy in second page', async ({ contextFactory, socksPort }});const page = await context.newPage();- await page.goto('http://non-existent.com');+ await page.goto('http://non-existent.test');expect(await page.title()).toBe('Served by the SOCKS proxy');const page2 = await context.newPage();- await page2.goto('http://non-existent.com');+ await page2.goto('http://non-existent.test');expect(await page2.title()).toBe('Served by the SOCKS proxy');await context.close();@@ -466,16 +466,16 @@ it('should isolate proxy credentials between contexts on navigation', async ({ cproxy: { server: server.PREFIX, username: 'user1', password: 'secret1' }});const page1 = await context1.newPage();- await page1.goto('http://non-existent.com/target.html');+ await page1.goto('http://non-existent.test/target.html');await expect(page1.getByTestId('user')).toHaveText('user1');const context2 = await contextFactory({proxy: { server: server.PREFIX, username: 'user2', password: 'secret2' }});const page2 = await context2.newPage();- await page2.goto('http://non-existent.com/target.html');+ await page2.goto('http://non-existent.test/target.html');await expect(page2.getByTestId('user')).toHaveText('user2');- await page1.goto('http://non-existent.com/target.html');+ await page1.goto('http://non-existent.test/target.html');await expect(page1.getByTestId('user')).toHaveText('user1');});diff --git a/tests/library/chromium/connect-over-cdp.spec.ts b/tests/library/chromium/connect-over-cdp.spec.tsindex a445ca60be..b68051e596 100644--- a/tests/library/chromium/connect-over-cdp.spec.ts+++ b/tests/library/chromium/connect-over-cdp.spec.ts@@ -600,7 +600,7 @@ test('should use proxy with connectOverCDP', async ({ browserType, server }, tesproxy: { server: `localhost:${server.PORT}` }});const page = await context.newPage();- await page.goto('http://non-existent.com/target.html');+ await page.goto('http://non-existent.test/target.html');expect(await page.title()).toBe('Served by the proxy');await cdpBrowser.close();} finally {diff --git a/tests/library/proxy.spec.ts b/tests/library/proxy.spec.tsindex db6e6e9038..01a2f98d02 100644--- a/tests/library/proxy.spec.ts+++ b/tests/library/proxy.spec.ts@@ -34,7 +34,7 @@ it('should use proxy @smoke', async ({ browserType, server, mode }) => {proxy: { server: server.HOST }});const page = await browser.newPage();- await page.goto('http://non-existent.com/target.html');+ await page.goto('http://non-existent.test/target.html');expect(await page.title()).toBe('Served by the proxy');await browser.close();});@@ -48,11 +48,11 @@ it('should use proxy for second page', async ({ browserType, server }) => {});const page = await browser.newPage();- await page.goto('http://non-existent.com/target.html');+ await page.goto('http://non-existent.test/target.html');expect(await page.title()).toBe('Served by the proxy');const page2 = await browser.newPage();- await page2.goto('http://non-existent.com/target.html');+ await page2.goto('http://non-existent.test/target.html');expect(await page2.title()).toBe('Served by the proxy');await browser.close();@@ -66,7 +66,7 @@ it('should work with IP:PORT notion', async ({ browserType, server }) => {proxy: { server: `127.0.0.1:${server.PORT}` }});const page = await browser.newPage();- await page.goto('http://non-existent.com/target.html');+ await page.goto('http://non-existent.test/target.html');expect(await page.title()).toBe('Served by the proxy');await browser.close();});@@ -157,7 +157,7 @@ it('should authenticate', async ({ browserType, server }) => {proxy: { server: server.HOST, username: 'user', password: 'secret' }});const page = await browser.newPage();- await page.goto('http://non-existent.com/target.html');+ await page.goto('http://non-existent.test/target.html');expect(await page.title()).toBe('Basic ' + Buffer.from('user:secret').toString('base64'));await browser.close();});@@ -179,7 +179,7 @@ it('should reconnect with credentials after CONNECT 407 closes the socket', {// on every CONNECT, while libsoup on Linux/macOS sends it only after a 407.// Force the first CONNECT to fail regardless to deterministically exercise// the reconnect path on all platforms.- if (req.method !== 'CONNECT' || !req.headers.host?.startsWith('non-existent.com'))+ if (req.method !== 'CONNECT' || !req.headers.host?.startsWith('non-existent.test'))return true;connectAttempts.push({ hadAuth: !!req.headers['proxy-authorization'] });if (!closedFirstConnect) {@@ -193,7 +193,7 @@ it('should reconnect with credentials after CONNECT 407 closes the socket', {proxy: { server: proxyServer.HOST, username: 'user', password: 'secret' },});const page = await browser.newPage({ ignoreHTTPSErrors: true });- await page.goto('https://non-existent.com/target.html');+ await page.goto('https://non-existent.test/target.html');expect(await page.title()).toBe('Served by https server via proxy');expect(connectAttempts.length).toBeGreaterThanOrEqual(2);expect(connectAttempts.some(a => a.hadAuth)).toBe(true);@@ -227,7 +227,7 @@ it('should work with authenticate followed by redirect', async ({ browserName, bproxy: { server: server.HOST, username: 'user', password: 'secret' }});const page = await browser.newPage();- await page.goto('http://non-existent.com/page1.html');+ await page.goto('http://non-existent.test/page1.html');expect(await page.title()).toBe('Served by the proxy');await browser.close();});@@ -308,7 +308,7 @@ it('should use socks proxy', async ({ browserType, socksPort }) => {proxy: { server: `socks5://localhost:${socksPort}` }});const page = await browser.newPage();- await page.goto('http://non-existent.com');+ await page.goto('http://non-existent.test');expect(await page.title()).toBe('Served by the SOCKS proxy');await browser.close();});@@ -319,11 +319,11 @@ it('should use socks proxy in second page', async ({ browserType, socksPort }) =});const page = await browser.newPage();- await page.goto('http://non-existent.com');+ await page.goto('http://non-existent.test');expect(await page.title()).toBe('Served by the SOCKS proxy');const page2 = await browser.newPage();- await page2.goto('http://non-existent.com');+ await page2.goto('http://non-existent.test');expect(await page2.title()).toBe('Served by the SOCKS proxy');await browser.close();diff --git a/tests/mcp/launch.spec.ts b/tests/mcp/launch.spec.tsindex 1678f43cb5..b3ae802f4a 100644--- a/tests/mcp/launch.spec.ts+++ b/tests/mcp/launch.spec.ts@@ -237,7 +237,7 @@ test('--proxy-server routes browser traffic through the proxy', {});expect(await client.callTool({name: 'browser_navigate',- arguments: { url: 'http://non-existent.com/target.html' },+ arguments: { url: 'http://non-existent.test/target.html' },})).toHaveResponse({page: expect.stringContaining('Served by the proxy'),});@@ -259,7 +259,7 @@ test('--proxy-server overrides contextOptions.proxy from config file', {});expect(await client.callTool({name: 'browser_navigate',- arguments: { url: 'http://non-existent.com/target.html' },+ arguments: { url: 'http://non-existent.test/target.html' },})).toHaveResponse({page: expect.stringContaining('Served by CLI proxy'),});@@ -284,7 +284,7 @@ test('--proxy-server should use credentials from the url', {});expect(await client.callTool({name: 'browser_navigate',- arguments: { url: 'http://non-existent.com/target.html' },+ arguments: { url: 'http://non-existent.test/target.html' },})).toHaveResponse({page: expect.stringContaining('Basic ' + Buffer.from('user:se@cret').toString('base64')),});