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

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

Issue 8588039: Remove "open in new tab" items from context menu if the process doesn't (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/render_view_context_menu_browsertest.cc
===================================================================
--- chrome/browser/tab_contents/render_view_context_menu_browsertest.cc (revision 0)
+++ chrome/browser/tab_contents/render_view_context_menu_browsertest.cc (revision 0)
@@ -0,0 +1,82 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+
+#include "base/memory/scoped_ptr.h"
+#include "base/string16.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/app/chrome_command_ids.h"
+#include "chrome/browser/tab_contents/render_view_context_menu.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
+
+namespace {
+
+class TestRenderViewContextMenu : public RenderViewContextMenu {
+ public:
+ TestRenderViewContextMenu(TabContents* tab_contents, ContextMenuParams params)
+ : RenderViewContextMenu(tab_contents, params) { }
+
+ virtual void PlatformInit() { }
+ virtual bool GetAcceleratorForCommandId(
+ int command_id,
+ ui::Accelerator* accelerator) {
+ return false;
+ }
+
+ bool IsItemPresent(int command_id) {
+ return menu_model_.GetIndexOfCommandId(command_id) != -1;
+ }
+};
+
+class ContextMenuBrowserTest : public InProcessBrowserTest {
+ public:
+ ContextMenuBrowserTest() { }
+
+ TestRenderViewContextMenu* CreateContextMenu(GURL unfiltered_url, GURL url) {
+ ContextMenuParams params;
+ params.media_type = WebKit::WebContextMenuData::MediaTypeNone;
+ params.unfiltered_link_url = unfiltered_url;
+ params.link_url = url;
+ TabContents* tab_contents = browser()->GetSelectedTabContents();
+ params.page_url = tab_contents->controller().GetActiveEntry()->url();
+#if defined(OS_MACOSX)
+ params.writing_direction_default = 0;
+ params.writing_direction_left_to_right = 0;
+ params.writing_direction_right_to_left = 0;
+#endif // OS_MACOSX
+ TestRenderViewContextMenu* menu = new TestRenderViewContextMenu(
+ browser()->GetSelectedTabContents(), params);
+ menu->Init();
+ return menu;
+ }
+};
+
+IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest,
+ OpenEntryPresentForNormalURLs) {
+ scoped_ptr<TestRenderViewContextMenu> menu(
+ CreateContextMenu(GURL("http://www.google.com/"),
+ GURL("http://www.google.com/")));
+
+ ASSERT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB));
+ ASSERT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW));
+ ASSERT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_COPYLINKLOCATION));
+}
+
+IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest,
+ OpenEntryAbsentForFilteredURLs) {
+ scoped_ptr<TestRenderViewContextMenu> menu(
+ CreateContextMenu(GURL("chrome://history"),
+ GURL()));
+
+ ASSERT_FALSE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB));
+ ASSERT_FALSE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW));
+ ASSERT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_COPYLINKLOCATION));
+}
+
+} // namespace
Property changes on: chrome/browser/tab_contents/render_view_context_menu_browsertest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698