fix: prevent title change for within page navigation (#46035)

* fix: prevent title change for on page navigation

Co-authored-by: Michaela Laurencin <mlaurencin@electronjs.org>

* add back and forward testing

Co-authored-by: Michaela Laurencin <mlaurencin@electronjs.org>

* update Chromium comment

Co-authored-by: Michaela Laurencin <mlaurencin@electronjs.org>

* remove errant script tag

Co-authored-by: Michaela Laurencin <mlaurencin@electronjs.org>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Michaela Laurencin <mlaurencin@electronjs.org>
This commit is contained in:
trop[bot] 2025-03-14 09:54:35 -05:00 committed by GitHub
parent c91ddf2609
commit 75cf1b08c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 37 additions and 9 deletions

View file

@ -2148,6 +2148,17 @@ void WebContents::DidFinishNavigation(
if (is_main_frame) {
Emit("did-navigate", url, http_response_code, http_status_text);
}
content::NavigationEntry* entry = navigation_handle->GetNavigationEntry();
// This check is needed due to an issue in Chromium
// Upstream is open to patching:
// https://bugs.chromium.org/p/chromium/issues/detail?id=1178663
// If a history entry has been made and the forward/back call has been
// made, proceed with setting the new title
if (entry &&
(entry->GetTransitionType() & ui::PAGE_TRANSITION_FORWARD_BACK))
WebContents::TitleWasSet(entry);
}
if (is_guest())
Emit("load-commit", url, is_main_frame);
@ -2168,15 +2179,6 @@ void WebContents::DidFinishNavigation(
frame_process_id, frame_routing_id);
}
}
content::NavigationEntry* entry = navigation_handle->GetNavigationEntry();
// This check is needed due to an issue in Chromium
// Check the Chromium issue to keep updated:
// https://bugs.chromium.org/p/chromium/issues/detail?id=1178663
// If a history entry has been made and the forward/back call has been made,
// proceed with setting the new title
if (entry && (entry->GetTransitionType() & ui::PAGE_TRANSITION_FORWARD_BACK))
WebContents::TitleWasSet(entry);
}
void WebContents::TitleWasSet(content::NavigationEntry* entry) {