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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 2770923002: Prevent browser-side hit testing when page popup is selected (Closed)
Patch Set: Changed the test Created 3 years, 9 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 6073 matching lines...) Expand 10 before | Expand all | Expand 10 after
6084 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup) 6084 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup)
6085 #else 6085 #else
6086 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) 6086 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget)
6087 #endif 6087 #endif
6088 IPC_END_MESSAGE_MAP() 6088 IPC_END_MESSAGE_MAP()
6089 return false; 6089 return false;
6090 } 6090 }
6091 6091
6092 gfx::Rect last_initial_rect() const { return initial_rect_; } 6092 gfx::Rect last_initial_rect() const { return initial_rect_; }
6093 6093
6094 int last_routing_id() const { return routing_id_; }
6095
6094 void Wait() { 6096 void Wait() {
6095 initial_rect_ = gfx::Rect(); 6097 initial_rect_ = gfx::Rect();
6098 routing_id_ = MSG_ROUTING_NONE;
6096 message_loop_runner_->Run(); 6099 message_loop_runner_->Run();
6097 } 6100 }
6098 6101
6099 void Reset() { 6102 void Reset() {
6100 initial_rect_ = gfx::Rect(); 6103 initial_rect_ = gfx::Rect();
6104 routing_id_ = MSG_ROUTING_NONE;
6101 message_loop_runner_ = new content::MessageLoopRunner; 6105 message_loop_runner_ = new content::MessageLoopRunner;
6102 } 6106 }
6103 6107
6104 private: 6108 private:
6105 ~ShowWidgetMessageFilter() override {} 6109 ~ShowWidgetMessageFilter() override {}
6106 6110
6107 void OnShowWidget(int route_id, const gfx::Rect& initial_rect) { 6111 void OnShowWidget(int route_id, const gfx::Rect& initial_rect) {
6108 content::BrowserThread::PostTask( 6112 content::BrowserThread::PostTask(
6109 content::BrowserThread::UI, FROM_HERE, 6113 content::BrowserThread::UI, FROM_HERE,
6110 base::Bind(&ShowWidgetMessageFilter::OnShowWidgetOnUI, this, route_id, 6114 base::Bind(&ShowWidgetMessageFilter::OnShowWidgetOnUI, this, route_id,
6111 initial_rect)); 6115 initial_rect));
6112 } 6116 }
6113 6117
6114 #if defined(OS_MACOSX) || defined(OS_ANDROID) 6118 #if defined(OS_MACOSX) || defined(OS_ANDROID)
6115 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params) { 6119 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params) {
6116 content::BrowserThread::PostTask( 6120 content::BrowserThread::PostTask(
6117 content::BrowserThread::UI, FROM_HERE, 6121 content::BrowserThread::UI, FROM_HERE,
6118 base::Bind(&ShowWidgetMessageFilter::OnShowWidgetOnUI, this, 6122 base::Bind(&ShowWidgetMessageFilter::OnShowWidgetOnUI, this,
6119 MSG_ROUTING_NONE, params.bounds)); 6123 MSG_ROUTING_NONE, params.bounds));
6120 } 6124 }
6121 #endif 6125 #endif
6122 6126
6123 void OnShowWidgetOnUI(int route_id, const gfx::Rect& initial_rect) { 6127 void OnShowWidgetOnUI(int route_id, const gfx::Rect& initial_rect) {
6124 initial_rect_ = initial_rect; 6128 initial_rect_ = initial_rect;
6129 routing_id_ = route_id;
6125 message_loop_runner_->Quit(); 6130 message_loop_runner_->Quit();
6126 } 6131 }
6127 6132
6128 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 6133 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
6129 gfx::Rect initial_rect_; 6134 gfx::Rect initial_rect_;
6135 int routing_id_;
6130 6136
6131 DISALLOW_COPY_AND_ASSIGN(ShowWidgetMessageFilter); 6137 DISALLOW_COPY_AND_ASSIGN(ShowWidgetMessageFilter);
6132 }; 6138 };
6133 6139
6134 // Test that clicking a select element in an out-of-process iframe creates 6140 // Test that clicking a select element in an out-of-process iframe creates
6135 // a popup menu in the correct position. 6141 // a popup menu in the correct position.
6136 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, PopupMenuTest) { 6142 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, PopupMenuTest) {
6137 GURL main_url( 6143 GURL main_url(
6138 embedded_test_server()->GetURL("/cross_site_iframe_factory.html?a(a)")); 6144 embedded_test_server()->GetURL("/cross_site_iframe_factory.html?a(a)"));
6139 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 6145 EXPECT_TRUE(NavigateToURL(shell(), main_url));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
6182 gfx::Rect popup_rect = filter->last_initial_rect(); 6188 gfx::Rect popup_rect = filter->last_initial_rect();
6183 #if defined(OS_MACOSX) || defined(OS_ANDROID) 6189 #if defined(OS_MACOSX) || defined(OS_ANDROID)
6184 // On Mac and Android we receive the coordinates before they are transformed, 6190 // On Mac and Android we receive the coordinates before they are transformed,
6185 // so they are still relative to the out-of-process iframe origin. 6191 // so they are still relative to the out-of-process iframe origin.
6186 EXPECT_EQ(popup_rect.x(), 9); 6192 EXPECT_EQ(popup_rect.x(), 9);
6187 EXPECT_EQ(popup_rect.y(), 9); 6193 EXPECT_EQ(popup_rect.y(), 9);
6188 #else 6194 #else
6189 EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354); 6195 EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354);
6190 EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 94); 6196 EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 94);
6191 #endif 6197 #endif
6198
6199 #if defined(OS_LINUX)
6200 // Verify click-and-drag selection of popups still works on Linux with
6201 // OOPIFs enabled. This is only necessary to test on Aura because Mac and
6202 // Android use native widgets. Windows does not support this as UI
6203 // convention (it requires separate clicks to open the menu and select an
6204 // option). See https://crbug.com/703191.
6205 int process_id = child_node->current_frame_host()->GetProcess()->GetID();
6206 filter->Reset();
6207 RenderWidgetHostInputEventRouter* router =
6208 static_cast<WebContentsImpl*>(shell()->web_contents())
6209 ->GetInputEventRouter();
6210 // Re-open the select element.
6211 click_event.x = 360;
6212 click_event.y = 90;
alexmos 2017/03/23 22:25:18 The 90 here seems weird to me, since it seems that
kenrb 2017/03/24 14:18:43 The y >= 94 is for the position of the drop-down m
6213 click_event.clickCount = 1;
6214 router->RouteMouseEvent(rwhv_root, &click_event, ui::LatencyInfo());
6215
6216 filter->Wait();
6217
6218 RenderWidgetHostView* popup_view =
6219 RenderWidgetHost::FromID(process_id, filter->last_routing_id())
6220 ->GetView();
6221
6222 RenderWidgetHostMouseEventMonitor popup_monitor(
6223 popup_view->GetRenderWidgetHost());
6224
6225 // Next send a mouse up directly targeting the first option, simulating a
alexmos 2017/03/23 22:25:18 It'd actually be nice to target one of the other o
kenrb 2017/03/24 14:18:43 It turns out not to be easy -- if you look at the
6226 // drag. This requires a ui::MouseEvent because it tests behavior that is
6227 // above RWH input event routing.
6228 ui::MouseEvent mouse_up_event(ui::ET_MOUSE_RELEASED, gfx::Point(10, 5),
6229 gfx::Point(10, 5), ui::EventTimeForNow(),
6230 ui::EF_LEFT_MOUSE_BUTTON,
6231 ui::EF_LEFT_MOUSE_BUTTON);
6232 static_cast<RenderWidgetHostViewAura*>(popup_view)
6233 ->OnMouseEvent(&mouse_up_event);
6234
6235 // This verifies that the popup actually received the event, and it wasn't
6236 // diverted to a different RenderWidgetHostView due to mouse capture.
6237 EXPECT_TRUE(popup_monitor.EventWasReceived());
6238 #endif
6192 } 6239 }
6193 6240
6194 // Test that clicking a select element in a nested out-of-process iframe creates 6241 // Test that clicking a select element in a nested out-of-process iframe creates
6195 // a popup menu in the correct position, even if the top-level page repositions 6242 // a popup menu in the correct position, even if the top-level page repositions
6196 // its out-of-process iframe. This verifies that screen positioning information 6243 // its out-of-process iframe. This verifies that screen positioning information
6197 // is propagating down the frame tree correctly. 6244 // is propagating down the frame tree correctly.
6198 #if defined(OS_ANDROID) 6245 #if defined(OS_ANDROID)
6199 // Surface-based hit testing and coordinate translation is not yet avaiable on 6246 // Surface-based hit testing and coordinate translation is not yet avaiable on
6200 // Android. 6247 // Android.
6201 #define MAYBE_NestedPopupMenuTest DISABLED_NestedPopupMenuTest 6248 #define MAYBE_NestedPopupMenuTest DISABLED_NestedPopupMenuTest
(...skipping 3414 matching lines...) Expand 10 before | Expand all | Expand 10 after
9616 9663
9617 // Try the same navigation, but use the browser-initiated path. 9664 // Try the same navigation, but use the browser-initiated path.
9618 NavigateFrameToURL(root->child_at(0), frame_url); 9665 NavigateFrameToURL(root->child_at(0), frame_url);
9619 EXPECT_FALSE(root->child_at(0)->render_manager()->pending_frame_host()); 9666 EXPECT_FALSE(root->child_at(0)->render_manager()->pending_frame_host());
9620 EXPECT_EQ(root->child_at(0)->current_url(), redirected_url); 9667 EXPECT_EQ(root->child_at(0)->current_url(), redirected_url);
9621 EXPECT_EQ(b_site_instance, 9668 EXPECT_EQ(b_site_instance,
9622 root->child_at(0)->current_frame_host()->GetSiteInstance()); 9669 root->child_at(0)->current_frame_host()->GetSiteInstance());
9623 } 9670 }
9624 9671
9625 } // namespace content 9672 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698