chrome/browser/tab_contents/render_view_context_menu_browsertest.cc
// Opens a link in a new tab via a "real" context menu.
Opens a link in a new tab via a "real" context menu.
Opens a link in a new tab via a " real " context menu .
IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest,
                       MAYBE_RealMenu) {
  ContextMenuNotificationObserver menu_observer(
      IDC_CONTENT_CONTEXT_OPENLINKNEWTAB);
  ui_test_utils::WindowedTabAddedNotificationObserver tab_observer(
      content::NotificationService::AllSources());
  ui_test_utils::NavigateToURL(
      browser(), GURL("data:text/html,<a href='about:blank'>link</a>"));
  WebKit::WebMouseEvent mouse_event;
  mouse_event.type = WebKit::WebInputEvent::MouseDown;
  mouse_event.button = WebKit::WebMouseEvent::ButtonRight;
  mouse_event.x = 15;
  mouse_event.y = 15;
  gfx::Rect offset;
  content::WebContents* tab = chrome::GetActiveWebContents(browser());
  tab->GetView()->GetContainerBounds(&offset);
  mouse_event.globalX = 15 + offset.x();
  mouse_event.globalY = 15 + offset.y();
  mouse_event.clickCount = 1;
  tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
  mouse_event.type = WebKit::WebInputEvent::MouseUp;
  tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
  tab_observer.Wait();
  tab = tab_observer.GetTab();
  content::WaitForLoadStop(tab);
  EXPECT_EQ(GURL("about:blank"), tab->GetURL());
}
IN_PROC_BROWSER_TEST_F ( ContextMenuBrowserTest , MAYBE_RealMenu ) { ContextMenuNotificationObserver menu_observer ( IDC_CONTENT_CONTEXT_OPENLINKNEWTAB ) ; ui_test_utils :: WindowedTabAddedNotificationObserver tab_observer ( content :: NotificationService :: AllSources ( ) ) ; ui_test_utils :: NavigateToURL ( browser ( ) , GURL ( " " ) ) ; WebKit :: WebMouseEvent mouse_event ; mouse_event . type = WebKit :: WebInputEvent :: MouseDown ; mouse_event . button = WebKit :: WebMouseEvent :: ButtonRight ; mouse_event . x = 15 ; mouse_event . y = 15 ; gfx :: Rect offset ; content :: WebContents * tab = chrome :: GetActiveWebContents ( browser ( ) ) ; tab -> GetView ( ) -> GetContainerBounds ( & offset ) ; mouse_event . globalX = 15 + offset . x ( ) ; mouse_event . globalY = 15 + offset . y ( ) ; mouse_event . clickCount = 1 ; tab -> GetRenderViewHost ( ) -> ForwardMouseEvent ( mouse_event ) ; mouse_event . type = WebKit :: WebInputEvent :: MouseUp ; tab -> GetRenderViewHost ( ) -> ForwardMouseEvent ( mouse_event ) ; tab_observer . Wait ( ) ; tab = tab_observer . GetTab ( ) ; content :: WaitForLoadStop ( tab ) ; EXPECT_EQ ( GURL ( " " ) , tab -> GetURL ( ) ) ; }
Opens a link in a new tab via a "real" context menu.
Opens a link in a new tab via a " real " context menu .
// Go to a page with a link // Open a context menu. // The menu_observer will select "Open in new tab", wait for the new tab to // be added. // Verify that it's the correct tab.