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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 events_received_.push_back(event.type()); | 228 events_received_.push_back(event.type()); |
229 }; | 229 }; |
230 | 230 |
231 private: | 231 private: |
232 RenderWidgetHost* host_; | 232 RenderWidgetHost* host_; |
233 std::vector<blink::WebInputEvent::Type> events_received_; | 233 std::vector<blink::WebInputEvent::Type> events_received_; |
234 | 234 |
235 DISALLOW_COPY_AND_ASSIGN(TestInputEventObserver); | 235 DISALLOW_COPY_AND_ASSIGN(TestInputEventObserver); |
236 }; | 236 }; |
237 | 237 |
238 double GetFrameDeviceScaleFactor(const ToRenderFrameHost& adapter) { | |
239 double device_scale_factor; | |
240 const char kGetFrameDeviceScaleFactor[] = | |
241 "window.domAutomationController.send(window.devicePixelRatio);"; | |
242 EXPECT_TRUE(ExecuteScriptAndExtractDouble(adapter, kGetFrameDeviceScaleFactor, | |
243 &device_scale_factor)); | |
244 return device_scale_factor; | |
245 } | |
246 | |
238 // Helper function that performs a surface hittest. | 247 // Helper function that performs a surface hittest. |
239 void SurfaceHitTestTestHelper( | 248 void SurfaceHitTestTestHelper( |
240 Shell* shell, | 249 Shell* shell, |
241 net::test_server::EmbeddedTestServer* embedded_test_server) { | 250 net::test_server::EmbeddedTestServer* embedded_test_server) { |
242 GURL main_url(embedded_test_server->GetURL( | 251 GURL main_url(embedded_test_server->GetURL( |
243 "/frame_tree/page_with_positioned_frame.html")); | 252 "/frame_tree/page_with_positioned_frame.html")); |
244 EXPECT_TRUE(NavigateToURL(shell, main_url)); | 253 EXPECT_TRUE(NavigateToURL(shell, main_url)); |
245 | 254 |
246 // It is safe to obtain the root frame tree node here, as it doesn't change. | 255 // It is safe to obtain the root frame tree node here, as it doesn't change. |
247 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell->web_contents()) | 256 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell->web_contents()) |
(...skipping 19 matching lines...) Expand all Loading... | |
267 | 276 |
268 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( | 277 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( |
269 root->current_frame_host()->GetRenderWidgetHost()->GetView()); | 278 root->current_frame_host()->GetRenderWidgetHost()->GetView()); |
270 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( | 279 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( |
271 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); | 280 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); |
272 | 281 |
273 SurfaceHitTestReadyNotifier notifier( | 282 SurfaceHitTestReadyNotifier notifier( |
274 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); | 283 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); |
275 notifier.WaitForSurfaceReady(); | 284 notifier.WaitForSurfaceReady(); |
276 | 285 |
286 #if defined(OS_ANDROID) | |
287 float scale_factor = GetFrameDeviceScaleFactor(shell->web_contents()); | |
alexmos
2017/03/06 07:22:03
Just curious, what values would this actually retu
kenrb
2017/03/07 19:20:20
It is always 3, in my testing.
| |
288 #else | |
289 float scale_factor = 1.0; | |
290 #endif | |
291 | |
292 // Get the view bounds of the child iframe, which should account for the | |
293 // relative offset of its direct parent within the root frame, for use in | |
294 // targeting the input event. | |
295 gfx::Rect bounds = rwhv_child->GetViewBounds(); | |
296 | |
277 // Target input event to child frame. | 297 // Target input event to child frame. |
278 blink::WebMouseEvent child_event(blink::WebInputEvent::MouseDown, | 298 blink::WebMouseEvent child_event(blink::WebInputEvent::MouseDown, |
279 blink::WebInputEvent::NoModifiers, | 299 blink::WebInputEvent::NoModifiers, |
280 blink::WebInputEvent::TimeStampForTesting); | 300 blink::WebInputEvent::TimeStampForTesting); |
281 child_event.button = blink::WebPointerProperties::Button::Left; | 301 child_event.button = blink::WebPointerProperties::Button::Left; |
282 child_event.x = 75; | 302 child_event.x = |
283 child_event.y = 75; | 303 gfx::ToCeiledInt((bounds.x() - root_view->GetViewBounds().x()) / |
304 scale_factor) + | |
305 3; | |
306 child_event.y = | |
307 gfx::ToCeiledInt((bounds.y() - root_view->GetViewBounds().y()) / | |
308 scale_factor) + | |
309 3; | |
284 child_event.clickCount = 1; | 310 child_event.clickCount = 1; |
285 main_frame_monitor.ResetEventReceived(); | 311 main_frame_monitor.ResetEventReceived(); |
286 child_frame_monitor.ResetEventReceived(); | 312 child_frame_monitor.ResetEventReceived(); |
287 router->RouteMouseEvent(root_view, &child_event, ui::LatencyInfo()); | 313 router->RouteMouseEvent(root_view, &child_event, ui::LatencyInfo()); |
288 | 314 |
289 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); | 315 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); |
290 EXPECT_EQ(23, child_frame_monitor.event().x); | 316 // The expected result coordinates are (3, 3), but can get slightly |
291 EXPECT_EQ(23, child_frame_monitor.event().y); | 317 // different results due to rounding error with some device scale factors. |
318 EXPECT_TRUE(child_frame_monitor.event().x <= 5 && | |
319 child_frame_monitor.event().x >= 1); | |
320 EXPECT_TRUE(child_frame_monitor.event().y <= 5 && | |
321 child_frame_monitor.event().y >= 1); | |
292 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); | 322 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); |
293 | 323 |
294 child_frame_monitor.ResetEventReceived(); | 324 child_frame_monitor.ResetEventReceived(); |
295 main_frame_monitor.ResetEventReceived(); | 325 main_frame_monitor.ResetEventReceived(); |
296 | 326 |
297 // Target input event to main frame. | 327 // Target input event to main frame. |
298 blink::WebMouseEvent main_event(blink::WebInputEvent::MouseDown, | 328 blink::WebMouseEvent main_event(blink::WebInputEvent::MouseDown, |
299 blink::WebInputEvent::NoModifiers, | 329 blink::WebInputEvent::NoModifiers, |
300 blink::WebInputEvent::TimeStampForTesting); | 330 blink::WebInputEvent::TimeStampForTesting); |
301 main_event.button = blink::WebPointerProperties::Button::Left; | 331 main_event.button = blink::WebPointerProperties::Button::Left; |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
699 }; | 729 }; |
700 | 730 |
701 bool operator==(const ParsedFeaturePolicyDeclaration& first, | 731 bool operator==(const ParsedFeaturePolicyDeclaration& first, |
702 const ParsedFeaturePolicyDeclaration& second) { | 732 const ParsedFeaturePolicyDeclaration& second) { |
703 return std::tie(first.feature_name, first.matches_all_origins, | 733 return std::tie(first.feature_name, first.matches_all_origins, |
704 first.origins) == std::tie(second.feature_name, | 734 first.origins) == std::tie(second.feature_name, |
705 second.matches_all_origins, | 735 second.matches_all_origins, |
706 second.origins); | 736 second.origins); |
707 } | 737 } |
708 | 738 |
709 double GetFrameDeviceScaleFactor(const ToRenderFrameHost& adapter) { | |
710 double device_scale_factor; | |
711 const char kGetFrameDeviceScaleFactor[] = | |
712 "window.domAutomationController.send(window.devicePixelRatio);"; | |
713 EXPECT_TRUE(ExecuteScriptAndExtractDouble(adapter, kGetFrameDeviceScaleFactor, | |
714 &device_scale_factor)); | |
715 return device_scale_factor; | |
716 } | |
717 | |
718 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest, | 739 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest, |
719 SubframeLoadsWithCorrectDeviceScaleFactor) { | 740 SubframeLoadsWithCorrectDeviceScaleFactor) { |
720 GURL main_url(embedded_test_server()->GetURL( | 741 GURL main_url(embedded_test_server()->GetURL( |
721 "a.com", "/cross_site_iframe_factory.html?a(b)")); | 742 "a.com", "/cross_site_iframe_factory.html?a(b)")); |
722 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 743 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
723 | 744 |
724 // On Android forcing device scale factor does not work for tests, therefore | 745 // On Android forcing device scale factor does not work for tests, therefore |
725 // we ensure that make frame and iframe have the same DIP scale there, but | 746 // we ensure that make frame and iframe have the same DIP scale there, but |
726 // not necessarily kDeviceScaleFactor. | 747 // not necessarily kDeviceScaleFactor. |
727 const double expected_dip_scale = | 748 const double expected_dip_scale = |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
958 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 979 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
959 bool frame_rect_received_; | 980 bool frame_rect_received_; |
960 gfx::Rect last_rect_; | 981 gfx::Rect last_rect_; |
961 | 982 |
962 DISALLOW_COPY_AND_ASSIGN(FrameRectChangedMessageFilter); | 983 DISALLOW_COPY_AND_ASSIGN(FrameRectChangedMessageFilter); |
963 }; | 984 }; |
964 | 985 |
965 // Test that the view bounds for an out-of-process iframe are set and updated | 986 // Test that the view bounds for an out-of-process iframe are set and updated |
966 // correctly, including accounting for local frame offsets in the parent and | 987 // correctly, including accounting for local frame offsets in the parent and |
967 // scroll positions. | 988 // scroll positions. |
968 #if defined(OS_ANDROID) | 989 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ViewBoundsInNestedFrameTest) { |
969 // Browser process hit testing is not implemented on Android. | |
970 // https://crbug.com/491334 | |
971 #define MAYBE_ViewBoundsInNestedFrameTest DISABLED_ViewBoundsInNestedFrameTest | |
972 #else | |
973 #define MAYBE_ViewBoundsInNestedFrameTest ViewBoundsInNestedFrameTest | |
974 #endif | |
975 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
976 MAYBE_ViewBoundsInNestedFrameTest) { | |
977 GURL main_url(embedded_test_server()->GetURL( | 990 GURL main_url(embedded_test_server()->GetURL( |
978 "a.com", "/cross_site_iframe_factory.html?a(a)")); | 991 "a.com", "/cross_site_iframe_factory.html?a(a)")); |
979 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 992 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
980 | 993 |
981 // It is safe to obtain the root frame tree node here, as it doesn't change. | 994 // It is safe to obtain the root frame tree node here, as it doesn't change. |
982 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 995 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
983 ->GetFrameTree() | 996 ->GetFrameTree() |
984 ->root(); | 997 ->root(); |
985 RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>( | 998 RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>( |
986 root->current_frame_host()->GetRenderWidgetHost()->GetView()); | 999 root->current_frame_host()->GetRenderWidgetHost()->GetView()); |
(...skipping 16 matching lines...) Expand all Loading... | |
1003 RenderWidgetHostViewBase* rwhv_nested = | 1016 RenderWidgetHostViewBase* rwhv_nested = |
1004 static_cast<RenderWidgetHostViewBase*>( | 1017 static_cast<RenderWidgetHostViewBase*>( |
1005 nested_iframe_node->current_frame_host() | 1018 nested_iframe_node->current_frame_host() |
1006 ->GetRenderWidgetHost() | 1019 ->GetRenderWidgetHost() |
1007 ->GetView()); | 1020 ->GetView()); |
1008 | 1021 |
1009 SurfaceHitTestReadyNotifier notifier( | 1022 SurfaceHitTestReadyNotifier notifier( |
1010 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_nested)); | 1023 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_nested)); |
1011 notifier.WaitForSurfaceReady(); | 1024 notifier.WaitForSurfaceReady(); |
1012 | 1025 |
1026 #if defined(OS_ANDROID) | |
1027 // Android browser tests have some differences that affect the results. One | |
1028 // is viewport dimensions, the other is that it handles scale factor | |
1029 // differently. | |
1030 int expected_x = 487; | |
1031 float scale_factor = GetFrameDeviceScaleFactor(web_contents()); | |
1032 #else | |
1033 int expected_x = 397; | |
1034 float scale_factor = 1.0; | |
1035 #endif | |
1036 int expected_y = 112; | |
1037 | |
1013 // Verify the view bounds of the nested iframe, which should account for the | 1038 // Verify the view bounds of the nested iframe, which should account for the |
1014 // relative offset of its direct parent within the root frame. | 1039 // relative offset of its direct parent within the root frame. |
1015 gfx::Rect bounds = rwhv_nested->GetViewBounds(); | 1040 gfx::Rect bounds = rwhv_nested->GetViewBounds(); |
1016 EXPECT_EQ(bounds.x() - rwhv_root->GetViewBounds().x(), 397); | 1041 int diff_x = bounds.x() - rwhv_root->GetViewBounds().x() - expected_x; |
1017 EXPECT_EQ(bounds.y() - rwhv_root->GetViewBounds().y(), 112); | 1042 int diff_y = bounds.y() - rwhv_root->GetViewBounds().y() - expected_y; |
1043 // diff_x and diff_y should usually be zero, but can get slightly different | |
1044 // results due to rounding error with some device scale factors. | |
1045 EXPECT_TRUE(diff_x <= 2 && diff_x >= -2); | |
alexmos
2017/03/06 07:22:03
nit: in places like these, you could include somet
kenrb
2017/03/07 19:20:20
Done.
| |
1046 EXPECT_TRUE(diff_y <= 2 && diff_y >= -2); | |
1018 | 1047 |
1019 scoped_refptr<FrameRectChangedMessageFilter> filter = | 1048 scoped_refptr<FrameRectChangedMessageFilter> filter = |
1020 new FrameRectChangedMessageFilter(); | 1049 new FrameRectChangedMessageFilter(); |
1021 root->current_frame_host()->GetProcess()->AddFilter(filter.get()); | 1050 root->current_frame_host()->GetProcess()->AddFilter(filter.get()); |
1022 | 1051 |
1023 // Scroll the parent frame downward to verify that the child rect gets updated | 1052 // Scroll the parent frame downward to verify that the child rect gets updated |
1024 // correctly. | 1053 // correctly. |
1025 blink::WebMouseWheelEvent scroll_event( | 1054 blink::WebMouseWheelEvent scroll_event( |
1026 blink::WebInputEvent::MouseWheel, blink::WebInputEvent::NoModifiers, | 1055 blink::WebInputEvent::MouseWheel, blink::WebInputEvent::NoModifiers, |
1027 blink::WebInputEvent::TimeStampForTesting); | 1056 blink::WebInputEvent::TimeStampForTesting); |
1028 scroll_event.x = 387; | 1057 |
1029 scroll_event.y = 110; | 1058 scroll_event.x = gfx::ToFlooredInt( |
1059 (bounds.x() - rwhv_root->GetViewBounds().x() - 5) / scale_factor); | |
1060 scroll_event.y = gfx::ToFlooredInt( | |
1061 (bounds.y() - rwhv_root->GetViewBounds().y() - 5) / scale_factor); | |
1030 scroll_event.deltaX = 0.0f; | 1062 scroll_event.deltaX = 0.0f; |
1031 scroll_event.deltaY = -30.0f; | 1063 scroll_event.deltaY = -30.0f; |
1032 rwhv_root->ProcessMouseWheelEvent(scroll_event, ui::LatencyInfo()); | 1064 rwhv_root->ProcessMouseWheelEvent(scroll_event, ui::LatencyInfo()); |
1033 | 1065 |
1034 filter->Wait(); | 1066 filter->Wait(); |
1035 | 1067 |
1036 // The precise amount of scroll for the first view position update is not | 1068 // The precise amount of scroll for the first view position update is not |
1037 // deterministic, so this simply verifies that the OOPIF moved from its | 1069 // deterministic, so this simply verifies that the OOPIF moved from its |
1038 // earlier position. | 1070 // earlier position. |
1039 gfx::Rect update_rect = filter->last_rect(); | 1071 gfx::Rect update_rect = filter->last_rect(); |
1040 EXPECT_LT(update_rect.y(), bounds.y() - rwhv_root->GetViewBounds().y()); | 1072 EXPECT_LT(update_rect.y(), bounds.y() - rwhv_root->GetViewBounds().y()); |
1041 } | 1073 } |
1042 | 1074 |
1043 // Test that scrolling a nested out-of-process iframe bubbles unused scroll | 1075 // Test that scrolling a nested out-of-process iframe bubbles unused scroll |
1044 // delta to a parent frame. | 1076 // delta to a parent frame. |
1045 // Browser process hit testing is not implemented on Android. | |
1046 // https://crbug.com/491334 | |
1047 // Flaky: https://crbug.com/627238 | 1077 // Flaky: https://crbug.com/627238 |
1048 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 1078 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
1049 DISABLED_ScrollBubblingFromOOPIFTest) { | 1079 DISABLED_ScrollBubblingFromOOPIFTest) { |
1050 GURL main_url(embedded_test_server()->GetURL( | 1080 GURL main_url(embedded_test_server()->GetURL( |
1051 "a.com", "/cross_site_iframe_factory.html?a(b)")); | 1081 "a.com", "/cross_site_iframe_factory.html?a(b)")); |
1052 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 1082 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
1053 | 1083 |
1054 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1084 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1055 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1085 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
1056 ->GetFrameTree() | 1086 ->GetFrameTree() |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1258 2); | 1288 2); |
1259 rwhv_parent->OnScrollEvent(&scroll_event); | 1289 rwhv_parent->OnScrollEvent(&scroll_event); |
1260 | 1290 |
1261 // Verify that this a mouse wheel event was sent to the child frame renderer. | 1291 // Verify that this a mouse wheel event was sent to the child frame renderer. |
1262 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); | 1292 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); |
1263 EXPECT_EQ(child_frame_monitor.EventType(), blink::WebInputEvent::MouseWheel); | 1293 EXPECT_EQ(child_frame_monitor.EventType(), blink::WebInputEvent::MouseWheel); |
1264 } | 1294 } |
1265 | 1295 |
1266 // Test that mouse events are being routed to the correct RenderWidgetHostView | 1296 // Test that mouse events are being routed to the correct RenderWidgetHostView |
1267 // based on coordinates. | 1297 // based on coordinates. |
1268 #if defined(OS_ANDROID) || defined(THREAD_SANITIZER) | 1298 #if defined(THREAD_SANITIZER) |
1269 // Browser process hit testing is not implemented on Android. | |
1270 // https://crbug.com/491334 | |
1271 // The test times out often on TSAN bot. | 1299 // The test times out often on TSAN bot. |
1272 // https://crbug.com/591170. | 1300 // https://crbug.com/591170. |
1273 #define MAYBE_SurfaceHitTestTest DISABLED_SurfaceHitTestTest | 1301 #define MAYBE_SurfaceHitTestTest DISABLED_SurfaceHitTestTest |
1274 #else | 1302 #else |
1275 #define MAYBE_SurfaceHitTestTest SurfaceHitTestTest | 1303 #define MAYBE_SurfaceHitTestTest SurfaceHitTestTest |
1276 #endif | 1304 #endif |
1277 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_SurfaceHitTestTest) { | 1305 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_SurfaceHitTestTest) { |
1278 SurfaceHitTestTestHelper(shell(), embedded_test_server()); | 1306 SurfaceHitTestTestHelper(shell(), embedded_test_server()); |
1279 } | 1307 } |
1280 | 1308 |
1281 // Same test as above, but runs in high-dpi mode. | 1309 // Same test as above, but runs in high-dpi mode. |
1282 #if defined(OS_ANDROID) || defined(OS_WIN) | 1310 #if defined(OS_ANDROID) || defined(OS_WIN) |
1283 // Browser process hit testing is not implemented on Android. | 1311 // High DPI browser tests are not needed on Android, and confuse some of the |
alexmos
2017/03/06 07:22:03
nit: mention why the High DPI tests are not needed
kenrb
2017/03/07 19:20:20
Done.
| |
1284 // https://crbug.com/491334 | 1312 // coordinate calculations. |
1285 // Windows is disabled because of https://crbug.com/545547. | 1313 // Windows is disabled because of https://crbug.com/545547. |
1286 #define MAYBE_HighDPISurfaceHitTestTest DISABLED_SurfaceHitTestTest | 1314 #define MAYBE_HighDPISurfaceHitTestTest DISABLED_SurfaceHitTestTest |
1287 #else | 1315 #else |
1288 #define MAYBE_HighDPISurfaceHitTestTest SurfaceHitTestTest | 1316 #define MAYBE_HighDPISurfaceHitTestTest SurfaceHitTestTest |
1289 #endif | 1317 #endif |
1290 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest, | 1318 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest, |
1291 MAYBE_HighDPISurfaceHitTestTest) { | 1319 MAYBE_HighDPISurfaceHitTestTest) { |
1292 SurfaceHitTestTestHelper(shell(), embedded_test_server()); | 1320 SurfaceHitTestTestHelper(shell(), embedded_test_server()); |
1293 } | 1321 } |
1294 | 1322 |
1295 // Test that mouse events are being routed to the correct RenderWidgetHostView | 1323 // Test that mouse events are being routed to the correct RenderWidgetHostView |
1296 // when there are nested out-of-process iframes. | 1324 // when there are nested out-of-process iframes. |
1297 #if defined(OS_ANDROID) | 1325 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NestedSurfaceHitTestTest) { |
1298 // Browser process hit testing is not implemented on Android. | |
1299 // https://crbug.com/491334 | |
1300 #define MAYBE_NestedSurfaceHitTestTest DISABLED_NestedSurfaceHitTestTest | |
1301 #else | |
1302 #define MAYBE_NestedSurfaceHitTestTest NestedSurfaceHitTestTest | |
1303 #endif | |
1304 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
1305 MAYBE_NestedSurfaceHitTestTest) { | |
1306 GURL main_url(embedded_test_server()->GetURL( | 1326 GURL main_url(embedded_test_server()->GetURL( |
1307 "/frame_tree/page_with_positioned_nested_frames.html")); | 1327 "/frame_tree/page_with_positioned_nested_frames.html")); |
1308 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 1328 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
1309 | 1329 |
1310 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1330 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1311 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); | 1331 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
1312 ASSERT_EQ(1U, root->child_count()); | 1332 ASSERT_EQ(1U, root->child_count()); |
1313 | 1333 |
1314 FrameTreeNode* parent_iframe_node = root->child_at(0); | 1334 FrameTreeNode* parent_iframe_node = root->child_at(0); |
1315 GURL site_url(embedded_test_server()->GetURL( | 1335 GURL site_url(embedded_test_server()->GetURL( |
(...skipping 25 matching lines...) Expand all Loading... | |
1341 RenderWidgetHostViewBase* rwhv_nested = | 1361 RenderWidgetHostViewBase* rwhv_nested = |
1342 static_cast<RenderWidgetHostViewBase*>( | 1362 static_cast<RenderWidgetHostViewBase*>( |
1343 nested_iframe_node->current_frame_host() | 1363 nested_iframe_node->current_frame_host() |
1344 ->GetRenderWidgetHost() | 1364 ->GetRenderWidgetHost() |
1345 ->GetView()); | 1365 ->GetView()); |
1346 | 1366 |
1347 SurfaceHitTestReadyNotifier notifier( | 1367 SurfaceHitTestReadyNotifier notifier( |
1348 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_nested)); | 1368 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_nested)); |
1349 notifier.WaitForSurfaceReady(); | 1369 notifier.WaitForSurfaceReady(); |
1350 | 1370 |
1371 #if defined(OS_ANDROID) | |
1372 float scale_factor = GetFrameDeviceScaleFactor(web_contents()); | |
1373 #else | |
1374 float scale_factor = 1.0; | |
1375 #endif | |
1376 | |
1377 // Get the view bounds of the nested iframe, which should account for the | |
1378 // relative offset of its direct parent within the root frame, for use in | |
1379 // targeting the input event. | |
1380 gfx::Rect bounds = rwhv_nested->GetViewBounds(); | |
1381 | |
1351 // Target input event to nested frame. | 1382 // Target input event to nested frame. |
1352 blink::WebMouseEvent nested_event(blink::WebInputEvent::MouseDown, | 1383 blink::WebMouseEvent nested_event(blink::WebInputEvent::MouseDown, |
1353 blink::WebInputEvent::NoModifiers, | 1384 blink::WebInputEvent::NoModifiers, |
1354 blink::WebInputEvent::TimeStampForTesting); | 1385 blink::WebInputEvent::TimeStampForTesting); |
1355 nested_event.button = blink::WebPointerProperties::Button::Left; | 1386 nested_event.button = blink::WebPointerProperties::Button::Left; |
1356 nested_event.x = 125; | 1387 nested_event.x = |
1357 nested_event.y = 125; | 1388 gfx::ToCeiledInt((bounds.x() - root_view->GetViewBounds().x()) / |
1389 scale_factor) + | |
1390 5; | |
1391 nested_event.y = | |
1392 gfx::ToCeiledInt((bounds.y() - root_view->GetViewBounds().y()) / | |
1393 scale_factor) + | |
1394 5; | |
1358 nested_event.clickCount = 1; | 1395 nested_event.clickCount = 1; |
1359 nested_frame_monitor.ResetEventReceived(); | 1396 nested_frame_monitor.ResetEventReceived(); |
1360 main_frame_monitor.ResetEventReceived(); | 1397 main_frame_monitor.ResetEventReceived(); |
1361 router->RouteMouseEvent(root_view, &nested_event, ui::LatencyInfo()); | 1398 router->RouteMouseEvent(root_view, &nested_event, ui::LatencyInfo()); |
1362 | 1399 |
1363 EXPECT_TRUE(nested_frame_monitor.EventWasReceived()); | 1400 EXPECT_TRUE(nested_frame_monitor.EventWasReceived()); |
1364 EXPECT_EQ(21, nested_frame_monitor.event().x); | 1401 // The expected result coordinates are (5, 5), but can get slightly |
1365 EXPECT_EQ(21, nested_frame_monitor.event().y); | 1402 // different results due to rounding error with some device scale factors. |
1403 EXPECT_TRUE(nested_frame_monitor.event().x <= 6 && | |
1404 nested_frame_monitor.event().x >= 4); | |
1405 EXPECT_TRUE(nested_frame_monitor.event().y <= 6 && | |
1406 nested_frame_monitor.event().y >= 4); | |
1366 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); | 1407 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); |
1367 } | 1408 } |
1368 | 1409 |
1369 // This test tests that browser process hittesting ignores frames with | 1410 // This test tests that browser process hittesting ignores frames with |
1370 // pointer-events: none. | 1411 // pointer-events: none. |
1371 #if defined(OS_ANDROID) | |
1372 // Browser process hit testing is not implemented on Android. | |
1373 // https://crbug.com/491334 | |
1374 #define MAYBE_SurfaceHitTestPointerEventsNone \ | |
1375 DISABLED_SurfaceHitTestPointerEventsNone | |
1376 #else | |
1377 #define MAYBE_SurfaceHitTestPointerEventsNone SurfaceHitTestPointerEventsNone | |
1378 #endif | |
1379 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 1412 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
1380 MAYBE_SurfaceHitTestPointerEventsNone) { | 1413 SurfaceHitTestPointerEventsNone) { |
1381 GURL main_url(embedded_test_server()->GetURL( | 1414 GURL main_url(embedded_test_server()->GetURL( |
1382 "/frame_tree/page_with_positioned_frame_pointer-events_none.html")); | 1415 "/frame_tree/page_with_positioned_frame_pointer-events_none.html")); |
1383 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 1416 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
1384 | 1417 |
1385 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1418 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1386 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); | 1419 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
1387 ASSERT_EQ(1U, root->child_count()); | 1420 ASSERT_EQ(1U, root->child_count()); |
1388 | 1421 |
1389 FrameTreeNode* child_node = root->child_at(0); | 1422 FrameTreeNode* child_node = root->child_at(0); |
1390 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); | 1423 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1423 router->RouteMouseEvent(root_view, &child_event, ui::LatencyInfo()); | 1456 router->RouteMouseEvent(root_view, &child_event, ui::LatencyInfo()); |
1424 | 1457 |
1425 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); | 1458 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); |
1426 EXPECT_EQ(75, main_frame_monitor.event().x); | 1459 EXPECT_EQ(75, main_frame_monitor.event().x); |
1427 EXPECT_EQ(75, main_frame_monitor.event().y); | 1460 EXPECT_EQ(75, main_frame_monitor.event().y); |
1428 EXPECT_FALSE(child_frame_monitor.EventWasReceived()); | 1461 EXPECT_FALSE(child_frame_monitor.EventWasReceived()); |
1429 } | 1462 } |
1430 | 1463 |
1431 // This test verifies that MouseEnter and MouseLeave events fire correctly | 1464 // This test verifies that MouseEnter and MouseLeave events fire correctly |
1432 // when the mouse cursor moves between processes. | 1465 // when the mouse cursor moves between processes. |
1433 #if defined(OS_ANDROID) | |
1434 // Browser process hit testing is not implemented on Android. | |
1435 // https://crbug.com/491334 | |
1436 #define MAYBE_CrossProcessMouseEnterAndLeaveTest \ | |
1437 DISABLED_CrossProcessMouseEnterAndLeaveTest | |
1438 #else | |
1439 #define MAYBE_CrossProcessMouseEnterAndLeaveTest \ | |
1440 CrossProcessMouseEnterAndLeaveTest | |
1441 #endif | |
1442 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 1466 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
1443 MAYBE_CrossProcessMouseEnterAndLeaveTest) { | 1467 CrossProcessMouseEnterAndLeaveTest) { |
1444 GURL main_url(embedded_test_server()->GetURL( | 1468 GURL main_url(embedded_test_server()->GetURL( |
1445 "a.com", "/cross_site_iframe_factory.html?a(b,c(d))")); | 1469 "a.com", "/cross_site_iframe_factory.html?a(b,c(d))")); |
1446 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 1470 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
1447 | 1471 |
1448 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1472 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
1449 ->GetFrameTree() | 1473 ->GetFrameTree() |
1450 ->root(); | 1474 ->root(); |
1451 | 1475 |
1452 EXPECT_EQ( | 1476 EXPECT_EQ( |
1453 " Site A ------------ proxies for B C D\n" | 1477 " Site A ------------ proxies for B C D\n" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1487 root->current_frame_host()->GetRenderWidgetHost()); | 1511 root->current_frame_host()->GetRenderWidgetHost()); |
1488 RenderWidgetHostMouseEventMonitor a_frame_monitor( | 1512 RenderWidgetHostMouseEventMonitor a_frame_monitor( |
1489 root->current_frame_host()->GetRenderWidgetHost()); | 1513 root->current_frame_host()->GetRenderWidgetHost()); |
1490 RenderWidgetHostMouseEventMonitor b_frame_monitor( | 1514 RenderWidgetHostMouseEventMonitor b_frame_monitor( |
1491 b_node->current_frame_host()->GetRenderWidgetHost()); | 1515 b_node->current_frame_host()->GetRenderWidgetHost()); |
1492 RenderWidgetHostMouseEventMonitor c_frame_monitor( | 1516 RenderWidgetHostMouseEventMonitor c_frame_monitor( |
1493 c_node->current_frame_host()->GetRenderWidgetHost()); | 1517 c_node->current_frame_host()->GetRenderWidgetHost()); |
1494 RenderWidgetHostMouseEventMonitor d_frame_monitor( | 1518 RenderWidgetHostMouseEventMonitor d_frame_monitor( |
1495 d_node->current_frame_host()->GetRenderWidgetHost()); | 1519 d_node->current_frame_host()->GetRenderWidgetHost()); |
1496 | 1520 |
1521 #if defined(OS_ANDROID) | |
1522 float scale_factor = GetFrameDeviceScaleFactor(shell()->web_contents()); | |
1523 #else | |
1524 float scale_factor = 1.0; | |
1525 #endif | |
1526 | |
1527 // Get the view bounds of the child iframe, which should account for the | |
1528 // relative offset of its direct parent within the root frame, for use in | |
1529 // targeting the input event. | |
1530 gfx::Rect a_bounds = rwhv_a->GetViewBounds(); | |
1531 gfx::Rect b_bounds = rwhv_b->GetViewBounds(); | |
1532 gfx::Rect d_bounds = rwhv_d->GetViewBounds(); | |
1533 | |
1497 gfx::Point point_in_a_frame(2, 2); | 1534 gfx::Point point_in_a_frame(2, 2); |
1498 gfx::Point point_in_b_frame(313, 147); | 1535 gfx::Point point_in_b_frame( |
1499 gfx::Point point_in_d_frame(471, 207); | 1536 gfx::ToCeiledInt((b_bounds.x() - a_bounds.x()) / scale_factor) + 25, |
1537 gfx::ToCeiledInt((b_bounds.y() - a_bounds.y()) / scale_factor) + 25); | |
1538 gfx::Point point_in_d_frame( | |
1539 gfx::ToCeiledInt((d_bounds.x() - a_bounds.x()) / scale_factor) + 25, | |
1540 gfx::ToCeiledInt((d_bounds.y() - a_bounds.y()) / scale_factor) + 25); | |
1500 | 1541 |
1501 blink::WebMouseEvent mouse_event(blink::WebInputEvent::MouseMove, | 1542 blink::WebMouseEvent mouse_event(blink::WebInputEvent::MouseMove, |
1502 blink::WebInputEvent::NoModifiers, | 1543 blink::WebInputEvent::NoModifiers, |
1503 blink::WebInputEvent::TimeStampForTesting); | 1544 blink::WebInputEvent::TimeStampForTesting); |
1504 mouse_event.x = point_in_a_frame.x(); | 1545 mouse_event.x = point_in_a_frame.x(); |
1505 mouse_event.y = point_in_a_frame.y(); | 1546 mouse_event.y = point_in_a_frame.y(); |
1506 | 1547 |
1507 // Send an initial MouseMove to the root view, which shouldn't affect the | 1548 // Send an initial MouseMove to the root view, which shouldn't affect the |
1508 // other renderers. | 1549 // other renderers. |
1509 web_contents()->GetInputEventRouter()->RouteMouseEvent(rwhv_a, &mouse_event, | 1550 web_contents()->GetInputEventRouter()->RouteMouseEvent(rwhv_a, &mouse_event, |
(...skipping 29 matching lines...) Expand all Loading... | |
1539 EXPECT_TRUE(b_frame_monitor.EventWasReceived()); | 1580 EXPECT_TRUE(b_frame_monitor.EventWasReceived()); |
1540 EXPECT_EQ(b_frame_monitor.event().type(), blink::WebInputEvent::MouseLeave); | 1581 EXPECT_EQ(b_frame_monitor.event().type(), blink::WebInputEvent::MouseLeave); |
1541 EXPECT_TRUE(c_frame_monitor.EventWasReceived()); | 1582 EXPECT_TRUE(c_frame_monitor.EventWasReceived()); |
1542 EXPECT_EQ(c_frame_monitor.event().type(), blink::WebInputEvent::MouseMove); | 1583 EXPECT_EQ(c_frame_monitor.event().type(), blink::WebInputEvent::MouseMove); |
1543 EXPECT_TRUE(d_frame_monitor.EventWasReceived()); | 1584 EXPECT_TRUE(d_frame_monitor.EventWasReceived()); |
1544 } | 1585 } |
1545 | 1586 |
1546 // Verify that mouse capture works on a RenderWidgetHostView level, so that | 1587 // Verify that mouse capture works on a RenderWidgetHostView level, so that |
1547 // dragging scroll bars and selecting text continues even when the mouse | 1588 // dragging scroll bars and selecting text continues even when the mouse |
1548 // cursor crosses over cross-process frame boundaries. | 1589 // cursor crosses over cross-process frame boundaries. |
1549 #if defined(OS_ANDROID) | 1590 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossProcessMouseCapture) { |
1550 // Browser process hit testing is not implemented on Android. | |
1551 // https://crbug.com/491334 | |
1552 #define MAYBE_CrossProcessMouseCapture DISABLED_CrossProcessMouseCapture | |
1553 #else | |
1554 #define MAYBE_CrossProcessMouseCapture CrossProcessMouseCapture | |
1555 #endif | |
1556 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
1557 MAYBE_CrossProcessMouseCapture) { | |
1558 GURL main_url(embedded_test_server()->GetURL( | 1591 GURL main_url(embedded_test_server()->GetURL( |
1559 "/frame_tree/page_with_positioned_frame.html")); | 1592 "/frame_tree/page_with_positioned_frame.html")); |
1560 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 1593 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
1561 | 1594 |
1562 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1595 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1563 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); | 1596 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
1564 ASSERT_EQ(1U, root->child_count()); | 1597 ASSERT_EQ(1U, root->child_count()); |
1565 | 1598 |
1566 FrameTreeNode* child_node = root->child_at(0); | 1599 FrameTreeNode* child_node = root->child_at(0); |
1567 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); | 1600 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); |
(...skipping 12 matching lines...) Expand all Loading... | |
1580 | 1613 |
1581 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( | 1614 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( |
1582 root->current_frame_host()->GetRenderWidgetHost()->GetView()); | 1615 root->current_frame_host()->GetRenderWidgetHost()->GetView()); |
1583 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( | 1616 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( |
1584 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); | 1617 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); |
1585 | 1618 |
1586 SurfaceHitTestReadyNotifier notifier( | 1619 SurfaceHitTestReadyNotifier notifier( |
1587 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); | 1620 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); |
1588 notifier.WaitForSurfaceReady(); | 1621 notifier.WaitForSurfaceReady(); |
1589 | 1622 |
1623 #if defined(OS_ANDROID) | |
1624 float scale_factor = GetFrameDeviceScaleFactor(shell()->web_contents()); | |
1625 #else | |
1626 float scale_factor = 1.0; | |
1627 #endif | |
alexmos
2017/03/06 07:22:03
nit: This block is repeated several times; it migh
kenrb
2017/03/07 19:20:20
Done.
| |
1628 | |
1629 // Get the view bounds of the child iframe, which should account for the | |
1630 // relative offset of its direct parent within the root frame, for use in | |
1631 // targeting the input event. | |
1632 gfx::Rect bounds = rwhv_child->GetViewBounds(); | |
1633 int child_frame_target_x = | |
1634 gfx::ToCeiledInt((bounds.x() - root_view->GetViewBounds().x()) / | |
1635 scale_factor) + | |
1636 5; | |
1637 int child_frame_target_y = | |
1638 gfx::ToCeiledInt((bounds.y() - root_view->GetViewBounds().y()) / | |
1639 scale_factor) + | |
1640 5; | |
1641 | |
1590 // Target MouseDown to child frame. | 1642 // Target MouseDown to child frame. |
1591 blink::WebMouseEvent mouse_event(blink::WebInputEvent::MouseDown, | 1643 blink::WebMouseEvent mouse_event(blink::WebInputEvent::MouseDown, |
1592 blink::WebInputEvent::NoModifiers, | 1644 blink::WebInputEvent::NoModifiers, |
1593 blink::WebInputEvent::TimeStampForTesting); | 1645 blink::WebInputEvent::TimeStampForTesting); |
1594 mouse_event.button = blink::WebPointerProperties::Button::Left; | 1646 mouse_event.button = blink::WebPointerProperties::Button::Left; |
1595 mouse_event.x = 75; | 1647 mouse_event.x = child_frame_target_x; |
1596 mouse_event.y = 75; | 1648 mouse_event.y = child_frame_target_y; |
1597 mouse_event.clickCount = 1; | 1649 mouse_event.clickCount = 1; |
1598 main_frame_monitor.ResetEventReceived(); | 1650 main_frame_monitor.ResetEventReceived(); |
1599 child_frame_monitor.ResetEventReceived(); | 1651 child_frame_monitor.ResetEventReceived(); |
1600 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); | 1652 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); |
1601 | 1653 |
1602 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); | 1654 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); |
1603 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); | 1655 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); |
1604 | 1656 |
1605 // Target MouseMove to main frame. This should still be routed to the | 1657 // Target MouseMove to main frame. This should still be routed to the |
1606 // child frame because it is now capturing mouse input. | 1658 // child frame because it is now capturing mouse input. |
(...skipping 11 matching lines...) Expand all Loading... | |
1618 mouse_event.x = 1; | 1670 mouse_event.x = 1; |
1619 mouse_event.y = 2; | 1671 mouse_event.y = 2; |
1620 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); | 1672 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); |
1621 | 1673 |
1622 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); | 1674 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); |
1623 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); | 1675 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); |
1624 | 1676 |
1625 // A MouseUp to the child frame should cancel the mouse capture. | 1677 // A MouseUp to the child frame should cancel the mouse capture. |
1626 mouse_event.setType(blink::WebInputEvent::MouseUp); | 1678 mouse_event.setType(blink::WebInputEvent::MouseUp); |
1627 mouse_event.setModifiers(blink::WebInputEvent::NoModifiers); | 1679 mouse_event.setModifiers(blink::WebInputEvent::NoModifiers); |
1628 mouse_event.x = 75; | 1680 mouse_event.x = child_frame_target_x; |
1629 mouse_event.y = 75; | 1681 mouse_event.y = child_frame_target_y; |
1630 main_frame_monitor.ResetEventReceived(); | 1682 main_frame_monitor.ResetEventReceived(); |
1631 child_frame_monitor.ResetEventReceived(); | 1683 child_frame_monitor.ResetEventReceived(); |
1632 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); | 1684 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); |
1633 | 1685 |
1634 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); | 1686 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); |
1635 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); | 1687 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); |
1636 | 1688 |
1637 // Subsequent MouseMove events targeted to the main frame should be routed | 1689 // Subsequent MouseMove events targeted to the main frame should be routed |
1638 // to that frame. | 1690 // to that frame. |
1639 mouse_event.setType(blink::WebInputEvent::MouseMove); | 1691 mouse_event.setType(blink::WebInputEvent::MouseMove); |
(...skipping 18 matching lines...) Expand all Loading... | |
1658 child_frame_monitor.ResetEventReceived(); | 1710 child_frame_monitor.ResetEventReceived(); |
1659 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); | 1711 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); |
1660 | 1712 |
1661 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); | 1713 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); |
1662 EXPECT_FALSE(child_frame_monitor.EventWasReceived()); | 1714 EXPECT_FALSE(child_frame_monitor.EventWasReceived()); |
1663 | 1715 |
1664 // Sending a MouseMove to the child frame should still result in the main | 1716 // Sending a MouseMove to the child frame should still result in the main |
1665 // frame receiving the event. | 1717 // frame receiving the event. |
1666 mouse_event.setType(blink::WebInputEvent::MouseMove); | 1718 mouse_event.setType(blink::WebInputEvent::MouseMove); |
1667 mouse_event.setModifiers(blink::WebInputEvent::LeftButtonDown); | 1719 mouse_event.setModifiers(blink::WebInputEvent::LeftButtonDown); |
1668 mouse_event.x = 75; | 1720 mouse_event.x = child_frame_target_x; |
1669 mouse_event.y = 75; | 1721 mouse_event.y = child_frame_target_y; |
1670 main_frame_monitor.ResetEventReceived(); | 1722 main_frame_monitor.ResetEventReceived(); |
1671 child_frame_monitor.ResetEventReceived(); | 1723 child_frame_monitor.ResetEventReceived(); |
1672 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); | 1724 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); |
1673 | 1725 |
1674 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); | 1726 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); |
1675 EXPECT_FALSE(child_frame_monitor.EventWasReceived()); | 1727 EXPECT_FALSE(child_frame_monitor.EventWasReceived()); |
1676 } | 1728 } |
1677 | 1729 |
1678 // Tests OOPIF rendering by checking that the RWH of the iframe generates | 1730 // Tests OOPIF rendering by checking that the RWH of the iframe generates |
1679 // OnSwapCompositorFrame message. | 1731 // OnSwapCompositorFrame message. |
(...skipping 4277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5957 notifier.WaitForSurfaceReady(); | 6009 notifier.WaitForSurfaceReady(); |
5958 | 6010 |
5959 // A WebContentsDelegate to listen for the ShowContextMenu message. | 6011 // A WebContentsDelegate to listen for the ShowContextMenu message. |
5960 ContextMenuObserverDelegate context_menu_delegate; | 6012 ContextMenuObserverDelegate context_menu_delegate; |
5961 shell->web_contents()->SetDelegate(&context_menu_delegate); | 6013 shell->web_contents()->SetDelegate(&context_menu_delegate); |
5962 | 6014 |
5963 RenderWidgetHostInputEventRouter* router = | 6015 RenderWidgetHostInputEventRouter* router = |
5964 static_cast<WebContentsImpl*>(shell->web_contents()) | 6016 static_cast<WebContentsImpl*>(shell->web_contents()) |
5965 ->GetInputEventRouter(); | 6017 ->GetInputEventRouter(); |
5966 | 6018 |
5967 gfx::Point point(75, 75); | 6019 #if defined(OS_ANDROID) |
6020 float scale_factor = GetFrameDeviceScaleFactor(shell->web_contents()); | |
6021 #else | |
6022 float scale_factor = 1.0; | |
6023 #endif | |
6024 | |
6025 gfx::Rect root_bounds = root_view->GetViewBounds(); | |
6026 gfx::Rect bounds = rwhv_child->GetViewBounds(); | |
6027 | |
6028 gfx::Point point( | |
6029 gfx::ToCeiledInt((bounds.x() - root_bounds.x()) / scale_factor) + 10, | |
6030 gfx::ToCeiledInt((bounds.y() - root_bounds.y()) / scale_factor) + 10); | |
5968 | 6031 |
5969 // Target right-click event to child frame. | 6032 // Target right-click event to child frame. |
5970 blink::WebMouseEvent click_event(blink::WebInputEvent::MouseDown, | 6033 blink::WebMouseEvent click_event(blink::WebInputEvent::MouseDown, |
5971 blink::WebInputEvent::NoModifiers, | 6034 blink::WebInputEvent::NoModifiers, |
5972 blink::WebInputEvent::TimeStampForTesting); | 6035 blink::WebInputEvent::TimeStampForTesting); |
5973 click_event.button = blink::WebPointerProperties::Button::Right; | 6036 click_event.button = blink::WebPointerProperties::Button::Right; |
5974 click_event.x = point.x(); | 6037 click_event.x = point.x(); |
5975 click_event.y = point.y(); | 6038 click_event.y = point.y(); |
5976 click_event.clickCount = 1; | 6039 click_event.clickCount = 1; |
5977 router->RouteMouseEvent(root_view, &click_event, ui::LatencyInfo()); | 6040 router->RouteMouseEvent(root_view, &click_event, ui::LatencyInfo()); |
5978 | 6041 |
5979 // We also need a MouseUp event, needed by Windows. | 6042 // We also need a MouseUp event, needed by Windows. |
5980 click_event.setType(blink::WebInputEvent::MouseUp); | 6043 click_event.setType(blink::WebInputEvent::MouseUp); |
5981 click_event.x = point.x(); | 6044 click_event.x = point.x(); |
5982 click_event.y = point.y(); | 6045 click_event.y = point.y(); |
5983 router->RouteMouseEvent(root_view, &click_event, ui::LatencyInfo()); | 6046 router->RouteMouseEvent(root_view, &click_event, ui::LatencyInfo()); |
5984 | 6047 |
5985 context_menu_delegate.Wait(); | 6048 context_menu_delegate.Wait(); |
5986 | 6049 |
5987 ContextMenuParams params = context_menu_delegate.getParams(); | 6050 ContextMenuParams params = context_menu_delegate.getParams(); |
5988 | 6051 |
5989 EXPECT_EQ(point.x(), params.x); | 6052 EXPECT_EQ(point.x(), params.x); |
5990 EXPECT_EQ(point.y(), params.y); | 6053 EXPECT_EQ(point.y(), params.y); |
5991 } | 6054 } |
5992 | 6055 |
5993 // Test that a mouse right-click to an out-of-process iframe causes a context | 6056 // Test that a mouse right-click to an out-of-process iframe causes a context |
5994 // menu to be generated with the correct screen position. | 6057 // menu to be generated with the correct screen position. |
5995 #if defined(OS_ANDROID) | 6058 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CreateContextMenuTest) { |
5996 // Browser process hit testing is not implemented on Android. | |
5997 // https://crbug.com/491334 | |
5998 #define MAYBE_CreateContextMenuTest DISABLED_CreateContextMenuTest | |
5999 #else | |
6000 #define MAYBE_CreateContextMenuTest CreateContextMenuTest | |
6001 #endif | |
6002 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_CreateContextMenuTest) { | |
6003 CreateContextMenuTestHelper(shell(), embedded_test_server()); | 6059 CreateContextMenuTestHelper(shell(), embedded_test_server()); |
6004 } | 6060 } |
6005 | 6061 |
6006 // Test that a mouse right-click to an out-of-process iframe causes a context | 6062 // Test that a mouse right-click to an out-of-process iframe causes a context |
6007 // menu to be generated with the correct screen position on a screen with | 6063 // menu to be generated with the correct screen position on a screen with |
6008 // non-default scale factor. | 6064 // non-default scale factor. |
6009 #if defined(OS_ANDROID) || defined(OS_WIN) | 6065 #if defined(OS_ANDROID) || defined(OS_WIN) |
6010 // Browser process hit testing is not implemented on Android. | 6066 // High DPI tests don't work properly on Android, which has fixed scale factor. |
6011 // https://crbug.com/491334 | |
6012 // Windows is disabled because of https://crbug.com/545547. | 6067 // Windows is disabled because of https://crbug.com/545547. |
6013 #define MAYBE_HighDPICreateContextMenuTest DISABLED_HighDPICreateContextMenuTest | 6068 #define MAYBE_HighDPICreateContextMenuTest DISABLED_HighDPICreateContextMenuTest |
6014 #else | 6069 #else |
6015 #define MAYBE_HighDPICreateContextMenuTest HighDPICreateContextMenuTest | 6070 #define MAYBE_HighDPICreateContextMenuTest HighDPICreateContextMenuTest |
6016 #endif | 6071 #endif |
6017 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest, | 6072 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest, |
6018 MAYBE_HighDPICreateContextMenuTest) { | 6073 MAYBE_HighDPICreateContextMenuTest) { |
6019 CreateContextMenuTestHelper(shell(), embedded_test_server()); | 6074 CreateContextMenuTestHelper(shell(), embedded_test_server()); |
6020 } | 6075 } |
6021 | 6076 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6078 } | 6133 } |
6079 | 6134 |
6080 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 6135 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
6081 gfx::Rect initial_rect_; | 6136 gfx::Rect initial_rect_; |
6082 | 6137 |
6083 DISALLOW_COPY_AND_ASSIGN(ShowWidgetMessageFilter); | 6138 DISALLOW_COPY_AND_ASSIGN(ShowWidgetMessageFilter); |
6084 }; | 6139 }; |
6085 | 6140 |
6086 // Test that clicking a select element in an out-of-process iframe creates | 6141 // Test that clicking a select element in an out-of-process iframe creates |
6087 // a popup menu in the correct position. | 6142 // a popup menu in the correct position. |
6088 #if defined(OS_ANDROID) | 6143 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, PopupMenuTest) { |
6089 // Surface-based hit testing and coordinate translation is not yet available | |
6090 // on Android. | |
6091 #define MAYBE_PopupMenuTest DISABLED_PopupMenuTest | |
6092 #else | |
6093 #define MAYBE_PopupMenuTest PopupMenuTest | |
6094 #endif | |
6095 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_PopupMenuTest) { | |
6096 GURL main_url( | 6144 GURL main_url( |
6097 embedded_test_server()->GetURL("/cross_site_iframe_factory.html?a(a)")); | 6145 embedded_test_server()->GetURL("/cross_site_iframe_factory.html?a(a)")); |
6098 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 6146 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
6099 | 6147 |
6100 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); | 6148 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
6101 | 6149 |
6102 #if !defined(OS_MACOSX) | 6150 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
6103 // Unused variable on Mac. | 6151 // Unused variable on Mac and Android. |
6104 RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>( | 6152 RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>( |
6105 root->current_frame_host()->GetRenderWidgetHost()->GetView()); | 6153 root->current_frame_host()->GetRenderWidgetHost()->GetView()); |
6106 #endif | 6154 #endif |
6107 web_contents()->SendScreenRects(); | 6155 web_contents()->SendScreenRects(); |
6108 | 6156 |
6109 content::TestNavigationObserver navigation_observer(shell()->web_contents()); | 6157 content::TestNavigationObserver navigation_observer(shell()->web_contents()); |
6110 FrameTreeNode* child_node = root->child_at(0); | 6158 FrameTreeNode* child_node = root->child_at(0); |
6111 GURL site_url(embedded_test_server()->GetURL( | 6159 GURL site_url(embedded_test_server()->GetURL( |
6112 "baz.com", "/site_isolation/page-with-select.html")); | 6160 "baz.com", "/site_isolation/page-with-select.html")); |
6113 NavigateFrameToURL(child_node, site_url); | 6161 NavigateFrameToURL(child_node, site_url); |
(...skipping 18 matching lines...) Expand all Loading... | |
6132 click_event.clickCount = 1; | 6180 click_event.clickCount = 1; |
6133 rwhv_child->ProcessMouseEvent(click_event, ui::LatencyInfo()); | 6181 rwhv_child->ProcessMouseEvent(click_event, ui::LatencyInfo()); |
6134 | 6182 |
6135 // Dismiss the popup. | 6183 // Dismiss the popup. |
6136 click_event.x = 1; | 6184 click_event.x = 1; |
6137 click_event.y = 1; | 6185 click_event.y = 1; |
6138 rwhv_child->ProcessMouseEvent(click_event, ui::LatencyInfo()); | 6186 rwhv_child->ProcessMouseEvent(click_event, ui::LatencyInfo()); |
6139 | 6187 |
6140 filter->Wait(); | 6188 filter->Wait(); |
6141 gfx::Rect popup_rect = filter->last_initial_rect(); | 6189 gfx::Rect popup_rect = filter->last_initial_rect(); |
6142 #if defined(OS_MACOSX) | 6190 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
6143 // On Mac we receive the coordinates before they are transformed, so they | 6191 // On Mac and Android we receive the coordinates before they are transformed, |
6144 // are still relative to the out-of-process iframe origin. | 6192 // so they are still relative to the out-of-process iframe origin. |
6145 EXPECT_EQ(popup_rect.x(), 9); | 6193 EXPECT_EQ(popup_rect.x(), 9); |
6146 EXPECT_EQ(popup_rect.y(), 9); | 6194 EXPECT_EQ(popup_rect.y(), 9); |
6147 #else | 6195 #else |
6148 EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354); | 6196 EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354); |
6149 EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 94); | 6197 EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 94); |
6150 #endif | 6198 #endif |
6151 } | 6199 } |
6152 | 6200 |
6153 // Test that clicking a select element in a nested out-of-process iframe creates | 6201 // Test that clicking a select element in a nested out-of-process iframe creates |
6154 // a popup menu in the correct position, even if the top-level page repositions | 6202 // a popup menu in the correct position, even if the top-level page repositions |
(...skipping 2831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8986 EXPECT_EQ(srcdoc_url, child->current_url()); | 9034 EXPECT_EQ(srcdoc_url, child->current_url()); |
8987 EXPECT_EQ(root->current_frame_host()->GetSiteInstance(), | 9035 EXPECT_EQ(root->current_frame_host()->GetSiteInstance(), |
8988 child->current_frame_host()->GetSiteInstance()); | 9036 child->current_frame_host()->GetSiteInstance()); |
8989 EXPECT_EQ(root->current_frame_host()->GetProcess(), | 9037 EXPECT_EQ(root->current_frame_host()->GetProcess(), |
8990 child->current_frame_host()->GetProcess()); | 9038 child->current_frame_host()->GetProcess()); |
8991 } | 9039 } |
8992 | 9040 |
8993 // Test that MouseDown and MouseUp to the same coordinates do not result in | 9041 // Test that MouseDown and MouseUp to the same coordinates do not result in |
8994 // different coordinates after routing. See bug https://crbug.com/670253. | 9042 // different coordinates after routing. See bug https://crbug.com/670253. |
8995 #if defined(OS_ANDROID) | 9043 #if defined(OS_ANDROID) |
8996 // Browser process hit testing is not implemented on Android. | 9044 // Android uses fixed scale factor, which makes this test unnecessary. |
8997 // https://crbug.com/491334 | |
8998 #define MAYBE_MouseClickWithNonIntegerScaleFactor \ | 9045 #define MAYBE_MouseClickWithNonIntegerScaleFactor \ |
8999 DISABLED_MouseClickWithNonIntegerScaleFactor | 9046 DISABLED_MouseClickWithNonIntegerScaleFactor |
9000 #else | 9047 #else |
9001 #define MAYBE_MouseClickWithNonIntegerScaleFactor \ | 9048 #define MAYBE_MouseClickWithNonIntegerScaleFactor \ |
9002 MouseClickWithNonIntegerScaleFactor | 9049 MouseClickWithNonIntegerScaleFactor |
9003 #endif | 9050 #endif |
9004 IN_PROC_BROWSER_TEST_F(SitePerProcessNonIntegerScaleFactorBrowserTest, | 9051 IN_PROC_BROWSER_TEST_F(SitePerProcessNonIntegerScaleFactorBrowserTest, |
9005 MAYBE_MouseClickWithNonIntegerScaleFactor) { | 9052 MAYBE_MouseClickWithNonIntegerScaleFactor) { |
9006 GURL initial_url(embedded_test_server()->GetURL("a.com", "/title1.html")); | 9053 GURL initial_url(embedded_test_server()->GetURL("a.com", "/title1.html")); |
9007 EXPECT_TRUE(NavigateToURL(shell(), initial_url)); | 9054 EXPECT_TRUE(NavigateToURL(shell(), initial_url)); |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9543 for (size_t index = 0; index < frames_.size(); ++index) { | 9590 for (size_t index = 0; index < frames_.size(); ++index) { |
9544 std::string text = base::StringPrintf("text%zu", index); | 9591 std::string text = base::StringPrintf("text%zu", index); |
9545 FocusInputInFrame(frames_[index]); | 9592 FocusInputInFrame(frames_[index]); |
9546 CommitText(text.c_str()); | 9593 CommitText(text.c_str()); |
9547 selection_observer.WaitForSelectedText(text); | 9594 selection_observer.WaitForSelectedText(text); |
9548 } | 9595 } |
9549 } | 9596 } |
9550 #endif // OS_ANDROID | 9597 #endif // OS_ANDROID |
9551 | 9598 |
9552 } // namespace content | 9599 } // namespace content |
OLD | NEW |