@@ -29,7 +29,7 @@ import { TimeoutSettings } from '../utils/timeoutSettings';
2929import { ChildProcess } from 'child_process' ;
3030import { envObjectToArray } from './clientHelper' ;
3131import { validateHeaders } from './network' ;
32- import { assert , makeWaitForNextTask , headersObjectToArray , createGuid , mkdirIfNeeded } from '../utils/utils' ;
32+ import { assert , makeWaitForNextTask , headersObjectToArray , mkdirIfNeeded } from '../utils/utils' ;
3333import { SelectorsOwner , sharedSelectors } from './selectors' ;
3434import { kBrowserClosedError } from '../utils/errors' ;
3535import { Stream } from './stream' ;
@@ -108,6 +108,7 @@ export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel, chann
108108 } ;
109109 const result = await this . _channel . launchPersistentContext ( persistentOptions ) ;
110110 const context = BrowserContext . from ( result . context ) ;
111+ context . _options = persistentOptions ;
111112 context . _logger = logger ;
112113 return context ;
113114 } , logger ) ;
@@ -188,16 +189,11 @@ export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel, chann
188189export class RemoteBrowser extends ChannelOwner < channels . RemoteBrowserChannel , channels . RemoteBrowserInitializer > {
189190 constructor ( parent : ChannelOwner , type : string , guid : string , initializer : channels . RemoteBrowserInitializer ) {
190191 super ( parent , type , guid , initializer ) ;
191- this . _channel . on ( 'video' , ( { context, stream } ) => this . _onVideo ( BrowserContext . from ( context ) , Stream . from ( stream ) ) ) ;
192+ this . _channel . on ( 'video' , ( { context, stream, relativePath } ) => this . _onVideo ( BrowserContext . from ( context ) , Stream . from ( stream ) , relativePath ) ) ;
192193 }
193194
194- private async _onVideo ( context : BrowserContext , stream : Stream ) {
195- if ( ! context . _videosPathForRemote ) {
196- stream . _channel . close ( ) . catch ( e => null ) ;
197- return ;
198- }
199-
200- const videoFile = path . join ( context . _videosPathForRemote , createGuid ( ) + '.webm' ) ;
195+ private async _onVideo ( context : BrowserContext , stream : Stream , relativePath : string ) {
196+ const videoFile = path . join ( context . _options . videosPath ! , relativePath ) ;
201197 await mkdirIfNeeded ( videoFile ) ;
202198 stream . stream ( ) . pipe ( fs . createWriteStream ( videoFile ) ) ;
203199 }
0 commit comments