| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 event_ = event; | 469 event_ = event; |
| 470 return false; | 470 return false; |
| 471 } | 471 } |
| 472 RenderWidgetHost* host_; | 472 RenderWidgetHost* host_; |
| 473 bool event_received; | 473 bool event_received; |
| 474 blink::WebMouseEvent event_; | 474 blink::WebMouseEvent event_; |
| 475 }; | 475 }; |
| 476 | 476 |
| 477 // Test that mouse events are being routed to the correct RenderWidgetHostView | 477 // Test that mouse events are being routed to the correct RenderWidgetHostView |
| 478 // based on coordinates. | 478 // based on coordinates. |
| 479 #if defined(OS_ANDROID) || defined(THREAD_SANITIZER) || defined(OS_LINUX) | 479 #if defined(OS_ANDROID) |
| 480 // Browser process hit testing is not implemented on Android. | 480 // Browser process hit testing is not implemented on Android. |
| 481 // https://crbug.com/491334 | 481 // https://crbug.com/491334 |
| 482 // Test fails under TSAN, see https://crbug.com/527618 | |
| 483 // Test is flaky under Linux, see https://crbug.com/528189 | |
| 484 #define MAYBE_SurfaceHitTestTest DISABLED_SurfaceHitTestTest | 482 #define MAYBE_SurfaceHitTestTest DISABLED_SurfaceHitTestTest |
| 485 #else | 483 #else |
| 486 #define MAYBE_SurfaceHitTestTest SurfaceHitTestTest | 484 #define MAYBE_SurfaceHitTestTest SurfaceHitTestTest |
| 487 #endif | 485 #endif |
| 488 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_SurfaceHitTestTest) { | 486 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_SurfaceHitTestTest) { |
| 489 if (!UseSurfacesEnabled()) | 487 if (!UseSurfacesEnabled()) |
| 490 return; | 488 return; |
| 491 | 489 |
| 492 GURL main_url(embedded_test_server()->GetURL( | 490 GURL main_url(embedded_test_server()->GetURL( |
| 493 "/frame_tree/page_with_positioned_frame.html")); | 491 "/frame_tree/page_with_positioned_frame.html")); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 | 532 |
| 535 uint32_t cur_render_frame_number = root_view->RendererFrameNumber(); | 533 uint32_t cur_render_frame_number = root_view->RendererFrameNumber(); |
| 536 | 534 |
| 537 // Target input event to child frame. | 535 // Target input event to child frame. |
| 538 blink::WebMouseEvent child_event; | 536 blink::WebMouseEvent child_event; |
| 539 child_event.type = blink::WebInputEvent::MouseDown; | 537 child_event.type = blink::WebInputEvent::MouseDown; |
| 540 child_event.button = blink::WebPointerProperties::ButtonLeft; | 538 child_event.button = blink::WebPointerProperties::ButtonLeft; |
| 541 child_event.x = 75; | 539 child_event.x = 75; |
| 542 child_event.y = 75; | 540 child_event.y = 75; |
| 543 child_event.clickCount = 1; | 541 child_event.clickCount = 1; |
| 542 main_frame_monitor.ResetEventReceived(); |
| 543 child_frame_monitor.ResetEventReceived(); |
| 544 router->RouteMouseEvent(root_view, &child_event); | 544 router->RouteMouseEvent(root_view, &child_event); |
| 545 | 545 |
| 546 if (!child_frame_monitor.EventWasReceived()) { | 546 while (!child_frame_monitor.EventWasReceived()) { |
| 547 main_frame_monitor.ResetEventReceived(); | |
| 548 // This is working around a big synchronization problem. It is very | 547 // This is working around a big synchronization problem. It is very |
| 549 // difficult to know if we have received a compositor frame from the | 548 // difficult to know if we have received a compositor frame from the |
| 550 // main frame renderer *after* it received the child frame's surface | 549 // main frame renderer *after* it received the child frame's surface |
| 551 // ID. Hit testing won't work until this happens. So if the hit test | 550 // ID. Hit testing won't work until this happens. So if the hit test |
| 552 // fails then we wait for another frame to arrive and try again. | 551 // fails then we wait for another frame to arrive and try again. |
| 553 // TODO(kenrb): We need a better way to do all of this, possibly coming | 552 // TODO(kenrb): We need a better way to do all of this, possibly coming |
| 554 // from http://crbug.com/405282. | 553 // from http://crbug.com/405282. |
| 555 while (root_view->RendererFrameNumber() <= cur_render_frame_number) { | 554 while (root_view->RendererFrameNumber() <= cur_render_frame_number) { |
| 556 base::RunLoop run_loop; | 555 base::RunLoop run_loop; |
| 557 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 556 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 558 FROM_HERE, run_loop.QuitClosure(), | 557 FROM_HERE, run_loop.QuitClosure(), |
| 559 base::TimeDelta::FromMilliseconds(10)); | 558 base::TimeDelta::FromMilliseconds(10)); |
| 560 run_loop.Run(); | 559 run_loop.Run(); |
| 561 } | 560 } |
| 561 cur_render_frame_number = root_view->RendererFrameNumber(); |
| 562 child_event.type = blink::WebInputEvent::MouseDown; |
| 563 child_event.button = blink::WebPointerProperties::ButtonLeft; |
| 564 child_event.x = 75; |
| 565 child_event.y = 75; |
| 566 child_event.clickCount = 1; |
| 567 main_frame_monitor.ResetEventReceived(); |
| 568 child_frame_monitor.ResetEventReceived(); |
| 562 router->RouteMouseEvent(root_view, &child_event); | 569 router->RouteMouseEvent(root_view, &child_event); |
| 563 } | 570 } |
| 564 | 571 |
| 565 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); | 572 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); |
| 566 EXPECT_EQ(23, child_frame_monitor.event().x); | 573 EXPECT_EQ(23, child_frame_monitor.event().x); |
| 567 EXPECT_EQ(23, child_frame_monitor.event().y); | 574 EXPECT_EQ(23, child_frame_monitor.event().y); |
| 568 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); | 575 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); |
| 569 | 576 |
| 570 child_frame_monitor.ResetEventReceived(); | 577 child_frame_monitor.ResetEventReceived(); |
| 571 main_frame_monitor.ResetEventReceived(); | 578 main_frame_monitor.ResetEventReceived(); |
| (...skipping 3020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3592 | 3599 |
| 3593 // CursorMessageFilter::Wait() implicitly tests whether we receive a | 3600 // CursorMessageFilter::Wait() implicitly tests whether we receive a |
| 3594 // ViewHostMsg_SetCursor message from the renderer process, because it does | 3601 // ViewHostMsg_SetCursor message from the renderer process, because it does |
| 3595 // does not return otherwise. | 3602 // does not return otherwise. |
| 3596 filter->Wait(); | 3603 filter->Wait(); |
| 3597 EXPECT_EQ(filter->last_set_cursor_routing_id(), rwh_child->GetRoutingID()); | 3604 EXPECT_EQ(filter->last_set_cursor_routing_id(), rwh_child->GetRoutingID()); |
| 3598 } | 3605 } |
| 3599 #endif | 3606 #endif |
| 3600 | 3607 |
| 3601 } // namespace content | 3608 } // namespace content |
| OLD | NEW |