@@ -44,22 +44,38 @@ import type { SdkObject } from '../instrumentation';
4444import type { Progress } from '../progress' ;
4545import type { ProtocolError } from '../protocolError' ;
4646import type { ConnectionTransport , ProtocolRequest } from '../transport' ;
47+ import type { BrowserContext } from '../browserContext' ;
4748import type * as types from '../types' ;
49+ import type * as channels from '@protocol/channels' ;
4850import type http from 'http' ;
4951import type stream from 'stream' ;
5052
5153const ARTIFACTS_FOLDER = path . join ( os . tmpdir ( ) , 'playwright-artifacts-' ) ;
5254
5355export class Chromium extends BrowserType {
5456 private _devtools : CRDevTools | undefined ;
57+ private _bidiChromium : BrowserType ;
5558
56- constructor ( parent : SdkObject ) {
59+ constructor ( parent : SdkObject , bidiChromium : BrowserType ) {
5760 super ( parent , 'chromium' ) ;
61+ this . _bidiChromium = bidiChromium ;
5862
5963 if ( debugMode ( ) === 'inspector' )
6064 this . _devtools = this . _createDevTools ( ) ;
6165 }
6266
67+ override launch ( progress : Progress , options : types . LaunchOptions , protocolLogger ?: types . ProtocolLogger ) : Promise < Browser > {
68+ if ( options . channel ?. startsWith ( 'bidi-' ) )
69+ return this . _bidiChromium . launch ( progress , options , protocolLogger ) ;
70+ return super . launch ( progress , options , protocolLogger ) ;
71+ }
72+
73+ override async launchPersistentContext ( progress : Progress , userDataDir : string , options : channels . BrowserTypeLaunchPersistentContextOptions & { cdpPort ?: number , internalIgnoreHTTPSErrors ?: boolean , socksProxyPort ?: number } ) : Promise < BrowserContext > {
74+ if ( options . channel ?. startsWith ( 'bidi-' ) )
75+ return this . _bidiChromium . launchPersistentContext ( progress , userDataDir , options ) ;
76+ return super . launchPersistentContext ( progress , userDataDir , options ) ;
77+ }
78+
6379 override async connectOverCDP ( progress : Progress , endpointURL : string , options : { slowMo ?: number , headers ?: types . HeadersArray } ) {
6480 return await this . _connectOverCDPInternal ( progress , endpointURL , options ) ;
6581 }
0 commit comments