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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 2509103002: Enable browser process hit testing on Android (Closed)
Patch Set: Added missing check Created 3 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>
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
247 // This method returns the scale factor on Android and 1.0 on other
248 // platforms in order to adjust coordinates appropriately.
249 double GetAdjustmentScaleFactorForAndroid(Shell* shell) {
250 #if defined(OS_ANDROID)
251 return GetFrameDeviceScaleFactor(shell->web_contents());
252 #else
253 return 1.0;
254 #endif
255 }
256
238 // Helper function that performs a surface hittest. 257 // Helper function that performs a surface hittest.
239 void SurfaceHitTestTestHelper( 258 void SurfaceHitTestTestHelper(
240 Shell* shell, 259 Shell* shell,
241 net::test_server::EmbeddedTestServer* embedded_test_server) { 260 net::test_server::EmbeddedTestServer* embedded_test_server) {
242 GURL main_url(embedded_test_server->GetURL( 261 GURL main_url(embedded_test_server->GetURL(
243 "/frame_tree/page_with_positioned_frame.html")); 262 "/frame_tree/page_with_positioned_frame.html"));
244 EXPECT_TRUE(NavigateToURL(shell, main_url)); 263 EXPECT_TRUE(NavigateToURL(shell, main_url));
245 264
246 // It is safe to obtain the root frame tree node here, as it doesn't change. 265 // 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()) 266 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell->web_contents())
(...skipping 19 matching lines...) Expand all
267 286
268 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( 287 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>(
269 root->current_frame_host()->GetRenderWidgetHost()->GetView()); 288 root->current_frame_host()->GetRenderWidgetHost()->GetView());
270 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( 289 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>(
271 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); 290 child_node->current_frame_host()->GetRenderWidgetHost()->GetView());
272 291
273 SurfaceHitTestReadyNotifier notifier( 292 SurfaceHitTestReadyNotifier notifier(
274 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); 293 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child));
275 notifier.WaitForSurfaceReady(); 294 notifier.WaitForSurfaceReady();
276 295
296 float scale_factor = GetAdjustmentScaleFactorForAndroid(shell);
297
298 // Get the view bounds of the child iframe, which should account for the
299 // relative offset of its direct parent within the root frame, for use in
300 // targeting the input event.
301 gfx::Rect bounds = rwhv_child->GetViewBounds();
302
277 // Target input event to child frame. 303 // Target input event to child frame.
278 blink::WebMouseEvent child_event(blink::WebInputEvent::MouseDown, 304 blink::WebMouseEvent child_event(blink::WebInputEvent::MouseDown,
279 blink::WebInputEvent::NoModifiers, 305 blink::WebInputEvent::NoModifiers,
280 blink::WebInputEvent::TimeStampForTesting); 306 blink::WebInputEvent::TimeStampForTesting);
281 child_event.button = blink::WebPointerProperties::Button::Left; 307 child_event.button = blink::WebPointerProperties::Button::Left;
282 child_event.x = 75; 308 child_event.x =
283 child_event.y = 75; 309 gfx::ToCeiledInt((bounds.x() - root_view->GetViewBounds().x()) /
310 scale_factor) +
311 3;
312 child_event.y =
313 gfx::ToCeiledInt((bounds.y() - root_view->GetViewBounds().y()) /
314 scale_factor) +
315 3;
284 child_event.clickCount = 1; 316 child_event.clickCount = 1;
285 main_frame_monitor.ResetEventReceived(); 317 main_frame_monitor.ResetEventReceived();
286 child_frame_monitor.ResetEventReceived(); 318 child_frame_monitor.ResetEventReceived();
287 router->RouteMouseEvent(root_view, &child_event, ui::LatencyInfo()); 319 router->RouteMouseEvent(root_view, &child_event, ui::LatencyInfo());
288 320
289 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); 321 EXPECT_TRUE(child_frame_monitor.EventWasReceived());
290 EXPECT_EQ(23, child_frame_monitor.event().x); 322 // The expected result coordinates are (3, 3), but can get slightly
291 EXPECT_EQ(23, child_frame_monitor.event().y); 323 // different results due to rounding error with some device scale factors.
324 EXPECT_TRUE(child_frame_monitor.event().x <= 5 &&
325 child_frame_monitor.event().x >= 1)
326 << " actual event.x: " << child_frame_monitor.event().x;
327 EXPECT_TRUE(child_frame_monitor.event().y <= 5 &&
328 child_frame_monitor.event().y >= 1)
329 << " actual event.y: " << child_frame_monitor.event().y;
292 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); 330 EXPECT_FALSE(main_frame_monitor.EventWasReceived());
293 331
294 child_frame_monitor.ResetEventReceived(); 332 child_frame_monitor.ResetEventReceived();
295 main_frame_monitor.ResetEventReceived(); 333 main_frame_monitor.ResetEventReceived();
296 334
297 // Target input event to main frame. 335 // Target input event to main frame.
298 blink::WebMouseEvent main_event(blink::WebInputEvent::MouseDown, 336 blink::WebMouseEvent main_event(blink::WebInputEvent::MouseDown,
299 blink::WebInputEvent::NoModifiers, 337 blink::WebInputEvent::NoModifiers,
300 blink::WebInputEvent::TimeStampForTesting); 338 blink::WebInputEvent::TimeStampForTesting);
301 main_event.button = blink::WebPointerProperties::Button::Left; 339 main_event.button = blink::WebPointerProperties::Button::Left;
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 }; 737 };
700 738
701 bool operator==(const ParsedFeaturePolicyDeclaration& first, 739 bool operator==(const ParsedFeaturePolicyDeclaration& first,
702 const ParsedFeaturePolicyDeclaration& second) { 740 const ParsedFeaturePolicyDeclaration& second) {
703 return std::tie(first.feature_name, first.matches_all_origins, 741 return std::tie(first.feature_name, first.matches_all_origins,
704 first.origins) == std::tie(second.feature_name, 742 first.origins) == std::tie(second.feature_name,
705 second.matches_all_origins, 743 second.matches_all_origins,
706 second.origins); 744 second.origins);
707 } 745 }
708 746
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, 747 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest,
719 SubframeLoadsWithCorrectDeviceScaleFactor) { 748 SubframeLoadsWithCorrectDeviceScaleFactor) {
720 GURL main_url(embedded_test_server()->GetURL( 749 GURL main_url(embedded_test_server()->GetURL(
721 "a.com", "/cross_site_iframe_factory.html?a(b)")); 750 "a.com", "/cross_site_iframe_factory.html?a(b)"));
722 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 751 EXPECT_TRUE(NavigateToURL(shell(), main_url));
723 752
724 // On Android forcing device scale factor does not work for tests, therefore 753 // 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 754 // we ensure that make frame and iframe have the same DIP scale there, but
726 // not necessarily kDeviceScaleFactor. 755 // not necessarily kDeviceScaleFactor.
727 const double expected_dip_scale = 756 const double expected_dip_scale =
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 987 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
959 bool frame_rect_received_; 988 bool frame_rect_received_;
960 gfx::Rect last_rect_; 989 gfx::Rect last_rect_;
961 990
962 DISALLOW_COPY_AND_ASSIGN(FrameRectChangedMessageFilter); 991 DISALLOW_COPY_AND_ASSIGN(FrameRectChangedMessageFilter);
963 }; 992 };
964 993
965 // Test that the view bounds for an out-of-process iframe are set and updated 994 // 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 995 // correctly, including accounting for local frame offsets in the parent and
967 // scroll positions. 996 // scroll positions.
968 #if defined(OS_ANDROID) 997 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( 998 GURL main_url(embedded_test_server()->GetURL(
978 "a.com", "/cross_site_iframe_factory.html?a(a)")); 999 "a.com", "/cross_site_iframe_factory.html?a(a)"));
979 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 1000 EXPECT_TRUE(NavigateToURL(shell(), main_url));
980 1001
981 // It is safe to obtain the root frame tree node here, as it doesn't change. 1002 // 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()) 1003 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
983 ->GetFrameTree() 1004 ->GetFrameTree()
984 ->root(); 1005 ->root();
985 RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>( 1006 RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>(
986 root->current_frame_host()->GetRenderWidgetHost()->GetView()); 1007 root->current_frame_host()->GetRenderWidgetHost()->GetView());
(...skipping 16 matching lines...) Expand all
1003 RenderWidgetHostViewBase* rwhv_nested = 1024 RenderWidgetHostViewBase* rwhv_nested =
1004 static_cast<RenderWidgetHostViewBase*>( 1025 static_cast<RenderWidgetHostViewBase*>(
1005 nested_iframe_node->current_frame_host() 1026 nested_iframe_node->current_frame_host()
1006 ->GetRenderWidgetHost() 1027 ->GetRenderWidgetHost()
1007 ->GetView()); 1028 ->GetView());
1008 1029
1009 SurfaceHitTestReadyNotifier notifier( 1030 SurfaceHitTestReadyNotifier notifier(
1010 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_nested)); 1031 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_nested));
1011 notifier.WaitForSurfaceReady(); 1032 notifier.WaitForSurfaceReady();
1012 1033
1034 #if defined(OS_ANDROID)
1035 // Android browser tests have some differences that affect the results. One
1036 // is viewport dimensions, the other is that it handles scale factor
1037 // differently.
1038 int expected_x = 487;
1039 #else
1040 int expected_x = 397;
1041 #endif
1042 int expected_y = 112;
1043 float scale_factor = GetAdjustmentScaleFactorForAndroid(shell());
1044
1013 // Verify the view bounds of the nested iframe, which should account for the 1045 // Verify the view bounds of the nested iframe, which should account for the
1014 // relative offset of its direct parent within the root frame. 1046 // relative offset of its direct parent within the root frame.
1015 gfx::Rect bounds = rwhv_nested->GetViewBounds(); 1047 gfx::Rect bounds = rwhv_nested->GetViewBounds();
1016 EXPECT_EQ(bounds.x() - rwhv_root->GetViewBounds().x(), 397); 1048 int diff_x = bounds.x() - rwhv_root->GetViewBounds().x() - expected_x;
1017 EXPECT_EQ(bounds.y() - rwhv_root->GetViewBounds().y(), 112); 1049 int diff_y = bounds.y() - rwhv_root->GetViewBounds().y() - expected_y;
1050 // diff_x and diff_y should usually be zero, but can get slightly different
1051 // results due to rounding error with some device scale factors.
1052 EXPECT_TRUE(diff_x <= 2 && diff_x >= -2) << " actual diff_x: " << diff_x;
1053 EXPECT_TRUE(diff_y <= 2 && diff_y >= -2) << " actual diff_y: " << diff_y;
1018 1054
1019 scoped_refptr<FrameRectChangedMessageFilter> filter = 1055 scoped_refptr<FrameRectChangedMessageFilter> filter =
1020 new FrameRectChangedMessageFilter(); 1056 new FrameRectChangedMessageFilter();
1021 root->current_frame_host()->GetProcess()->AddFilter(filter.get()); 1057 root->current_frame_host()->GetProcess()->AddFilter(filter.get());
1022 1058
1023 // Scroll the parent frame downward to verify that the child rect gets updated 1059 // Scroll the parent frame downward to verify that the child rect gets updated
1024 // correctly. 1060 // correctly.
1025 blink::WebMouseWheelEvent scroll_event( 1061 blink::WebMouseWheelEvent scroll_event(
1026 blink::WebInputEvent::MouseWheel, blink::WebInputEvent::NoModifiers, 1062 blink::WebInputEvent::MouseWheel, blink::WebInputEvent::NoModifiers,
1027 blink::WebInputEvent::TimeStampForTesting); 1063 blink::WebInputEvent::TimeStampForTesting);
1028 scroll_event.x = 387; 1064
1029 scroll_event.y = 110; 1065 scroll_event.x = gfx::ToFlooredInt(
1066 (bounds.x() - rwhv_root->GetViewBounds().x() - 5) / scale_factor);
1067 scroll_event.y = gfx::ToFlooredInt(
1068 (bounds.y() - rwhv_root->GetViewBounds().y() - 5) / scale_factor);
1030 scroll_event.deltaX = 0.0f; 1069 scroll_event.deltaX = 0.0f;
1031 scroll_event.deltaY = -30.0f; 1070 scroll_event.deltaY = -30.0f;
1032 rwhv_root->ProcessMouseWheelEvent(scroll_event, ui::LatencyInfo()); 1071 rwhv_root->ProcessMouseWheelEvent(scroll_event, ui::LatencyInfo());
1033 1072
1034 filter->Wait(); 1073 filter->Wait();
1035 1074
1036 // The precise amount of scroll for the first view position update is not 1075 // 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 1076 // deterministic, so this simply verifies that the OOPIF moved from its
1038 // earlier position. 1077 // earlier position.
1039 gfx::Rect update_rect = filter->last_rect(); 1078 gfx::Rect update_rect = filter->last_rect();
1040 EXPECT_LT(update_rect.y(), bounds.y() - rwhv_root->GetViewBounds().y()); 1079 EXPECT_LT(update_rect.y(), bounds.y() - rwhv_root->GetViewBounds().y());
1041 } 1080 }
1042 1081
1043 // Test that scrolling a nested out-of-process iframe bubbles unused scroll 1082 // Test that scrolling a nested out-of-process iframe bubbles unused scroll
1044 // delta to a parent frame. 1083 // 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 1084 // Flaky: https://crbug.com/627238
1048 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 1085 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
1049 DISABLED_ScrollBubblingFromOOPIFTest) { 1086 DISABLED_ScrollBubblingFromOOPIFTest) {
1050 GURL main_url(embedded_test_server()->GetURL( 1087 GURL main_url(embedded_test_server()->GetURL(
1051 "a.com", "/cross_site_iframe_factory.html?a(b)")); 1088 "a.com", "/cross_site_iframe_factory.html?a(b)"));
1052 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 1089 EXPECT_TRUE(NavigateToURL(shell(), main_url));
1053 1090
1054 // It is safe to obtain the root frame tree node here, as it doesn't change. 1091 // 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()) 1092 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
1056 ->GetFrameTree() 1093 ->GetFrameTree()
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 2); 1295 2);
1259 rwhv_parent->OnScrollEvent(&scroll_event); 1296 rwhv_parent->OnScrollEvent(&scroll_event);
1260 1297
1261 // Verify that this a mouse wheel event was sent to the child frame renderer. 1298 // Verify that this a mouse wheel event was sent to the child frame renderer.
1262 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); 1299 EXPECT_TRUE(child_frame_monitor.EventWasReceived());
1263 EXPECT_EQ(child_frame_monitor.EventType(), blink::WebInputEvent::MouseWheel); 1300 EXPECT_EQ(child_frame_monitor.EventType(), blink::WebInputEvent::MouseWheel);
1264 } 1301 }
1265 1302
1266 // Test that mouse events are being routed to the correct RenderWidgetHostView 1303 // Test that mouse events are being routed to the correct RenderWidgetHostView
1267 // based on coordinates. 1304 // based on coordinates.
1268 #if defined(OS_ANDROID) || defined(THREAD_SANITIZER) 1305 #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. 1306 // The test times out often on TSAN bot.
1272 // https://crbug.com/591170. 1307 // https://crbug.com/591170.
1273 #define MAYBE_SurfaceHitTestTest DISABLED_SurfaceHitTestTest 1308 #define MAYBE_SurfaceHitTestTest DISABLED_SurfaceHitTestTest
1274 #else 1309 #else
1275 #define MAYBE_SurfaceHitTestTest SurfaceHitTestTest 1310 #define MAYBE_SurfaceHitTestTest SurfaceHitTestTest
1276 #endif 1311 #endif
1277 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_SurfaceHitTestTest) { 1312 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_SurfaceHitTestTest) {
1278 SurfaceHitTestTestHelper(shell(), embedded_test_server()); 1313 SurfaceHitTestTestHelper(shell(), embedded_test_server());
1279 } 1314 }
1280 1315
1281 // Same test as above, but runs in high-dpi mode. 1316 // Same test as above, but runs in high-dpi mode.
1282 #if defined(OS_ANDROID) || defined(OS_WIN) 1317 #if defined(OS_ANDROID) || defined(OS_WIN)
1283 // Browser process hit testing is not implemented on Android. 1318 // High DPI browser tests are not needed on Android, and confuse some of the
1284 // https://crbug.com/491334 1319 // coordinate calculations. Android uses fixed device scale factor.
1285 // Windows is disabled because of https://crbug.com/545547. 1320 // Windows is disabled because of https://crbug.com/545547.
1286 #define MAYBE_HighDPISurfaceHitTestTest DISABLED_SurfaceHitTestTest 1321 #define MAYBE_HighDPISurfaceHitTestTest DISABLED_SurfaceHitTestTest
1287 #else 1322 #else
1288 #define MAYBE_HighDPISurfaceHitTestTest SurfaceHitTestTest 1323 #define MAYBE_HighDPISurfaceHitTestTest SurfaceHitTestTest
1289 #endif 1324 #endif
1290 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest, 1325 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest,
1291 MAYBE_HighDPISurfaceHitTestTest) { 1326 MAYBE_HighDPISurfaceHitTestTest) {
1292 SurfaceHitTestTestHelper(shell(), embedded_test_server()); 1327 SurfaceHitTestTestHelper(shell(), embedded_test_server());
1293 } 1328 }
1294 1329
1295 // Test that mouse events are being routed to the correct RenderWidgetHostView 1330 // Test that mouse events are being routed to the correct RenderWidgetHostView
1296 // when there are nested out-of-process iframes. 1331 // when there are nested out-of-process iframes.
1297 #if defined(OS_ANDROID) 1332 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( 1333 GURL main_url(embedded_test_server()->GetURL(
1307 "/frame_tree/page_with_positioned_nested_frames.html")); 1334 "/frame_tree/page_with_positioned_nested_frames.html"));
1308 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 1335 EXPECT_TRUE(NavigateToURL(shell(), main_url));
1309 1336
1310 // It is safe to obtain the root frame tree node here, as it doesn't change. 1337 // It is safe to obtain the root frame tree node here, as it doesn't change.
1311 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); 1338 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
1312 ASSERT_EQ(1U, root->child_count()); 1339 ASSERT_EQ(1U, root->child_count());
1313 1340
1314 FrameTreeNode* parent_iframe_node = root->child_at(0); 1341 FrameTreeNode* parent_iframe_node = root->child_at(0);
1315 GURL site_url(embedded_test_server()->GetURL( 1342 GURL site_url(embedded_test_server()->GetURL(
(...skipping 25 matching lines...) Expand all
1341 RenderWidgetHostViewBase* rwhv_nested = 1368 RenderWidgetHostViewBase* rwhv_nested =
1342 static_cast<RenderWidgetHostViewBase*>( 1369 static_cast<RenderWidgetHostViewBase*>(
1343 nested_iframe_node->current_frame_host() 1370 nested_iframe_node->current_frame_host()
1344 ->GetRenderWidgetHost() 1371 ->GetRenderWidgetHost()
1345 ->GetView()); 1372 ->GetView());
1346 1373
1347 SurfaceHitTestReadyNotifier notifier( 1374 SurfaceHitTestReadyNotifier notifier(
1348 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_nested)); 1375 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_nested));
1349 notifier.WaitForSurfaceReady(); 1376 notifier.WaitForSurfaceReady();
1350 1377
1378 float scale_factor = GetAdjustmentScaleFactorForAndroid(shell());
1379
1380 // Get the view bounds of the nested iframe, which should account for the
1381 // relative offset of its direct parent within the root frame, for use in
1382 // targeting the input event.
1383 gfx::Rect bounds = rwhv_nested->GetViewBounds();
1384
1351 // Target input event to nested frame. 1385 // Target input event to nested frame.
1352 blink::WebMouseEvent nested_event(blink::WebInputEvent::MouseDown, 1386 blink::WebMouseEvent nested_event(blink::WebInputEvent::MouseDown,
1353 blink::WebInputEvent::NoModifiers, 1387 blink::WebInputEvent::NoModifiers,
1354 blink::WebInputEvent::TimeStampForTesting); 1388 blink::WebInputEvent::TimeStampForTesting);
1355 nested_event.button = blink::WebPointerProperties::Button::Left; 1389 nested_event.button = blink::WebPointerProperties::Button::Left;
1356 nested_event.x = 125; 1390 nested_event.x =
1357 nested_event.y = 125; 1391 gfx::ToCeiledInt((bounds.x() - root_view->GetViewBounds().x()) /
1392 scale_factor) +
1393 5;
1394 nested_event.y =
1395 gfx::ToCeiledInt((bounds.y() - root_view->GetViewBounds().y()) /
1396 scale_factor) +
1397 5;
1358 nested_event.clickCount = 1; 1398 nested_event.clickCount = 1;
1359 nested_frame_monitor.ResetEventReceived(); 1399 nested_frame_monitor.ResetEventReceived();
1360 main_frame_monitor.ResetEventReceived(); 1400 main_frame_monitor.ResetEventReceived();
1361 router->RouteMouseEvent(root_view, &nested_event, ui::LatencyInfo()); 1401 router->RouteMouseEvent(root_view, &nested_event, ui::LatencyInfo());
1362 1402
1363 EXPECT_TRUE(nested_frame_monitor.EventWasReceived()); 1403 EXPECT_TRUE(nested_frame_monitor.EventWasReceived());
1364 EXPECT_EQ(21, nested_frame_monitor.event().x); 1404 // The expected result coordinates are (5, 5), but can get slightly
1365 EXPECT_EQ(21, nested_frame_monitor.event().y); 1405 // different results due to rounding error with some device scale factors.
1406 EXPECT_TRUE(nested_frame_monitor.event().x <= 6 &&
1407 nested_frame_monitor.event().x >= 4)
1408 << " actual event.x: " << nested_frame_monitor.event().x;
1409 EXPECT_TRUE(nested_frame_monitor.event().y <= 6 &&
1410 nested_frame_monitor.event().y >= 4)
1411 << " actual event.y: " << nested_frame_monitor.event().y;
1366 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); 1412 EXPECT_FALSE(main_frame_monitor.EventWasReceived());
1367 } 1413 }
1368 1414
1369 // This test tests that browser process hittesting ignores frames with 1415 // This test tests that browser process hittesting ignores frames with
1370 // pointer-events: none. 1416 // 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, 1417 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
1380 MAYBE_SurfaceHitTestPointerEventsNone) { 1418 SurfaceHitTestPointerEventsNone) {
1381 GURL main_url(embedded_test_server()->GetURL( 1419 GURL main_url(embedded_test_server()->GetURL(
1382 "/frame_tree/page_with_positioned_frame_pointer-events_none.html")); 1420 "/frame_tree/page_with_positioned_frame_pointer-events_none.html"));
1383 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 1421 EXPECT_TRUE(NavigateToURL(shell(), main_url));
1384 1422
1385 // It is safe to obtain the root frame tree node here, as it doesn't change. 1423 // It is safe to obtain the root frame tree node here, as it doesn't change.
1386 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); 1424 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
1387 ASSERT_EQ(1U, root->child_count()); 1425 ASSERT_EQ(1U, root->child_count());
1388 1426
1389 FrameTreeNode* child_node = root->child_at(0); 1427 FrameTreeNode* child_node = root->child_at(0);
1390 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); 1428 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html"));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 router->RouteMouseEvent(root_view, &child_event, ui::LatencyInfo()); 1461 router->RouteMouseEvent(root_view, &child_event, ui::LatencyInfo());
1424 1462
1425 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); 1463 EXPECT_TRUE(main_frame_monitor.EventWasReceived());
1426 EXPECT_EQ(75, main_frame_monitor.event().x); 1464 EXPECT_EQ(75, main_frame_monitor.event().x);
1427 EXPECT_EQ(75, main_frame_monitor.event().y); 1465 EXPECT_EQ(75, main_frame_monitor.event().y);
1428 EXPECT_FALSE(child_frame_monitor.EventWasReceived()); 1466 EXPECT_FALSE(child_frame_monitor.EventWasReceived());
1429 } 1467 }
1430 1468
1431 // This test verifies that MouseEnter and MouseLeave events fire correctly 1469 // This test verifies that MouseEnter and MouseLeave events fire correctly
1432 // when the mouse cursor moves between processes. 1470 // 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, 1471 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
1443 MAYBE_CrossProcessMouseEnterAndLeaveTest) { 1472 CrossProcessMouseEnterAndLeaveTest) {
1444 GURL main_url(embedded_test_server()->GetURL( 1473 GURL main_url(embedded_test_server()->GetURL(
1445 "a.com", "/cross_site_iframe_factory.html?a(b,c(d))")); 1474 "a.com", "/cross_site_iframe_factory.html?a(b,c(d))"));
1446 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 1475 EXPECT_TRUE(NavigateToURL(shell(), main_url));
1447 1476
1448 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 1477 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
1449 ->GetFrameTree() 1478 ->GetFrameTree()
1450 ->root(); 1479 ->root();
1451 1480
1452 EXPECT_EQ( 1481 EXPECT_EQ(
1453 " Site A ------------ proxies for B C D\n" 1482 " Site A ------------ proxies for B C D\n"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 root->current_frame_host()->GetRenderWidgetHost()); 1516 root->current_frame_host()->GetRenderWidgetHost());
1488 RenderWidgetHostMouseEventMonitor a_frame_monitor( 1517 RenderWidgetHostMouseEventMonitor a_frame_monitor(
1489 root->current_frame_host()->GetRenderWidgetHost()); 1518 root->current_frame_host()->GetRenderWidgetHost());
1490 RenderWidgetHostMouseEventMonitor b_frame_monitor( 1519 RenderWidgetHostMouseEventMonitor b_frame_monitor(
1491 b_node->current_frame_host()->GetRenderWidgetHost()); 1520 b_node->current_frame_host()->GetRenderWidgetHost());
1492 RenderWidgetHostMouseEventMonitor c_frame_monitor( 1521 RenderWidgetHostMouseEventMonitor c_frame_monitor(
1493 c_node->current_frame_host()->GetRenderWidgetHost()); 1522 c_node->current_frame_host()->GetRenderWidgetHost());
1494 RenderWidgetHostMouseEventMonitor d_frame_monitor( 1523 RenderWidgetHostMouseEventMonitor d_frame_monitor(
1495 d_node->current_frame_host()->GetRenderWidgetHost()); 1524 d_node->current_frame_host()->GetRenderWidgetHost());
1496 1525
1526 float scale_factor = GetAdjustmentScaleFactorForAndroid(shell());
1527
1528 // Get the view bounds of the child iframe, which should account for the
1529 // relative offset of its direct parent within the root frame, for use in
1530 // targeting the input event.
1531 gfx::Rect a_bounds = rwhv_a->GetViewBounds();
1532 gfx::Rect b_bounds = rwhv_b->GetViewBounds();
1533 gfx::Rect d_bounds = rwhv_d->GetViewBounds();
1534
1497 gfx::Point point_in_a_frame(2, 2); 1535 gfx::Point point_in_a_frame(2, 2);
1498 gfx::Point point_in_b_frame(313, 147); 1536 gfx::Point point_in_b_frame(
1499 gfx::Point point_in_d_frame(471, 207); 1537 gfx::ToCeiledInt((b_bounds.x() - a_bounds.x()) / scale_factor) + 25,
1538 gfx::ToCeiledInt((b_bounds.y() - a_bounds.y()) / scale_factor) + 25);
1539 gfx::Point point_in_d_frame(
1540 gfx::ToCeiledInt((d_bounds.x() - a_bounds.x()) / scale_factor) + 25,
1541 gfx::ToCeiledInt((d_bounds.y() - a_bounds.y()) / scale_factor) + 25);
1500 1542
1501 blink::WebMouseEvent mouse_event(blink::WebInputEvent::MouseMove, 1543 blink::WebMouseEvent mouse_event(blink::WebInputEvent::MouseMove,
1502 blink::WebInputEvent::NoModifiers, 1544 blink::WebInputEvent::NoModifiers,
1503 blink::WebInputEvent::TimeStampForTesting); 1545 blink::WebInputEvent::TimeStampForTesting);
1504 mouse_event.x = point_in_a_frame.x(); 1546 mouse_event.x = point_in_a_frame.x();
1505 mouse_event.y = point_in_a_frame.y(); 1547 mouse_event.y = point_in_a_frame.y();
1506 1548
1507 // Send an initial MouseMove to the root view, which shouldn't affect the 1549 // Send an initial MouseMove to the root view, which shouldn't affect the
1508 // other renderers. 1550 // other renderers.
1509 web_contents()->GetInputEventRouter()->RouteMouseEvent(rwhv_a, &mouse_event, 1551 web_contents()->GetInputEventRouter()->RouteMouseEvent(rwhv_a, &mouse_event,
(...skipping 29 matching lines...) Expand all
1539 EXPECT_TRUE(b_frame_monitor.EventWasReceived()); 1581 EXPECT_TRUE(b_frame_monitor.EventWasReceived());
1540 EXPECT_EQ(b_frame_monitor.event().type(), blink::WebInputEvent::MouseLeave); 1582 EXPECT_EQ(b_frame_monitor.event().type(), blink::WebInputEvent::MouseLeave);
1541 EXPECT_TRUE(c_frame_monitor.EventWasReceived()); 1583 EXPECT_TRUE(c_frame_monitor.EventWasReceived());
1542 EXPECT_EQ(c_frame_monitor.event().type(), blink::WebInputEvent::MouseMove); 1584 EXPECT_EQ(c_frame_monitor.event().type(), blink::WebInputEvent::MouseMove);
1543 EXPECT_TRUE(d_frame_monitor.EventWasReceived()); 1585 EXPECT_TRUE(d_frame_monitor.EventWasReceived());
1544 } 1586 }
1545 1587
1546 // Verify that mouse capture works on a RenderWidgetHostView level, so that 1588 // Verify that mouse capture works on a RenderWidgetHostView level, so that
1547 // dragging scroll bars and selecting text continues even when the mouse 1589 // dragging scroll bars and selecting text continues even when the mouse
1548 // cursor crosses over cross-process frame boundaries. 1590 // cursor crosses over cross-process frame boundaries.
1549 #if defined(OS_ANDROID) 1591 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( 1592 GURL main_url(embedded_test_server()->GetURL(
1559 "/frame_tree/page_with_positioned_frame.html")); 1593 "/frame_tree/page_with_positioned_frame.html"));
1560 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 1594 EXPECT_TRUE(NavigateToURL(shell(), main_url));
1561 1595
1562 // It is safe to obtain the root frame tree node here, as it doesn't change. 1596 // It is safe to obtain the root frame tree node here, as it doesn't change.
1563 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); 1597 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
1564 ASSERT_EQ(1U, root->child_count()); 1598 ASSERT_EQ(1U, root->child_count());
1565 1599
1566 FrameTreeNode* child_node = root->child_at(0); 1600 FrameTreeNode* child_node = root->child_at(0);
1567 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); 1601 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html"));
(...skipping 12 matching lines...) Expand all
1580 1614
1581 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( 1615 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>(
1582 root->current_frame_host()->GetRenderWidgetHost()->GetView()); 1616 root->current_frame_host()->GetRenderWidgetHost()->GetView());
1583 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( 1617 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>(
1584 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); 1618 child_node->current_frame_host()->GetRenderWidgetHost()->GetView());
1585 1619
1586 SurfaceHitTestReadyNotifier notifier( 1620 SurfaceHitTestReadyNotifier notifier(
1587 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); 1621 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child));
1588 notifier.WaitForSurfaceReady(); 1622 notifier.WaitForSurfaceReady();
1589 1623
1624 float scale_factor = GetAdjustmentScaleFactorForAndroid(shell());
1625
1626 // Get the view bounds of the child iframe, which should account for the
1627 // relative offset of its direct parent within the root frame, for use in
1628 // targeting the input event.
1629 gfx::Rect bounds = rwhv_child->GetViewBounds();
1630 int child_frame_target_x =
1631 gfx::ToCeiledInt((bounds.x() - root_view->GetViewBounds().x()) /
1632 scale_factor) +
1633 5;
1634 int child_frame_target_y =
1635 gfx::ToCeiledInt((bounds.y() - root_view->GetViewBounds().y()) /
1636 scale_factor) +
1637 5;
1638
1590 // Target MouseDown to child frame. 1639 // Target MouseDown to child frame.
1591 blink::WebMouseEvent mouse_event(blink::WebInputEvent::MouseDown, 1640 blink::WebMouseEvent mouse_event(blink::WebInputEvent::MouseDown,
1592 blink::WebInputEvent::NoModifiers, 1641 blink::WebInputEvent::NoModifiers,
1593 blink::WebInputEvent::TimeStampForTesting); 1642 blink::WebInputEvent::TimeStampForTesting);
1594 mouse_event.button = blink::WebPointerProperties::Button::Left; 1643 mouse_event.button = blink::WebPointerProperties::Button::Left;
1595 mouse_event.x = 75; 1644 mouse_event.x = child_frame_target_x;
1596 mouse_event.y = 75; 1645 mouse_event.y = child_frame_target_y;
1597 mouse_event.clickCount = 1; 1646 mouse_event.clickCount = 1;
1598 main_frame_monitor.ResetEventReceived(); 1647 main_frame_monitor.ResetEventReceived();
1599 child_frame_monitor.ResetEventReceived(); 1648 child_frame_monitor.ResetEventReceived();
1600 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); 1649 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo());
1601 1650
1602 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); 1651 EXPECT_FALSE(main_frame_monitor.EventWasReceived());
1603 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); 1652 EXPECT_TRUE(child_frame_monitor.EventWasReceived());
1604 1653
1605 // Target MouseMove to main frame. This should still be routed to the 1654 // Target MouseMove to main frame. This should still be routed to the
1606 // child frame because it is now capturing mouse input. 1655 // child frame because it is now capturing mouse input.
(...skipping 11 matching lines...) Expand all
1618 mouse_event.x = 1; 1667 mouse_event.x = 1;
1619 mouse_event.y = 2; 1668 mouse_event.y = 2;
1620 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); 1669 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo());
1621 1670
1622 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); 1671 EXPECT_FALSE(main_frame_monitor.EventWasReceived());
1623 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); 1672 EXPECT_TRUE(child_frame_monitor.EventWasReceived());
1624 1673
1625 // A MouseUp to the child frame should cancel the mouse capture. 1674 // A MouseUp to the child frame should cancel the mouse capture.
1626 mouse_event.setType(blink::WebInputEvent::MouseUp); 1675 mouse_event.setType(blink::WebInputEvent::MouseUp);
1627 mouse_event.setModifiers(blink::WebInputEvent::NoModifiers); 1676 mouse_event.setModifiers(blink::WebInputEvent::NoModifiers);
1628 mouse_event.x = 75; 1677 mouse_event.x = child_frame_target_x;
1629 mouse_event.y = 75; 1678 mouse_event.y = child_frame_target_y;
1630 main_frame_monitor.ResetEventReceived(); 1679 main_frame_monitor.ResetEventReceived();
1631 child_frame_monitor.ResetEventReceived(); 1680 child_frame_monitor.ResetEventReceived();
1632 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); 1681 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo());
1633 1682
1634 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); 1683 EXPECT_FALSE(main_frame_monitor.EventWasReceived());
1635 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); 1684 EXPECT_TRUE(child_frame_monitor.EventWasReceived());
1636 1685
1637 // Subsequent MouseMove events targeted to the main frame should be routed 1686 // Subsequent MouseMove events targeted to the main frame should be routed
1638 // to that frame. 1687 // to that frame.
1639 mouse_event.setType(blink::WebInputEvent::MouseMove); 1688 mouse_event.setType(blink::WebInputEvent::MouseMove);
(...skipping 18 matching lines...) Expand all
1658 child_frame_monitor.ResetEventReceived(); 1707 child_frame_monitor.ResetEventReceived();
1659 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); 1708 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo());
1660 1709
1661 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); 1710 EXPECT_TRUE(main_frame_monitor.EventWasReceived());
1662 EXPECT_FALSE(child_frame_monitor.EventWasReceived()); 1711 EXPECT_FALSE(child_frame_monitor.EventWasReceived());
1663 1712
1664 // Sending a MouseMove to the child frame should still result in the main 1713 // Sending a MouseMove to the child frame should still result in the main
1665 // frame receiving the event. 1714 // frame receiving the event.
1666 mouse_event.setType(blink::WebInputEvent::MouseMove); 1715 mouse_event.setType(blink::WebInputEvent::MouseMove);
1667 mouse_event.setModifiers(blink::WebInputEvent::LeftButtonDown); 1716 mouse_event.setModifiers(blink::WebInputEvent::LeftButtonDown);
1668 mouse_event.x = 75; 1717 mouse_event.x = child_frame_target_x;
1669 mouse_event.y = 75; 1718 mouse_event.y = child_frame_target_y;
1670 main_frame_monitor.ResetEventReceived(); 1719 main_frame_monitor.ResetEventReceived();
1671 child_frame_monitor.ResetEventReceived(); 1720 child_frame_monitor.ResetEventReceived();
1672 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo()); 1721 router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo());
1673 1722
1674 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); 1723 EXPECT_TRUE(main_frame_monitor.EventWasReceived());
1675 EXPECT_FALSE(child_frame_monitor.EventWasReceived()); 1724 EXPECT_FALSE(child_frame_monitor.EventWasReceived());
1676 } 1725 }
1677 1726
1678 // Tests OOPIF rendering by checking that the RWH of the iframe generates 1727 // Tests OOPIF rendering by checking that the RWH of the iframe generates
1679 // OnSwapCompositorFrame message. 1728 // OnSwapCompositorFrame message.
(...skipping 4277 matching lines...) Expand 10 before | Expand all | Expand 10 after
5957 notifier.WaitForSurfaceReady(); 6006 notifier.WaitForSurfaceReady();
5958 6007
5959 // A WebContentsDelegate to listen for the ShowContextMenu message. 6008 // A WebContentsDelegate to listen for the ShowContextMenu message.
5960 ContextMenuObserverDelegate context_menu_delegate; 6009 ContextMenuObserverDelegate context_menu_delegate;
5961 shell->web_contents()->SetDelegate(&context_menu_delegate); 6010 shell->web_contents()->SetDelegate(&context_menu_delegate);
5962 6011
5963 RenderWidgetHostInputEventRouter* router = 6012 RenderWidgetHostInputEventRouter* router =
5964 static_cast<WebContentsImpl*>(shell->web_contents()) 6013 static_cast<WebContentsImpl*>(shell->web_contents())
5965 ->GetInputEventRouter(); 6014 ->GetInputEventRouter();
5966 6015
5967 gfx::Point point(75, 75); 6016 float scale_factor = GetAdjustmentScaleFactorForAndroid(shell);
6017
6018 gfx::Rect root_bounds = root_view->GetViewBounds();
6019 gfx::Rect bounds = rwhv_child->GetViewBounds();
6020
6021 gfx::Point point(
6022 gfx::ToCeiledInt((bounds.x() - root_bounds.x()) / scale_factor) + 10,
6023 gfx::ToCeiledInt((bounds.y() - root_bounds.y()) / scale_factor) + 10);
5968 6024
5969 // Target right-click event to child frame. 6025 // Target right-click event to child frame.
5970 blink::WebMouseEvent click_event(blink::WebInputEvent::MouseDown, 6026 blink::WebMouseEvent click_event(blink::WebInputEvent::MouseDown,
5971 blink::WebInputEvent::NoModifiers, 6027 blink::WebInputEvent::NoModifiers,
5972 blink::WebInputEvent::TimeStampForTesting); 6028 blink::WebInputEvent::TimeStampForTesting);
5973 click_event.button = blink::WebPointerProperties::Button::Right; 6029 click_event.button = blink::WebPointerProperties::Button::Right;
5974 click_event.x = point.x(); 6030 click_event.x = point.x();
5975 click_event.y = point.y(); 6031 click_event.y = point.y();
5976 click_event.clickCount = 1; 6032 click_event.clickCount = 1;
5977 router->RouteMouseEvent(root_view, &click_event, ui::LatencyInfo()); 6033 router->RouteMouseEvent(root_view, &click_event, ui::LatencyInfo());
5978 6034
5979 // We also need a MouseUp event, needed by Windows. 6035 // We also need a MouseUp event, needed by Windows.
5980 click_event.setType(blink::WebInputEvent::MouseUp); 6036 click_event.setType(blink::WebInputEvent::MouseUp);
5981 click_event.x = point.x(); 6037 click_event.x = point.x();
5982 click_event.y = point.y(); 6038 click_event.y = point.y();
5983 router->RouteMouseEvent(root_view, &click_event, ui::LatencyInfo()); 6039 router->RouteMouseEvent(root_view, &click_event, ui::LatencyInfo());
5984 6040
5985 context_menu_delegate.Wait(); 6041 context_menu_delegate.Wait();
5986 6042
5987 ContextMenuParams params = context_menu_delegate.getParams(); 6043 ContextMenuParams params = context_menu_delegate.getParams();
5988 6044
5989 EXPECT_EQ(point.x(), params.x); 6045 EXPECT_EQ(point.x(), params.x);
5990 EXPECT_EQ(point.y(), params.y); 6046 EXPECT_EQ(point.y(), params.y);
5991 } 6047 }
5992 6048
5993 // Test that a mouse right-click to an out-of-process iframe causes a context 6049 // 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. 6050 // menu to be generated with the correct screen position.
5995 #if defined(OS_ANDROID) 6051 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()); 6052 CreateContextMenuTestHelper(shell(), embedded_test_server());
6004 } 6053 }
6005 6054
6006 // Test that a mouse right-click to an out-of-process iframe causes a context 6055 // 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 6056 // menu to be generated with the correct screen position on a screen with
6008 // non-default scale factor. 6057 // non-default scale factor.
6009 #if defined(OS_ANDROID) || defined(OS_WIN) 6058 #if defined(OS_ANDROID) || defined(OS_WIN)
6010 // Browser process hit testing is not implemented on Android. 6059 // 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. 6060 // Windows is disabled because of https://crbug.com/545547.
6013 #define MAYBE_HighDPICreateContextMenuTest DISABLED_HighDPICreateContextMenuTest 6061 #define MAYBE_HighDPICreateContextMenuTest DISABLED_HighDPICreateContextMenuTest
6014 #else 6062 #else
6015 #define MAYBE_HighDPICreateContextMenuTest HighDPICreateContextMenuTest 6063 #define MAYBE_HighDPICreateContextMenuTest HighDPICreateContextMenuTest
6016 #endif 6064 #endif
6017 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest, 6065 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest,
6018 MAYBE_HighDPICreateContextMenuTest) { 6066 MAYBE_HighDPICreateContextMenuTest) {
6019 CreateContextMenuTestHelper(shell(), embedded_test_server()); 6067 CreateContextMenuTestHelper(shell(), embedded_test_server());
6020 } 6068 }
6021 6069
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
6078 } 6126 }
6079 6127
6080 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 6128 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
6081 gfx::Rect initial_rect_; 6129 gfx::Rect initial_rect_;
6082 6130
6083 DISALLOW_COPY_AND_ASSIGN(ShowWidgetMessageFilter); 6131 DISALLOW_COPY_AND_ASSIGN(ShowWidgetMessageFilter);
6084 }; 6132 };
6085 6133
6086 // Test that clicking a select element in an out-of-process iframe creates 6134 // Test that clicking a select element in an out-of-process iframe creates
6087 // a popup menu in the correct position. 6135 // a popup menu in the correct position.
6088 #if defined(OS_ANDROID) 6136 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( 6137 GURL main_url(
6097 embedded_test_server()->GetURL("/cross_site_iframe_factory.html?a(a)")); 6138 embedded_test_server()->GetURL("/cross_site_iframe_factory.html?a(a)"));
6098 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 6139 EXPECT_TRUE(NavigateToURL(shell(), main_url));
6099 6140
6100 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); 6141 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
6101 6142
6102 #if !defined(OS_MACOSX) 6143 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
6103 // Unused variable on Mac. 6144 // Unused variable on Mac and Android.
6104 RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>( 6145 RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>(
6105 root->current_frame_host()->GetRenderWidgetHost()->GetView()); 6146 root->current_frame_host()->GetRenderWidgetHost()->GetView());
6106 #endif 6147 #endif
6107 web_contents()->SendScreenRects(); 6148 web_contents()->SendScreenRects();
6108 6149
6109 content::TestNavigationObserver navigation_observer(shell()->web_contents()); 6150 content::TestNavigationObserver navigation_observer(shell()->web_contents());
6110 FrameTreeNode* child_node = root->child_at(0); 6151 FrameTreeNode* child_node = root->child_at(0);
6111 GURL site_url(embedded_test_server()->GetURL( 6152 GURL site_url(embedded_test_server()->GetURL(
6112 "baz.com", "/site_isolation/page-with-select.html")); 6153 "baz.com", "/site_isolation/page-with-select.html"));
6113 NavigateFrameToURL(child_node, site_url); 6154 NavigateFrameToURL(child_node, site_url);
(...skipping 18 matching lines...) Expand all
6132 click_event.clickCount = 1; 6173 click_event.clickCount = 1;
6133 rwhv_child->ProcessMouseEvent(click_event, ui::LatencyInfo()); 6174 rwhv_child->ProcessMouseEvent(click_event, ui::LatencyInfo());
6134 6175
6135 // Dismiss the popup. 6176 // Dismiss the popup.
6136 click_event.x = 1; 6177 click_event.x = 1;
6137 click_event.y = 1; 6178 click_event.y = 1;
6138 rwhv_child->ProcessMouseEvent(click_event, ui::LatencyInfo()); 6179 rwhv_child->ProcessMouseEvent(click_event, ui::LatencyInfo());
6139 6180
6140 filter->Wait(); 6181 filter->Wait();
6141 gfx::Rect popup_rect = filter->last_initial_rect(); 6182 gfx::Rect popup_rect = filter->last_initial_rect();
6142 #if defined(OS_MACOSX) 6183 #if defined(OS_MACOSX) || defined(OS_ANDROID)
6143 // On Mac we receive the coordinates before they are transformed, so they 6184 // On Mac and Android we receive the coordinates before they are transformed,
6144 // are still relative to the out-of-process iframe origin. 6185 // so they are still relative to the out-of-process iframe origin.
6145 EXPECT_EQ(popup_rect.x(), 9); 6186 EXPECT_EQ(popup_rect.x(), 9);
6146 EXPECT_EQ(popup_rect.y(), 9); 6187 EXPECT_EQ(popup_rect.y(), 9);
6147 #else 6188 #else
6148 EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354); 6189 EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354);
6149 EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 94); 6190 EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 94);
6150 #endif 6191 #endif
6151 } 6192 }
6152 6193
6153 // Test that clicking a select element in a nested out-of-process iframe creates 6194 // 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 6195 // 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
8986 EXPECT_EQ(srcdoc_url, child->current_url()); 9027 EXPECT_EQ(srcdoc_url, child->current_url());
8987 EXPECT_EQ(root->current_frame_host()->GetSiteInstance(), 9028 EXPECT_EQ(root->current_frame_host()->GetSiteInstance(),
8988 child->current_frame_host()->GetSiteInstance()); 9029 child->current_frame_host()->GetSiteInstance());
8989 EXPECT_EQ(root->current_frame_host()->GetProcess(), 9030 EXPECT_EQ(root->current_frame_host()->GetProcess(),
8990 child->current_frame_host()->GetProcess()); 9031 child->current_frame_host()->GetProcess());
8991 } 9032 }
8992 9033
8993 // Test that MouseDown and MouseUp to the same coordinates do not result in 9034 // Test that MouseDown and MouseUp to the same coordinates do not result in
8994 // different coordinates after routing. See bug https://crbug.com/670253. 9035 // different coordinates after routing. See bug https://crbug.com/670253.
8995 #if defined(OS_ANDROID) 9036 #if defined(OS_ANDROID)
8996 // Browser process hit testing is not implemented on Android. 9037 // Android uses fixed scale factor, which makes this test unnecessary.
8997 // https://crbug.com/491334
8998 #define MAYBE_MouseClickWithNonIntegerScaleFactor \ 9038 #define MAYBE_MouseClickWithNonIntegerScaleFactor \
8999 DISABLED_MouseClickWithNonIntegerScaleFactor 9039 DISABLED_MouseClickWithNonIntegerScaleFactor
9000 #else 9040 #else
9001 #define MAYBE_MouseClickWithNonIntegerScaleFactor \ 9041 #define MAYBE_MouseClickWithNonIntegerScaleFactor \
9002 MouseClickWithNonIntegerScaleFactor 9042 MouseClickWithNonIntegerScaleFactor
9003 #endif 9043 #endif
9004 IN_PROC_BROWSER_TEST_F(SitePerProcessNonIntegerScaleFactorBrowserTest, 9044 IN_PROC_BROWSER_TEST_F(SitePerProcessNonIntegerScaleFactorBrowserTest,
9005 MAYBE_MouseClickWithNonIntegerScaleFactor) { 9045 MAYBE_MouseClickWithNonIntegerScaleFactor) {
9006 GURL initial_url(embedded_test_server()->GetURL("a.com", "/title1.html")); 9046 GURL initial_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
9007 EXPECT_TRUE(NavigateToURL(shell(), initial_url)); 9047 EXPECT_TRUE(NavigateToURL(shell(), initial_url));
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
9576 9616
9577 // Try the same navigation, but use the browser-initiated path. 9617 // Try the same navigation, but use the browser-initiated path.
9578 NavigateFrameToURL(root->child_at(0), frame_url); 9618 NavigateFrameToURL(root->child_at(0), frame_url);
9579 EXPECT_FALSE(root->child_at(0)->render_manager()->pending_frame_host()); 9619 EXPECT_FALSE(root->child_at(0)->render_manager()->pending_frame_host());
9580 EXPECT_EQ(root->child_at(0)->current_url(), redirected_url); 9620 EXPECT_EQ(root->child_at(0)->current_url(), redirected_url);
9581 EXPECT_EQ(b_site_instance, 9621 EXPECT_EQ(b_site_instance,
9582 root->child_at(0)->current_frame_host()->GetSiteInstance()); 9622 root->child_at(0)->current_frame_host()->GetSiteInstance());
9583 } 9623 }
9584 9624
9585 } // namespace content 9625 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.cc ('k') | ui/android/delegated_frame_host_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698