| OLD | NEW |
| 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 10 matching lines...) Expand all Loading... |
| 21 #include "base/path_service.h" | 21 #include "base/path_service.h" |
| 22 #include "base/sequenced_task_runner.h" | 22 #include "base/sequenced_task_runner.h" |
| 23 #include "base/single_thread_task_runner.h" | 23 #include "base/single_thread_task_runner.h" |
| 24 #include "base/strings/pattern.h" | 24 #include "base/strings/pattern.h" |
| 25 #include "base/strings/stringprintf.h" | 25 #include "base/strings/stringprintf.h" |
| 26 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 27 #include "base/test/test_timeouts.h" | 27 #include "base/test/test_timeouts.h" |
| 28 #include "base/threading/sequenced_task_runner_handle.h" | 28 #include "base/threading/sequenced_task_runner_handle.h" |
| 29 #include "base/threading/thread_task_runner_handle.h" | 29 #include "base/threading/thread_task_runner_handle.h" |
| 30 #include "build/build_config.h" | 30 #include "build/build_config.h" |
| 31 #include "cc/input/touch_action.h" |
| 31 #include "content/browser/frame_host/cross_process_frame_connector.h" | 32 #include "content/browser/frame_host/cross_process_frame_connector.h" |
| 32 #include "content/browser/frame_host/frame_navigation_entry.h" | 33 #include "content/browser/frame_host/frame_navigation_entry.h" |
| 33 #include "content/browser/frame_host/frame_tree.h" | 34 #include "content/browser/frame_host/frame_tree.h" |
| 34 #include "content/browser/frame_host/interstitial_page_impl.h" | 35 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 35 #include "content/browser/frame_host/navigation_controller_impl.h" | 36 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 36 #include "content/browser/frame_host/navigation_entry_impl.h" | 37 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 37 #include "content/browser/frame_host/navigator.h" | 38 #include "content/browser/frame_host/navigator.h" |
| 38 #include "content/browser/frame_host/render_frame_proxy_host.h" | 39 #include "content/browser/frame_host/render_frame_proxy_host.h" |
| 39 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 40 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
| 40 #include "content/browser/gpu/compositor_util.h" | 41 #include "content/browser/gpu/compositor_util.h" |
| 41 #include "content/browser/loader/navigation_url_loader_network_service.h" | 42 #include "content/browser/loader/navigation_url_loader_network_service.h" |
| 42 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 43 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 43 #include "content/browser/renderer_host/input/input_router_impl.h" | 44 #include "content/browser/renderer_host/input/input_router_impl.h" |
| 44 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h" | 45 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h" |
| 45 #include "content/browser/renderer_host/render_view_host_impl.h" | 46 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 46 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" | 47 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
| 47 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 48 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 48 #include "content/browser/web_contents/web_contents_impl.h" | 49 #include "content/browser/web_contents/web_contents_impl.h" |
| 49 #include "content/common/child_process_messages.h" | 50 #include "content/common/child_process_messages.h" |
| 50 #include "content/common/frame_messages.h" | 51 #include "content/common/frame_messages.h" |
| 51 #include "content/common/input/synthetic_tap_gesture_params.h" | 52 #include "content/common/input/synthetic_tap_gesture_params.h" |
| 52 #include "content/common/input/touch_action.h" | |
| 53 #include "content/common/input_messages.h" | 53 #include "content/common/input_messages.h" |
| 54 #include "content/common/renderer.mojom.h" | 54 #include "content/common/renderer.mojom.h" |
| 55 #include "content/common/view_messages.h" | 55 #include "content/common/view_messages.h" |
| 56 #include "content/public/browser/browser_thread.h" | 56 #include "content/public/browser/browser_thread.h" |
| 57 #include "content/public/browser/interstitial_page_delegate.h" | 57 #include "content/public/browser/interstitial_page_delegate.h" |
| 58 #include "content/public/browser/navigation_handle.h" | 58 #include "content/public/browser/navigation_handle.h" |
| 59 #include "content/public/browser/notification_observer.h" | 59 #include "content/public/browser/notification_observer.h" |
| 60 #include "content/public/browser/notification_service.h" | 60 #include "content/public/browser/notification_service.h" |
| 61 #include "content/public/browser/notification_types.h" | 61 #include "content/public/browser/notification_types.h" |
| 62 #include "content/public/browser/resource_dispatcher_host.h" | 62 #include "content/public/browser/resource_dispatcher_host.h" |
| (...skipping 5725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5788 embedded_test_server()->GetURL("b.com", "/page_with_touch_handler.html")); | 5788 embedded_test_server()->GetURL("b.com", "/page_with_touch_handler.html")); |
| 5789 NavigateFrameToURL(root->child_at(0), frame_url); | 5789 NavigateFrameToURL(root->child_at(0), frame_url); |
| 5790 | 5790 |
| 5791 // Synchronize with the child and parent renderers to guarantee that the | 5791 // Synchronize with the child and parent renderers to guarantee that the |
| 5792 // surface information required for event hit testing is ready. | 5792 // surface information required for event hit testing is ready. |
| 5793 WaitForChildFrameSurfaceReady(root->child_at(0)->current_frame_host()); | 5793 WaitForChildFrameSurfaceReady(root->child_at(0)->current_frame_host()); |
| 5794 | 5794 |
| 5795 // There's no intrinsic reason the following values can't be equal, but they | 5795 // There's no intrinsic reason the following values can't be equal, but they |
| 5796 // aren't at present, and if they become the same this test will need to be | 5796 // aren't at present, and if they become the same this test will need to be |
| 5797 // updated to accommodate. | 5797 // updated to accommodate. |
| 5798 EXPECT_NE(TOUCH_ACTION_AUTO, TOUCH_ACTION_NONE); | 5798 EXPECT_NE(cc::kTouchActionAuto, cc::kTouchActionNone); |
| 5799 | 5799 |
| 5800 // Verify the child's input router is initially set for TOUCH_ACTION_AUTO. The | 5800 // Verify the child's input router is initially set for kTouchActionAuto. The |
| 5801 // TouchStart event will trigger TOUCH_ACTION_NONE being sent back to the | 5801 // TouchStart event will trigger kTouchActionNone being sent back to the |
| 5802 // browser. | 5802 // browser. |
| 5803 RenderWidgetHostImpl* child_render_widget_host = | 5803 RenderWidgetHostImpl* child_render_widget_host = |
| 5804 root->child_at(0)->current_frame_host()->GetRenderWidgetHost(); | 5804 root->child_at(0)->current_frame_host()->GetRenderWidgetHost(); |
| 5805 InputRouterImpl* child_input_router = | 5805 InputRouterImpl* child_input_router = |
| 5806 static_cast<InputRouterImpl*>(child_render_widget_host->input_router()); | 5806 static_cast<InputRouterImpl*>(child_render_widget_host->input_router()); |
| 5807 EXPECT_EQ(TOUCH_ACTION_AUTO, | 5807 EXPECT_EQ(cc::kTouchActionAuto, |
| 5808 child_input_router->touch_action_filter_.allowed_touch_action()); | 5808 child_input_router->touch_action_filter_.allowed_touch_action()); |
| 5809 | 5809 |
| 5810 // Simulate touch event to sub-frame. | 5810 // Simulate touch event to sub-frame. |
| 5811 gfx::Point child_center(150, 150); | 5811 gfx::Point child_center(150, 150); |
| 5812 auto* rwhv = static_cast<RenderWidgetHostViewAura*>( | 5812 auto* rwhv = static_cast<RenderWidgetHostViewAura*>( |
| 5813 contents->GetRenderWidgetHostView()); | 5813 contents->GetRenderWidgetHostView()); |
| 5814 | 5814 |
| 5815 // Wait until renderer's compositor thread is synced. | 5815 // Wait until renderer's compositor thread is synced. |
| 5816 { | 5816 { |
| 5817 MainThreadFrameObserver observer(child_render_widget_host); | 5817 MainThreadFrameObserver observer(child_render_widget_host); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5833 | 5833 |
| 5834 // Verify touch handler in subframe was invoked. | 5834 // Verify touch handler in subframe was invoked. |
| 5835 std::string result; | 5835 std::string result; |
| 5836 EXPECT_TRUE(ExecuteScriptAndExtractString( | 5836 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 5837 root->child_at(0), | 5837 root->child_at(0), |
| 5838 "window.domAutomationController.send(getLastTouchEvent());", &result)); | 5838 "window.domAutomationController.send(getLastTouchEvent());", &result)); |
| 5839 EXPECT_EQ("touchstart", result); | 5839 EXPECT_EQ("touchstart", result); |
| 5840 | 5840 |
| 5841 // Verify the presence of the touch handler in the child frame correctly | 5841 // Verify the presence of the touch handler in the child frame correctly |
| 5842 // propagates touch-action:none information back to the child's input router. | 5842 // propagates touch-action:none information back to the child's input router. |
| 5843 EXPECT_EQ(TOUCH_ACTION_NONE, | 5843 EXPECT_EQ(cc::kTouchActionNone, |
| 5844 child_input_router->touch_action_filter_.allowed_touch_action()); | 5844 child_input_router->touch_action_filter_.allowed_touch_action()); |
| 5845 } | 5845 } |
| 5846 | 5846 |
| 5847 // This test verifies that the test in | 5847 // This test verifies that the test in |
| 5848 // SitePerProcessBrowserTest.SubframeTouchEventRouting also works properly for | 5848 // SitePerProcessBrowserTest.SubframeTouchEventRouting also works properly for |
| 5849 // the main frame. Prior to the CL in which this test is introduced, use of | 5849 // the main frame. Prior to the CL in which this test is introduced, use of |
| 5850 // MainThreadFrameObserver in SubframeTouchEventRouting was not necessary since | 5850 // MainThreadFrameObserver in SubframeTouchEventRouting was not necessary since |
| 5851 // the touch events were handled on the main thread. Now they are handled on the | 5851 // the touch events were handled on the main thread. Now they are handled on the |
| 5852 // compositor thread, hence the need to synchronize. | 5852 // compositor thread, hence the need to synchronize. |
| 5853 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 5853 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 5854 MainframeTouchEventRouting) { | 5854 MainframeTouchEventRouting) { |
| 5855 GURL main_url(embedded_test_server()->GetURL( | 5855 GURL main_url(embedded_test_server()->GetURL( |
| 5856 "/page_with_touch_handler.html")); | 5856 "/page_with_touch_handler.html")); |
| 5857 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 5857 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 5858 | 5858 |
| 5859 WebContentsImpl* contents = web_contents(); | 5859 WebContentsImpl* contents = web_contents(); |
| 5860 FrameTreeNode* root = contents->GetFrameTree()->root(); | 5860 FrameTreeNode* root = contents->GetFrameTree()->root(); |
| 5861 | 5861 |
| 5862 // Synchronize with the renderers to guarantee that the | 5862 // Synchronize with the renderers to guarantee that the |
| 5863 // surface information required for event hit testing is ready. | 5863 // surface information required for event hit testing is ready. |
| 5864 auto* rwhv = static_cast<RenderWidgetHostViewAura*>( | 5864 auto* rwhv = static_cast<RenderWidgetHostViewAura*>( |
| 5865 contents->GetRenderWidgetHostView()); | 5865 contents->GetRenderWidgetHostView()); |
| 5866 | 5866 |
| 5867 // There's no intrinsic reason the following values can't be equal, but they | 5867 // There's no intrinsic reason the following values can't be equal, but they |
| 5868 // aren't at present, and if they become the same this test will need to be | 5868 // aren't at present, and if they become the same this test will need to be |
| 5869 // updated to accommodate. | 5869 // updated to accommodate. |
| 5870 EXPECT_NE(TOUCH_ACTION_AUTO, TOUCH_ACTION_NONE); | 5870 EXPECT_NE(cc::kTouchActionAuto, cc::kTouchActionNone); |
| 5871 | 5871 |
| 5872 // Verify the main frame's input router is initially set for | 5872 // Verify the main frame's input router is initially set for |
| 5873 // TOUCH_ACTION_AUTO. The | 5873 // kTouchActionAuto. The |
| 5874 // TouchStart event will trigger TOUCH_ACTION_NONE being sent back to the | 5874 // TouchStart event will trigger kTouchActionNone being sent back to the |
| 5875 // browser. | 5875 // browser. |
| 5876 RenderWidgetHostImpl* render_widget_host = | 5876 RenderWidgetHostImpl* render_widget_host = |
| 5877 root->current_frame_host()->GetRenderWidgetHost(); | 5877 root->current_frame_host()->GetRenderWidgetHost(); |
| 5878 InputRouterImpl* input_router = | 5878 InputRouterImpl* input_router = |
| 5879 static_cast<InputRouterImpl*>(render_widget_host->input_router()); | 5879 static_cast<InputRouterImpl*>(render_widget_host->input_router()); |
| 5880 EXPECT_EQ(TOUCH_ACTION_AUTO, | 5880 EXPECT_EQ(cc::kTouchActionAuto, |
| 5881 input_router->touch_action_filter_.allowed_touch_action()); | 5881 input_router->touch_action_filter_.allowed_touch_action()); |
| 5882 | 5882 |
| 5883 // Simulate touch event to sub-frame. | 5883 // Simulate touch event to sub-frame. |
| 5884 gfx::Point frame_center(150, 150); | 5884 gfx::Point frame_center(150, 150); |
| 5885 | 5885 |
| 5886 // Wait until renderer's compositor thread is synced. | 5886 // Wait until renderer's compositor thread is synced. |
| 5887 { | 5887 { |
| 5888 auto observer = | 5888 auto observer = |
| 5889 base::MakeUnique<MainThreadFrameObserver>(render_widget_host); | 5889 base::MakeUnique<MainThreadFrameObserver>(render_widget_host); |
| 5890 observer->Wait(); | 5890 observer->Wait(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5906 | 5906 |
| 5907 // Verify touch handler in subframe was invoked. | 5907 // Verify touch handler in subframe was invoked. |
| 5908 std::string result; | 5908 std::string result; |
| 5909 EXPECT_TRUE(ExecuteScriptAndExtractString( | 5909 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 5910 root, "window.domAutomationController.send(getLastTouchEvent());", | 5910 root, "window.domAutomationController.send(getLastTouchEvent());", |
| 5911 &result)); | 5911 &result)); |
| 5912 EXPECT_EQ("touchstart", result); | 5912 EXPECT_EQ("touchstart", result); |
| 5913 | 5913 |
| 5914 // Verify the presence of the touch handler in the child frame correctly | 5914 // Verify the presence of the touch handler in the child frame correctly |
| 5915 // propagates touch-action:none information back to the child's input router. | 5915 // propagates touch-action:none information back to the child's input router. |
| 5916 EXPECT_EQ(TOUCH_ACTION_NONE, | 5916 EXPECT_EQ(cc::kTouchActionNone, |
| 5917 input_router->touch_action_filter_.allowed_touch_action()); | 5917 input_router->touch_action_filter_.allowed_touch_action()); |
| 5918 } | 5918 } |
| 5919 | 5919 |
| 5920 namespace { | 5920 namespace { |
| 5921 | 5921 |
| 5922 // Declared here to be close to the SubframeGestureEventRouting test. | 5922 // Declared here to be close to the SubframeGestureEventRouting test. |
| 5923 void OnSyntheticGestureCompleted(scoped_refptr<MessageLoopRunner> runner, | 5923 void OnSyntheticGestureCompleted(scoped_refptr<MessageLoopRunner> runner, |
| 5924 SyntheticGesture::Result result) { | 5924 SyntheticGesture::Result result) { |
| 5925 EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result); | 5925 EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result); |
| 5926 runner->Quit(); | 5926 runner->Quit(); |
| (...skipping 4240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10167 names.insert(root->children[0]->frame_entry->frame_unique_name()); | 10167 names.insert(root->children[0]->frame_entry->frame_unique_name()); |
| 10168 } | 10168 } |
| 10169 | 10169 |
| 10170 // More than one entry in the set means that the subframe frame navigation | 10170 // More than one entry in the set means that the subframe frame navigation |
| 10171 // entries didn't have a consistent unique name. This will break history | 10171 // entries didn't have a consistent unique name. This will break history |
| 10172 // navigations =( | 10172 // navigations =( |
| 10173 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; | 10173 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; |
| 10174 } | 10174 } |
| 10175 | 10175 |
| 10176 } // namespace content | 10176 } // namespace content |
| OLD | NEW |