Index: ios/web/web_state/ui/crw_web_controller.mm |
diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm |
index ac54fae6cb1165cbe32452f382ac5e5a74d5c55b..b00480f8839552a20b2481b17fdedcf05b3c70c7 100644 |
--- a/ios/web/web_state/ui/crw_web_controller.mm |
+++ b/ios/web/web_state/ui/crw_web_controller.mm |
@@ -1853,6 +1853,15 @@ - (void)updateCurrentBackForwardListItemHolder { |
// page, and should not be associated. |
if (_webUIManager) |
return; |
+ // The WKWebViewConfiguration's |userScripts| are not injected when navigating |
+ // via BFLI to a page created using window.history.pushState. This means that |
+ // calling window.history navigation functions will invoke WKWebView's |
+ // non-overridden implementations, causing a mismatch between the |
+ // WKBackForwardList and NavigationManager. |
+ web::NavigationItemImpl* currentItem = |
+ [self currentSessionEntry].navigationItemImpl; |
+ if (currentItem->IsCreatedFromPushState()) |
+ return; |
web::WKBackForwardListItemHolder* holder = |
[self currentBackForwardListItemHolder]; |