mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(firefox): imply default ports for proxy (#3850)
This commit is contained in:
parent
f758a09d8e
commit
8bc09af458
@ -47,6 +47,7 @@ export class FFBrowser extends Browser {
|
|||||||
}
|
}
|
||||||
if (options.proxy) {
|
if (options.proxy) {
|
||||||
const proxyServer = new URL(options.proxy.server);
|
const proxyServer = new URL(options.proxy.server);
|
||||||
|
let proxyPort = parseInt(proxyServer.port, 10);
|
||||||
let aType: 'http'|'https'|'socks'|'socks4' = 'http';
|
let aType: 'http'|'https'|'socks'|'socks4' = 'http';
|
||||||
if (proxyServer.protocol === 'socks5:')
|
if (proxyServer.protocol === 'socks5:')
|
||||||
aType = 'socks';
|
aType = 'socks';
|
||||||
@ -54,11 +55,17 @@ export class FFBrowser extends Browser {
|
|||||||
aType = 'socks4';
|
aType = 'socks4';
|
||||||
else if (proxyServer.protocol === 'https:')
|
else if (proxyServer.protocol === 'https:')
|
||||||
aType = 'https';
|
aType = 'https';
|
||||||
|
if (proxyServer.port === '') {
|
||||||
|
if (proxyServer.protocol === 'http:')
|
||||||
|
proxyPort = 80;
|
||||||
|
else if (proxyServer.protocol === 'https:')
|
||||||
|
proxyPort = 443;
|
||||||
|
}
|
||||||
promises.push(browser._connection.send('Browser.setBrowserProxy', {
|
promises.push(browser._connection.send('Browser.setBrowserProxy', {
|
||||||
type: aType,
|
type: aType,
|
||||||
bypass: options.proxy.bypass ? options.proxy.bypass.split(',').map(domain => domain.trim()) : [],
|
bypass: options.proxy.bypass ? options.proxy.bypass.split(',').map(domain => domain.trim()) : [],
|
||||||
host: proxyServer.hostname,
|
host: proxyServer.hostname,
|
||||||
port: parseInt(proxyServer.port, 10),
|
port: proxyPort,
|
||||||
username: options.proxy.username,
|
username: options.proxy.username,
|
||||||
password: options.proxy.password,
|
password: options.proxy.password,
|
||||||
}));
|
}));
|
||||||
|
@ -152,3 +152,11 @@ it('should use socks proxy', (test, parameters) => {
|
|||||||
await browser.close();
|
await browser.close();
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does launch without a port', async ({ browserType, defaultBrowserOptions }) => {
|
||||||
|
const browser = await browserType.launch({
|
||||||
|
...defaultBrowserOptions,
|
||||||
|
proxy: { server: 'http://localhost' }
|
||||||
|
});
|
||||||
|
await browser.close();
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user