chore: follow-up to connectOverCDP fetch logic (#36377)

Signed-off-by: Max Schmitt <max@schmitt.mx>
This commit is contained in:
Max Schmitt 2025-06-26 19:27:51 +02:00 committed by GitHub
parent 56ccccddb8
commit 98caf348e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 18 deletions

View File

@ -382,7 +382,7 @@ async function urlToWSEndpoint(progress: Progress, endpointURL: string, headers:
progress.log(`<ws preparing> retrieving websocket url from ${endpointURL}`);
const url = new URL(endpointURL);
if (!url.pathname.endsWith('/'))
url.pathname = url.pathname + '/';
url.pathname += '/';
url.pathname += 'json/version/';
const httpURL = url.toString();

View File

@ -41,23 +41,6 @@ test('should connect to an existing cdp session', async ({ browserType, mode },
}
});
test('should connect to an existing cdp session with verbose path', async ({ browserType, mode }, testInfo) => {
const port = 9339 + testInfo.workerIndex;
const browserServer = await browserType.launch({
args: ['--remote-debugging-port=' + port]
});
try {
const cdpBrowser = await browserType.connectOverCDP({
endpointURL: `http://127.0.0.1:${port}/json/version/abcdefg`,
});
const contexts = cdpBrowser.contexts();
expect(contexts.length).toBe(1);
await cdpBrowser.close();
} finally {
await browserServer.close();
}
});
test('should use logger in default context', async ({ browserType }, testInfo) => {
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/28813' });
const port = 9339 + testInfo.workerIndex;
@ -289,6 +272,30 @@ test('should send extra headers with connect request', async ({ browserType, ser
}
});
test('should keep URL parameters when adding json/version', {
annotation: {
type: 'issue',
description: 'https://github.com/microsoft/playwright/issues/36097'
}
}, async ({ browserType, server }) => {
await Promise.all([
server.waitForRequest('/browser/json/version/?foo=bar'),
browserType.connectOverCDP(`http://localhost:${server.PORT}/browser/?foo=bar`).catch(() => {})
]);
});
test('should append /json/version with a slash if there isnt one', {
annotation: {
type: 'issue',
description: 'https://github.com/microsoft/playwright/issues/36378'
}
}, async ({ browserType, server }) => {
await Promise.all([
server.waitForRequest('/browser/json/version/?foo=bar'),
browserType.connectOverCDP(`http://localhost:${server.PORT}/browser?foo=bar`).catch(() => {})
]);
});
test('should send default User-Agent header with connect request', async ({ browserType, server }, testInfo) => {
{
const [request] = await Promise.all([