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

Unified Diff: content/browser/site_per_process_browsertest.cc

Issue 1382593004: Allow out-of-process iframes to update the mouse cursor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits addressed Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
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..4b2cb4fdb01fff58d837459624baad0800aa8797 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,85 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
EXPECT_EQ(root, root->frame_tree()->GetFocusedFrame());
}
+// There are no cursors on Android.
+#if !defined(OS_ANDROID)
+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_; }
+
+ void Wait() {
+ last_set_cursor_routing_id_ = MSG_ROUTING_NONE;
+ message_loop_runner_->Run();
+ }
+
+ 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);
+
+ // CursorMessageFilter::Wait() implicitly tests whether we receive a
+ // ViewHostMsg_SetCursor message from the renderer process, because it does
+ // does not return otherwise.
+ filter->Wait();
+ EXPECT_EQ(filter->last_set_cursor_routing_id(), rwh_child->GetRoutingID());
+}
+#endif
+
} // namespace content
« no previous file with comments | « content/browser/frame_host/render_widget_host_view_child_frame.cc ('k') | third_party/WebKit/Source/core/frame/FrameView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698