fix: make fetch api work with connectOverCDP (#13521)

This commit is contained in:
Max Schmitt 2022-04-14 12:53:49 +02:00 committed by GitHub
parent 7fca001985
commit 584140f97a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View file

@ -141,7 +141,7 @@ export abstract class APIRequestContext extends SdkObject {
const method = params.method?.toUpperCase() || 'GET';
const proxy = defaults.proxy;
let agent;
if (proxy) {
if (proxy && proxy.server !== 'per-context') {
// TODO: support bypass proxy
const proxyOpts = url.parse(proxy.server);
if (proxyOpts.protocol?.startsWith('socks')) {

View file

@ -955,3 +955,21 @@ it('should abort requests when browser context closes', async ({ contextFactory,
expect(error.message).toContain('Request context disposed');
await connectionClosed;
});
it('should work with connectOverCDP', async ({ browserName, browserType, server }, testInfo) => {
it.skip(browserName !== 'chromium');
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] = cdpBrowser.contexts();
const response = await context.request.get(server.PREFIX + '/simple.json');
expect(response.url()).toBe(server.PREFIX + '/simple.json');
expect(response.status()).toBe(200);
expect(await response.text()).toBe('{"foo": "bar"}\n');
} finally {
await browserServer.close();
}
});