File tree Expand file tree Collapse file tree 3 files changed +408
-185
lines changed
packages/playwright-core/src/server/bidi Expand file tree Collapse file tree 3 files changed +408
-185
lines changed Original file line number Diff line number Diff line change @@ -216,6 +216,12 @@ export class BidiBrowserContext extends BrowserContext {
216
216
userContexts : [ this . _userContextId ( ) ] ,
217
217
} ) ) ;
218
218
}
219
+ if ( this . _options . userAgent ) {
220
+ promises . push ( this . _browser . _browserSession . send ( 'emulation.setUserAgentOverride' , {
221
+ userAgent : this . _options . userAgent ,
222
+ userContexts : [ this . _userContextId ( ) ] ,
223
+ } ) ) ;
224
+ }
219
225
await Promise . all ( promises ) ;
220
226
}
221
227
@@ -317,6 +323,11 @@ export class BidiBrowserContext extends BrowserContext {
317
323
}
318
324
319
325
async setUserAgent ( userAgent : string | undefined ) : Promise < void > {
326
+ this . _options . userAgent = userAgent ;
327
+ await this . _browser . _browserSession . send ( 'emulation.setUserAgentOverride' , {
328
+ userAgent : userAgent ?? null ,
329
+ userContexts : [ this . _userContextId ( ) ] ,
330
+ } ) ;
320
331
}
321
332
322
333
async doUpdateOffline ( ) : Promise < void > {
Original file line number Diff line number Diff line change @@ -125,6 +125,10 @@ export interface Commands {
125
125
params : Bidi . Emulation . SetTimezoneOverrideParameters ;
126
126
returnType : Bidi . EmptyResult ;
127
127
} ;
128
+ 'emulation.setUserAgentOverride' : {
129
+ params : Bidi . Emulation . SetUserAgentOverrideParameters ;
130
+ returnType : Bidi . Emulation . SetUserAgentOverrideResult ;
131
+ } ;
128
132
129
133
'emulation.setLocaleOverride' : {
130
134
params : Bidi . Emulation . SetLocaleOverrideParameters ;
You can’t perform that action at this time.
0 commit comments