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_; |