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
feat(proxy): support local.playwright for proxying (#8330)
Pavel Feldmancad7fc2ef79f
diff --git a/src/client/playwright.ts b/src/client/playwright.tsindex 1c60943bf7..2d19b3da15 100644--- a/src/client/playwright.ts+++ b/src/client/playwright.ts@@ -76,6 +76,8 @@ export class Playwright extends ChannelOwner<channels.PlaywrightChannel, channel}private async _onSocksRequested(uid: string, host: string, port: number): Promise<void> {+ if (host === 'local.playwright')+ host = 'localhost';try {if (this._redirectPortForTest)port = this._redirectPortForTest;diff --git a/tests/port-forwarding-server.spec.ts b/tests/port-forwarding-server.spec.tsindex 92af987c6e..0cdbe63169 100644--- a/tests/port-forwarding-server.spec.ts+++ b/tests/port-forwarding-server.spec.ts@@ -76,7 +76,7 @@ const it = contextTest.extend<{ pageFactory: (redirectPortForTest?: number) => P},});-it.fixme(({ platform, browserName }) => browserName === 'webkit' && platform !== 'linux');+it.fixme(({ platform, browserName }) => browserName === 'webkit' && platform === 'win32');it.skip(({ mode }) => mode !== 'default');async function startTestServer() {@@ -102,7 +102,8 @@ it('should forward non-forwarded requests', async ({ pageFactory, server }) => {expect(reachedOriginalTarget).toBe(true);});-it('should proxy local requests', async ({ pageFactory, server }, workerInfo) => {+it('should proxy localhost requests', async ({ pageFactory, server, browserName, platform }, workerInfo) => {+ it.skip(browserName === 'webkit' && platform === 'darwin');const { testServerPort, stopTestServer } = await startTestServer();let reachedOriginalTarget = false;server.setRoute('/foo.html', async (req, res) => {@@ -117,6 +118,22 @@ it('should proxy local requests', async ({ pageFactory, server }, workerInfo) =>stopTestServer();});+it('should proxy local.playwright requests', async ({ pageFactory, server, browserName }, workerInfo) => {+ it.fixme(browserName === 'firefox', 'Firefox performs DNS on browser side');+ const { testServerPort, stopTestServer } = await startTestServer();+ let reachedOriginalTarget = false;+ server.setRoute('/foo.html', async (req, res) => {+ reachedOriginalTarget = true;+ res.end('<html><body></body></html>');+ });+ const examplePort = 20_000 + workerInfo.workerIndex * 3;+ const page = await pageFactory(testServerPort);+ await page.goto(`http://local.playwright:${examplePort}/foo.html`);+ expect(await page.content()).toContain('from-retargeted-server');+ expect(reachedOriginalTarget).toBe(false);+ stopTestServer();+});+it('should lead to the error page for forwarded requests when the connection is refused', async ({ pageFactory, browserName }, workerInfo) => {const examplePort = 20_000 + workerInfo.workerIndex * 3;const page = await pageFactory();