@@ -180,7 +180,7 @@ export class Electron implements api.Electron {
180180 const chromeMatch = await Promise . race ( [ chromeMatchPromise , waitForXserverError ] ) ;
181181 const browser = await chromium . connectOverCDP ( chromeMatch [ 1 ] , { timeout : progress . timeUntilDeadline ( ) , isLocal : true } ) ;
182182
183- app = new ElectronApplication ( worker , browser , launchedProcess , kill ) ;
183+ app = new ElectronApplication ( worker , browser , launchedProcess ) ;
184184 await progress . race ( app . _initialize ( ) ) ;
185185 return app ;
186186 } catch ( error ) {
@@ -194,13 +194,12 @@ export class ElectronApplication extends EventEmitter implements api.ElectronApp
194194 private _worker : Worker ;
195195 private _browser : Browser ;
196196 private _process : childProcess . ChildProcess ;
197- private _kill : ( ) => Promise < void > ;
198197 private _context : BrowserContext ;
199198 private _windows = new Map < Page , JSHandle < BrowserWindow > | undefined > ( ) ;
200199 private _appHandlePromise = new ManualPromise < JSHandle < ElectronAppType > > ( ) ;
201200 private _closedPromise : Promise < void > | undefined ;
202201
203- constructor ( worker : Worker , browser : Browser , process : childProcess . ChildProcess , kill : ( ) => Promise < void > ) {
202+ constructor ( worker : Worker , browser : Browser , process : childProcess . ChildProcess ) {
204203 super ( ) ;
205204
206205 this . _worker = worker ;
@@ -215,7 +214,6 @@ export class ElectronApplication extends EventEmitter implements api.ElectronApp
215214 this . _context . close = ( ) => this . close ( ) ;
216215
217216 this . _process = process ;
218- this . _kill = kill ;
219217 }
220218
221219 _onClose ( ) {
@@ -251,25 +249,14 @@ export class ElectronApplication extends EventEmitter implements api.ElectronApp
251249 await this . close ( ) ;
252250 }
253251
254- async close ( options : { timeout ?: number } = { } ) {
252+ async close ( ) {
255253 if ( ! this . _closedPromise ) {
256254 this . _closedPromise = new Promise < void > ( f => this . once ( Events . ElectronApplication . Close , f ) ) ;
257255 await this . _browser . close ( ) ;
258256 const appHandle = await this . _appHandlePromise ;
259257 await appHandle . evaluate ( ( { app } ) => app . quit ( ) ) . catch ( ( ) => { } ) ;
260258 await this . _worker . _disconnect ( ) ;
261259 }
262- if ( options . timeout ) {
263- let timer : NodeJS . Timeout | undefined ;
264- const timedOut = new Promise < boolean > ( resolve => {
265- timer = setTimeout ( ( ) => resolve ( true ) , options . timeout ) ;
266- } ) ;
267- const exited = this . _closedPromise . then ( ( ) => false ) ;
268- const didTimeout = await Promise . race ( [ exited , timedOut ] ) ;
269- clearTimeout ( timer ) ;
270- if ( didTimeout )
271- await this . _kill ( ) ;
272- }
273260 await this . _closedPromise ;
274261 }
275262
0 commit comments