@@ -10,9 +10,10 @@ import { IBoundLog } from '@secret-agent/interfaces/ILog';
1010import Log from '@secret-agent/commons/Logger' ;
1111import SessionState from './SessionState' ;
1212
13- interface IFrameNavigationEvents {
13+ export interface IFrameNavigationEvents {
1414 'navigation-requested' : INavigation ;
1515 'status-change' : {
16+ id : number ;
1617 url : string ;
1718 stateChanges : { [ state : string ] : Date } ;
1819 newStatus : NavigationState ;
@@ -77,6 +78,7 @@ export default class FrameNavigations extends TypedEventEmitter<IFrameNavigation
7778 this . checkStoredNavigationReason ( nextTop , url ) ;
7879
7980 const currentTop = this . top ;
81+ let shouldPublishLocationChange = false ;
8082 // if in-page, set the state to match current top
8183 if ( reason === 'inPage' ) {
8284 if ( currentTop ) {
@@ -93,12 +95,22 @@ export default class FrameNavigations extends TypedEventEmitter<IFrameNavigation
9395 nextTop . stateChanges . set ( LoadStatus . ContentPaint , nextTop . initiatedTime ) ;
9496 nextTop . resourceId . resolve ( - 1 ) ;
9597 }
98+ shouldPublishLocationChange = true ;
9699 nextTop . finalUrl = url ;
97100 }
98101 this . history . push ( nextTop ) ;
99102
100103 this . emit ( 'navigation-requested' , nextTop ) ;
101104 this . captureNavigationUpdate ( nextTop ) ;
105+ if ( shouldPublishLocationChange ) {
106+ this . emit ( 'status-change' , {
107+ id : nextTop . id ,
108+ newStatus : LoadStatus . ContentPaint ,
109+ url,
110+ // @ts -ignore
111+ stateChanges : Object . fromEntries ( nextTop . stateChanges ) ,
112+ } ) ;
113+ }
102114 return nextTop ;
103115 }
104116
@@ -295,6 +307,7 @@ export default class FrameNavigations extends TypedEventEmitter<IFrameNavigation
295307 navigation . stateChanges . set ( newStatus , statusChangeDate ?? new Date ( ) ) ;
296308
297309 this . emit ( 'status-change' , {
310+ id : navigation . id ,
298311 url : navigation . finalUrl ?? navigation . requestedUrl ,
299312 // @ts -ignore - Typescript refuses to recognize this function
300313 stateChanges : Object . fromEntries ( navigation . stateChanges ) ,
0 commit comments