fix(launchServer): disable socks by default (#19723)

Socks does not support ipV6 yet.

References #19661.
This commit is contained in:
Dmitry Gozman 2022-12-27 10:43:36 -08:00 committed by GitHub
parent 1bb019ac81
commit 3ad65e7ce8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 3 deletions

View File

@ -37,8 +37,9 @@ export class BrowserServerLauncherImpl implements BrowserServerLauncher {
async launchServer(options: LaunchServerOptions = {}): Promise<BrowserServer> {
const playwright = createPlaywright('javascript');
const socksProxy = new SocksProxy();
playwright.options.socksProxyPort = await socksProxy.listen(0);
// TODO: enable socks proxy once ipv6 is supported.
const socksProxy = false ? new SocksProxy() : undefined;
playwright.options.socksProxyPort = await socksProxy?.listen(0);
// 1. Pre-launch the browser
const metadata = serverSideCallMetadata();
@ -68,7 +69,7 @@ export class BrowserServerLauncherImpl implements BrowserServerLauncher {
(browserServer as any)._disconnectForTest = () => server.close();
(browserServer as any)._userDataDirForTest = (browser as any)._userDataDirForTest;
browser.options.browserProcess.onclose = (exitCode, signal) => {
socksProxy.close().catch(() => {});
socksProxy?.close().catch(() => {});
server.close();
browserServer.emit('close', exitCode, signal);
};

View File

@ -30,6 +30,7 @@ import type { Browser, ConnectOptions } from 'playwright-core';
type ExtraFixtures = {
connect: (wsEndpoint: string, options?: ConnectOptions, redirectPortForTest?: number) => Promise<Browser>,
dummyServerPort: number,
ipV6ServerUrl: string,
};
const test = playwrightTest.extend<ExtraFixtures>({
connect: async ({ browserType }, use) => {
@ -54,6 +55,16 @@ const test = playwrightTest.extend<ExtraFixtures>({
await use((server.address() as net.AddressInfo).port);
await new Promise<Error>(resolve => server.close(resolve));
},
ipV6ServerUrl: async ({}, use) => {
const server = http.createServer((req: http.IncomingMessage, res: http.ServerResponse) => {
res.end('<html><body>from-ipv6-server</body></html>');
});
await new Promise<void>(resolve => server.listen(0, '::1', resolve));
const address = server.address() as net.AddressInfo;
await use('http://[::1]:' + address.port);
await new Promise<Error>(resolve => server.close(resolve));
},
});
test.slow(true, 'All connect tests are slow');
@ -126,6 +137,16 @@ for (const kind of ['launchServer', 'run-server'] as const) {
}
});
test('should be able to visit ipv6', async ({ connect, startRemoteServer, ipV6ServerUrl }) => {
test.fixme(kind === 'run-server', 'socks proxy does not support ipv6 yet');
const remoteServer = await startRemoteServer(kind);
const browser = await connect(remoteServer.wsEndpoint());
const page = await browser.newPage();
await page.goto(ipV6ServerUrl);
expect(await page.content()).toContain('from-ipv6-server');
await browser.close();
});
test('should be able to connect two browsers at the same time', async ({ connect, startRemoteServer }) => {
const remoteServer = await startRemoteServer(kind);
@ -679,6 +700,7 @@ for (const kind of ['launchServer', 'run-server'] as const) {
test.describe('socks proxy', () => {
test.fixme(({ platform, browserName }) => browserName === 'webkit' && platform === 'win32');
test.skip(({ mode }) => mode !== 'default');
test.skip(kind === 'launchServer', 'not supported yet');
test('should forward non-forwarded requests', async ({ server, startRemoteServer, connect }) => {
let reachedOriginalTarget = false;