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

Unified Diff: content/browser/site_per_process_browsertest.cc

Issue 2917173002: Make PopupMenuTest wait for RenderWidgetHostView initialization (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/site_per_process_browsertest.cc
diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc
index 0812caa0472b7d754761ddbed6dfa850105691ec..cbbedc1f236c4f363a491d98a54dfa6a9034e835 100644
--- a/content/browser/site_per_process_browsertest.cc
+++ b/content/browser/site_per_process_browsertest.cc
@@ -6475,9 +6475,20 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, PopupMenuTest) {
filter->Wait();
- RenderWidgetHostView* popup_view =
+ RenderWidgetHostViewAura* popup_view = static_cast<RenderWidgetHostViewAura*>(
RenderWidgetHost::FromID(process_id, filter->last_routing_id())
- ->GetView();
+ ->GetView());
+ // The IO thread posts to ViewMsg_ShowWidget handlers in both the message
+ // filter above and the WebContents, which initializes the popup's view.
+ // It is possible for this code to execute before the WebContents handler,
+ // in which case OnMouseEvent would be called on an uninitialized RWHVA.
+ // This loop ensures that the initialization completes before proceeding.
+ while (!popup_view->window()) {
+ base::RunLoop loop;
+ base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
+ loop.QuitClosure());
+ loop.Run();
+ }
RenderWidgetHostMouseEventMonitor popup_monitor(
popup_view->GetRenderWidgetHost());
@@ -6489,8 +6500,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, PopupMenuTest) {
gfx::Point(10, 5), ui::EventTimeForNow(),
ui::EF_LEFT_MOUSE_BUTTON,
ui::EF_LEFT_MOUSE_BUTTON);
- static_cast<RenderWidgetHostViewAura*>(popup_view)
- ->OnMouseEvent(&mouse_up_event);
+ popup_view->OnMouseEvent(&mouse_up_event);
// This verifies that the popup actually received the event, and it wasn't
// diverted to a different RenderWidgetHostView due to mouse capture.
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698