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

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: Improved feng shui 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..3d12dc373ac3f81a4d03f062e58598f6d27857a7 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,86 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
EXPECT_EQ(root, root->frame_tree()->GetFocusedFrame());
}
+class CursorMessageFilter : public content::BrowserMessageFilter {
+ public:
+ explicit CursorMessageFilter()
dcheng 2015/10/05 06:48:24 No explicit.
kenrb 2015/10/06 17:39:19 Done.
+ : 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() { return last_set_cursor_routing_id_; }
dcheng 2015/10/05 06:48:24 Nit: const.
kenrb 2015/10/06 17:39:19 Done.
+
+ bool Wait() WARN_UNUSED_RESULT {
+ last_set_cursor_routing_id_ = MSG_ROUTING_NONE;
+ base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
nasko 2015/10/05 18:18:46 Why do we need to post a task at all? If we never
kenrb 2015/10/06 17:39:19 When I tried locally without this, the test ran fo
+ FROM_HERE, message_loop_runner_->QuitClosure(),
+ base::TimeDelta::FromMilliseconds(2000));
dcheng 2015/10/05 06:48:24 Is there any significance to 2 seconds?
kenrb 2015/10/06 17:39:19 No, it's arbitrary. Just needed a value large enou
+ 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();
+ // rwh_child->ForwardMouseEvent(mouse_event);
+ 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());
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698