OLD | NEW |
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 <list> | 5 #include <list> |
6 #include <set> | 6 #include <set> |
7 | 7 |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 ASSERT_TRUE(StartEmbeddedTestServer()); | 498 ASSERT_TRUE(StartEmbeddedTestServer()); |
499 ASSERT_TRUE(RunExtensionTest("webnavigation/failures")) << message_; | 499 ASSERT_TRUE(RunExtensionTest("webnavigation/failures")) << message_; |
500 } | 500 } |
501 | 501 |
502 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, FilteredTest) { | 502 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, FilteredTest) { |
503 ASSERT_TRUE(StartEmbeddedTestServer()); | 503 ASSERT_TRUE(StartEmbeddedTestServer()); |
504 ASSERT_TRUE(RunExtensionTest("webnavigation/filtered")) << message_; | 504 ASSERT_TRUE(RunExtensionTest("webnavigation/filtered")) << message_; |
505 } | 505 } |
506 | 506 |
507 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, UserAction) { | 507 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, UserAction) { |
| 508 content::IsolateAllSitesForTesting(base::CommandLine::ForCurrentProcess()); |
508 ASSERT_TRUE(StartEmbeddedTestServer()); | 509 ASSERT_TRUE(StartEmbeddedTestServer()); |
509 | 510 |
510 // Wait for the extension to set itself up and return control to us. | 511 // Wait for the extension to set itself up and return control to us. |
511 ASSERT_TRUE(RunExtensionTest("webnavigation/userAction")) << message_; | 512 ASSERT_TRUE(RunExtensionTest("webnavigation/userAction")) << message_; |
512 | 513 |
513 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 514 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
514 content::WaitForLoadStop(tab); | 515 content::WaitForLoadStop(tab); |
515 | 516 |
516 ResultCatcher catcher; | 517 ResultCatcher catcher; |
517 | 518 |
518 ExtensionService* service = extensions::ExtensionSystem::Get( | 519 ExtensionService* service = extensions::ExtensionSystem::Get( |
519 browser()->profile())->extension_service(); | 520 browser()->profile())->extension_service(); |
520 const extensions::Extension* extension = | 521 const extensions::Extension* extension = |
521 service->GetExtensionById(last_loaded_extension_id(), false); | 522 service->GetExtensionById(last_loaded_extension_id(), false); |
522 GURL url = extension->GetResourceURL("a.html"); | 523 GURL url = extension->GetResourceURL( |
| 524 "a.html?" + base::IntToString(embedded_test_server()->port())); |
523 | 525 |
524 ui_test_utils::NavigateToURL(browser(), url); | 526 ui_test_utils::NavigateToURL(browser(), url); |
525 | 527 |
526 // This corresponds to "Open link in new tab". | 528 // This corresponds to "Open link in new tab". |
527 content::ContextMenuParams params; | 529 content::ContextMenuParams params; |
528 params.is_editable = false; | 530 params.is_editable = false; |
529 params.media_type = blink::WebContextMenuData::MediaTypeNone; | 531 params.media_type = blink::WebContextMenuData::MediaTypeNone; |
530 params.page_url = url; | 532 params.page_url = url; |
531 params.link_url = extension->GetResourceURL("b.html"); | 533 params.link_url = extension->GetResourceURL("b.html"); |
532 | 534 |
533 TestRenderViewContextMenu menu(tab->GetMainFrame(), params); | 535 // Get the child frame, which will be the one associated with the context |
| 536 // menu. |
| 537 std::vector<content::RenderFrameHost*> frames = tab->GetAllFrames(); |
| 538 EXPECT_EQ(2UL, frames.size()); |
| 539 EXPECT_TRUE(frames[1]->GetParent()); |
| 540 |
| 541 TestRenderViewContextMenu menu(frames[1], params); |
534 menu.Init(); | 542 menu.Init(); |
535 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 0); | 543 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 0); |
536 | 544 |
537 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 545 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
538 } | 546 } |
539 | 547 |
540 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, RequestOpenTab) { | 548 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, RequestOpenTab) { |
541 ASSERT_TRUE(StartEmbeddedTestServer()); | 549 ASSERT_TRUE(StartEmbeddedTestServer()); |
542 | 550 |
543 // Wait for the extension to set itself up and return control to us. | 551 // Wait for the extension to set itself up and return control to us. |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 "extensions/api_test/webnavigation/crash/b.html", | 798 "extensions/api_test/webnavigation/crash/b.html", |
791 embedded_test_server()->port())); | 799 embedded_test_server()->port())); |
792 ui_test_utils::NavigateToURL(browser(), url); | 800 ui_test_utils::NavigateToURL(browser(), url); |
793 | 801 |
794 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 802 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
795 } | 803 } |
796 | 804 |
797 #endif | 805 #endif |
798 | 806 |
799 } // namespace extensions | 807 } // namespace extensions |
OLD | NEW |