Chromium Code Reviews| 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..18b764f4feb6ec1bd94c2dc2083386c7719f8952 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,40 @@ 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 observers |
| + ContextMenuNotificationObserver menu_observer(IDC_CONTENT_CONTEXT_SAVELINKAS); |
|
lazyboy
2014/06/20 17:23:31
Using ContextMenuNotificationObserver would result
Nikhil
2014/06/20 19:37:51
I tried similar approach earlier by modifying exis
lazyboy
2014/06/20 19:50:56
The notification observer in that class should acc
Nikhil
2014/06/23 08:02:35
Modified existing ContextMenuNotificationObserver
|
| + content::WindowedNotificationObserver download_observer( |
| + chrome::NOTIFICATION_DOWNLOAD_INITIATED, |
| + 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 get created and download to initiate |
| + download_observer.Wait(); |
| + |
| + 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) { |