| 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 "chrome/browser/renderer_context_menu/render_view_context_menu.h" | 5 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); | 358 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); |
| 359 | 359 |
| 360 // Wait for context menu to be visible. | 360 // Wait for context menu to be visible. |
| 361 menu_observer.WaitForMenuOpenAndClose(); | 361 menu_observer.WaitForMenuOpenAndClose(); |
| 362 | 362 |
| 363 // Compare filename. | 363 // Compare filename. |
| 364 base::string16 suggested_filename = menu_observer.params().suggested_filename; | 364 base::string16 suggested_filename = menu_observer.params().suggested_filename; |
| 365 ASSERT_EQ(kSuggestedFilename, base::UTF16ToUTF8(suggested_filename).c_str()); | 365 ASSERT_EQ(kSuggestedFilename, base::UTF16ToUTF8(suggested_filename).c_str()); |
| 366 } | 366 } |
| 367 | 367 |
| 368 // Ensure that View Page Info won't crash if there is no visible entry. | |
| 369 // See http://crbug.com/370863. | |
| 370 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, ViewPageInfoWithNoEntry) { | |
| 371 // Create a new tab with no committed entry. | |
| 372 ui_test_utils::WindowedTabAddedNotificationObserver tab_observer( | |
| 373 content::NotificationService::AllSources()); | |
| 374 ASSERT_TRUE(content::ExecuteScript( | |
| 375 browser()->tab_strip_model()->GetActiveWebContents(), "window.open();")); | |
| 376 tab_observer.Wait(); | |
| 377 content::WebContents* tab = tab_observer.GetTab(); | |
| 378 EXPECT_FALSE(tab->GetController().GetLastCommittedEntry()); | |
| 379 EXPECT_FALSE(tab->GetController().GetVisibleEntry()); | |
| 380 | |
| 381 // Create a context menu. | |
| 382 content::ContextMenuParams context_menu_params; | |
| 383 TestRenderViewContextMenu menu(tab->GetMainFrame(), context_menu_params); | |
| 384 menu.Init(); | |
| 385 | |
| 386 // The item shouldn't be enabled in the menu. | |
| 387 EXPECT_FALSE(menu.IsCommandIdEnabled(IDC_CONTENT_CONTEXT_VIEWPAGEINFO)); | |
| 388 | |
| 389 // Ensure that viewing page info doesn't crash even if you can get to it. | |
| 390 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_VIEWPAGEINFO, 0); | |
| 391 } | |
| 392 | |
| 393 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, DataSaverOpenOrigImageInNewTab) { | 368 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, DataSaverOpenOrigImageInNewTab) { |
| 394 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 369 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 395 command_line->AppendSwitch( | 370 command_line->AppendSwitch( |
| 396 data_reduction_proxy::switches::kEnableDataReductionProxy); | 371 data_reduction_proxy::switches::kEnableDataReductionProxy); |
| 397 | 372 |
| 398 std::unique_ptr<TestRenderViewContextMenu> menu = | 373 std::unique_ptr<TestRenderViewContextMenu> menu = |
| 399 CreateContextMenuMediaTypeImage(GURL("http://url.com/image.png")); | 374 CreateContextMenuMediaTypeImage(GURL("http://url.com/image.png")); |
| 400 | 375 |
| 401 ASSERT_FALSE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB)); | 376 ASSERT_FALSE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB)); |
| 402 ASSERT_TRUE(menu->IsItemPresent( | 377 ASSERT_TRUE(menu->IsItemPresent( |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 IN_PROC_BROWSER_TEST_F(LoadImageBrowserTest, LoadImage) { | 825 IN_PROC_BROWSER_TEST_F(LoadImageBrowserTest, LoadImage) { |
| 851 static const char kValidImage[] = "/load_image/image.png"; | 826 static const char kValidImage[] = "/load_image/image.png"; |
| 852 SetupAndLoadImagePage(kValidImage); | 827 SetupAndLoadImagePage(kValidImage); |
| 853 AddLoadImageInterceptor(kValidImage); | 828 AddLoadImageInterceptor(kValidImage); |
| 854 AttemptLoadImage(); | 829 AttemptLoadImage(); |
| 855 interceptor_->WaitForRequests(1); | 830 interceptor_->WaitForRequests(1); |
| 856 EXPECT_EQ(1, interceptor_->num_requests()); | 831 EXPECT_EQ(1, interceptor_->num_requests()); |
| 857 } | 832 } |
| 858 | 833 |
| 859 } // namespace | 834 } // namespace |
| OLD | NEW |