fix(windows): enable socks5 hostname resolution on WebKit (#20435)

Fixes https://github.com/microsoft/playwright/issues/20451
This commit is contained in:
Max Schmitt 2023-01-27 23:33:06 +01:00 committed by GitHub
parent 252b489a7f
commit 71752b4b2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -75,7 +75,9 @@ export class WebKit extends BrowserType {
if (proxy.bypass)
webkitArguments.push(...proxy.bypass.split(',').map(t => `--ignore-host=${t}`));
} else if (process.platform === 'win32') {
webkitArguments.push(`--curl-proxy=${proxy.server}`);
// Enable socks5 hostname resolution on Windows. Workaround can be removed once fixed upstream.
// See https://github.com/microsoft/playwright/issues/20451
webkitArguments.push(`--curl-proxy=${proxy.server.replace(/^socks5:\/\//, 'socks5h://')}`);
if (proxy.bypass)
webkitArguments.push(`--curl-noproxy=${proxy.bypass}`);
}

View File

@ -85,7 +85,9 @@ export class WKBrowser extends Browser {
async doCreateNewContext(options: channels.BrowserNewContextParams): Promise<BrowserContext> {
const createOptions = options.proxy ? {
proxyServer: options.proxy.server,
// Enable socks5 hostname resolution on Windows. Workaround can be removed once fixed upstream.
// See https://github.com/microsoft/playwright/issues/20451
proxyServer: process.platform === 'win32' ? options.proxy.server.replace(/^socks5:\/\//, 'socks5h://') : options.proxy.server,
proxyBypassList: options.proxy.bypass
} : undefined;
const { browserContextId } = await this._browserSession.send('Playwright.createContext', createOptions);