diff options
Diffstat (limited to 'chromium/chrome/browser/tab_contents')
4 files changed, 29 insertions, 22 deletions
diff --git a/chromium/chrome/browser/tab_contents/form_interaction_tab_helper.cc b/chromium/chrome/browser/tab_contents/form_interaction_tab_helper.cc index a051fd57620..9161993328e 100644 --- a/chromium/chrome/browser/tab_contents/form_interaction_tab_helper.cc +++ b/chromium/chrome/browser/tab_contents/form_interaction_tab_helper.cc @@ -5,7 +5,6 @@ #include "chrome/browser/tab_contents/form_interaction_tab_helper.h" #include "base/bind.h" -#include "base/task/post_task.h" #include "components/performance_manager/public/graph/graph.h" #include "components/performance_manager/public/graph/page_node.h" #include "components/performance_manager/public/performance_manager.h" @@ -68,8 +67,8 @@ void FormInteractionTabHelper::GraphObserver::DispatchOnHadFormInteraction( void FormInteractionTabHelper::GraphObserver::OnHadFormInteractionChanged( const performance_manager::PageNode* page_node) { // Forward the notification over to the UI thread. - base::PostTask(FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(&GraphObserver::DispatchOnHadFormInteraction, + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&GraphObserver::DispatchOnHadFormInteraction, page_node->GetContentsProxy(), page_node->HadFormInteraction())); } diff --git a/chromium/chrome/browser/tab_contents/form_interaction_tab_helper_unittest.cc b/chromium/chrome/browser/tab_contents/form_interaction_tab_helper_unittest.cc index 88bc9fe0d5a..38c7993d8a3 100644 --- a/chromium/chrome/browser/tab_contents/form_interaction_tab_helper_unittest.cc +++ b/chromium/chrome/browser/tab_contents/form_interaction_tab_helper_unittest.cc @@ -19,6 +19,7 @@ #include "components/performance_manager/public/performance_manager.h" #include "components/performance_manager/test_support/graph_impl.h" #include "components/performance_manager/test_support/mock_graphs.h" +#include "components/performance_manager/test_support/test_harness_helper.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/test/navigation_simulator.h" @@ -36,9 +37,7 @@ class FormInteractionTabHelperTest : public ChromeRenderViewHostTestHarness { void SetUp() override { ChromeRenderViewHostTestHarness::SetUp(); - perf_man_ = - performance_manager::PerformanceManagerImpl::Create(base::DoNothing()); - registry_ = performance_manager::PerformanceManagerRegistry::Create(); + pm_harness_.SetUp(); performance_manager::testing::CreatePageAggregatorAndPassItToGraph(); performance_manager::PerformanceManagerImpl::CallOnGraph( FROM_HERE, base::BindOnce([](performance_manager::Graph* graph) { @@ -49,7 +48,6 @@ class FormInteractionTabHelperTest : public ChromeRenderViewHostTestHarness { std::unique_ptr<content::WebContents> CreateTestWebContents() { std::unique_ptr<content::WebContents> contents = ChromeRenderViewHostTestHarness::CreateTestWebContents(); - registry_->CreatePageNodeForWebContents(contents.get()); FormInteractionTabHelper::CreateForWebContents(contents.get()); // Simulate a navigation event to force the initialization of the main // frame. @@ -60,16 +58,12 @@ class FormInteractionTabHelperTest : public ChromeRenderViewHostTestHarness { } void TearDown() override { - registry_->TearDown(); - registry_.reset(); - performance_manager::PerformanceManagerImpl::Destroy(std::move(perf_man_)); - task_environment()->RunUntilIdle(); + pm_harness_.TearDown(); ChromeRenderViewHostTestHarness::TearDown(); } private: - std::unique_ptr<performance_manager::PerformanceManagerImpl> perf_man_; - std::unique_ptr<performance_manager::PerformanceManagerRegistry> registry_; + performance_manager::PerformanceManagerTestHarnessHelper pm_harness_; }; TEST_F(FormInteractionTabHelperTest, HadFormInteractionSingleFrame) { diff --git a/chromium/chrome/browser/tab_contents/navigation_metrics_recorder_browsertest.cc b/chromium/chrome/browser/tab_contents/navigation_metrics_recorder_browsertest.cc index c3e8989646e..4d693b58603 100644 --- a/chromium/chrome/browser/tab_contents/navigation_metrics_recorder_browsertest.cc +++ b/chromium/chrome/browser/tab_contents/navigation_metrics_recorder_browsertest.cc @@ -11,6 +11,7 @@ #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/interactive_test_utils.h" #include "chrome/test/base/ui_test_utils.h" +#include "components/navigation_metrics/navigation_metrics.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host.h" #include "content/public/browser/web_contents.h" @@ -53,11 +54,13 @@ IN_PROC_BROWSER_TEST_F(NavigationMetricsRecorderBrowserTest, TestMetrics) { base::HistogramTester histograms; ui_test_utils::NavigateToURL(browser(), GURL("data:text/html, <html></html>")); - histograms.ExpectTotalCount("Navigation.MainFrameScheme", 1); - histograms.ExpectBucketCount("Navigation.MainFrameScheme", 5 /* data: */, 1); - histograms.ExpectTotalCount("Navigation.MainFrameSchemeDifferentPage", 1); - histograms.ExpectBucketCount("Navigation.MainFrameSchemeDifferentPage", + histograms.ExpectTotalCount(navigation_metrics::kMainFrameScheme, 1); + histograms.ExpectBucketCount(navigation_metrics::kMainFrameScheme, 5 /* data: */, 1); + histograms.ExpectTotalCount(navigation_metrics::kMainFrameSchemeDifferentPage, + 1); + histograms.ExpectBucketCount( + navigation_metrics::kMainFrameSchemeDifferentPage, 5 /* data: */, 1); } IN_PROC_BROWSER_TEST_F(NavigationMetricsRecorderBrowserTest, diff --git a/chromium/chrome/browser/tab_contents/view_source_browsertest.cc b/chromium/chrome/browser/tab_contents/view_source_browsertest.cc index bd11caab8dd..dc01e1f9b4f 100644 --- a/chromium/chrome/browser/tab_contents/view_source_browsertest.cc +++ b/chromium/chrome/browser/tab_contents/view_source_browsertest.cc @@ -339,7 +339,18 @@ IN_PROC_BROWSER_TEST_F(ViewSourceTest, HttpPostInMainframe) { "document.getElementById('form').submit();")); form_post_observer.Wait(); GURL target_url(embedded_test_server()->GetURL("a.com", "/echoall")); - EXPECT_EQ(target_url, original_main_frame->GetLastCommittedURL()); + + content::RenderFrameHost* current_main_frame = + original_contents->GetMainFrame(); + if (content::CanSameSiteMainFrameNavigationsChangeRenderFrameHosts()) { + // When ProactivelySwapBrowsingInstance or RenderDocument is enabled on + // same-site main frame navigations, the form submission above will result + // in a change of RFH. + EXPECT_NE(current_main_frame, original_main_frame); + } else { + EXPECT_EQ(current_main_frame, original_main_frame); + } + EXPECT_EQ(target_url, current_main_frame->GetLastCommittedURL()); // Extract the response nonce. std::string response_nonce; @@ -347,13 +358,13 @@ IN_PROC_BROWSER_TEST_F(ViewSourceTest, HttpPostInMainframe) { domAutomationController.send( document.getElementById('response-nonce').innerText); )"; EXPECT_TRUE(ExecuteScriptAndExtractString( - original_main_frame, response_nonce_extraction_script, &response_nonce)); + current_main_frame, response_nonce_extraction_script, &response_nonce)); // Open view-source mode tab for the main frame. This tries to mimic the // behavior of RenderViewContextMenu::ExecuteCommand when it handles // IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE. content::WebContentsAddedObserver view_source_contents_observer; - original_main_frame->ViewSource(); + current_main_frame->ViewSource(); content::WebContents* view_source_contents = view_source_contents_observer.GetWebContents(); EXPECT_TRUE(WaitForLoadStop(view_source_contents)); @@ -390,7 +401,7 @@ IN_PROC_BROWSER_TEST_F(ViewSourceTest, HttpPostInMainframe) { // Verify that the original contents and the view-source contents are in a // different process - see https://crbug.com/699493. - EXPECT_NE(original_main_frame->GetSiteInstance(), + EXPECT_NE(current_main_frame->GetSiteInstance(), view_source_contents->GetMainFrame()->GetSiteInstance()); // Verify the title of view-source is derived from the URL (not from the title @@ -399,7 +410,7 @@ IN_PROC_BROWSER_TEST_F(ViewSourceTest, HttpPostInMainframe) { EXPECT_EQ("EmbeddedTestServer - EchoAll", base::UTF16ToUTF8(original_contents->GetTitle())); EXPECT_THAT(title, Not(HasSubstr("EmbeddedTestServer - EchoAll"))); - GURL original_url = original_main_frame->GetLastCommittedURL(); + GURL original_url = current_main_frame->GetLastCommittedURL(); EXPECT_THAT(title, HasSubstr(content::kViewSourceScheme)); EXPECT_THAT(title, HasSubstr(original_url.host())); EXPECT_THAT(title, HasSubstr(original_url.port())); |