Commit 5ba3f264 authored by Nasko Oskov's avatar Nasko Oskov Committed by Commit Bot

Add checks to WCOSanityChecker for consistency between navigation callbacks

This CL tries to verify that whenever WCO::ReadyToCommitNavigation has
been dispatched, subsequent WCO::DidFinishNavigation will return the same
RenderFrameHost consistently.

Change-Id: I3797b6c55b038941a65a92aa3439526e3ca62537
Reviewed-on: https://chromium-review.googlesource.com/977050
Commit-Queue: Nasko Oskov <nasko@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Reviewed-by: default avatarKaran Bhatia <karandeepb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545675}
parent 3d134d7b
......@@ -194,6 +194,10 @@ void WebContentsObserverSanityChecker::ReadyToCommitNavigation(
CHECK(navigation_handle->GetRenderFrameHost());
CHECK_EQ(navigation_handle->GetWebContents(), web_contents());
CHECK(navigation_handle->GetRenderFrameHost() != nullptr);
ready_to_commit_hosts_.insert(
std::make_pair(navigation_handle->GetNavigationId(),
navigation_handle->GetRenderFrameHost()));
}
void WebContentsObserverSanityChecker::DidFinishNavigation(
......@@ -208,6 +212,16 @@ void WebContentsObserverSanityChecker::DidFinishNavigation(
CHECK(!navigation_handle->HasCommitted() ||
navigation_handle->GetRenderFrameHost() != nullptr);
// If ReadyToCommitNavigation was dispatched, verify that the
// |navigation_handle| has the same RenderFrameHost at this time as the one
// returned at ReadyToCommitNavigation.
if (base::ContainsKey(ready_to_commit_hosts_,
navigation_handle->GetNavigationId())) {
CHECK_EQ(ready_to_commit_hosts_[navigation_handle->GetNavigationId()],
navigation_handle->GetRenderFrameHost());
ready_to_commit_hosts_.erase(navigation_handle->GetNavigationId());
}
ongoing_navigations_.erase(navigation_handle);
}
......@@ -313,6 +327,7 @@ WebContentsObserverSanityChecker::WebContentsObserverSanityChecker(
WebContentsObserverSanityChecker::~WebContentsObserverSanityChecker() {
CHECK(web_contents_destroyed_);
CHECK(ready_to_commit_hosts_.empty());
}
void WebContentsObserverSanityChecker::AssertRenderFrameExists(
......
......@@ -89,6 +89,7 @@ class WebContentsObserverSanityChecker : public WebContentsObserver,
void EnsureStableParentValue(RenderFrameHost* render_frame_host);
bool HasAnyChildren(RenderFrameHost* render_frame_host);
std::map<int64_t, RenderFrameHost*> ready_to_commit_hosts_;
std::set<GlobalRoutingID> current_hosts_;
std::set<GlobalRoutingID> live_routes_;
std::set<GlobalRoutingID> deleted_routes_;
......
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