fix: make fetch api work with connectOverCDP (#13521)
This commit is contained in:
parent
7fca001985
commit
584140f97a
|
|
@ -141,7 +141,7 @@ export abstract class APIRequestContext extends SdkObject {
|
||||||
const method = params.method?.toUpperCase() || 'GET';
|
const method = params.method?.toUpperCase() || 'GET';
|
||||||
const proxy = defaults.proxy;
|
const proxy = defaults.proxy;
|
||||||
let agent;
|
let agent;
|
||||||
if (proxy) {
|
if (proxy && proxy.server !== 'per-context') {
|
||||||
// TODO: support bypass proxy
|
// TODO: support bypass proxy
|
||||||
const proxyOpts = url.parse(proxy.server);
|
const proxyOpts = url.parse(proxy.server);
|
||||||
if (proxyOpts.protocol?.startsWith('socks')) {
|
if (proxyOpts.protocol?.startsWith('socks')) {
|
||||||
|
|
|
||||||
|
|
@ -955,3 +955,21 @@ it('should abort requests when browser context closes', async ({ contextFactory,
|
||||||
expect(error.message).toContain('Request context disposed');
|
expect(error.message).toContain('Request context disposed');
|
||||||
await connectionClosed;
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue