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

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: 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
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.
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);
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.x = 1;
1363 mouse_event.y = 1;
1364 main_frame_monitor.ResetEventReceived();
1365 child_frame_monitor.ResetEventReceived();
1366 router->RouteMouseEvent(root_view, &mouse_event);
1367
1368 EXPECT_FALSE(main_frame_monitor.EventWasReceived());
1369 EXPECT_TRUE(child_frame_monitor.EventWasReceived());
1370
1371 // A MouseUp to the child frame should cancel the mouse capture.
1372 mouse_event.type = blink::WebInputEvent::MouseUp;
1373 mouse_event.x = 75;
1374 mouse_event.y = 75;
1375 router->RouteMouseEvent(root_view, &mouse_event);
mustaq 2016/09/13 16:57:15 Nit: May be test for mouseup too that the event go
kenrb 2016/09/13 20:01:53 Done.
1376
1377 // Subsequent MouseMove events targeted to the main frame should be routed
1378 // to that frame.
1379 mouse_event.type = blink::WebInputEvent::MouseMove;
1380 mouse_event.x = 1;
1381 mouse_event.y = 1;
1382 main_frame_monitor.ResetEventReceived();
1383 child_frame_monitor.ResetEventReceived();
1384 router->RouteMouseEvent(root_view, &mouse_event);
1385
1386 EXPECT_TRUE(main_frame_monitor.EventWasReceived());
1387 EXPECT_FALSE(child_frame_monitor.EventWasReceived());
1388 }
mustaq 2016/09/13 16:57:15 Is the behavior symmetric for the "reciprocal" cas
kenrb 2016/09/13 20:01:53 Done.
1389
1301 // Tests OOPIF rendering by checking that the RWH of the iframe generates 1390 // Tests OOPIF rendering by checking that the RWH of the iframe generates
1302 // OnSwapCompositorFrame message. 1391 // OnSwapCompositorFrame message.
1303 #if defined(OS_ANDROID) 1392 #if defined(OS_ANDROID)
1304 // http://crbug.com/471850 1393 // http://crbug.com/471850
1305 #define MAYBE_CompositorFrameSwapped DISABLED_CompositorFrameSwapped 1394 #define MAYBE_CompositorFrameSwapped DISABLED_CompositorFrameSwapped
1306 #else 1395 #else
1307 #define MAYBE_CompositorFrameSwapped CompositorFrameSwapped 1396 #define MAYBE_CompositorFrameSwapped CompositorFrameSwapped
1308 #endif 1397 #endif
1309 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 1398 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
1310 MAYBE_CompositorFrameSwapped) { 1399 MAYBE_CompositorFrameSwapped) {
(...skipping 6603 matching lines...) Expand 10 before | Expand all | Expand 10 after
7914 child_rfh->OnDispatchLoad(); 8003 child_rfh->OnDispatchLoad();
7915 8004
7916 // In the bug, OnDispatchLoad killed the b.com renderer. Ensure that this is 8005 // 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 8006 // not the case. Note that the process kill doesn't happen immediately, so
7918 // IsRenderFrameLive() can't be checked here (yet). Instead, check that 8007 // IsRenderFrameLive() can't be checked here (yet). Instead, check that
7919 // JavaScript can still execute in b.com using the popup. 8008 // JavaScript can still execute in b.com using the popup.
7920 EXPECT_TRUE(ExecuteScript(popup_shell->web_contents(), "true")); 8009 EXPECT_TRUE(ExecuteScript(popup_shell->web_contents(), "true"));
7921 } 8010 }
7922 8011
7923 } // namespace content 8012 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698