Skip to content

Commit f44d660

Browse files
authored
feat(webkit): use consistent user agent for headful and headless (#756)
1 parent ce72198 commit f44d660

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/webkit/wkBrowser.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import { WKConnection, WKSession, kPageProxyMessageReceived, PageProxyMessageRec
2828
import { WKPageProxy } from './wkPageProxy';
2929
import * as platform from '../platform';
3030

31+
const DEFAULT_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Safari/605.1.15';
32+
3133
export class WKBrowser extends platform.EventEmitter implements Browser {
3234
private readonly _connection: WKConnection;
3335
private readonly _browserSession: WKSession;
@@ -73,6 +75,7 @@ export class WKBrowser extends platform.EventEmitter implements Browser {
7375

7476
async newContext(options: BrowserContextOptions = {}): Promise<BrowserContext> {
7577
const { browserContextId } = await this._browserSession.send('Browser.createContext');
78+
options.userAgent = options.userAgent || DEFAULT_USER_AGENT;
7679
const context = this._createBrowserContext(browserContextId, options);
7780
if (options.ignoreHTTPSErrors)
7881
await this._browserSession.send('Browser.setIgnoreCertificateErrors', { browserContextId, ignore: true });

0 commit comments

Comments
 (0)