OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "chrome/app/chrome_command_ids.h" | 6 #include "chrome/app/chrome_command_ids.h" |
7 #include "chrome/browser/extensions/extension_browsertest.h" | 7 #include "chrome/browser/extensions/extension_browsertest.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/extensions/extension_test_message_listener.h" | 9 #include "chrome/browser/extensions/extension_test_message_listener.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 124 } |
125 | 125 |
126 bool LoadContextMenuExtensionIncognito(std::string subdirectory) { | 126 bool LoadContextMenuExtensionIncognito(std::string subdirectory) { |
127 FilePath extension_dir = | 127 FilePath extension_dir = |
128 test_data_dir_.AppendASCII("context_menus").AppendASCII(subdirectory); | 128 test_data_dir_.AppendASCII("context_menus").AppendASCII(subdirectory); |
129 return LoadExtensionIncognito(extension_dir); | 129 return LoadExtensionIncognito(extension_dir); |
130 } | 130 } |
131 | 131 |
132 TestRenderViewContextMenu* CreateMenu(Browser* browser, | 132 TestRenderViewContextMenu* CreateMenu(Browser* browser, |
133 const GURL& page_url, | 133 const GURL& page_url, |
134 const GURL& link_url) { | 134 const GURL& link_url, |
| 135 const GURL& frame_url) { |
135 TabContents* tab_contents = browser->GetSelectedTabContents(); | 136 TabContents* tab_contents = browser->GetSelectedTabContents(); |
136 WebContextMenuData data; | 137 WebContextMenuData data; |
137 ContextMenuParams params(data); | 138 ContextMenuParams params(data); |
138 params.page_url = page_url; | 139 params.page_url = page_url; |
139 params.link_url = link_url; | 140 params.link_url = link_url; |
| 141 params.frame_url = frame_url; |
140 TestRenderViewContextMenu* menu = | 142 TestRenderViewContextMenu* menu = |
141 new TestRenderViewContextMenu(tab_contents, params); | 143 new TestRenderViewContextMenu(tab_contents, params); |
142 menu->Init(); | 144 menu->Init(); |
143 return menu; | 145 return menu; |
144 } | 146 } |
145 | 147 |
146 // Shortcut to return the current ExtensionMenuManager. | 148 // Shortcut to return the current ExtensionMenuManager. |
147 ExtensionMenuManager* menu_manager() { | 149 ExtensionMenuManager* menu_manager() { |
148 return browser()->profile()->GetExtensionService()->menu_manager(); | 150 return browser()->profile()->GetExtensionService()->menu_manager(); |
149 } | 151 } |
(...skipping 23 matching lines...) Expand all Loading... |
173 result.insert(result.end(), list->begin(), list->end()); | 175 result.insert(result.end(), list->begin(), list->end()); |
174 } | 176 } |
175 return result; | 177 return result; |
176 } | 178 } |
177 | 179 |
178 // This creates a test menu for a page with |page_url| and |link_url|, looks | 180 // This creates a test menu for a page with |page_url| and |link_url|, looks |
179 // for an extension item with the given |label|, and returns true if the item | 181 // for an extension item with the given |label|, and returns true if the item |
180 // was found. | 182 // was found. |
181 bool MenuHasItemWithLabel(const GURL& page_url, | 183 bool MenuHasItemWithLabel(const GURL& page_url, |
182 const GURL& link_url, | 184 const GURL& link_url, |
| 185 const GURL& frame_url, |
183 const std::string& label) { | 186 const std::string& label) { |
184 scoped_ptr<TestRenderViewContextMenu> menu( | 187 scoped_ptr<TestRenderViewContextMenu> menu( |
185 CreateMenu(browser(), page_url, link_url)); | 188 CreateMenu(browser(), page_url, link_url, frame_url)); |
186 return menu->HasExtensionItemWithLabel(label); | 189 return menu->HasExtensionItemWithLabel(label); |
187 } | 190 } |
188 }; | 191 }; |
189 | 192 |
190 // Tests adding a simple context menu item. | 193 // Tests adding a simple context menu item. |
191 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, Simple) { | 194 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, Simple) { |
192 ExtensionTestMessageListener listener1("created item", false); | 195 ExtensionTestMessageListener listener1("created item", false); |
193 ExtensionTestMessageListener listener2("onclick fired", false); | 196 ExtensionTestMessageListener listener2("onclick fired", false); |
194 ASSERT_TRUE(LoadContextMenuExtension("simple")); | 197 ASSERT_TRUE(LoadContextMenuExtension("simple")); |
195 | 198 |
196 // Wait for the extension to tell us it's created an item. | 199 // Wait for the extension to tell us it's created an item. |
197 ASSERT_TRUE(listener1.WaitUntilSatisfied()); | 200 ASSERT_TRUE(listener1.WaitUntilSatisfied()); |
198 | 201 |
199 GURL page_url("http://www.google.com"); | 202 GURL page_url("http://www.google.com"); |
200 | 203 |
201 // Create and build our test context menu. | 204 // Create and build our test context menu. |
202 scoped_ptr<TestRenderViewContextMenu> menu( | 205 scoped_ptr<TestRenderViewContextMenu> menu( |
203 CreateMenu(browser(), page_url, GURL())); | 206 CreateMenu(browser(), page_url, GURL(), GURL())); |
204 | 207 |
205 // Look for the extension item in the menu, and execute it. | 208 // Look for the extension item in the menu, and execute it. |
206 int command_id = IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST; | 209 int command_id = IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST; |
207 ASSERT_TRUE(menu->IsCommandIdEnabled(command_id)); | 210 ASSERT_TRUE(menu->IsCommandIdEnabled(command_id)); |
208 menu->ExecuteCommand(command_id); | 211 menu->ExecuteCommand(command_id); |
209 | 212 |
210 // Wait for the extension's script to tell us its onclick fired. | 213 // Wait for the extension's script to tell us its onclick fired. |
211 ASSERT_TRUE(listener2.WaitUntilSatisfied()); | 214 ASSERT_TRUE(listener2.WaitUntilSatisfied()); |
212 } | 215 } |
213 | 216 |
214 // Tests that setting "documentUrlPatterns" for an item properly restricts | 217 // Tests that setting "documentUrlPatterns" for an item properly restricts |
215 // those items to matching pages. | 218 // those items to matching pages. |
216 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, Patterns) { | 219 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, Patterns) { |
217 ExtensionTestMessageListener listener("created items", false); | 220 ExtensionTestMessageListener listener("created items", false); |
218 | 221 |
219 ASSERT_TRUE(LoadContextMenuExtension("patterns")); | 222 ASSERT_TRUE(LoadContextMenuExtension("patterns")); |
220 | 223 |
221 // Wait for the js test code to create its two items with patterns. | 224 // Wait for the js test code to create its two items with patterns. |
222 ASSERT_TRUE(listener.WaitUntilSatisfied()); | 225 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
223 | 226 |
224 // Check that a document url that should match the items' patterns appears. | 227 // Check that a document url that should match the items' patterns appears. |
225 GURL google_url("http://www.google.com"); | 228 GURL google_url("http://www.google.com"); |
226 ASSERT_TRUE(MenuHasItemWithLabel(google_url, | 229 ASSERT_TRUE(MenuHasItemWithLabel(google_url, |
227 GURL(), | 230 GURL(), |
| 231 GURL(), |
228 std::string("test_item1"))); | 232 std::string("test_item1"))); |
229 ASSERT_TRUE(MenuHasItemWithLabel(google_url, | 233 ASSERT_TRUE(MenuHasItemWithLabel(google_url, |
230 GURL(), | 234 GURL(), |
| 235 GURL(), |
231 std::string("test_item2"))); | 236 std::string("test_item2"))); |
232 | 237 |
233 // Now check with a non-matching url. | 238 // Now check with a non-matching url. |
234 GURL test_url("http://www.test.com"); | 239 GURL test_url("http://www.test.com"); |
235 ASSERT_FALSE(MenuHasItemWithLabel(test_url, | 240 ASSERT_FALSE(MenuHasItemWithLabel(test_url, |
236 GURL(), | 241 GURL(), |
| 242 GURL(), |
237 std::string("test_item1"))); | 243 std::string("test_item1"))); |
238 ASSERT_FALSE(MenuHasItemWithLabel(test_url, | 244 ASSERT_FALSE(MenuHasItemWithLabel(test_url, |
239 GURL(), | 245 GURL(), |
| 246 GURL(), |
240 std::string("test_item2"))); | 247 std::string("test_item2"))); |
241 } | 248 } |
242 | 249 |
243 // Tests registering an item with a very long title that should get truncated in | 250 // Tests registering an item with a very long title that should get truncated in |
244 // the actual menu displayed. | 251 // the actual menu displayed. |
245 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, LongTitle) { | 252 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, LongTitle) { |
246 ExtensionTestMessageListener listener("created", false); | 253 ExtensionTestMessageListener listener("created", false); |
247 | 254 |
248 // Load the extension and wait until it's created a menu item. | 255 // Load the extension and wait until it's created a menu item. |
249 ASSERT_TRUE(LoadContextMenuExtension("long_title")); | 256 ASSERT_TRUE(LoadContextMenuExtension("long_title")); |
250 ASSERT_TRUE(listener.WaitUntilSatisfied()); | 257 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
251 | 258 |
252 // Make sure we have an item registered with a long title. | 259 // Make sure we have an item registered with a long title. |
253 size_t limit = RenderViewContextMenu::kMaxExtensionItemTitleLength; | 260 size_t limit = RenderViewContextMenu::kMaxExtensionItemTitleLength; |
254 ExtensionMenuItem::List items = GetItems(); | 261 ExtensionMenuItem::List items = GetItems(); |
255 ASSERT_EQ(1u, items.size()); | 262 ASSERT_EQ(1u, items.size()); |
256 ExtensionMenuItem* item = items.at(0); | 263 ExtensionMenuItem* item = items.at(0); |
257 ASSERT_GT(item->title().size(), limit); | 264 ASSERT_GT(item->title().size(), limit); |
258 | 265 |
259 // Create a context menu, then find the item's label. It should be properly | 266 // Create a context menu, then find the item's label. It should be properly |
260 // truncated. | 267 // truncated. |
261 GURL url("http://foo.com/"); | 268 GURL url("http://foo.com/"); |
262 scoped_ptr<TestRenderViewContextMenu> menu( | 269 scoped_ptr<TestRenderViewContextMenu> menu( |
263 CreateMenu(browser(), url, GURL())); | 270 CreateMenu(browser(), url, GURL(), GURL())); |
264 | 271 |
265 string16 label; | 272 string16 label; |
266 ASSERT_TRUE(menu->GetItemLabel(item->id(), &label)); | 273 ASSERT_TRUE(menu->GetItemLabel(item->id(), &label)); |
267 ASSERT_TRUE(label.size() <= limit); | 274 ASSERT_TRUE(label.size() <= limit); |
268 } | 275 } |
269 | 276 |
270 // Checks that in |menu|, the item at |index| has type |expected_type| and a | 277 // Checks that in |menu|, the item at |index| has type |expected_type| and a |
271 // label of |expected_label|. | 278 // label of |expected_label|. |
272 static void ExpectLabelAndType(const char* expected_label, | 279 static void ExpectLabelAndType(const char* expected_label, |
273 MenuModel::ItemType expected_type, | 280 MenuModel::ItemType expected_type, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 // Navigate to test1.html inside the extension, which should create a bunch | 325 // Navigate to test1.html inside the extension, which should create a bunch |
319 // of items at the top-level (but they'll get pushed into an auto-generated | 326 // of items at the top-level (but they'll get pushed into an auto-generated |
320 // parent). | 327 // parent). |
321 ExtensionTestMessageListener listener1("test1 create finished", false); | 328 ExtensionTestMessageListener listener1("test1 create finished", false); |
322 ui_test_utils::NavigateToURL(browser(), | 329 ui_test_utils::NavigateToURL(browser(), |
323 GURL(extension->GetResourceURL("test1.html"))); | 330 GURL(extension->GetResourceURL("test1.html"))); |
324 listener1.WaitUntilSatisfied(); | 331 listener1.WaitUntilSatisfied(); |
325 | 332 |
326 GURL url("http://www.google.com/"); | 333 GURL url("http://www.google.com/"); |
327 scoped_ptr<TestRenderViewContextMenu> menu( | 334 scoped_ptr<TestRenderViewContextMenu> menu( |
328 CreateMenu(browser(), url, GURL())); | 335 CreateMenu(browser(), url, GURL(), GURL())); |
329 | 336 |
330 // The top-level item should be an "automagic parent" with the extension's | 337 // The top-level item should be an "automagic parent" with the extension's |
331 // name. | 338 // name. |
332 MenuModel* model = NULL; | 339 MenuModel* model = NULL; |
333 int index = 0; | 340 int index = 0; |
334 string16 label; | 341 string16 label; |
335 ASSERT_TRUE(menu->GetMenuModelAndItemIndex( | 342 ASSERT_TRUE(menu->GetMenuModelAndItemIndex( |
336 IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST, &model, &index)); | 343 IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST, &model, &index)); |
337 EXPECT_EQ(UTF8ToUTF16(extension->name()), model->GetLabelAt(index)); | 344 EXPECT_EQ(UTF8ToUTF16(extension->name()), model->GetLabelAt(index)); |
338 ASSERT_EQ(MenuModel::TYPE_SUBMENU, model->GetTypeAt(index)); | 345 ASSERT_EQ(MenuModel::TYPE_SUBMENU, model->GetTypeAt(index)); |
339 | 346 |
340 // Get the submenu and verify the items there. | 347 // Get the submenu and verify the items there. |
341 MenuModel* submenu = model->GetSubmenuModelAt(index); | 348 MenuModel* submenu = model->GetSubmenuModelAt(index); |
342 ASSERT_TRUE(submenu != NULL); | 349 ASSERT_TRUE(submenu != NULL); |
343 VerifyMenuForSeparatorsTest(*submenu); | 350 VerifyMenuForSeparatorsTest(*submenu); |
344 | 351 |
345 // Now run our second test - navigate to test2.html which creates an explicit | 352 // Now run our second test - navigate to test2.html which creates an explicit |
346 // parent node and populates that with the same items as in test1. | 353 // parent node and populates that with the same items as in test1. |
347 ExtensionTestMessageListener listener2("test2 create finished", false); | 354 ExtensionTestMessageListener listener2("test2 create finished", false); |
348 ui_test_utils::NavigateToURL(browser(), | 355 ui_test_utils::NavigateToURL(browser(), |
349 GURL(extension->GetResourceURL("test2.html"))); | 356 GURL(extension->GetResourceURL("test2.html"))); |
350 listener2.WaitUntilSatisfied(); | 357 listener2.WaitUntilSatisfied(); |
351 menu.reset(CreateMenu(browser(), url, GURL())); | 358 menu.reset(CreateMenu(browser(), url, GURL(), GURL())); |
352 ASSERT_TRUE(menu->GetMenuModelAndItemIndex( | 359 ASSERT_TRUE(menu->GetMenuModelAndItemIndex( |
353 IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST, &model, &index)); | 360 IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST, &model, &index)); |
354 EXPECT_EQ(UTF8ToUTF16("parent"), model->GetLabelAt(index)); | 361 EXPECT_EQ(UTF8ToUTF16("parent"), model->GetLabelAt(index)); |
355 submenu = model->GetSubmenuModelAt(index); | 362 submenu = model->GetSubmenuModelAt(index); |
356 ASSERT_TRUE(submenu != NULL); | 363 ASSERT_TRUE(submenu != NULL); |
357 VerifyMenuForSeparatorsTest(*submenu); | 364 VerifyMenuForSeparatorsTest(*submenu); |
358 } | 365 } |
359 | 366 |
360 // Tests that targetUrlPattern keeps items from appearing when there is no | 367 // Tests that targetUrlPattern keeps items from appearing when there is no |
361 // target url. | 368 // target url. |
362 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, TargetURLs) { | 369 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, TargetURLs) { |
363 ExtensionTestMessageListener listener("created items", false); | 370 ExtensionTestMessageListener listener("created items", false); |
364 ASSERT_TRUE(LoadContextMenuExtension("target_urls")); | 371 ASSERT_TRUE(LoadContextMenuExtension("target_urls")); |
365 ASSERT_TRUE(listener.WaitUntilSatisfied()); | 372 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
366 | 373 |
367 GURL google_url("http://www.google.com"); | 374 GURL google_url("http://www.google.com"); |
368 GURL non_google_url("http://www.foo.com"); | 375 GURL non_google_url("http://www.foo.com"); |
369 | 376 |
370 // No target url - the item should not appear. | 377 // No target url - the item should not appear. |
371 ASSERT_FALSE(MenuHasItemWithLabel(google_url, GURL(), std::string("item1"))); | 378 ASSERT_FALSE(MenuHasItemWithLabel( |
| 379 google_url, GURL(), GURL(), std::string("item1"))); |
372 | 380 |
373 // A matching target url - the item should appear. | 381 // A matching target url - the item should appear. |
374 ASSERT_TRUE(MenuHasItemWithLabel(google_url, | 382 ASSERT_TRUE(MenuHasItemWithLabel(google_url, |
375 google_url, | 383 google_url, |
| 384 GURL(), |
376 std::string("item1"))); | 385 std::string("item1"))); |
377 | 386 |
378 // A non-matching target url - the item should not appear. | 387 // A non-matching target url - the item should not appear. |
379 ASSERT_FALSE(MenuHasItemWithLabel(google_url, | 388 ASSERT_FALSE(MenuHasItemWithLabel(google_url, |
380 non_google_url, | 389 non_google_url, |
| 390 GURL(), |
381 std::string("item1"))); | 391 std::string("item1"))); |
382 } | 392 } |
383 | 393 |
384 // Tests adding a simple context menu item. | 394 // Tests adding of context menus in incognito mode. |
385 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, IncognitoSplit) { | 395 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, IncognitoSplit) { |
386 ExtensionTestMessageListener created("created item regular", false); | 396 ExtensionTestMessageListener created("created item regular", false); |
387 ExtensionTestMessageListener created_incognito("created item incognito", | 397 ExtensionTestMessageListener created_incognito("created item incognito", |
388 false); | 398 false); |
389 | 399 |
390 ExtensionTestMessageListener onclick("onclick fired regular", false); | 400 ExtensionTestMessageListener onclick("onclick fired regular", false); |
391 ExtensionTestMessageListener onclick_incognito("onclick fired incognito", | 401 ExtensionTestMessageListener onclick_incognito("onclick fired incognito", |
392 false); | 402 false); |
393 | 403 |
394 // Open an incognito window. | 404 // Open an incognito window. |
395 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), GURL("about:blank")); | 405 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), GURL("about:blank")); |
396 | 406 |
397 ASSERT_TRUE(LoadContextMenuExtensionIncognito("incognito")); | 407 ASSERT_TRUE(LoadContextMenuExtensionIncognito("incognito")); |
398 | 408 |
399 // Wait for the extension's processes to tell us they've created an item. | 409 // Wait for the extension's processes to tell us they've created an item. |
400 ASSERT_TRUE(created.WaitUntilSatisfied()); | 410 ASSERT_TRUE(created.WaitUntilSatisfied()); |
401 ASSERT_TRUE(created_incognito.WaitUntilSatisfied()); | 411 ASSERT_TRUE(created_incognito.WaitUntilSatisfied()); |
402 | 412 |
403 GURL page_url("http://www.google.com"); | 413 GURL page_url("http://www.google.com"); |
404 | 414 |
405 // Create and build our test context menu. | 415 // Create and build our test context menu. |
406 Browser* browser_incognito = BrowserList::FindBrowserWithType( | 416 Browser* browser_incognito = BrowserList::FindBrowserWithType( |
407 browser()->profile()->GetOffTheRecordProfile(), | 417 browser()->profile()->GetOffTheRecordProfile(), |
408 Browser::TYPE_NORMAL, false); | 418 Browser::TYPE_NORMAL, false); |
409 ASSERT_TRUE(browser_incognito); | 419 ASSERT_TRUE(browser_incognito); |
410 scoped_ptr<TestRenderViewContextMenu> menu( | 420 scoped_ptr<TestRenderViewContextMenu> menu( |
411 CreateMenu(browser(), page_url, GURL())); | 421 CreateMenu(browser(), page_url, GURL(), GURL())); |
412 scoped_ptr<TestRenderViewContextMenu> menu_incognito( | 422 scoped_ptr<TestRenderViewContextMenu> menu_incognito( |
413 CreateMenu(browser_incognito, page_url, GURL())); | 423 CreateMenu(browser_incognito, page_url, GURL(), GURL())); |
414 | 424 |
415 // Look for the extension item in the menu, and execute it. | 425 // Look for the extension item in the menu, and execute it. |
416 int command_id = IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST; | 426 int command_id = IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST; |
417 ASSERT_TRUE(menu->IsCommandIdEnabled(command_id)); | 427 ASSERT_TRUE(menu->IsCommandIdEnabled(command_id)); |
418 menu->ExecuteCommand(command_id); | 428 menu->ExecuteCommand(command_id); |
419 | 429 |
420 // Wait for the extension's script to tell us its onclick fired. Ensure | 430 // Wait for the extension's script to tell us its onclick fired. Ensure |
421 // that the incognito version doesn't fire until we explicitly click the | 431 // that the incognito version doesn't fire until we explicitly click the |
422 // incognito menu item. | 432 // incognito menu item. |
423 ASSERT_TRUE(onclick.WaitUntilSatisfied()); | 433 ASSERT_TRUE(onclick.WaitUntilSatisfied()); |
424 EXPECT_FALSE(onclick_incognito.was_satisfied()); | 434 EXPECT_FALSE(onclick_incognito.was_satisfied()); |
425 | 435 |
426 ASSERT_TRUE(menu_incognito->IsCommandIdEnabled(command_id)); | 436 ASSERT_TRUE(menu_incognito->IsCommandIdEnabled(command_id)); |
427 menu_incognito->ExecuteCommand(command_id); | 437 menu_incognito->ExecuteCommand(command_id); |
428 ASSERT_TRUE(onclick_incognito.WaitUntilSatisfied()); | 438 ASSERT_TRUE(onclick_incognito.WaitUntilSatisfied()); |
429 } | 439 } |
| 440 |
| 441 // Tests that items with a context of frames only appear when the menu is |
| 442 // invoked in a frame. |
| 443 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, Frames) { |
| 444 ExtensionTestMessageListener listener("created items", false); |
| 445 ASSERT_TRUE(LoadContextMenuExtension("frames")); |
| 446 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
| 447 |
| 448 GURL page_url("http://www.google.com"); |
| 449 GURL no_frame_url; |
| 450 GURL frame_url("http://www.google.com"); |
| 451 |
| 452 ASSERT_TRUE(MenuHasItemWithLabel( |
| 453 page_url, GURL(), no_frame_url, std::string("Page item"))); |
| 454 ASSERT_FALSE(MenuHasItemWithLabel( |
| 455 page_url, GURL(), no_frame_url, std::string("Frame item"))); |
| 456 |
| 457 ASSERT_TRUE(MenuHasItemWithLabel( |
| 458 page_url, GURL(), frame_url, std::string("Page item"))); |
| 459 ASSERT_TRUE(MenuHasItemWithLabel( |
| 460 page_url, GURL(), frame_url, std::string("Frame item"))); |
| 461 } |
OLD | NEW |