mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: fix connectOverCDP on Windows when proxy is used (#10080)
This commit is contained in:
parent
95a5c5cb79
commit
84d2ee3929
@ -91,7 +91,13 @@ export class Chromium extends BrowserType {
|
|||||||
browserLogsCollector: new RecentLogsCollector(),
|
browserLogsCollector: new RecentLogsCollector(),
|
||||||
artifactsDir,
|
artifactsDir,
|
||||||
downloadsPath: artifactsDir,
|
downloadsPath: artifactsDir,
|
||||||
tracesDir: artifactsDir
|
tracesDir: artifactsDir,
|
||||||
|
// On Windows context level proxies only work, if there isn't a global proxy
|
||||||
|
// set. This is currently a bug in the CR/Windows networking stack. By
|
||||||
|
// passing an arbitrary value we disable the check in PW land which warns
|
||||||
|
// users in normal (launch/launchServer) mode since otherwise connectOverCDP
|
||||||
|
// does not work at all with proxies on Windows.
|
||||||
|
proxy: { server: 'per-context' },
|
||||||
};
|
};
|
||||||
progress.throwIfAborted();
|
progress.throwIfAborted();
|
||||||
const browser = await CRBrowser.connect(chromeTransport, browserOptions);
|
const browser = await CRBrowser.connect(chromeTransport, browserOptions);
|
||||||
|
|||||||
@ -418,3 +418,25 @@ playwrightTest('should connect to an existing cdp session when passed as a first
|
|||||||
await browserServer.close();
|
await browserServer.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
playwrightTest('should use proxy with connectOverCDP', async ({ browserType, server }, testInfo) => {
|
||||||
|
server.setRoute('/target.html', async (req, res) => {
|
||||||
|
res.end('<html><title>Served by the proxy</title></html>');
|
||||||
|
});
|
||||||
|
const port = 9339 + testInfo.workerIndex;
|
||||||
|
const browserServer = await browserType.launch({
|
||||||
|
args: ['--remote-debugging-port=' + port]
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
const cdpBrowser = await browserType.connectOverCDP(`http://localhost:${port}/`);
|
||||||
|
const context = await cdpBrowser.newContext({
|
||||||
|
proxy: { server: `localhost:${server.PORT}` }
|
||||||
|
});
|
||||||
|
const page = await context.newPage();
|
||||||
|
await page.goto('http://non-existent.com/target.html');
|
||||||
|
expect(await page.title()).toBe('Served by the proxy');
|
||||||
|
await cdpBrowser.close();
|
||||||
|
} finally {
|
||||||
|
await browserServer.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user