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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 247 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
248 tab, | 248 tab, |
249 "window.domAutomationController.send(window.document.referrer);", | 249 "window.domAutomationController.send(window.document.referrer);", |
250 &page_referrer)); | 250 &page_referrer)); |
251 ASSERT_EQ(kEmptyReferrer, page_referrer); | 251 ASSERT_EQ(kEmptyReferrer, page_referrer); |
252 } | 252 } |
253 | 253 |
254 // Check filename on clicking "Save Link As" via a "real" context menu. | 254 // Check filename on clicking "Save Link As" via a "real" context menu. |
255 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, SuggestedFileName) { | 255 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, SuggestedFileName) { |
256 // Register observer. | 256 // Register observer. |
257 SaveLinkAsContextMenuObserver menu_observer( | 257 ContextMenuWaiter menu_observer(content::NotificationService::AllSources()); |
258 content::NotificationService::AllSources()); | |
259 | 258 |
260 // Go to a page with a link having download attribute. | 259 // Go to a page with a link having download attribute. |
261 const std::string kSuggestedFilename("test_filename.png"); | 260 const std::string kSuggestedFilename("test_filename.png"); |
262 ui_test_utils::NavigateToURL( | 261 ui_test_utils::NavigateToURL( |
263 browser(), | 262 browser(), |
264 GURL("data:text/html,<a href='about:blank' download='" + | 263 GURL("data:text/html,<a href='about:blank' download='" + |
265 kSuggestedFilename + "'>link</a>")); | 264 kSuggestedFilename + "'>link</a>")); |
266 | 265 |
267 // Open a context menu. | 266 // Open a context menu. |
268 blink::WebMouseEvent mouse_event; | 267 blink::WebMouseEvent mouse_event; |
269 mouse_event.type = blink::WebInputEvent::MouseDown; | 268 mouse_event.type = blink::WebInputEvent::MouseDown; |
270 mouse_event.button = blink::WebMouseEvent::ButtonRight; | 269 mouse_event.button = blink::WebMouseEvent::ButtonRight; |
271 mouse_event.x = 15; | 270 mouse_event.x = 15; |
272 mouse_event.y = 15; | 271 mouse_event.y = 15; |
273 content::WebContents* tab = | 272 content::WebContents* tab = |
274 browser()->tab_strip_model()->GetActiveWebContents(); | 273 browser()->tab_strip_model()->GetActiveWebContents(); |
275 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 274 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
276 mouse_event.type = blink::WebInputEvent::MouseUp; | 275 mouse_event.type = blink::WebInputEvent::MouseUp; |
277 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 276 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
278 | 277 |
279 // Wait for context menu to be visible. | 278 // Wait for context menu to be visible. |
280 menu_observer.WaitForMenu(); | 279 menu_observer.WaitForMenuOpenAndClose(); |
281 | 280 |
282 // Compare filename. | 281 // Compare filename. |
283 base::string16 suggested_filename = menu_observer.GetSuggestedFilename(); | 282 base::string16 suggested_filename = menu_observer.params().suggested_filename; |
284 ASSERT_EQ(kSuggestedFilename, base::UTF16ToUTF8(suggested_filename).c_str()); | 283 ASSERT_EQ(kSuggestedFilename, base::UTF16ToUTF8(suggested_filename).c_str()); |
285 } | 284 } |
286 | 285 |
287 // Ensure that View Page Info won't crash if there is no visible entry. | 286 // Ensure that View Page Info won't crash if there is no visible entry. |
288 // See http://crbug.com/370863. | 287 // See http://crbug.com/370863. |
289 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, ViewPageInfoWithNoEntry) { | 288 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, ViewPageInfoWithNoEntry) { |
290 // Create a new tab with no committed entry. | 289 // Create a new tab with no committed entry. |
291 ui_test_utils::WindowedTabAddedNotificationObserver tab_observer( | 290 ui_test_utils::WindowedTabAddedNotificationObserver tab_observer( |
292 content::NotificationService::AllSources()); | 291 content::NotificationService::AllSources()); |
293 ASSERT_TRUE(content::ExecuteScript( | 292 ASSERT_TRUE(content::ExecuteScript( |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 browser()->tab_strip_model()->GetActiveWebContents(); | 519 browser()->tab_strip_model()->GetActiveWebContents(); |
521 ThumbnailResponseWatcher watcher(tab->GetRenderProcessHost()); | 520 ThumbnailResponseWatcher watcher(tab->GetRenderProcessHost()); |
522 AttemptImageSearch(); | 521 AttemptImageSearch(); |
523 | 522 |
524 // The browser should receive a response from the renderer, because the | 523 // The browser should receive a response from the renderer, because the |
525 // renderer should not crash. | 524 // renderer should not crash. |
526 EXPECT_EQ(ThumbnailResponseWatcher::THUMBNAIL_RECEIVED, watcher.Wait()); | 525 EXPECT_EQ(ThumbnailResponseWatcher::THUMBNAIL_RECEIVED, watcher.Wait()); |
527 } | 526 } |
528 | 527 |
529 } // namespace | 528 } // namespace |
OLD | NEW |