@@ -89,7 +89,7 @@ export interface AgentTab {
8989 pendingRestoreUrl ?: string
9090 pageIssue ?: BrowserPageIssue
9191 syntheticForward ?: { url : string ; baseHistoryIndex : number }
92- preserveSyntheticForwardOnNextLoad ?: boolean
92+ preserveSyntheticForwardOnNextNavigation ?: boolean
9393 recoveringUnresponsive ?: boolean
9494}
9595
@@ -1043,18 +1043,23 @@ export function recordPageLoadFailure(
10431043 publishPageIssue ( tab , true )
10441044}
10451045
1046- /** Clears transient recovery state when Chromium begins a new top-level load . */
1046+ /** Clears transient recovery state when Chromium begins loading a new document . */
10471047export function notePageLoadStarted ( contents : WebContents ) : void {
10481048 const tab = tabForContents ( contents )
10491049 if ( ! tab ) return
10501050 const changed = Boolean ( tab . pageIssue )
10511051 tab . pageIssue = undefined
1052- if ( tab . preserveSyntheticForwardOnNextLoad ) {
1053- tab . preserveSyntheticForwardOnNextLoad = false
1052+ if ( changed ) publishPageIssue ( tab )
1053+ }
1054+
1055+ function notePageNavigationStarted ( contents : WebContents ) : void {
1056+ const tab = tabForContents ( contents )
1057+ if ( ! tab ) return
1058+ if ( tab . preserveSyntheticForwardOnNextNavigation ) {
1059+ tab . preserveSyntheticForwardOnNextNavigation = false
10541060 } else {
10551061 tab . syntheticForward = undefined
10561062 }
1057- if ( changed ) publishPageIssue ( tab )
10581063}
10591064
10601065/** Includes Sim's failed-navigation entry in the browser's Back availability. */
@@ -1085,7 +1090,7 @@ export function goBack(contents: WebContents): boolean {
10851090 return true
10861091 }
10871092 if ( ! contents . navigationHistory . canGoBack ( ) ) return false
1088- tab . preserveSyntheticForwardOnNextLoad = Boolean ( tab . syntheticForward )
1093+ tab . preserveSyntheticForwardOnNextNavigation = Boolean ( tab . syntheticForward )
10891094 contents . navigationHistory . goBack ( )
10901095 return true
10911096}
@@ -1100,7 +1105,7 @@ export function goForward(contents: WebContents): boolean {
11001105 contents . navigationHistory . getActiveIndex ( ) < syntheticForward . baseHistoryIndex &&
11011106 contents . navigationHistory . canGoForward ( )
11021107 ) {
1103- tab . preserveSyntheticForwardOnNextLoad = true
1108+ tab . preserveSyntheticForwardOnNextNavigation = true
11041109 contents . navigationHistory . goForward ( )
11051110 return true
11061111 }
@@ -1498,6 +1503,7 @@ function createTabView(): WebContentsView {
14981503 'did-start-navigation' ,
14991504 bindToBrowserScope ( scopeId , ( details ) => {
15001505 if ( ! details . isMainFrame ) return
1506+ notePageNavigationStarted ( contents )
15011507 events ?. onTabNavigated ( contents , false )
15021508 } )
15031509 )
0 commit comments