Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Unified Diff: content/test/content_browser_test_utils_internal.cc

Issue 2377453002: Deflake RaceCrossOriginNavigationAndSamePageHistoryNavigation test. (Closed)
Patch Set: Add a HasCommitted check. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/test/content_browser_test_utils_internal.cc
diff --git a/content/test/content_browser_test_utils_internal.cc b/content/test/content_browser_test_utils_internal.cc
index 447796106abf5d7ffab460651332c8e6515ea767..d3af538759c0d9d386e256d79e2e8770a202d622 100644
--- a/content/test/content_browser_test_utils_internal.cc
+++ b/content/test/content_browser_test_utils_internal.cc
@@ -20,6 +20,7 @@
#include "content/browser/frame_host/cross_process_frame_connector.h"
#include "content/browser/frame_host/frame_tree_node.h"
#include "content/browser/frame_host/navigator.h"
+#include "content/browser/frame_host/render_frame_host_delegate.h"
#include "content/browser/frame_host/render_frame_proxy_host.h"
#include "content/browser/frame_host/render_widget_host_view_child_frame.h"
#include "content/browser/renderer_host/delegated_frame_host.h"
@@ -371,4 +372,29 @@ bool FrameTestNavigationManager::ShouldMonitorNavigation(
handle->GetFrameTreeNodeId() == filtering_frame_tree_node_id_;
}
+UrlCommitObserver::UrlCommitObserver(FrameTreeNode* frame_tree_node,
+ const GURL& url)
+ : content::WebContentsObserver(frame_tree_node->current_frame_host()
+ ->delegate()
+ ->GetAsWebContents()),
+ frame_tree_node_id_(frame_tree_node->frame_tree_node_id()),
+ url_(url),
+ message_loop_runner_(new MessageLoopRunner) {}
+
+UrlCommitObserver::~UrlCommitObserver() {}
+
+void UrlCommitObserver::Wait() {
+ message_loop_runner_->Run();
+}
+
+void UrlCommitObserver::DidFinishNavigation(
+ NavigationHandle* navigation_handle) {
+ if (navigation_handle->HasCommitted() &&
+ !navigation_handle->IsErrorPage() &&
+ navigation_handle->GetURL() == url_ &&
+ navigation_handle->GetFrameTreeNodeId() == frame_tree_node_id_) {
+ message_loop_runner_->Quit();
+ }
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698