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

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 nits, convert test to use positioned iframe. 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 EXPECT_TRUE(WaitForRenderFrameReady(root->child_at(0)->current_frame_host()));
4587
4588 // Synchronize with the child and parent renderers to guarantee that the
4589 // surface information required for event hit testing is ready.
4590 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>(
4591 root->child_at(0)->current_frame_host()->GetView());
4592 SurfaceHitTestReadyNotifier notifier(
4593 static_cast<RenderWidgetHostViewChildFrame*>(child_rwhv));
4594 notifier.WaitForSurfaceReady();
4595
4596 // There have been no GestureTaps sent yet.
4597 {
4598 std::string result;
4599 EXPECT_TRUE(ExecuteScriptAndExtractString(
4600 root->child_at(0)->current_frame_host(),
tdresser 2016/03/02 17:54:43 It would likely make sense to cache the current_fr
wjmaclean 2016/03/02 18:33:40 Done.
4601 "window.domAutomationController.send(getClickStatus());", &result));
4602 EXPECT_EQ("0 clicks received", result);
4603 }
4604
4605 // Simulate touch sequence to send GestureTap to sub-frame.
4606 SyntheticTapGestureParams params;
4607 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
4608 gfx::Point center(150, 150);
4609 params.position = gfx::PointF(center.x(), center.y());
4610 params.duration_ms = 100;
4611 scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params));
4612
4613 scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner();
4614
4615 RenderWidgetHostImpl* render_widget_host =
4616 root->current_frame_host()->GetRenderWidgetHost();
4617 //TODO(wjmaclean): Convert the call to base::Bind() to a lambda someday.
4618 render_widget_host->QueueSyntheticGesture(
4619 std::move(gesture), base::Bind(OnSyntheticGestureCompleted, runner));
4620
4621 runner->Run();
4622 runner = nullptr;
4623
4624 // Verify click handler in subframe was invoked
4625 {
4626 std::string result;
4627 EXPECT_TRUE(ExecuteScriptAndExtractString(
4628 root->child_at(0)->current_frame_host(),
4629 "window.domAutomationController.send(getClickStatus());", &result));
4630 EXPECT_EQ("1 clicks received", result);
4631 }
4632 }
4557 #endif // defined(USE_AURA) 4633 #endif // defined(USE_AURA)
4558 4634
4559 // Ensure that a cross-process subframe can receive keyboard events when in 4635 // Ensure that a cross-process subframe can receive keyboard events when in
4560 // focus. 4636 // focus.
4561 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4637 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4562 SubframeKeyboardEventRouting) { 4638 SubframeKeyboardEventRouting) {
4563 GURL main_url(embedded_test_server()->GetURL( 4639 GURL main_url(embedded_test_server()->GetURL(
4564 "a.com", "/frame_tree/page_with_one_frame.html")); 4640 "a.com", "/frame_tree/page_with_one_frame.html"));
4565 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4641 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4566 4642
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
5474 5550
5475 // Force the renderer to generate a new frame. 5551 // Force the renderer to generate a new frame.
5476 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), 5552 EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
5477 "document.body.style.background = 'black'")); 5553 "document.body.style.background = 'black'"));
5478 5554
5479 // Waits for the next frame. 5555 // Waits for the next frame.
5480 observer->Wait(); 5556 observer->Wait();
5481 } 5557 }
5482 5558
5483 } // namespace content 5559 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698