Skip to content

Commit

Permalink
fix(launchServer): disable socks by default (#19723)
Browse files Browse the repository at this point in the history
Socks does not support ipV6 yet.

References #19661.
  • Loading branch information
dgozman authored Dec 27, 2022
1 parent 1bb019a commit 3ad65e7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/playwright-core/src/browserServerImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
};
Expand Down
22 changes: 22 additions & 0 deletions tests/library/browsertype-connect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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');
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3ad65e7

Please sign in to comment.