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

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: Rebase 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 6293 matching lines...) Expand 10 before | Expand all | Expand 10 after
6304 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup) 6304 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup)
6305 #else 6305 #else
6306 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) 6306 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget)
6307 #endif 6307 #endif
6308 IPC_END_MESSAGE_MAP() 6308 IPC_END_MESSAGE_MAP()
6309 return false; 6309 return false;
6310 } 6310 }
6311 6311
6312 gfx::Rect last_initial_rect() const { return initial_rect_; } 6312 gfx::Rect last_initial_rect() const { return initial_rect_; }
6313 6313
6314 int last_routing_id() const { return routing_id_; }
6315
6314 void Wait() { 6316 void Wait() {
6315 initial_rect_ = gfx::Rect(); 6317 initial_rect_ = gfx::Rect();
6318 routing_id_ = MSG_ROUTING_NONE;
6316 message_loop_runner_->Run(); 6319 message_loop_runner_->Run();
6317 } 6320 }
6318 6321
6319 void Reset() { 6322 void Reset() {
6320 initial_rect_ = gfx::Rect(); 6323 initial_rect_ = gfx::Rect();
6324 routing_id_ = MSG_ROUTING_NONE;
6321 message_loop_runner_ = new content::MessageLoopRunner; 6325 message_loop_runner_ = new content::MessageLoopRunner;
6322 } 6326 }
6323 6327
6324 private: 6328 private:
6325 ~ShowWidgetMessageFilter() override {} 6329 ~ShowWidgetMessageFilter() override {}
6326 6330
6327 void OnShowWidget(int route_id, const gfx::Rect& initial_rect) { 6331 void OnShowWidget(int route_id, const gfx::Rect& initial_rect) {
6328 content::BrowserThread::PostTask( 6332 content::BrowserThread::PostTask(
6329 content::BrowserThread::UI, FROM_HERE, 6333 content::BrowserThread::UI, FROM_HERE,
6330 base::Bind(&ShowWidgetMessageFilter::OnShowWidgetOnUI, this, route_id, 6334 base::Bind(&ShowWidgetMessageFilter::OnShowWidgetOnUI, this, route_id,
6331 initial_rect)); 6335 initial_rect));
6332 } 6336 }
6333 6337
6334 #if defined(OS_MACOSX) || defined(OS_ANDROID) 6338 #if defined(OS_MACOSX) || defined(OS_ANDROID)
6335 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params) { 6339 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params) {
6336 content::BrowserThread::PostTask( 6340 content::BrowserThread::PostTask(
6337 content::BrowserThread::UI, FROM_HERE, 6341 content::BrowserThread::UI, FROM_HERE,
6338 base::Bind(&ShowWidgetMessageFilter::OnShowWidgetOnUI, this, 6342 base::Bind(&ShowWidgetMessageFilter::OnShowWidgetOnUI, this,
6339 MSG_ROUTING_NONE, params.bounds)); 6343 MSG_ROUTING_NONE, params.bounds));
6340 } 6344 }
6341 #endif 6345 #endif
6342 6346
6343 void OnShowWidgetOnUI(int route_id, const gfx::Rect& initial_rect) { 6347 void OnShowWidgetOnUI(int route_id, const gfx::Rect& initial_rect) {
6344 initial_rect_ = initial_rect; 6348 initial_rect_ = initial_rect;
6349 routing_id_ = route_id;
6345 message_loop_runner_->Quit(); 6350 message_loop_runner_->Quit();
6346 } 6351 }
6347 6352
6348 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 6353 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
6349 gfx::Rect initial_rect_; 6354 gfx::Rect initial_rect_;
6355 int routing_id_;
6350 6356
6351 DISALLOW_COPY_AND_ASSIGN(ShowWidgetMessageFilter); 6357 DISALLOW_COPY_AND_ASSIGN(ShowWidgetMessageFilter);
6352 }; 6358 };
6353 6359
6354 // Test that clicking a select element in an out-of-process iframe creates 6360 // Test that clicking a select element in an out-of-process iframe creates
6355 // a popup menu in the correct position. 6361 // a popup menu in the correct position.
6356 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, PopupMenuTest) { 6362 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, PopupMenuTest) {
6357 GURL main_url( 6363 GURL main_url(
6358 embedded_test_server()->GetURL("/cross_site_iframe_factory.html?a(a)")); 6364 embedded_test_server()->GetURL("/cross_site_iframe_factory.html?a(a)"));
6359 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 6365 EXPECT_TRUE(NavigateToURL(shell(), main_url));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
6402 gfx::Rect popup_rect = filter->last_initial_rect(); 6408 gfx::Rect popup_rect = filter->last_initial_rect();
6403 #if defined(OS_MACOSX) || defined(OS_ANDROID) 6409 #if defined(OS_MACOSX) || defined(OS_ANDROID)
6404 // On Mac and Android we receive the coordinates before they are transformed, 6410 // On Mac and Android we receive the coordinates before they are transformed,
6405 // so they are still relative to the out-of-process iframe origin. 6411 // so they are still relative to the out-of-process iframe origin.
6406 EXPECT_EQ(popup_rect.x(), 9); 6412 EXPECT_EQ(popup_rect.x(), 9);
6407 EXPECT_EQ(popup_rect.y(), 9); 6413 EXPECT_EQ(popup_rect.y(), 9);
6408 #else 6414 #else
6409 EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354); 6415 EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354);
6410 EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 94); 6416 EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 94);
6411 #endif 6417 #endif
6418
6419 #if defined(OS_LINUX)
6420 // Verify click-and-drag selection of popups still works on Linux with
6421 // OOPIFs enabled. This is only necessary to test on Aura because Mac and
6422 // Android use native widgets. Windows does not support this as UI
6423 // convention (it requires separate clicks to open the menu and select an
6424 // option). See https://crbug.com/703191.
6425 int process_id = child_node->current_frame_host()->GetProcess()->GetID();
6426 filter->Reset();
6427 RenderWidgetHostInputEventRouter* router =
6428 static_cast<WebContentsImpl*>(shell()->web_contents())
6429 ->GetInputEventRouter();
6430 // Re-open the select element.
6431 click_event.x = 360;
6432 click_event.y = 90;
6433 click_event.clickCount = 1;
6434 router->RouteMouseEvent(rwhv_root, &click_event, ui::LatencyInfo());
6435
6436 filter->Wait();
6437
6438 RenderWidgetHostView* popup_view =
6439 RenderWidgetHost::FromID(process_id, filter->last_routing_id())
6440 ->GetView();
6441
6442 RenderWidgetHostMouseEventMonitor popup_monitor(
6443 popup_view->GetRenderWidgetHost());
6444
6445 // Next send a mouse up directly targeting the first option, simulating a
6446 // drag. This requires a ui::MouseEvent because it tests behavior that is
6447 // above RWH input event routing.
6448 ui::MouseEvent mouse_up_event(ui::ET_MOUSE_RELEASED, gfx::Point(10, 5),
6449 gfx::Point(10, 5), ui::EventTimeForNow(),
6450 ui::EF_LEFT_MOUSE_BUTTON,
6451 ui::EF_LEFT_MOUSE_BUTTON);
6452 static_cast<RenderWidgetHostViewAura*>(popup_view)
6453 ->OnMouseEvent(&mouse_up_event);
6454
6455 // This verifies that the popup actually received the event, and it wasn't
6456 // diverted to a different RenderWidgetHostView due to mouse capture.
6457 EXPECT_TRUE(popup_monitor.EventWasReceived());
6458 #endif
6412 } 6459 }
6413 6460
6414 // Test that clicking a select element in a nested out-of-process iframe creates 6461 // Test that clicking a select element in a nested out-of-process iframe creates
6415 // a popup menu in the correct position, even if the top-level page repositions 6462 // a popup menu in the correct position, even if the top-level page repositions
6416 // its out-of-process iframe. This verifies that screen positioning information 6463 // its out-of-process iframe. This verifies that screen positioning information
6417 // is propagating down the frame tree correctly. 6464 // is propagating down the frame tree correctly.
6418 #if defined(OS_ANDROID) 6465 #if defined(OS_ANDROID)
6419 // Surface-based hit testing and coordinate translation is not yet avaiable on 6466 // Surface-based hit testing and coordinate translation is not yet avaiable on
6420 // Android. 6467 // Android.
6421 #define MAYBE_NestedPopupMenuTest DISABLED_NestedPopupMenuTest 6468 #define MAYBE_NestedPopupMenuTest DISABLED_NestedPopupMenuTest
(...skipping 3526 matching lines...) Expand 10 before | Expand all | Expand 10 after
9948 names.insert(root->children[0]->frame_entry->frame_unique_name()); 9995 names.insert(root->children[0]->frame_entry->frame_unique_name());
9949 } 9996 }
9950 9997
9951 // More than one entry in the set means that the subframe frame navigation 9998 // More than one entry in the set means that the subframe frame navigation
9952 // entries didn't have a consistent unique name. This will break history 9999 // entries didn't have a consistent unique name. This will break history
9953 // navigations =( 10000 // navigations =(
9954 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; 10001 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!";
9955 } 10002 }
9956 10003
9957 } // namespace content 10004 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698