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" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
13 #include "base/strings/pattern.h" | 13 #include "base/strings/pattern.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
17 #include "content/browser/frame_host/cross_process_frame_connector.h" | 17 #include "content/browser/frame_host/cross_process_frame_connector.h" |
18 #include "content/browser/frame_host/frame_tree.h" | 18 #include "content/browser/frame_host/frame_tree.h" |
19 #include "content/browser/frame_host/navigator.h" | 19 #include "content/browser/frame_host/navigator.h" |
20 #include "content/browser/frame_host/render_frame_proxy_host.h" | 20 #include "content/browser/frame_host/render_frame_proxy_host.h" |
21 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 21 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
22 #include "content/browser/gpu/compositor_util.h" | 22 #include "content/browser/gpu/compositor_util.h" |
23 #include "content/browser/renderer_host/render_view_host_impl.h" | 23 #include "content/browser/renderer_host/render_view_host_impl.h" |
24 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" | 24 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
25 #include "content/browser/web_contents/web_contents_impl.h" | 25 #include "content/browser/web_contents/web_contents_impl.h" |
26 #include "content/common/frame_messages.h" | 26 #include "content/common/frame_messages.h" |
27 #include "content/common/view_messages.h" | |
27 #include "content/public/browser/notification_observer.h" | 28 #include "content/public/browser/notification_observer.h" |
28 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
29 #include "content/public/browser/notification_types.h" | 30 #include "content/public/browser/notification_types.h" |
30 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
31 #include "content/public/test/browser_test_utils.h" | 32 #include "content/public/test/browser_test_utils.h" |
32 #include "content/public/test/content_browser_test_utils.h" | 33 #include "content/public/test/content_browser_test_utils.h" |
33 #include "content/public/test/test_navigation_observer.h" | 34 #include "content/public/test/test_navigation_observer.h" |
34 #include "content/public/test/test_utils.h" | 35 #include "content/public/test/test_utils.h" |
35 #include "content/shell/browser/shell.h" | 36 #include "content/shell/browser/shell.h" |
36 #include "content/test/content_browser_test_utils_internal.h" | 37 #include "content/test/content_browser_test_utils_internal.h" |
(...skipping 3470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3507 // document's body. | 3508 // document's body. |
3508 while (msg_queue.WaitForMessage(&status)) { | 3509 while (msg_queue.WaitForMessage(&status)) { |
3509 if (status == "\"document-blur\"") | 3510 if (status == "\"document-blur\"") |
3510 break; | 3511 break; |
3511 } | 3512 } |
3512 | 3513 |
3513 // The root frame should be focused again. | 3514 // The root frame should be focused again. |
3514 EXPECT_EQ(root, root->frame_tree()->GetFocusedFrame()); | 3515 EXPECT_EQ(root, root->frame_tree()->GetFocusedFrame()); |
3515 } | 3516 } |
3516 | 3517 |
3518 #if !defined(OS_ANDROID) | |
3519 // There are no cursors on Android. | |
nasko
2015/10/15 17:06:54
nit: I'd move the comment before the !defined.
kenrb
2015/10/15 17:12:55
Done.
| |
3520 class CursorMessageFilter : public content::BrowserMessageFilter { | |
3521 public: | |
3522 CursorMessageFilter() | |
3523 : content::BrowserMessageFilter(ViewMsgStart), | |
3524 message_loop_runner_(new content::MessageLoopRunner), | |
3525 last_set_cursor_routing_id_(MSG_ROUTING_NONE) {} | |
3526 | |
3527 bool OnMessageReceived(const IPC::Message& message) override { | |
3528 if (message.type() == ViewHostMsg_SetCursor::ID) { | |
3529 content::BrowserThread::PostTask( | |
3530 content::BrowserThread::UI, FROM_HERE, | |
3531 base::Bind(&CursorMessageFilter::OnSetCursor, this, | |
3532 message.routing_id())); | |
3533 } | |
3534 return false; | |
3535 } | |
3536 | |
3537 void OnSetCursor(int routing_id) { | |
3538 last_set_cursor_routing_id_ = routing_id; | |
3539 message_loop_runner_->Quit(); | |
3540 } | |
3541 | |
3542 int last_set_cursor_routing_id() const { return last_set_cursor_routing_id_; } | |
3543 | |
3544 bool Wait() WARN_UNUSED_RESULT { | |
3545 last_set_cursor_routing_id_ = MSG_ROUTING_NONE; | |
3546 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | |
3547 FROM_HERE, message_loop_runner_->QuitClosure(), | |
3548 base::TimeDelta::FromMilliseconds(10000)); | |
3549 message_loop_runner_->Run(); | |
3550 if (last_set_cursor_routing_id_ == MSG_ROUTING_NONE) | |
3551 return false; | |
3552 return true; | |
3553 } | |
3554 | |
3555 private: | |
3556 ~CursorMessageFilter() override {} | |
3557 | |
3558 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | |
3559 int last_set_cursor_routing_id_; | |
3560 | |
3561 DISALLOW_COPY_AND_ASSIGN(CursorMessageFilter); | |
3562 }; | |
3563 | |
3564 // Verify that we receive a mouse cursor update message when we mouse over | |
3565 // a text field contained in an out-of-process iframe. | |
3566 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
3567 CursorUpdateFromReceivedFromCrossSiteIframe) { | |
3568 GURL main_url(embedded_test_server()->GetURL( | |
3569 "/frame_tree/page_with_positioned_frame.html")); | |
3570 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | |
3571 | |
3572 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | |
3573 ->GetFrameTree() | |
3574 ->root(); | |
3575 | |
3576 FrameTreeNode* child_node = root->child_at(0); | |
3577 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | |
3578 child_node->current_frame_host()->GetSiteInstance()); | |
3579 | |
3580 scoped_refptr<CursorMessageFilter> filter = new CursorMessageFilter(); | |
3581 child_node->current_frame_host()->GetProcess()->AddFilter(filter.get()); | |
3582 | |
3583 // Send a MouseMove to the subframe. The frame contains text, and moving the | |
3584 // mouse over it should cause the renderer to send a mouse cursor update. | |
3585 blink::WebMouseEvent mouse_event; | |
3586 mouse_event.type = blink::WebInputEvent::MouseMove; | |
3587 mouse_event.x = 60; | |
3588 mouse_event.y = 60; | |
3589 RenderWidgetHost* rwh_child = | |
3590 root->child_at(0)->current_frame_host()->GetRenderWidgetHost(); | |
3591 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( | |
3592 root->current_frame_host()->GetRenderWidgetHost()->GetView()); | |
3593 static_cast<WebContentsImpl*>(shell()->web_contents()) | |
3594 ->GetInputEventRouter() | |
3595 ->RouteMouseEvent(root_view, &mouse_event); | |
3596 | |
3597 EXPECT_TRUE(filter->Wait()); | |
3598 EXPECT_EQ(filter->last_set_cursor_routing_id(), rwh_child->GetRoutingID()); | |
3599 } | |
3600 #endif | |
3601 | |
3517 } // namespace content | 3602 } // namespace content |
OLD | NEW |