OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 236 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
237 tab, | 237 tab, |
238 "window.domAutomationController.send(window.document.referrer);", | 238 "window.domAutomationController.send(window.document.referrer);", |
239 &page_referrer)); | 239 &page_referrer)); |
240 ASSERT_EQ(kEmptyReferrer, page_referrer); | 240 ASSERT_EQ(kEmptyReferrer, page_referrer); |
241 } | 241 } |
242 | 242 |
243 // Check filename on clicking "Save Link As" via a "real" context menu. | 243 // Check filename on clicking "Save Link As" via a "real" context menu. |
244 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, SuggestedFileName) { | 244 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, SuggestedFileName) { |
245 // Register observer. | 245 // Register observer. |
246 SaveLinkAsContextMenuObserver menu_observer( | 246 ContextMenuWaiter menu_observer(content::NotificationService::AllSources()); |
247 content::NotificationService::AllSources()); | |
248 | 247 |
249 // Go to a page with a link having download attribute. | 248 // Go to a page with a link having download attribute. |
250 const std::string kSuggestedFilename("test_filename.png"); | 249 const std::string kSuggestedFilename("test_filename.png"); |
251 ui_test_utils::NavigateToURL( | 250 ui_test_utils::NavigateToURL( |
252 browser(), | 251 browser(), |
253 GURL("data:text/html,<a href='about:blank' download='" + | 252 GURL("data:text/html,<a href='about:blank' download='" + |
254 kSuggestedFilename + "'>link</a>")); | 253 kSuggestedFilename + "'>link</a>")); |
255 | 254 |
256 // Open a context menu. | 255 // Open a context menu. |
257 blink::WebMouseEvent mouse_event; | 256 blink::WebMouseEvent mouse_event; |
258 mouse_event.type = blink::WebInputEvent::MouseDown; | 257 mouse_event.type = blink::WebInputEvent::MouseDown; |
259 mouse_event.button = blink::WebMouseEvent::ButtonRight; | 258 mouse_event.button = blink::WebMouseEvent::ButtonRight; |
260 mouse_event.x = 15; | 259 mouse_event.x = 15; |
261 mouse_event.y = 15; | 260 mouse_event.y = 15; |
262 content::WebContents* tab = | 261 content::WebContents* tab = |
263 browser()->tab_strip_model()->GetActiveWebContents(); | 262 browser()->tab_strip_model()->GetActiveWebContents(); |
264 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 263 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
265 mouse_event.type = blink::WebInputEvent::MouseUp; | 264 mouse_event.type = blink::WebInputEvent::MouseUp; |
266 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 265 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
267 | 266 |
268 // Wait for context menu to be visible. | 267 // Wait for context menu to be visible. |
269 menu_observer.WaitForMenu(); | 268 menu_observer.WaitForMenuOpenAndClose(); |
270 | 269 |
271 // Compare filename. | 270 // Compare filename. |
272 base::string16 suggested_filename = menu_observer.GetSuggestedFilename(); | 271 base::string16 suggested_filename = menu_observer.params().suggested_filename; |
273 ASSERT_EQ(kSuggestedFilename, base::UTF16ToUTF8(suggested_filename).c_str()); | 272 ASSERT_EQ(kSuggestedFilename, base::UTF16ToUTF8(suggested_filename).c_str()); |
274 } | 273 } |
275 | 274 |
276 // Ensure that View Page Info won't crash if there is no visible entry. | 275 // Ensure that View Page Info won't crash if there is no visible entry. |
277 // See http://crbug.com/370863. | 276 // See http://crbug.com/370863. |
278 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, ViewPageInfoWithNoEntry) { | 277 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, ViewPageInfoWithNoEntry) { |
279 // Create a new tab with no committed entry. | 278 // Create a new tab with no committed entry. |
280 ui_test_utils::WindowedTabAddedNotificationObserver tab_observer( | 279 ui_test_utils::WindowedTabAddedNotificationObserver tab_observer( |
281 content::NotificationService::AllSources()); | 280 content::NotificationService::AllSources()); |
282 ASSERT_TRUE(content::ExecuteScript( | 281 ASSERT_TRUE(content::ExecuteScript( |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 browser()->tab_strip_model()->GetActiveWebContents(); | 470 browser()->tab_strip_model()->GetActiveWebContents(); |
472 ThumbnailResponseWatcher watcher(tab->GetRenderProcessHost()); | 471 ThumbnailResponseWatcher watcher(tab->GetRenderProcessHost()); |
473 AttemptImageSearch(); | 472 AttemptImageSearch(); |
474 | 473 |
475 // The browser should receive a response from the renderer, because the | 474 // The browser should receive a response from the renderer, because the |
476 // renderer should not crash. | 475 // renderer should not crash. |
477 EXPECT_EQ(ThumbnailResponseWatcher::THUMBNAIL_RECEIVED, watcher.Wait()); | 476 EXPECT_EQ(ThumbnailResponseWatcher::THUMBNAIL_RECEIVED, watcher.Wait()); |
478 } | 477 } |
479 | 478 |
480 } // namespace | 479 } // namespace |
OLD | NEW |