Commit f3ce736b authored by Eugene But's avatar Eugene But Committed by Commit Bot

Fix HistoryTabHelper::DidFinishNavigation crash.

Per DidFinishNavigation documentation, this callback can be called for
replaced navigations, in which case NavigationContext::HasCommitted will
return false.

This CL adds an early return to HistoryTabHelper::DidFinishNavigation
if the navigation was not committed.

Bug: 813024
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I7a0a1f180faae9715b4992d3f7b810e3287a7cda
Reviewed-on: https://chromium-review.googlesource.com/984376Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547043}
parent 094f08a9
......@@ -97,6 +97,10 @@ void HistoryTabHelper::DidFinishNavigation(
return;
}
if (!navigation_context->HasCommitted()) {
return;
}
DCHECK(web_state->GetNavigationManager()->GetVisibleItem());
web::NavigationItem* visible_item =
web_state_->GetNavigationManager()->GetVisibleItem();
......
......@@ -223,6 +223,7 @@ class TabTest : public BlockCleanupTest {
context2.SetUrl(redirect_url);
web_state_impl_->OnNavigationStarted(&context2);
[tab_ navigationManagerImpl]->CommitPendingItem();
context2.SetHasCommitted(true);
web_state_impl_->UpdateHttpResponseHeaders(redirect_url);
web_state_impl_->OnNavigationFinished(&context2);
web_state_impl_->SetIsLoading(true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment