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

Side by Side 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, 9 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
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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/location.h" 14 #include "base/location.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/strings/pattern.h" 17 #include "base/strings/pattern.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "base/test/test_timeouts.h" 20 #include "base/test/test_timeouts.h"
21 #include "base/thread_task_runner_handle.h" 21 #include "base/thread_task_runner_handle.h"
22 #include "build/build_config.h" 22 #include "build/build_config.h"
23 #include "content/browser/frame_host/cross_process_frame_connector.h" 23 #include "content/browser/frame_host/cross_process_frame_connector.h"
24 #include "content/browser/frame_host/frame_tree.h" 24 #include "content/browser/frame_host/frame_tree.h"
25 #include "content/browser/frame_host/navigator.h" 25 #include "content/browser/frame_host/navigator.h"
26 #include "content/browser/frame_host/render_frame_proxy_host.h" 26 #include "content/browser/frame_host/render_frame_proxy_host.h"
27 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" 27 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
28 #include "content/browser/gpu/compositor_util.h" 28 #include "content/browser/gpu/compositor_util.h"
29 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h"
29 #include "content/browser/renderer_host/render_view_host_impl.h" 30 #include "content/browser/renderer_host/render_view_host_impl.h"
30 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" 31 #include "content/browser/renderer_host/render_widget_host_input_event_router.h"
32 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
31 #include "content/browser/web_contents/web_contents_impl.h" 33 #include "content/browser/web_contents/web_contents_impl.h"
32 #include "content/common/frame_messages.h" 34 #include "content/common/frame_messages.h"
35 #include "content/common/input/synthetic_tap_gesture_params.h"
33 #include "content/common/view_messages.h" 36 #include "content/common/view_messages.h"
34 #include "content/public/browser/notification_observer.h" 37 #include "content/public/browser/notification_observer.h"
35 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
36 #include "content/public/browser/notification_types.h" 39 #include "content/public/browser/notification_types.h"
37 #include "content/public/browser/resource_dispatcher_host.h" 40 #include "content/public/browser/resource_dispatcher_host.h"
38 #include "content/public/common/browser_side_navigation_policy.h" 41 #include "content/public/common/browser_side_navigation_policy.h"
39 #include "content/public/common/content_switches.h" 42 #include "content/public/common/content_switches.h"
40 #include "content/public/test/browser_test_utils.h" 43 #include "content/public/test/browser_test_utils.h"
41 #include "content/public/test/content_browser_test_utils.h" 44 #include "content/public/test/content_browser_test_utils.h"
42 #include "content/public/test/test_navigation_observer.h" 45 #include "content/public/test/test_navigation_observer.h"
(...skipping 4504 matching lines...) Expand 10 before | Expand all | Expand 10 after
4547 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f); 4550 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f);
4548 rwhv->OnTouchEvent(&touch_event); 4551 rwhv->OnTouchEvent(&touch_event);
4549 4552
4550 // Verify touch handler in subframe was invoked 4553 // Verify touch handler in subframe was invoked
4551 std::string result; 4554 std::string result;
4552 EXPECT_TRUE(ExecuteScriptAndExtractString( 4555 EXPECT_TRUE(ExecuteScriptAndExtractString(
4553 root->child_at(0)->current_frame_host(), 4556 root->child_at(0)->current_frame_host(),
4554 "window.domAutomationController.send(getLastTouchEvent());", &result)); 4557 "window.domAutomationController.send(getLastTouchEvent());", &result));
4555 EXPECT_EQ("touchstart", result); 4558 EXPECT_EQ("touchstart", result);
4556 } 4559 }
4560
4561 namespace {
4562
4563 // Declared here to be close to the SubframeGestureEventRouting test.
4564 void OnSyntheticGestureCompleted(scoped_refptr<MessageLoopRunner> runner,
4565 SyntheticGesture::Result result) {
4566 EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result);
4567 runner->Quit();
4568 }
4569
4570 } // namespace anonymous
4571
4572 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4573 SubframeGestureEventRouting) {
4574 GURL main_url(embedded_test_server()->GetURL(
4575 "/frame_tree/page_with_positioned_nested_frames.html"));
4576 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4577
4578 WebContentsImpl* web_contents =
4579 static_cast<WebContentsImpl*>(shell()->web_contents());
4580 FrameTreeNode* root = web_contents->GetFrameTree()->root();
4581 ASSERT_EQ(1U, root->child_count());
4582
4583 GURL frame_url(
4584 embedded_test_server()->GetURL("b.com", "/page_with_click_handler.html"));
4585 NavigateFrameToURL(root->child_at(0), frame_url);
4586 auto child_frame_host = root->child_at(0)->current_frame_host();
4587 EXPECT_TRUE(WaitForRenderFrameReady(child_frame_host));
4588
4589 // Synchronize with the child and parent renderers to guarantee that the
4590 // surface information required for event hit testing is ready.
4591 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>(
4592 child_frame_host->GetView());
4593 SurfaceHitTestReadyNotifier notifier(
4594 static_cast<RenderWidgetHostViewChildFrame*>(child_rwhv));
4595 notifier.WaitForSurfaceReady();
4596
4597 // There have been no GestureTaps sent yet.
4598 {
4599 std::string result;
4600 EXPECT_TRUE(ExecuteScriptAndExtractString(
4601 child_frame_host,
4602 "window.domAutomationController.send(getClickStatus());", &result));
4603 EXPECT_EQ("0 clicks received", result);
4604 }
4605
4606 // Simulate touch sequence to send GestureTap to sub-frame.
4607 SyntheticTapGestureParams params;
4608 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
4609 gfx::Point center(150, 150);
4610 params.position = gfx::PointF(center.x(), center.y());
4611 params.duration_ms = 100;
4612 scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params));
4613
4614 scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner();
4615
4616 RenderWidgetHostImpl* render_widget_host =
4617 root->current_frame_host()->GetRenderWidgetHost();
4618 //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.
4619 render_widget_host->QueueSyntheticGesture(
4620 std::move(gesture), base::Bind(OnSyntheticGestureCompleted, runner));
4621
4622 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.
4623 runner = nullptr;
4624
4625 // Verify click handler in subframe was invoked
4626 {
4627 std::string result;
4628 EXPECT_TRUE(ExecuteScriptAndExtractString(
4629 child_frame_host,
4630 "window.domAutomationController.send(getClickStatus());", &result));
4631 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
4632 }
4633 }
4557 #endif // defined(USE_AURA) 4634 #endif // defined(USE_AURA)
4558 4635
4559 // Ensure that a cross-process subframe can receive keyboard events when in 4636 // Ensure that a cross-process subframe can receive keyboard events when in
4560 // focus. 4637 // focus.
4561 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4638 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4562 SubframeKeyboardEventRouting) { 4639 SubframeKeyboardEventRouting) {
4563 GURL main_url(embedded_test_server()->GetURL( 4640 GURL main_url(embedded_test_server()->GetURL(
4564 "a.com", "/frame_tree/page_with_one_frame.html")); 4641 "a.com", "/frame_tree/page_with_one_frame.html"));
4565 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4642 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4566 4643
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
5474 5551
5475 // Force the renderer to generate a new frame. 5552 // Force the renderer to generate a new frame.
5476 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), 5553 EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
5477 "document.body.style.background = 'black'")); 5554 "document.body.style.background = 'black'"));
5478 5555
5479 // Waits for the next frame. 5556 // Waits for the next frame.
5480 observer->Wait(); 5557 observer->Wait();
5481 } 5558 }
5482 5559
5483 } // namespace content 5560 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698