@@ -29,7 +29,7 @@ import { TimeoutSettings } from '../utils/timeoutSettings';
29
29
import { ChildProcess } from 'child_process' ;
30
30
import { envObjectToArray } from './clientHelper' ;
31
31
import { validateHeaders } from './network' ;
32
- import { assert , makeWaitForNextTask , headersObjectToArray , createGuid , mkdirIfNeeded } from '../utils/utils' ;
32
+ import { assert , makeWaitForNextTask , headersObjectToArray , mkdirIfNeeded } from '../utils/utils' ;
33
33
import { SelectorsOwner , sharedSelectors } from './selectors' ;
34
34
import { kBrowserClosedError } from '../utils/errors' ;
35
35
import { Stream } from './stream' ;
@@ -108,6 +108,7 @@ export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel, chann
108
108
} ;
109
109
const result = await this . _channel . launchPersistentContext ( persistentOptions ) ;
110
110
const context = BrowserContext . from ( result . context ) ;
111
+ context . _options = persistentOptions ;
111
112
context . _logger = logger ;
112
113
return context ;
113
114
} , logger ) ;
@@ -188,16 +189,11 @@ export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel, chann
188
189
export class RemoteBrowser extends ChannelOwner < channels . RemoteBrowserChannel , channels . RemoteBrowserInitializer > {
189
190
constructor ( parent : ChannelOwner , type : string , guid : string , initializer : channels . RemoteBrowserInitializer ) {
190
191
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 ) ) ;
192
193
}
193
194
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 ) ;
201
197
await mkdirIfNeeded ( videoFile ) ;
202
198
stream . stream ( ) . pipe ( fs . createWriteStream ( videoFile ) ) ;
203
199
}
0 commit comments