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

Unified Diff: chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc

Issue 1293963002: Fixing the Position of Context Menu for BrowserPlugin (<webview>) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed a Build Error in MAC Created 5 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc
diff --git a/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc b/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc
index ac03c12541e947a19f8b9f125cf84fcab39f5e4a..64dbd622dbbd8bce32fb505563f6c211db8a276f 100644
--- a/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc
+++ b/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc
@@ -287,7 +287,10 @@ class WebViewInteractiveTest
mouse_event.x = mouse_event.windowX = x;
mouse_event.y = mouse_event.windowY = y;
mouse_event.modifiers = 0;
-
+ // Needed for the WebViewTest.ContextMenuPositionAfterCSSTransforms
+ gfx::Rect rect = rwh->GetView()->GetViewBounds();
+ mouse_event.globalX = x + rect.x();
+ mouse_event.globalY = y + rect.y();
mouse_event.type = blink::WebInputEvent::MouseDown;
rwh->ForwardMouseEvent(mouse_event);
mouse_event.type = blink::WebInputEvent::MouseUp;
@@ -849,6 +852,55 @@ IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, ContextMenuParamCoordinates) {
ASSERT_EQ(20, menu_observer.params().y);
}
+// Tests whether <webview> context menu sees <webview> local coordinates in its
+// RenderViewContextMenu params, when it is subject to CSS transforms.
+IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest,
+ ContextMenuParamsAfterCSSTransforms) {
+ LoadAndLaunchPlatformApp("web_view/context_menus/coordinates_with_transforms",
+ "Launched");
+
+ if (!embedder_web_contents_)
+ embedder_web_contents_ = GetFirstAppWindowWebContents();
+ EXPECT_TRUE(embedder_web_contents());
+
+ if (!guest_web_contents_)
+ guest_web_contents_ = GetGuestViewManager()->WaitForSingleGuestCreated();
+ EXPECT_TRUE(guest_web_contents());
+
+ // We will send the input event to the embedder rather than the guest; which
+ // is more realistic. We need to do this to make sure that the MouseDown event
+ // is received forwarded by the BrowserPlugin to the RWHVG and eventually back
+ // to the guest. The RWHVG will in turn notify the ChromeWVGDelegate of the
+ // newly observed mouse down (potentially a context menu).
+ const std::string transforms[] = {"rotate(20deg)", "scale(1.5, 2.0)",
+ "translate(20px, 30px)", "NONE"};
+ for (size_t index = 0; index < 4; ++index) {
+ std::string command =
+ base::StringPrintf("setTransform('%s')", transforms[index].c_str());
+ ExtensionTestMessageListener transform_set_listener("TRANSFORM_SET", false);
+ EXPECT_TRUE(content::ExecuteScript(embedder_web_contents(), command));
+ ASSERT_TRUE(transform_set_listener.WaitUntilSatisfied());
+
+ gfx::Rect embedder_view_bounds =
+ embedder_web_contents()->GetRenderWidgetHostView()->GetViewBounds();
+ gfx::Rect guest_view_bounds =
+ guest_web_contents()->GetRenderWidgetHostView()->GetViewBounds();
+ ContextMenuWaiter menu_observer(content::NotificationService::AllSources());
+ gfx::Point guest_window_point(150, 150);
+ gfx::Point embedder_window_point = guest_window_point;
+ embedder_window_point += guest_view_bounds.OffsetFromOrigin();
+ embedder_window_point -= embedder_view_bounds.OffsetFromOrigin();
+ SimulateRWHMouseClick(embedder_web_contents()->GetRenderViewHost(),
+ blink::WebMouseEvent::ButtonRight,
+ /* Using window coordinates for the embedder */
+ embedder_window_point.x(), embedder_window_point.y());
+
+ menu_observer.WaitForMenuOpenAndClose();
+ EXPECT_EQ(menu_observer.params().x, guest_window_point.x());
+ EXPECT_EQ(menu_observer.params().y, guest_window_point.y());
+ }
+}
+
IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, ExecuteCode) {
ASSERT_TRUE(RunPlatformAppTestWithArg(
"platform_apps/web_view/common", "execute_code")) << message_;
« no previous file with comments | « no previous file | chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698