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 afdb77c98861e546d87dddd7d88a9c488cd20ee7..2828338a4422e4a3d962537d47998809b7aa6433 100644 |
--- a/ios/web/web_state/ui/crw_web_controller.mm |
+++ b/ios/web/web_state/ui/crw_web_controller.mm |
@@ -1862,6 +1862,18 @@ registerLoadRequestForURL:(const GURL&)requestURL |
params.url, params.referrer, params.transition_type, |
navigationInitiationType, params.user_agent_override_option); |
+ // Mark pending item as created from hash change if necessary. This is needed |
+ // because window.hashchange message may not arrive on time. |
+ web::NavigationItemImpl* pendingItem = self.sessionController.pendingItem; |
+ if (pendingItem) { |
+ GURL lastCommittedURL = _webStateImpl->GetLastCommittedURL(); |
+ GURL pendingURL = pendingItem->GetURL(); |
+ if (lastCommittedURL != pendingURL && |
+ lastCommittedURL.EqualsIgnoringRef(pendingURL)) { |
+ pendingItem->SetIsCreatedFromHashChange(true); |
+ } |
+ } |
+ |
web::NavigationItemImpl* addedItem = self.currentNavItem; |
DCHECK(addedItem); |
if (params.extra_headers) |