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

Unified Diff: chrome/browser/renderer_context_menu/render_view_context_menu_browsertest.cc

Issue 1668553003: Fix server-side image map click location with "Open link in new tab" Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add Test for HTMLAnchorElement Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/renderer_context_menu/render_view_context_menu_browsertest.cc
diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu_browsertest.cc b/chrome/browser/renderer_context_menu/render_view_context_menu_browsertest.cc
index a4c05d7275bdb52b49420b4bf7cfe7c1c0032300..a282618d54c51ac55d66cd2d05404b5037df664c 100644
--- a/chrome/browser/renderer_context_menu/render_view_context_menu_browsertest.cc
+++ b/chrome/browser/renderer_context_menu/render_view_context_menu_browsertest.cc
@@ -803,6 +803,13 @@ class LoadImageBrowserTest : public InProcessBrowserTest {
ui_test_utils::NavigateToURL(browser(), page);
}
+ void SetupAndLoadImageMapPage(const std::string& image_path) {
+ ASSERT_TRUE(embedded_test_server()->Start());
+ GURL image_url(embedded_test_server()->GetURL(image_path));
+ GURL page("data:text/html,<body style='margin:0px'><a href='http://test/test.cgi'><img src='" + image_url.spec() + "' ismap></a></body>");
+ ui_test_utils::NavigateToURL(browser(), page);
+ }
+
void AddLoadImageInterceptor(const std::string& image_path) {
interceptor_ = new LoadImageRequestInterceptor();
scoped_ptr<net::URLRequestInterceptor> owned_interceptor(interceptor_);
@@ -847,4 +854,47 @@ IN_PROC_BROWSER_TEST_F(LoadImageBrowserTest, LoadImage) {
EXPECT_EQ(1, interceptor_->num_requests());
}
+// Verify that Server-side image map click location with "Open link in new tab"
+IN_PROC_BROWSER_TEST_F(LoadImageBrowserTest, OpenInNewTabImageMap) {
+ static const char kValidImage[] = "/webui/test_image.png";
+ ContextMenuNotificationObserver new_tab_observer(
+ IDC_CONTENT_CONTEXT_OPENLINKNEWTAB);
+ ContextMenuNotificationObserver menu_observer(
+ IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE);
+ ui_test_utils::WindowedTabAddedNotificationObserver tab_observer(
+ content::NotificationService::AllSources());
+
+ // Go to a page with a image map
+ SetupAndLoadImageMapPage(kValidImage);
+ AddLoadImageInterceptor(kValidImage);
+
+ // Open a context menu.
+ blink::WebMouseEvent mouse_event;
+ mouse_event.type = blink::WebInputEvent::MouseDown;
+ mouse_event.button = blink::WebMouseEvent::ButtonRight;
+ mouse_event.x = 20;
+ mouse_event.y = 20;
+ content::WebContents* tab =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ gfx::Rect offset = tab->GetContainerBounds();
+ mouse_event.globalX = 20 + offset.x();
+ mouse_event.globalY = 20 + offset.y();
+ mouse_event.clickCount = 1;
+ tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event);
+ mouse_event.type = blink::WebInputEvent::MouseUp;
+ tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event);
+
+ // Wait for Image Context Menu
+ interceptor_->WaitForRequests(1);
+
+ // The menu_observer will select "Open link in new tab", wait for the new
+ // tab to be added.
+ tab_observer.Wait();
+ tab = tab_observer.GetTab();
+ content::WaitForLoadStop(tab);
+
+ // Verify whether URL include click location or not.
+ EXPECT_EQ(GURL("http://test/test.cgi?20,20"), tab->GetURL());
+}
+
} // namespace
« no previous file with comments | « no previous file | chrome/test/data/webui/test_image.png » ('j') | third_party/WebKit/Source/core/html/HTMLAnchorElement.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698