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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 2917173002: Make PopupMenuTest wait for RenderWidgetHostView initialization (Closed)
Patch Set: Created 3 years, 6 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/site_per_process_browsertest.h" 5 #include "content/browser/site_per_process_browsertest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 6457 matching lines...) Expand 10 before | Expand all | Expand 10 after
6468 RenderWidgetHostInputEventRouter* router = 6468 RenderWidgetHostInputEventRouter* router =
6469 static_cast<WebContentsImpl*>(shell()->web_contents()) 6469 static_cast<WebContentsImpl*>(shell()->web_contents())
6470 ->GetInputEventRouter(); 6470 ->GetInputEventRouter();
6471 // Re-open the select element. 6471 // Re-open the select element.
6472 click_event.SetPositionInWidget(360, 90); 6472 click_event.SetPositionInWidget(360, 90);
6473 click_event.click_count = 1; 6473 click_event.click_count = 1;
6474 router->RouteMouseEvent(rwhv_root, &click_event, ui::LatencyInfo()); 6474 router->RouteMouseEvent(rwhv_root, &click_event, ui::LatencyInfo());
6475 6475
6476 filter->Wait(); 6476 filter->Wait();
6477 6477
6478 RenderWidgetHostView* popup_view = 6478 RenderWidgetHostViewAura* popup_view = static_cast<RenderWidgetHostViewAura*>(
6479 RenderWidgetHost::FromID(process_id, filter->last_routing_id()) 6479 RenderWidgetHost::FromID(process_id, filter->last_routing_id())
6480 ->GetView(); 6480 ->GetView());
6481 // The IO thread posts to ViewMsg_ShowWidget handlers in both the message
6482 // filter above and the WebContents, which initializes the popup's view.
6483 // It is possible for this code to execute before the WebContents handler,
6484 // in which case OnMouseEvent would be called on an uninitialized RWHVA.
6485 // This loop ensures that the initialization completes before proceeding.
6486 while (!popup_view->window()) {
6487 base::RunLoop loop;
6488 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
6489 loop.QuitClosure());
6490 loop.Run();
6491 }
6481 6492
6482 RenderWidgetHostMouseEventMonitor popup_monitor( 6493 RenderWidgetHostMouseEventMonitor popup_monitor(
6483 popup_view->GetRenderWidgetHost()); 6494 popup_view->GetRenderWidgetHost());
6484 6495
6485 // Next send a mouse up directly targeting the first option, simulating a 6496 // Next send a mouse up directly targeting the first option, simulating a
6486 // drag. This requires a ui::MouseEvent because it tests behavior that is 6497 // drag. This requires a ui::MouseEvent because it tests behavior that is
6487 // above RWH input event routing. 6498 // above RWH input event routing.
6488 ui::MouseEvent mouse_up_event(ui::ET_MOUSE_RELEASED, gfx::Point(10, 5), 6499 ui::MouseEvent mouse_up_event(ui::ET_MOUSE_RELEASED, gfx::Point(10, 5),
6489 gfx::Point(10, 5), ui::EventTimeForNow(), 6500 gfx::Point(10, 5), ui::EventTimeForNow(),
6490 ui::EF_LEFT_MOUSE_BUTTON, 6501 ui::EF_LEFT_MOUSE_BUTTON,
6491 ui::EF_LEFT_MOUSE_BUTTON); 6502 ui::EF_LEFT_MOUSE_BUTTON);
6492 static_cast<RenderWidgetHostViewAura*>(popup_view) 6503 popup_view->OnMouseEvent(&mouse_up_event);
6493 ->OnMouseEvent(&mouse_up_event);
6494 6504
6495 // This verifies that the popup actually received the event, and it wasn't 6505 // This verifies that the popup actually received the event, and it wasn't
6496 // diverted to a different RenderWidgetHostView due to mouse capture. 6506 // diverted to a different RenderWidgetHostView due to mouse capture.
6497 EXPECT_TRUE(popup_monitor.EventWasReceived()); 6507 EXPECT_TRUE(popup_monitor.EventWasReceived());
6498 #endif 6508 #endif
6499 } 6509 }
6500 6510
6501 // Test that clicking a select element in a nested out-of-process iframe creates 6511 // Test that clicking a select element in a nested out-of-process iframe creates
6502 // a popup menu in the correct position, even if the top-level page repositions 6512 // a popup menu in the correct position, even if the top-level page repositions
6503 // its out-of-process iframe. This verifies that screen positioning information 6513 // its out-of-process iframe. This verifies that screen positioning information
(...skipping 3677 matching lines...) Expand 10 before | Expand all | Expand 10 after
10181 // Go back again. This should go to foo.com. 10191 // Go back again. This should go to foo.com.
10182 { 10192 {
10183 TestNavigationObserver back_observer(web_contents()); 10193 TestNavigationObserver back_observer(web_contents());
10184 web_contents()->GetController().GoBack(); 10194 web_contents()->GetController().GoBack();
10185 back_observer.Wait(); 10195 back_observer.Wait();
10186 } 10196 }
10187 EXPECT_EQ(foo_url, web_contents()->GetMainFrame()->GetLastCommittedURL()); 10197 EXPECT_EQ(foo_url, web_contents()->GetMainFrame()->GetLastCommittedURL());
10188 } 10198 }
10189 10199
10190 } // namespace content 10200 } // namespace content
OLDNEW
« 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