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

Side by Side 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 unified diff | Download patch
OLDNEW
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
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 // There are no cursors on Android.
3519 #if !defined(OS_ANDROID)
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 void Wait() {
3545 last_set_cursor_routing_id_ = MSG_ROUTING_NONE;
3546 message_loop_runner_->Run();
3547 }
3548
3549 private:
3550 ~CursorMessageFilter() override {}
3551
3552 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
3553 int last_set_cursor_routing_id_;
3554
3555 DISALLOW_COPY_AND_ASSIGN(CursorMessageFilter);
3556 };
3557
3558 // Verify that we receive a mouse cursor update message when we mouse over
3559 // a text field contained in an out-of-process iframe.
3560 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
3561 CursorUpdateFromReceivedFromCrossSiteIframe) {
3562 GURL main_url(embedded_test_server()->GetURL(
3563 "/frame_tree/page_with_positioned_frame.html"));
3564 EXPECT_TRUE(NavigateToURL(shell(), main_url));
3565
3566 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
3567 ->GetFrameTree()
3568 ->root();
3569
3570 FrameTreeNode* child_node = root->child_at(0);
3571 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
3572 child_node->current_frame_host()->GetSiteInstance());
3573
3574 scoped_refptr<CursorMessageFilter> filter = new CursorMessageFilter();
3575 child_node->current_frame_host()->GetProcess()->AddFilter(filter.get());
3576
3577 // Send a MouseMove to the subframe. The frame contains text, and moving the
3578 // mouse over it should cause the renderer to send a mouse cursor update.
3579 blink::WebMouseEvent mouse_event;
3580 mouse_event.type = blink::WebInputEvent::MouseMove;
3581 mouse_event.x = 60;
3582 mouse_event.y = 60;
3583 RenderWidgetHost* rwh_child =
3584 root->child_at(0)->current_frame_host()->GetRenderWidgetHost();
3585 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>(
3586 root->current_frame_host()->GetRenderWidgetHost()->GetView());
3587 static_cast<WebContentsImpl*>(shell()->web_contents())
3588 ->GetInputEventRouter()
3589 ->RouteMouseEvent(root_view, &mouse_event);
3590
3591 // CursorMessageFilter::Wait() implicitly tests whether we receive a
3592 // ViewHostMsg_SetCursor message from the renderer process, because it does
3593 // does not return otherwise.
3594 filter->Wait();
3595 EXPECT_EQ(filter->last_set_cursor_routing_id(), rwh_child->GetRoutingID());
3596 }
3597 #endif
3598
3517 } // namespace content 3599 } // namespace content
OLDNEW
« 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