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

Unified Diff: content/browser/site_per_process_browsertest.cc

Issue 1752833002: Implement Gesture event hit testing/forwarding for OOPIF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wjmCFTouch.v2
Patch Set: Address comments. Created 4 years, 10 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/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 56f1e765f0f40dc85590c95d77f3f40a65594c1b..89d757d7bb83907e381c80226c6b4357d3f4bc9b 100644
--- a/content/browser/site_per_process_browsertest.cc
+++ b/content/browser/site_per_process_browsertest.cc
@@ -26,10 +26,13 @@
#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/renderer_host/render_widget_host_view_aura.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"
@@ -4554,6 +4557,80 @@ 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(
+ "/frame_tree/page_with_positioned_nested_frames.html"));
+ EXPECT_TRUE(NavigateToURL(shell(), main_url));
+
+ WebContentsImpl* web_contents =
+ static_cast<WebContentsImpl*>(shell()->web_contents());
+ FrameTreeNode* root = web_contents->GetFrameTree()->root();
+ ASSERT_EQ(1U, root->child_count());
+
+ GURL frame_url(
+ embedded_test_server()->GetURL("b.com", "/page_with_click_handler.html"));
+ NavigateFrameToURL(root->child_at(0), frame_url);
+ auto child_frame_host = root->child_at(0)->current_frame_host();
+ EXPECT_TRUE(WaitForRenderFrameReady(child_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*>(
+ child_frame_host->GetView());
+ SurfaceHitTestReadyNotifier notifier(
+ static_cast<RenderWidgetHostViewChildFrame*>(child_rwhv));
+ notifier.WaitForSurfaceReady();
+
+ // There have been no GestureTaps sent yet.
+ {
+ std::string result;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ child_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(150, 150);
+ 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.
nasko 2016/03/03 19:01:24 nit: Space between // and TODO.
wjmaclean 2016/03/03 22:27:50 Done.
+ render_widget_host->QueueSyntheticGesture(
+ std::move(gesture), base::Bind(OnSyntheticGestureCompleted, runner));
+
+ runner->Run();
nasko 2016/03/03 19:01:24 A small comment about why we are running the messa
wjmaclean 2016/03/03 22:27:50 Done.
+ runner = nullptr;
+
+ // Verify click handler in subframe was invoked
+ {
+ std::string result;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ child_frame_host,
+ "window.domAutomationController.send(getClickStatus());", &result));
+ EXPECT_EQ("1 clicks received", result);
nasko 2016/03/03 19:01:24 fun: "1 clicks" is technically incorrect grammar ;
wjmaclean 2016/03/03 22:27:50 Ha ha, yes :-) I'm not sure how "1" gets special
+ }
+}
#endif // defined(USE_AURA)
// Ensure that a cross-process subframe can receive keyboard events when in

Powered by Google App Engine
This is Rietveld 408576698