mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(launchServer): disable socks by default (#19723)
Socks does not support ipV6 yet. References #19661.
This commit is contained in:
parent
1bb019ac81
commit
3ad65e7ce8
@ -37,8 +37,9 @@ export class BrowserServerLauncherImpl implements BrowserServerLauncher {
|
|||||||
|
|
||||||
async launchServer(options: LaunchServerOptions = {}): Promise<BrowserServer> {
|
async launchServer(options: LaunchServerOptions = {}): Promise<BrowserServer> {
|
||||||
const playwright = createPlaywright('javascript');
|
const playwright = createPlaywright('javascript');
|
||||||
const socksProxy = new SocksProxy();
|
// TODO: enable socks proxy once ipv6 is supported.
|
||||||
playwright.options.socksProxyPort = await socksProxy.listen(0);
|
const socksProxy = false ? new SocksProxy() : undefined;
|
||||||
|
playwright.options.socksProxyPort = await socksProxy?.listen(0);
|
||||||
|
|
||||||
// 1. Pre-launch the browser
|
// 1. Pre-launch the browser
|
||||||
const metadata = serverSideCallMetadata();
|
const metadata = serverSideCallMetadata();
|
||||||
@ -68,7 +69,7 @@ export class BrowserServerLauncherImpl implements BrowserServerLauncher {
|
|||||||
(browserServer as any)._disconnectForTest = () => server.close();
|
(browserServer as any)._disconnectForTest = () => server.close();
|
||||||
(browserServer as any)._userDataDirForTest = (browser as any)._userDataDirForTest;
|
(browserServer as any)._userDataDirForTest = (browser as any)._userDataDirForTest;
|
||||||
browser.options.browserProcess.onclose = (exitCode, signal) => {
|
browser.options.browserProcess.onclose = (exitCode, signal) => {
|
||||||
socksProxy.close().catch(() => {});
|
socksProxy?.close().catch(() => {});
|
||||||
server.close();
|
server.close();
|
||||||
browserServer.emit('close', exitCode, signal);
|
browserServer.emit('close', exitCode, signal);
|
||||||
};
|
};
|
||||||
|
@ -30,6 +30,7 @@ import type { Browser, ConnectOptions } from 'playwright-core';
|
|||||||
type ExtraFixtures = {
|
type ExtraFixtures = {
|
||||||
connect: (wsEndpoint: string, options?: ConnectOptions, redirectPortForTest?: number) => Promise<Browser>,
|
connect: (wsEndpoint: string, options?: ConnectOptions, redirectPortForTest?: number) => Promise<Browser>,
|
||||||
dummyServerPort: number,
|
dummyServerPort: number,
|
||||||
|
ipV6ServerUrl: string,
|
||||||
};
|
};
|
||||||
const test = playwrightTest.extend<ExtraFixtures>({
|
const test = playwrightTest.extend<ExtraFixtures>({
|
||||||
connect: async ({ browserType }, use) => {
|
connect: async ({ browserType }, use) => {
|
||||||
@ -54,6 +55,16 @@ const test = playwrightTest.extend<ExtraFixtures>({
|
|||||||
await use((server.address() as net.AddressInfo).port);
|
await use((server.address() as net.AddressInfo).port);
|
||||||
await new Promise<Error>(resolve => server.close(resolve));
|
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');
|
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 }) => {
|
test('should be able to connect two browsers at the same time', async ({ connect, startRemoteServer }) => {
|
||||||
const remoteServer = await startRemoteServer(kind);
|
const remoteServer = await startRemoteServer(kind);
|
||||||
|
|
||||||
@ -679,6 +700,7 @@ for (const kind of ['launchServer', 'run-server'] as const) {
|
|||||||
test.describe('socks proxy', () => {
|
test.describe('socks proxy', () => {
|
||||||
test.fixme(({ platform, browserName }) => browserName === 'webkit' && platform === 'win32');
|
test.fixme(({ platform, browserName }) => browserName === 'webkit' && platform === 'win32');
|
||||||
test.skip(({ mode }) => mode !== 'default');
|
test.skip(({ mode }) => mode !== 'default');
|
||||||
|
test.skip(kind === 'launchServer', 'not supported yet');
|
||||||
|
|
||||||
test('should forward non-forwarded requests', async ({ server, startRemoteServer, connect }) => {
|
test('should forward non-forwarded requests', async ({ server, startRemoteServer, connect }) => {
|
||||||
let reachedOriginalTarget = false;
|
let reachedOriginalTarget = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user