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 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1404 web_contents()->GetInputEventRouter()->RouteMouseEvent(rwhv_a, &mouse_event); | 1404 web_contents()->GetInputEventRouter()->RouteMouseEvent(rwhv_a, &mouse_event); |
1405 EXPECT_TRUE(a_frame_monitor.EventWasReceived()); | 1405 EXPECT_TRUE(a_frame_monitor.EventWasReceived()); |
1406 EXPECT_EQ(a_frame_monitor.event().type, blink::WebInputEvent::MouseMove); | 1406 EXPECT_EQ(a_frame_monitor.event().type, blink::WebInputEvent::MouseMove); |
1407 EXPECT_TRUE(b_frame_monitor.EventWasReceived()); | 1407 EXPECT_TRUE(b_frame_monitor.EventWasReceived()); |
1408 EXPECT_EQ(b_frame_monitor.event().type, blink::WebInputEvent::MouseLeave); | 1408 EXPECT_EQ(b_frame_monitor.event().type, blink::WebInputEvent::MouseLeave); |
1409 EXPECT_TRUE(c_frame_monitor.EventWasReceived()); | 1409 EXPECT_TRUE(c_frame_monitor.EventWasReceived()); |
1410 EXPECT_EQ(c_frame_monitor.event().type, blink::WebInputEvent::MouseMove); | 1410 EXPECT_EQ(c_frame_monitor.event().type, blink::WebInputEvent::MouseMove); |
1411 EXPECT_TRUE(d_frame_monitor.EventWasReceived()); | 1411 EXPECT_TRUE(d_frame_monitor.EventWasReceived()); |
1412 } | 1412 } |
1413 | 1413 |
| 1414 // Verify that mouse capture works on a RenderWidgetHostView level, so that |
| 1415 // dragging scroll bars and selecting text continues even when the mouse |
| 1416 // cursor crosses over cross-process frame boundaries. |
| 1417 #if defined(OS_ANDROID) |
| 1418 // Browser process hit testing is not implemented on Android. |
| 1419 // https://crbug.com/491334 |
| 1420 #define MAYBE_CrossProcessMouseCapture DISABLED_CrossProcessMouseCapture |
| 1421 #else |
| 1422 #define MAYBE_CrossProcessMouseCapture CrossProcessMouseCapture |
| 1423 #endif |
| 1424 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 1425 MAYBE_CrossProcessMouseCapture) { |
| 1426 GURL main_url(embedded_test_server()->GetURL( |
| 1427 "/frame_tree/page_with_positioned_frame.html")); |
| 1428 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 1429 |
| 1430 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 1431 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| 1432 ASSERT_EQ(1U, root->child_count()); |
| 1433 |
| 1434 FrameTreeNode* child_node = root->child_at(0); |
| 1435 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); |
| 1436 EXPECT_EQ(site_url, child_node->current_url()); |
| 1437 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
| 1438 child_node->current_frame_host()->GetSiteInstance()); |
| 1439 |
| 1440 // Create listeners for mouse events. |
| 1441 RenderWidgetHostMouseEventMonitor main_frame_monitor( |
| 1442 root->current_frame_host()->GetRenderWidgetHost()); |
| 1443 RenderWidgetHostMouseEventMonitor child_frame_monitor( |
| 1444 child_node->current_frame_host()->GetRenderWidgetHost()); |
| 1445 |
| 1446 RenderWidgetHostInputEventRouter* router = |
| 1447 web_contents()->GetInputEventRouter(); |
| 1448 |
| 1449 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( |
| 1450 root->current_frame_host()->GetRenderWidgetHost()->GetView()); |
| 1451 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( |
| 1452 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); |
| 1453 |
| 1454 SurfaceHitTestReadyNotifier notifier( |
| 1455 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); |
| 1456 notifier.WaitForSurfaceReady(); |
| 1457 |
| 1458 // Target MouseDown to child frame. |
| 1459 blink::WebMouseEvent mouse_event; |
| 1460 mouse_event.type = blink::WebInputEvent::MouseDown; |
| 1461 mouse_event.button = blink::WebPointerProperties::Button::Left; |
| 1462 mouse_event.x = 75; |
| 1463 mouse_event.y = 75; |
| 1464 mouse_event.clickCount = 1; |
| 1465 main_frame_monitor.ResetEventReceived(); |
| 1466 child_frame_monitor.ResetEventReceived(); |
| 1467 router->RouteMouseEvent(root_view, &mouse_event); |
| 1468 |
| 1469 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); |
| 1470 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); |
| 1471 |
| 1472 // Target MouseMove to main frame. This should still be routed to the |
| 1473 // child frame because it is now capturing mouse input. |
| 1474 mouse_event.type = blink::WebInputEvent::MouseMove; |
| 1475 mouse_event.modifiers = blink::WebInputEvent::LeftButtonDown; |
| 1476 mouse_event.x = 1; |
| 1477 mouse_event.y = 1; |
| 1478 // Note that this event is sent twice, with the monitors cleared after |
| 1479 // the first time, because the first MouseMove to the child frame |
| 1480 // causes a MouseMove to be sent to the main frame also, which we |
| 1481 // need to ignore. |
| 1482 router->RouteMouseEvent(root_view, &mouse_event); |
| 1483 main_frame_monitor.ResetEventReceived(); |
| 1484 child_frame_monitor.ResetEventReceived(); |
| 1485 mouse_event.x = 1; |
| 1486 mouse_event.y = 2; |
| 1487 router->RouteMouseEvent(root_view, &mouse_event); |
| 1488 |
| 1489 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); |
| 1490 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); |
| 1491 |
| 1492 // A MouseUp to the child frame should cancel the mouse capture. |
| 1493 mouse_event.type = blink::WebInputEvent::MouseUp; |
| 1494 mouse_event.modifiers = 0; |
| 1495 mouse_event.x = 75; |
| 1496 mouse_event.y = 75; |
| 1497 main_frame_monitor.ResetEventReceived(); |
| 1498 child_frame_monitor.ResetEventReceived(); |
| 1499 router->RouteMouseEvent(root_view, &mouse_event); |
| 1500 |
| 1501 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); |
| 1502 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); |
| 1503 |
| 1504 // Subsequent MouseMove events targeted to the main frame should be routed |
| 1505 // to that frame. |
| 1506 mouse_event.type = blink::WebInputEvent::MouseMove; |
| 1507 mouse_event.x = 1; |
| 1508 mouse_event.y = 3; |
| 1509 // Sending the MouseMove twice for the same reason as above. |
| 1510 router->RouteMouseEvent(root_view, &mouse_event); |
| 1511 main_frame_monitor.ResetEventReceived(); |
| 1512 child_frame_monitor.ResetEventReceived(); |
| 1513 mouse_event.x = 1; |
| 1514 mouse_event.y = 4; |
| 1515 router->RouteMouseEvent(root_view, &mouse_event); |
| 1516 |
| 1517 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); |
| 1518 EXPECT_FALSE(child_frame_monitor.EventWasReceived()); |
| 1519 |
| 1520 // Target MouseDown to the main frame to cause it to capture input. |
| 1521 mouse_event.type = blink::WebInputEvent::MouseDown; |
| 1522 mouse_event.x = 1; |
| 1523 mouse_event.y = 1; |
| 1524 main_frame_monitor.ResetEventReceived(); |
| 1525 child_frame_monitor.ResetEventReceived(); |
| 1526 router->RouteMouseEvent(root_view, &mouse_event); |
| 1527 |
| 1528 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); |
| 1529 EXPECT_FALSE(child_frame_monitor.EventWasReceived()); |
| 1530 |
| 1531 // Sending a MouseMove to the child frame should still result in the main |
| 1532 // frame receiving the event. |
| 1533 mouse_event.type = blink::WebInputEvent::MouseMove; |
| 1534 mouse_event.modifiers = blink::WebInputEvent::LeftButtonDown; |
| 1535 mouse_event.x = 75; |
| 1536 mouse_event.y = 75; |
| 1537 main_frame_monitor.ResetEventReceived(); |
| 1538 child_frame_monitor.ResetEventReceived(); |
| 1539 router->RouteMouseEvent(root_view, &mouse_event); |
| 1540 |
| 1541 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); |
| 1542 EXPECT_FALSE(child_frame_monitor.EventWasReceived()); |
| 1543 } |
| 1544 |
1414 // Tests OOPIF rendering by checking that the RWH of the iframe generates | 1545 // Tests OOPIF rendering by checking that the RWH of the iframe generates |
1415 // OnSwapCompositorFrame message. | 1546 // OnSwapCompositorFrame message. |
1416 #if defined(OS_ANDROID) | 1547 #if defined(OS_ANDROID) |
1417 // http://crbug.com/471850 | 1548 // http://crbug.com/471850 |
1418 #define MAYBE_CompositorFrameSwapped DISABLED_CompositorFrameSwapped | 1549 #define MAYBE_CompositorFrameSwapped DISABLED_CompositorFrameSwapped |
1419 #else | 1550 #else |
1420 #define MAYBE_CompositorFrameSwapped CompositorFrameSwapped | 1551 #define MAYBE_CompositorFrameSwapped CompositorFrameSwapped |
1421 #endif | 1552 #endif |
1422 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 1553 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
1423 MAYBE_CompositorFrameSwapped) { | 1554 MAYBE_CompositorFrameSwapped) { |
(...skipping 6667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8091 " Site A ------------ proxies for B C\n" | 8222 " Site A ------------ proxies for B C\n" |
8092 " +--Site B ------- proxies for A C\n" | 8223 " +--Site B ------- proxies for A C\n" |
8093 " +--Site C -- proxies for A B\n" | 8224 " +--Site C -- proxies for A B\n" |
8094 "Where A = http://a.com/\n" | 8225 "Where A = http://a.com/\n" |
8095 " B = http://b.com/\n" | 8226 " B = http://b.com/\n" |
8096 " C = http://c.com/", | 8227 " C = http://c.com/", |
8097 DepictFrameTree(root)); | 8228 DepictFrameTree(root)); |
8098 } | 8229 } |
8099 | 8230 |
8100 } // namespace content | 8231 } // namespace content |
OLD | NEW |