@@ -352,9 +352,8 @@ class FrameSession {
352
352
return this . _targetId === this . _crPage . _targetId ;
353
353
}
354
354
355
- private _addSessionListeners ( ) {
356
- this . _eventListeners = [
357
- helper . addEventListener ( this . _client , 'Inspector.targetCrashed' , event => this . _onTargetCrashed ( ) ) ,
355
+ private _addRendererListeners ( ) {
356
+ this . _eventListeners . push ( ...[
358
357
helper . addEventListener ( this . _client , 'Log.entryAdded' , event => this . _onLogEntryAdded ( event ) ) ,
359
358
helper . addEventListener ( this . _client , 'Page.fileChooserOpened' , event => this . _onFileChooserOpened ( event ) ) ,
360
359
helper . addEventListener ( this . _client , 'Page.frameAttached' , event => this . _onFrameAttached ( event . frameId , event . parentFrameId ) ) ,
@@ -364,9 +363,6 @@ class FrameSession {
364
363
helper . addEventListener ( this . _client , 'Page.frameStoppedLoading' , event => this . _onFrameStoppedLoading ( event . frameId ) ) ,
365
364
helper . addEventListener ( this . _client , 'Page.javascriptDialogOpening' , event => this . _onDialog ( event ) ) ,
366
365
helper . addEventListener ( this . _client , 'Page.navigatedWithinDocument' , event => this . _onFrameNavigatedWithinDocument ( event . frameId , event . url ) ) ,
367
- helper . addEventListener ( this . _client , 'Page.downloadWillBegin' , event => this . _onDownloadWillBegin ( event ) ) ,
368
- helper . addEventListener ( this . _client , 'Page.downloadProgress' , event => this . _onDownloadProgress ( event ) ) ,
369
- helper . addEventListener ( this . _client , 'Page.screencastFrame' , event => this . _onScreencastFrame ( event ) ) ,
370
366
helper . addEventListener ( this . _client , 'Runtime.bindingCalled' , event => this . _onBindingCalled ( event ) ) ,
371
367
helper . addEventListener ( this . _client , 'Runtime.consoleAPICalled' , event => this . _onConsoleAPI ( event ) ) ,
372
368
helper . addEventListener ( this . _client , 'Runtime.exceptionThrown' , exception => this . _handleException ( exception . exceptionDetails ) ) ,
@@ -375,8 +371,17 @@ class FrameSession {
375
371
helper . addEventListener ( this . _client , 'Runtime.executionContextsCleared' , event => this . _onExecutionContextsCleared ( ) ) ,
376
372
helper . addEventListener ( this . _client , 'Target.attachedToTarget' , event => this . _onAttachedToTarget ( event ) ) ,
377
373
helper . addEventListener ( this . _client , 'Target.detachedFromTarget' , event => this . _onDetachedFromTarget ( event ) ) ,
374
+ ] ) ;
375
+ }
376
+
377
+ private _addBrowserListeners ( ) {
378
+ this . _eventListeners . push ( ...[
379
+ helper . addEventListener ( this . _client , 'Inspector.targetCrashed' , event => this . _onTargetCrashed ( ) ) ,
380
+ helper . addEventListener ( this . _client , 'Page.downloadWillBegin' , event => this . _onDownloadWillBegin ( event ) ) ,
381
+ helper . addEventListener ( this . _client , 'Page.downloadProgress' , event => this . _onDownloadProgress ( event ) ) ,
382
+ helper . addEventListener ( this . _client , 'Page.screencastFrame' , event => this . _onScreencastFrame ( event ) ) ,
378
383
helper . addEventListener ( this . _client , 'Page.windowOpen' , event => this . _onWindowOpen ( event ) ) ,
379
- ] ;
384
+ ] ) ;
380
385
}
381
386
382
387
async _initialize ( hasUIWindow : boolean ) {
@@ -388,13 +393,14 @@ class FrameSession {
388
393
}
389
394
let lifecycleEventsEnabled : Promise < any > ;
390
395
if ( ! this . _isMainFrame ( ) )
391
- this . _addSessionListeners ( ) ;
396
+ this . _addRendererListeners ( ) ;
397
+ this . _addBrowserListeners ( ) ;
392
398
const promises : Promise < any > [ ] = [
393
399
this . _client . send ( 'Page.enable' ) ,
394
400
this . _client . send ( 'Page.getFrameTree' ) . then ( ( { frameTree} ) => {
395
401
if ( this . _isMainFrame ( ) ) {
396
402
this . _handleFrameTree ( frameTree ) ;
397
- this . _addSessionListeners ( ) ;
403
+ this . _addRendererListeners ( ) ;
398
404
}
399
405
const localFrames = this . _isMainFrame ( ) ? this . _page . frames ( ) : [ this . _page . _frameManager . frame ( this . _targetId ) ! ] ;
400
406
for ( const frame of localFrames ) {
0 commit comments