Chromium Code Reviews| Index: content/browser/site_per_process_browsertest.cc |
| diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc |
| index 8a907d52d7d44a38dfba270d7488ff27cf59572c..68bf5226eefc5b5d617b6c7acdd8aa4915f4b986 100644 |
| --- a/content/browser/site_per_process_browsertest.cc |
| +++ b/content/browser/site_per_process_browsertest.cc |
| @@ -24,6 +24,7 @@ |
| #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
| #include "content/browser/web_contents/web_contents_impl.h" |
| #include "content/common/frame_messages.h" |
| +#include "content/common/view_messages.h" |
| #include "content/public/browser/notification_observer.h" |
| #include "content/public/browser/notification_service.h" |
| #include "content/public/browser/notification_types.h" |
| @@ -3514,4 +3515,88 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| EXPECT_EQ(root, root->frame_tree()->GetFocusedFrame()); |
| } |
| +#if !defined(OS_ANDROID) |
| +// 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.
|
| +class CursorMessageFilter : public content::BrowserMessageFilter { |
| + public: |
| + CursorMessageFilter() |
| + : content::BrowserMessageFilter(ViewMsgStart), |
| + message_loop_runner_(new content::MessageLoopRunner), |
| + last_set_cursor_routing_id_(MSG_ROUTING_NONE) {} |
| + |
| + bool OnMessageReceived(const IPC::Message& message) override { |
| + if (message.type() == ViewHostMsg_SetCursor::ID) { |
| + content::BrowserThread::PostTask( |
| + content::BrowserThread::UI, FROM_HERE, |
| + base::Bind(&CursorMessageFilter::OnSetCursor, this, |
| + message.routing_id())); |
| + } |
| + return false; |
| + } |
| + |
| + void OnSetCursor(int routing_id) { |
| + last_set_cursor_routing_id_ = routing_id; |
| + message_loop_runner_->Quit(); |
| + } |
| + |
| + int last_set_cursor_routing_id() const { return last_set_cursor_routing_id_; } |
| + |
| + bool Wait() WARN_UNUSED_RESULT { |
| + last_set_cursor_routing_id_ = MSG_ROUTING_NONE; |
| + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| + FROM_HERE, message_loop_runner_->QuitClosure(), |
| + base::TimeDelta::FromMilliseconds(10000)); |
| + message_loop_runner_->Run(); |
| + if (last_set_cursor_routing_id_ == MSG_ROUTING_NONE) |
| + return false; |
| + return true; |
| + } |
| + |
| + private: |
| + ~CursorMessageFilter() override {} |
| + |
| + scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
| + int last_set_cursor_routing_id_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(CursorMessageFilter); |
| +}; |
| + |
| +// Verify that we receive a mouse cursor update message when we mouse over |
| +// a text field contained in an out-of-process iframe. |
| +IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| + CursorUpdateFromReceivedFromCrossSiteIframe) { |
| + GURL main_url(embedded_test_server()->GetURL( |
| + "/frame_tree/page_with_positioned_frame.html")); |
| + EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| + |
| + FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| + ->GetFrameTree() |
| + ->root(); |
| + |
| + FrameTreeNode* child_node = root->child_at(0); |
| + EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
| + child_node->current_frame_host()->GetSiteInstance()); |
| + |
| + scoped_refptr<CursorMessageFilter> filter = new CursorMessageFilter(); |
| + child_node->current_frame_host()->GetProcess()->AddFilter(filter.get()); |
| + |
| + // Send a MouseMove to the subframe. The frame contains text, and moving the |
| + // mouse over it should cause the renderer to send a mouse cursor update. |
| + blink::WebMouseEvent mouse_event; |
| + mouse_event.type = blink::WebInputEvent::MouseMove; |
| + mouse_event.x = 60; |
| + mouse_event.y = 60; |
| + RenderWidgetHost* rwh_child = |
| + root->child_at(0)->current_frame_host()->GetRenderWidgetHost(); |
| + RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( |
| + root->current_frame_host()->GetRenderWidgetHost()->GetView()); |
| + static_cast<WebContentsImpl*>(shell()->web_contents()) |
| + ->GetInputEventRouter() |
| + ->RouteMouseEvent(root_view, &mouse_event); |
| + |
| + EXPECT_TRUE(filter->Wait()); |
| + EXPECT_EQ(filter->last_set_cursor_routing_id(), rwh_child->GetRoutingID()); |
| +} |
| +#endif |
| + |
| } // namespace content |