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 13 matching lines...) Expand all Loading... | |
24 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
26 #include "content/browser/frame_host/cross_process_frame_connector.h" | 26 #include "content/browser/frame_host/cross_process_frame_connector.h" |
27 #include "content/browser/frame_host/frame_tree.h" | 27 #include "content/browser/frame_host/frame_tree.h" |
28 #include "content/browser/frame_host/interstitial_page_impl.h" | 28 #include "content/browser/frame_host/interstitial_page_impl.h" |
29 #include "content/browser/frame_host/navigator.h" | 29 #include "content/browser/frame_host/navigator.h" |
30 #include "content/browser/frame_host/render_frame_proxy_host.h" | 30 #include "content/browser/frame_host/render_frame_proxy_host.h" |
31 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 31 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
32 #include "content/browser/gpu/compositor_util.h" | 32 #include "content/browser/gpu/compositor_util.h" |
33 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 33 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
34 #include "content/browser/renderer_host/input/input_router_impl.h" | |
34 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h" | 35 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h" |
35 #include "content/browser/renderer_host/render_view_host_impl.h" | 36 #include "content/browser/renderer_host/render_view_host_impl.h" |
36 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" | 37 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
37 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 38 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
38 #include "content/browser/web_contents/web_contents_impl.h" | 39 #include "content/browser/web_contents/web_contents_impl.h" |
39 #include "content/common/child_process_messages.h" | 40 #include "content/common/child_process_messages.h" |
40 #include "content/common/frame_messages.h" | 41 #include "content/common/frame_messages.h" |
41 #include "content/common/input/synthetic_tap_gesture_params.h" | 42 #include "content/common/input/synthetic_tap_gesture_params.h" |
43 #include "content/common/input/touch_action.h" | |
42 #include "content/common/input_messages.h" | 44 #include "content/common/input_messages.h" |
43 #include "content/common/renderer.mojom.h" | 45 #include "content/common/renderer.mojom.h" |
44 #include "content/common/view_messages.h" | 46 #include "content/common/view_messages.h" |
45 #include "content/public/browser/interstitial_page_delegate.h" | 47 #include "content/public/browser/interstitial_page_delegate.h" |
46 #include "content/public/browser/navigation_handle.h" | 48 #include "content/public/browser/navigation_handle.h" |
47 #include "content/public/browser/notification_observer.h" | 49 #include "content/public/browser/notification_observer.h" |
48 #include "content/public/browser/notification_service.h" | 50 #include "content/public/browser/notification_service.h" |
49 #include "content/public/browser/notification_types.h" | 51 #include "content/public/browser/notification_types.h" |
50 #include "content/public/browser/resource_dispatcher_host.h" | 52 #include "content/public/browser/resource_dispatcher_host.h" |
51 #include "content/public/common/browser_side_navigation_policy.h" | 53 #include "content/public/common/browser_side_navigation_policy.h" |
(...skipping 5293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5345 // Use new window to navigate main window. | 5347 // Use new window to navigate main window. |
5346 std::string script = | 5348 std::string script = |
5347 "window.opener.location.href = '" + cross_url.spec() + "'"; | 5349 "window.opener.location.href = '" + cross_url.spec() + "'"; |
5348 EXPECT_TRUE(ExecuteScript(popup, script)); | 5350 EXPECT_TRUE(ExecuteScript(popup, script)); |
5349 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 5351 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
5350 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), cross_url); | 5352 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), cross_url); |
5351 } | 5353 } |
5352 | 5354 |
5353 // Ensure that a cross-process subframe with a touch-handler can receive touch | 5355 // Ensure that a cross-process subframe with a touch-handler can receive touch |
5354 // events. | 5356 // events. |
5355 #if defined(USE_AURA) | 5357 #if defined(USE_AURA) |
Charlie Reis
2017/01/13 21:37:17
Just checking-- are you ok with your new test bein
wjmaclean
2017/01/13 21:59:22
I think so ... the existing touch-test is Aura onl
| |
5356 // Browser process hit testing is not implemented on Android, and this test | 5358 // Browser process hit testing is not implemented on Android, and this test |
5357 // requires Aura for RenderWidgetHostViewAura::OnTouchEvent(). | 5359 // requires Aura for RenderWidgetHostViewAura::OnTouchEvent(). |
5358 // https://crbug.com/491334 | 5360 // https://crbug.com/491334 |
5359 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 5361 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
5360 SubframeTouchEventRouting) { | 5362 SubframeTouchEventRouting) { |
5361 GURL main_url(embedded_test_server()->GetURL( | 5363 GURL main_url(embedded_test_server()->GetURL( |
5362 "/frame_tree/page_with_positioned_nested_frames.html")); | 5364 "/frame_tree/page_with_positioned_nested_frames.html")); |
5363 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 5365 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
5364 | 5366 |
5365 WebContentsImpl* contents = web_contents(); | 5367 WebContentsImpl* contents = web_contents(); |
5366 FrameTreeNode* root = contents->GetFrameTree()->root(); | 5368 FrameTreeNode* root = contents->GetFrameTree()->root(); |
5367 ASSERT_EQ(1U, root->child_count()); | 5369 ASSERT_EQ(1U, root->child_count()); |
5368 | 5370 |
5369 GURL frame_url( | 5371 GURL frame_url( |
5370 embedded_test_server()->GetURL("b.com", "/page_with_touch_handler.html")); | 5372 embedded_test_server()->GetURL("b.com", "/page_with_touch_handler.html")); |
5371 NavigateFrameToURL(root->child_at(0), frame_url); | 5373 NavigateFrameToURL(root->child_at(0), frame_url); |
5372 | 5374 |
5373 // Synchronize with the child and parent renderers to guarantee that the | 5375 // Synchronize with the child and parent renderers to guarantee that the |
5374 // surface information required for event hit testing is ready. | 5376 // surface information required for event hit testing is ready. |
5375 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>( | 5377 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>( |
5376 root->child_at(0)->current_frame_host()->GetView()); | 5378 root->child_at(0)->current_frame_host()->GetView()); |
5377 SurfaceHitTestReadyNotifier notifier( | 5379 SurfaceHitTestReadyNotifier notifier( |
5378 static_cast<RenderWidgetHostViewChildFrame*>(child_rwhv)); | 5380 static_cast<RenderWidgetHostViewChildFrame*>(child_rwhv)); |
5379 notifier.WaitForSurfaceReady(); | 5381 notifier.WaitForSurfaceReady(); |
5380 | 5382 |
5383 // There's no intrinsic reason the following values can't be equal, but they | |
5384 // aren't at present, and if they become the same this test will need to be | |
5385 // updated to accommodate. | |
5386 EXPECT_NE(TOUCH_ACTION_AUTO, TOUCH_ACTION_NONE); | |
Charlie Reis
2017/01/13 21:37:17
nit: Add blank line after.
wjmaclean
2017/01/13 21:59:22
Done.
| |
5387 // Verify the child's input router is initially set for TOUCH_ACTION_AUTO. The | |
5388 // TouchStart event will trigger TOUCH_ACTION_NONE being sent back to the | |
5389 // browser. | |
5390 RenderWidgetHostImpl* child_render_widget_host = | |
5391 root->child_at(0)->current_frame_host()->GetRenderWidgetHost(); | |
5392 InputRouterImpl* child_input_router = | |
5393 static_cast<InputRouterImpl*>(child_render_widget_host->input_router()); | |
5394 EXPECT_EQ(TOUCH_ACTION_AUTO, child_input_router->allowed_touch_action()); | |
5395 | |
5381 // Simulate touch event to sub-frame. | 5396 // Simulate touch event to sub-frame. |
5382 gfx::Point child_center(150, 150); | 5397 gfx::Point child_center(150, 150); |
5383 auto* rwhv = static_cast<RenderWidgetHostViewAura*>( | 5398 auto* rwhv = static_cast<RenderWidgetHostViewAura*>( |
5384 contents->GetRenderWidgetHostView()); | 5399 contents->GetRenderWidgetHostView()); |
5385 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0, | 5400 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0, |
5386 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f); | 5401 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f); |
5387 rwhv->OnTouchEvent(&touch_event); | 5402 rwhv->OnTouchEvent(&touch_event); |
5388 | 5403 |
5389 // Verify touch handler in subframe was invoked | 5404 // Verify touch handler in subframe was invoked |
5390 std::string result; | 5405 std::string result; |
5391 EXPECT_TRUE(ExecuteScriptAndExtractString( | 5406 EXPECT_TRUE(ExecuteScriptAndExtractString( |
5392 root->child_at(0), | 5407 root->child_at(0), |
5393 "window.domAutomationController.send(getLastTouchEvent());", &result)); | 5408 "window.domAutomationController.send(getLastTouchEvent());", &result)); |
5394 EXPECT_EQ("touchstart", result); | 5409 EXPECT_EQ("touchstart", result); |
5410 | |
5411 // Verify the presence of the touch handler in the child frame correctly | |
5412 // propagates touch-action:none information back to the child's input router. | |
5413 EXPECT_EQ(TOUCH_ACTION_NONE, child_input_router->allowed_touch_action()); | |
5395 } | 5414 } |
5396 | 5415 |
5397 namespace { | 5416 namespace { |
5398 | 5417 |
5399 // Declared here to be close to the SubframeGestureEventRouting test. | 5418 // Declared here to be close to the SubframeGestureEventRouting test. |
5400 void OnSyntheticGestureCompleted(scoped_refptr<MessageLoopRunner> runner, | 5419 void OnSyntheticGestureCompleted(scoped_refptr<MessageLoopRunner> runner, |
5401 SyntheticGesture::Result result) { | 5420 SyntheticGesture::Result result) { |
5402 EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result); | 5421 EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result); |
5403 runner->Quit(); | 5422 runner->Quit(); |
5404 } | 5423 } |
(...skipping 3635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9040 | 9059 |
9041 std::string result; | 9060 std::string result; |
9042 EXPECT_TRUE(ExecuteScriptAndExtractString( | 9061 EXPECT_TRUE(ExecuteScriptAndExtractString( |
9043 root, | 9062 root, |
9044 "window.domAutomationController.send(frames[0].document.body.innerText);", | 9063 "window.domAutomationController.send(frames[0].document.body.innerText);", |
9045 &result)); | 9064 &result)); |
9046 EXPECT_EQ("This page has no title.", result); | 9065 EXPECT_EQ("This page has no title.", result); |
9047 } | 9066 } |
9048 | 9067 |
9049 } // namespace content | 9068 } // namespace content |
OLD | NEW |