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

Side by Side Diff: chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc

Issue 2385363002: Pass the RenderProcessHost id on retargeting. (Closed)
Patch Set: Created 4 years, 2 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
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 <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
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 std::vector<content::RenderFrameHost*> frames = tab->GetAllFrames();
536 content::RenderFrameHost* subframe = nullptr;
537 for (const auto& frame : frames) {
Charlie Reis 2016/10/03 22:15:23 This is a bit odd at first glance. Maybe clarify
nasko 2016/10/03 22:38:04 Done.
538 if (frame->GetParent()) {
539 subframe = frame;
540 break;
541 }
542 }
543 DCHECK(subframe);
544
545 TestRenderViewContextMenu menu(subframe, params);
534 menu.Init(); 546 menu.Init();
535 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 0); 547 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 0);
536 548
537 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 549 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
538 } 550 }
539 551
540 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, RequestOpenTab) { 552 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, RequestOpenTab) {
541 ASSERT_TRUE(StartEmbeddedTestServer()); 553 ASSERT_TRUE(StartEmbeddedTestServer());
542 554
543 // Wait for the extension to set itself up and return control to us. 555 // 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
790 "extensions/api_test/webnavigation/crash/b.html", 802 "extensions/api_test/webnavigation/crash/b.html",
791 embedded_test_server()->port())); 803 embedded_test_server()->port()));
792 ui_test_utils::NavigateToURL(browser(), url); 804 ui_test_utils::NavigateToURL(browser(), url);
793 805
794 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 806 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
795 } 807 }
796 808
797 #endif 809 #endif
798 810
799 } // namespace extensions 811 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698