mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
test(proxy): add a failing test for HTTPS proxy CONNECT User Agent (#5972)
This commit is contained in:
parent
2cce8850b7
commit
49bbc2bc76
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import { it, expect } from './fixtures';
|
||||
import net from 'net';
|
||||
|
||||
it('should throw for bad server value', async ({browserType, browserOptions}) => {
|
||||
const error = await browserType.launch({
|
||||
@ -172,3 +173,33 @@ it('does launch without a port', async ({ browserType, browserOptions }) => {
|
||||
});
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should use proxy', test => {
|
||||
test.fixme('Non-emulated user agent is used in proxy CONNECT');
|
||||
}, async ({ browserType, browserOptions }) => {
|
||||
let requestText = '';
|
||||
// This is our proxy server
|
||||
const server = net.createServer(socket => {
|
||||
socket.on('data', data => {
|
||||
requestText = data.toString();
|
||||
socket.end();
|
||||
});
|
||||
});
|
||||
await new Promise(f => server.listen(0, f));
|
||||
|
||||
const browser = await browserType.launch({
|
||||
...browserOptions,
|
||||
proxy: { server: `http://127.0.0.1:${(server.address() as any).port}` }
|
||||
});
|
||||
|
||||
const page = await browser.newPage({
|
||||
userAgent: 'MyUserAgent'
|
||||
});
|
||||
|
||||
// HTTPS over HTTP proxy will start with CONNECT request.
|
||||
await page.goto('https://bing.com/').catch(() => {});
|
||||
await browser.close();
|
||||
server.close();
|
||||
// This connect request should have emulated user agent.
|
||||
expect(requestText).toContain('MyUserAgent');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user