Chromium Code Reviews| 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 aa76834ce162400bdad7408af8552c2d10c694b0..35e8e5dd4534541c1b3e4267d1c66dd6614d7796 100644 |
| --- a/content/browser/site_per_process_browsertest.cc |
| +++ b/content/browser/site_per_process_browsertest.cc |
| @@ -26,10 +26,12 @@ |
| #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/gpu/compositor_util.h" |
| +#include "content/browser/renderer_host/input/synthetic_tap_gesture.h" |
| #include "content/browser/renderer_host/render_view_host_impl.h" |
| #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
| #include "content/browser/web_contents/web_contents_impl.h" |
| #include "content/common/frame_messages.h" |
| +#include "content/common/input/synthetic_tap_gesture_params.h" |
| #include "content/common/view_messages.h" |
| #include "content/public/browser/notification_observer.h" |
| #include "content/public/browser/notification_service.h" |
| @@ -4477,6 +4479,78 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| "window.domAutomationController.send(getLastTouchEvent());", &result)); |
| EXPECT_EQ("touchstart", result); |
| } |
| + |
| +namespace { |
| + |
| +// Declared here to be close to the SubframeGestureEventRouting test. |
| +void OnSyntheticGestureCompleted(scoped_refptr<MessageLoopRunner> runner, |
| + SyntheticGesture::Result result) { |
| + EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result); |
| + runner->Quit(); |
| +} |
| + |
| +} // namespace anonymous |
| + |
| +IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| + SubframeGestureEventRouting) { |
| + GURL main_url(embedded_test_server()->GetURL( |
| + "a.com", "/frame_tree/page_with_one_frame.html")); |
| + EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| + |
| + WebContentsImpl* web_contents = |
| + static_cast<WebContentsImpl*>(shell()->web_contents()); |
| + FrameTreeNode* root = web_contents->GetFrameTree()->root(); |
| + |
| + GURL frame_url( |
| + embedded_test_server()->GetURL("b.com", "/page_with_click_handler.html")); |
| + NavigateFrameToURL(root->child_at(0), frame_url); |
| + EXPECT_TRUE(WaitForRenderFrameReady(root->child_at(0)->current_frame_host())); |
| + |
| + // Synchronize with the child and parent renderers to guarantee that the |
| + // surface information required for event hit testing is ready. |
| + RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>( |
| + root->child_at(0)->current_frame_host()->GetView()); |
| + SurfaceHitTestReadyNotifier notifier( |
| + static_cast<RenderWidgetHostViewChildFrame*>(child_rwhv)); |
| + notifier.WaitForSurfaceReady(); |
| + |
| + // There have been no GestureTaps send yet. |
|
kenrb
2016/03/02 16:23:13
nit: s/send/sent
|
| + { |
| + std::string result; |
| + EXPECT_TRUE(ExecuteScriptAndExtractString( |
| + root->child_at(0)->current_frame_host(), |
| + "window.domAutomationController.send(getClickStatus());", &result)); |
| + EXPECT_EQ("0 clicks received", result); |
| + } |
| + |
| + // Simulate touch sequence to send GestureTap to sub-frame. |
| + SyntheticTapGestureParams params; |
| + params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
| + gfx::Point center = child_rwhv->GetBoundsInRootWindow().CenterPoint(); |
| + params.position = gfx::PointF(center.x(), center.y()); |
| + params.duration_ms = 100; |
| + scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params)); |
| + |
| + scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner(); |
| + |
| + RenderWidgetHostImpl* render_widget_host = |
| + root->current_frame_host()->GetRenderWidgetHost(); |
| + //TODO(wjmaclean): Convert the call to base::Bind() to a lambda someday. |
| + render_widget_host->QueueSyntheticGesture( |
| + std::move(gesture), base::Bind(OnSyntheticGestureCompleted, runner)); |
| + |
| + runner->Run(); |
| + runner = nullptr; |
| + |
| + // Verify click handler in subframe was invoked |
| + { |
| + std::string result; |
| + EXPECT_TRUE(ExecuteScriptAndExtractString( |
| + root->child_at(0)->current_frame_host(), |
| + "window.domAutomationController.send(getClickStatus());", &result)); |
| + EXPECT_EQ("1 clicks received", result); |
| + } |
| +} |
| #endif // defined(USE_AURA) |
| // Ensure that a cross-process subframe can receive keyboard events when in |