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

Unified Diff: chrome/browser/renderer_context_menu/render_view_context_menu_unittest.cc

Issue 2850153002: Disable Open in Incognito context item for urls disallowed in Incognito (Closed)
Patch Set: Use IsURLAllowedInIncognito function to control link Created 3 years, 8 months 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
Index: chrome/browser/renderer_context_menu/render_view_context_menu_unittest.cc
diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu_unittest.cc b/chrome/browser/renderer_context_menu/render_view_context_menu_unittest.cc
index f7c69fc06e4898b368fe4fb096fb492749dfbe77..04acece95f16e3f5afae9a4d0c37b75ab1ef74f1 100644
--- a/chrome/browser/renderer_context_menu/render_view_context_menu_unittest.cc
+++ b/chrome/browser/renderer_context_menu/render_view_context_menu_unittest.cc
@@ -96,6 +96,20 @@ std::unique_ptr<TestRenderViewContextMenu> CreateContextMenu(
return menu;
}
+// Returns a test context menu for a chrome:// url not permitted to open in
+// incognito mode.
+std::unique_ptr<TestRenderViewContextMenu> CreateContextMenuOnChromeLink(
+ content::WebContents* web_contents,
+ ProtocolHandlerRegistry* registry) {
+ content::ContextMenuParams params = CreateParams(MenuItem::LINK);
+ params.unfiltered_link_url = params.link_url = GURL("chrome://settings");
+ std::unique_ptr<TestRenderViewContextMenu> menu(
+ new TestRenderViewContextMenu(web_contents->GetMainFrame(), params));
+ menu->set_protocol_handler_registry(registry);
+ menu->Init();
+ return menu;
+}
+
} // namespace
class RenderViewContextMenuTest : public testing::Test {
@@ -380,6 +394,10 @@ class RenderViewContextMenuPrefsTest : public ChromeRenderViewHostTestHarness {
return ::CreateContextMenu(web_contents(), registry_.get());
}
+ std::unique_ptr<TestRenderViewContextMenu> CreateContextMenuOnChromeLink() {
+ return ::CreateContextMenuOnChromeLink(web_contents(), registry_.get());
lazyboy 2017/05/02 23:44:55 Is there a reason not to put the implementation ri
elawrence 2017/05/03 01:44:47 Done. I was mimic'ing the pattern of CreateContex
+ }
+
void AppendImageItems(TestRenderViewContextMenu* menu) {
menu->AppendImageItems();
}
@@ -455,6 +473,17 @@ TEST_F(RenderViewContextMenuPrefsTest,
menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD));
}
+// Verifies Incognito Mode is not enabled for links disallowed in Incognito.
+TEST_F(RenderViewContextMenuPrefsTest,
+ DisableOpenInIncognitoWindowForChromeUrls) {
+ std::unique_ptr<TestRenderViewContextMenu> menu(
+ CreateContextMenuOnChromeLink());
+
+ ASSERT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD));
+ EXPECT_FALSE(
+ menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD));
+}
+
// Make sure the checking custom command id that is not enabled will not
// cause DCHECK failure.
TEST_F(RenderViewContextMenuPrefsTest,

Powered by Google App Engine
This is Rietveld 408576698