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

Side by Side Diff: chrome/browser/tab_contents/render_view_context_menu_browsertest.cc

Issue 130773004: Start moving context menu code to RenderFrame. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 30 matching lines...) Expand all
41 params.link_url = url; 41 params.link_url = url;
42 WebContents* web_contents = 42 WebContents* web_contents =
43 browser()->tab_strip_model()->GetActiveWebContents(); 43 browser()->tab_strip_model()->GetActiveWebContents();
44 params.page_url = web_contents->GetController().GetActiveEntry()->GetURL(); 44 params.page_url = web_contents->GetController().GetActiveEntry()->GetURL();
45 #if defined(OS_MACOSX) 45 #if defined(OS_MACOSX)
46 params.writing_direction_default = 0; 46 params.writing_direction_default = 0;
47 params.writing_direction_left_to_right = 0; 47 params.writing_direction_left_to_right = 0;
48 params.writing_direction_right_to_left = 0; 48 params.writing_direction_right_to_left = 0;
49 #endif // OS_MACOSX 49 #endif // OS_MACOSX
50 TestRenderViewContextMenu* menu = new TestRenderViewContextMenu( 50 TestRenderViewContextMenu* menu = new TestRenderViewContextMenu(
51 browser()->tab_strip_model()->GetActiveWebContents(), params); 51 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame(),
52 params);
52 menu->Init(); 53 menu->Init();
53 return menu; 54 return menu;
54 } 55 }
55 }; 56 };
56 57
57 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, 58 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest,
58 OpenEntryPresentForNormalURLs) { 59 OpenEntryPresentForNormalURLs) {
59 scoped_ptr<TestRenderViewContextMenu> menu( 60 scoped_ptr<TestRenderViewContextMenu> menu(
60 CreateContextMenu(GURL("http://www.google.com/"), 61 CreateContextMenu(GURL("http://www.google.com/"),
61 GURL("http://www.google.com/"))); 62 GURL("http://www.google.com/")));
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 const GURL kReferrerWithFragment("http://foo.com/test#fragment"); 138 const GURL kReferrerWithFragment("http://foo.com/test#fragment");
138 const std::string kCorrectReferrer("http://foo.com/test"); 139 const std::string kCorrectReferrer("http://foo.com/test");
139 140
140 // Set up menu with link URL. 141 // Set up menu with link URL.
141 content::ContextMenuParams context_menu_params; 142 content::ContextMenuParams context_menu_params;
142 context_menu_params.page_url = kReferrerWithFragment; 143 context_menu_params.page_url = kReferrerWithFragment;
143 context_menu_params.link_url = echoheader; 144 context_menu_params.link_url = echoheader;
144 145
145 // Select "Open Link in New Tab" and wait for the new tab to be added. 146 // Select "Open Link in New Tab" and wait for the new tab to be added.
146 TestRenderViewContextMenu menu( 147 TestRenderViewContextMenu menu(
147 browser()->tab_strip_model()->GetActiveWebContents(), 148 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame(),
148 context_menu_params); 149 context_menu_params);
149 menu.Init(); 150 menu.Init();
150 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 0); 151 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 0);
151 152
152 tab_observer.Wait(); 153 tab_observer.Wait();
153 content::WebContents* tab = tab_observer.GetTab(); 154 content::WebContents* tab = tab_observer.GetTab();
154 content::WaitForLoadStop(tab); 155 content::WaitForLoadStop(tab);
155 156
156 // Verify that it's the correct tab. 157 // Verify that it's the correct tab.
157 ASSERT_EQ(echoheader, tab->GetURL()); 158 ASSERT_EQ(echoheader, tab->GetURL());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 const std::string kNoneReferrer("None"); 190 const std::string kNoneReferrer("None");
190 const std::string kEmptyReferrer(""); 191 const std::string kEmptyReferrer("");
191 192
192 // Set up menu with link URL. 193 // Set up menu with link URL.
193 content::ContextMenuParams context_menu_params; 194 content::ContextMenuParams context_menu_params;
194 context_menu_params.page_url = kReferrerWithFragment; 195 context_menu_params.page_url = kReferrerWithFragment;
195 context_menu_params.link_url = echoheader; 196 context_menu_params.link_url = echoheader;
196 197
197 // Select "Open Link in Incognito Window" and wait for window to be added. 198 // Select "Open Link in Incognito Window" and wait for window to be added.
198 TestRenderViewContextMenu menu( 199 TestRenderViewContextMenu menu(
199 browser()->tab_strip_model()->GetActiveWebContents(), 200 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame(),
200 context_menu_params); 201 context_menu_params);
201 menu.Init(); 202 menu.Init();
202 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD, 0); 203 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD, 0);
203 204
204 tab_observer.Wait(); 205 tab_observer.Wait();
205 content::WebContents* tab = tab_observer.GetTab(); 206 content::WebContents* tab = tab_observer.GetTab();
206 content::WaitForLoadStop(tab); 207 content::WaitForLoadStop(tab);
207 208
208 // Verify that it's the correct tab. 209 // Verify that it's the correct tab.
209 ASSERT_EQ(echoheader, tab->GetURL()); 210 ASSERT_EQ(echoheader, tab->GetURL());
210 // Verify that the text on the page matches |kNoneReferrer|. 211 // Verify that the text on the page matches |kNoneReferrer|.
211 std::string actual_referrer; 212 std::string actual_referrer;
212 ASSERT_TRUE(content::ExecuteScriptAndExtractString( 213 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
213 tab, 214 tab,
214 "window.domAutomationController.send(window.document.body.textContent);", 215 "window.domAutomationController.send(window.document.body.textContent);",
215 &actual_referrer)); 216 &actual_referrer));
216 ASSERT_EQ(kNoneReferrer, actual_referrer); 217 ASSERT_EQ(kNoneReferrer, actual_referrer);
217 218
218 // Verify that the referrer on the page matches |kEmptyReferrer|. 219 // Verify that the referrer on the page matches |kEmptyReferrer|.
219 std::string page_referrer; 220 std::string page_referrer;
220 ASSERT_TRUE(content::ExecuteScriptAndExtractString( 221 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
221 tab, 222 tab,
222 "window.domAutomationController.send(window.document.referrer);", 223 "window.domAutomationController.send(window.document.referrer);",
223 &page_referrer)); 224 &page_referrer));
224 ASSERT_EQ(kEmptyReferrer, page_referrer); 225 ASSERT_EQ(kEmptyReferrer, page_referrer);
225 } 226 }
226 227
227 } // namespace 228 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698