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

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

Issue 339153002: Use suggested filename for "Save Link As" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback Created 6 years, 6 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 f2958f09b583f1fd99382fc2e939e6e4ebe8bd8f..b71c7dc82c10d2f78738e2be3fe7d14b9d8e24df 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
@@ -229,6 +229,39 @@ IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, OpenIncognitoNoneReferrer) {
ASSERT_EQ(kEmptyReferrer, page_referrer);
}
+// Check filename on clicking "Save Link As" via a "real" context menu.
+IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, SuggestedFileName) {
+ // Register observer.
+ SaveLinkAsContextMenuObserver menu_observer(
+ content::NotificationService::AllSources());
+
+ // Go to a page with a link having download attribute.
+ const std::string kSuggestedFilename("test_filename.png");
+ ui_test_utils::NavigateToURL(
+ browser(),
+ GURL("data:text/html,<a href='about:blank' download='" +
+ kSuggestedFilename + "'>link</a>"));
+
+ // Open a context menu.
+ blink::WebMouseEvent mouse_event;
+ mouse_event.type = blink::WebInputEvent::MouseDown;
+ mouse_event.button = blink::WebMouseEvent::ButtonRight;
+ mouse_event.x = 15;
+ mouse_event.y = 15;
+ content::WebContents* tab =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
+ mouse_event.type = blink::WebInputEvent::MouseUp;
+ tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
+
+ // Wait for context menu to be visible.
+ menu_observer.WaitForMenu();
+
+ // Compare filename.
+ base::string16 suggested_filename = menu_observer.GetSuggestedFilename();
+ ASSERT_EQ(kSuggestedFilename, base::UTF16ToUTF8(suggested_filename).c_str());
+}
+
// Ensure that View Page Info won't crash if there is no visible entry.
// See http://crbug.com/370863.
IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, ViewPageInfoWithNoEntry) {

Powered by Google App Engine
This is Rietveld 408576698