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

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

Issue 2339503002: Allow OOPIFs to capture mouse input while mouse button is held down (Closed)
Patch Set: Clear capture target on its destruction Created 4 years, 3 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_input_event_router.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 main_frame_monitor.ResetEventReceived(); 1291 main_frame_monitor.ResetEventReceived();
1292 child_frame_monitor.ResetEventReceived(); 1292 child_frame_monitor.ResetEventReceived();
1293 router->RouteMouseEvent(root_view, &child_event); 1293 router->RouteMouseEvent(root_view, &child_event);
1294 1294
1295 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); 1295 EXPECT_TRUE(main_frame_monitor.EventWasReceived());
1296 EXPECT_EQ(75, main_frame_monitor.event().x); 1296 EXPECT_EQ(75, main_frame_monitor.event().x);
1297 EXPECT_EQ(75, main_frame_monitor.event().y); 1297 EXPECT_EQ(75, main_frame_monitor.event().y);
1298 EXPECT_FALSE(child_frame_monitor.EventWasReceived()); 1298 EXPECT_FALSE(child_frame_monitor.EventWasReceived());
1299 } 1299 }
1300 1300
1301 // Verify that mouse capture works on a RenderWidgetHostView level, so that
1302 // dragging scroll bars and selecting text continues even when the mouse
1303 // cursor crosses over inter-process frame boundaries.
nasko 2016/09/14 16:36:47 nit: s/inter-process/cross-process/
kenrb 2016/09/14 20:33:32 Done.
1304 #if defined(OS_ANDROID)
1305 // Browser process hit testing is not implemented on Android.
1306 // https://crbug.com/491334
1307 #define MAYBE_CrossProcessMouseCapture DISABLED_CrossProcessMouseCapture
1308 #else
1309 #define MAYBE_CrossProcessMouseCapture CrossProcessMouseCapture
1310 #endif
1311 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
1312 MAYBE_CrossProcessMouseCapture) {
1313 GURL main_url(embedded_test_server()->GetURL(
1314 "/frame_tree/page_with_positioned_frame.html"));
1315 NavigateToURL(shell(), main_url);
nasko 2016/09/14 16:36:48 EXPECT_TRUE
kenrb 2016/09/14 20:33:32 Done.
1316
1317 // It is safe to obtain the root frame tree node here, as it doesn't change.
1318 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
1319 ASSERT_EQ(1U, root->child_count());
1320
1321 FrameTreeNode* child_node = root->child_at(0);
1322 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html"));
1323 EXPECT_EQ(site_url, child_node->current_url());
1324 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
1325 child_node->current_frame_host()->GetSiteInstance());
1326
1327 // Create listeners for mouse events.
1328 RenderWidgetHostMouseEventMonitor main_frame_monitor(
1329 root->current_frame_host()->GetRenderWidgetHost());
1330 RenderWidgetHostMouseEventMonitor child_frame_monitor(
1331 child_node->current_frame_host()->GetRenderWidgetHost());
1332
1333 RenderWidgetHostInputEventRouter* router =
1334 web_contents()->GetInputEventRouter();
1335
1336 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>(
1337 root->current_frame_host()->GetRenderWidgetHost()->GetView());
1338 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>(
1339 child_node->current_frame_host()->GetRenderWidgetHost()->GetView());
1340
1341 SurfaceHitTestReadyNotifier notifier(
1342 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child));
1343 notifier.WaitForSurfaceReady();
1344
1345 // Target MouseDown to child frame.
1346 blink::WebMouseEvent mouse_event;
1347 mouse_event.type = blink::WebInputEvent::MouseDown;
1348 mouse_event.button = blink::WebPointerProperties::Button::Left;
1349 mouse_event.x = 75;
1350 mouse_event.y = 75;
1351 mouse_event.clickCount = 1;
1352 main_frame_monitor.ResetEventReceived();
1353 child_frame_monitor.ResetEventReceived();
1354 router->RouteMouseEvent(root_view, &mouse_event);
1355
1356 EXPECT_FALSE(main_frame_monitor.EventWasReceived());
1357 EXPECT_TRUE(child_frame_monitor.EventWasReceived());
1358
1359 // Target MouseMove to main frame. This should still be routed to the
1360 // child frame because it is now capturing mouse input.
1361 mouse_event.type = blink::WebInputEvent::MouseMove;
1362 mouse_event.modifiers = blink::WebInputEvent::LeftButtonDown;
1363 mouse_event.x = 1;
1364 mouse_event.y = 1;
1365 main_frame_monitor.ResetEventReceived();
1366 child_frame_monitor.ResetEventReceived();
1367 router->RouteMouseEvent(root_view, &mouse_event);
1368
1369 EXPECT_FALSE(main_frame_monitor.EventWasReceived());
1370 EXPECT_TRUE(child_frame_monitor.EventWasReceived());
1371
1372 // A MouseUp to the child frame should cancel the mouse capture.
1373 mouse_event.type = blink::WebInputEvent::MouseUp;
1374 mouse_event.modifiers = 0;
1375 mouse_event.x = 75;
1376 mouse_event.y = 75;
1377 main_frame_monitor.ResetEventReceived();
1378 child_frame_monitor.ResetEventReceived();
1379 router->RouteMouseEvent(root_view, &mouse_event);
1380
1381 EXPECT_FALSE(main_frame_monitor.EventWasReceived());
1382 EXPECT_TRUE(child_frame_monitor.EventWasReceived());
1383
1384 // Subsequent MouseMove events targeted to the main frame should be routed
1385 // to that frame.
1386 mouse_event.type = blink::WebInputEvent::MouseMove;
1387 mouse_event.x = 1;
1388 mouse_event.y = 1;
nasko 2016/09/14 16:36:48 nit: Should we actually move the mouse event to a
kenrb 2016/09/14 20:33:32 Done.
1389 main_frame_monitor.ResetEventReceived();
1390 child_frame_monitor.ResetEventReceived();
1391 router->RouteMouseEvent(root_view, &mouse_event);
1392
1393 EXPECT_TRUE(main_frame_monitor.EventWasReceived());
1394 EXPECT_FALSE(child_frame_monitor.EventWasReceived());
1395
1396 // Target MouseDown to the main frame to cause it to capture input.
1397 mouse_event.type = blink::WebInputEvent::MouseDown;
1398 mouse_event.x = 1;
1399 mouse_event.y = 1;
1400 main_frame_monitor.ResetEventReceived();
1401 child_frame_monitor.ResetEventReceived();
1402 router->RouteMouseEvent(root_view, &mouse_event);
1403
1404 EXPECT_TRUE(main_frame_monitor.EventWasReceived());
1405 EXPECT_FALSE(child_frame_monitor.EventWasReceived());
1406
1407 // Sending a MouseMove to the child frame should still result in the main
1408 // frame receiving the event.
1409 mouse_event.type = blink::WebInputEvent::MouseMove;
1410 mouse_event.modifiers = blink::WebInputEvent::LeftButtonDown;
1411 mouse_event.x = 75;
1412 mouse_event.y = 75;
1413 main_frame_monitor.ResetEventReceived();
1414 child_frame_monitor.ResetEventReceived();
1415 router->RouteMouseEvent(root_view, &mouse_event);
1416
1417 EXPECT_TRUE(main_frame_monitor.EventWasReceived());
1418 EXPECT_FALSE(child_frame_monitor.EventWasReceived());
1419 }
1420
1301 // Tests OOPIF rendering by checking that the RWH of the iframe generates 1421 // Tests OOPIF rendering by checking that the RWH of the iframe generates
1302 // OnSwapCompositorFrame message. 1422 // OnSwapCompositorFrame message.
1303 #if defined(OS_ANDROID) 1423 #if defined(OS_ANDROID)
1304 // http://crbug.com/471850 1424 // http://crbug.com/471850
1305 #define MAYBE_CompositorFrameSwapped DISABLED_CompositorFrameSwapped 1425 #define MAYBE_CompositorFrameSwapped DISABLED_CompositorFrameSwapped
1306 #else 1426 #else
1307 #define MAYBE_CompositorFrameSwapped CompositorFrameSwapped 1427 #define MAYBE_CompositorFrameSwapped CompositorFrameSwapped
1308 #endif 1428 #endif
1309 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 1429 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
1310 MAYBE_CompositorFrameSwapped) { 1430 MAYBE_CompositorFrameSwapped) {
(...skipping 6603 matching lines...) Expand 10 before | Expand all | Expand 10 after
7914 child_rfh->OnDispatchLoad(); 8034 child_rfh->OnDispatchLoad();
7915 8035
7916 // In the bug, OnDispatchLoad killed the b.com renderer. Ensure that this is 8036 // In the bug, OnDispatchLoad killed the b.com renderer. Ensure that this is
7917 // not the case. Note that the process kill doesn't happen immediately, so 8037 // not the case. Note that the process kill doesn't happen immediately, so
7918 // IsRenderFrameLive() can't be checked here (yet). Instead, check that 8038 // IsRenderFrameLive() can't be checked here (yet). Instead, check that
7919 // JavaScript can still execute in b.com using the popup. 8039 // JavaScript can still execute in b.com using the popup.
7920 EXPECT_TRUE(ExecuteScript(popup_shell->web_contents(), "true")); 8040 EXPECT_TRUE(ExecuteScript(popup_shell->web_contents(), "true"));
7921 } 8041 }
7922 8042
7923 } // namespace content 8043 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_input_event_router.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698