mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
feat(remote): send 'x-playwright-browser' header (#12556)
This commit is contained in:
parent
5ca7858ace
commit
d836ed41d3
@ -128,7 +128,8 @@ export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel> imple
|
||||
return await this._wrapApiCall(async () => {
|
||||
const deadline = params.timeout ? monotonicTime() + params.timeout : 0;
|
||||
let browser: Browser;
|
||||
const connectParams: channels.BrowserTypeConnectParams = { wsEndpoint, headers: params.headers, slowMo: params.slowMo, timeout: params.timeout };
|
||||
const headers = { 'x-playwright-browser': this.name(), ...params.headers };
|
||||
const connectParams: channels.BrowserTypeConnectParams = { wsEndpoint, headers, slowMo: params.slowMo, timeout: params.timeout };
|
||||
if ((params as any).__testHookRedirectPortForwarding)
|
||||
connectParams.socksProxyRedirectPortForTest = (params as any).__testHookRedirectPortForwarding;
|
||||
const { pipe } = await this._channel.connect(connectParams);
|
||||
|
||||
@ -134,7 +134,7 @@ test('should send extra headers with connect request', async ({ browserType, sta
|
||||
expect(request.headers['foo']).toBe('bar');
|
||||
});
|
||||
|
||||
test('should send default User-Agent header with connect request', async ({ browserType, startRemoteServer, server }) => {
|
||||
test('should send default User-Agent and X-Playwright-Browser headers with connect request', async ({ browserType, browserName, server }) => {
|
||||
const [request] = await Promise.all([
|
||||
server.waitForWebSocketConnectionRequest(),
|
||||
browserType.connect({
|
||||
@ -146,6 +146,7 @@ test('should send default User-Agent header with connect request', async ({ brow
|
||||
}).catch(() => {})
|
||||
]);
|
||||
expect(request.headers['user-agent']).toBe(getUserAgent());
|
||||
expect(request.headers['x-playwright-browser']).toBe(browserName);
|
||||
expect(request.headers['foo']).toBe('bar');
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user