| 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.
|
|
|