diff options
author | jbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-06 00:18:38 +0000 |
---|---|---|
committer | jbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-06 00:18:38 +0000 |
commit | f074608f3fe830a7ba2edd347c6fc15203aa6b36 (patch) | |
tree | f5256a03265ec1b0749575023920c70fbf76f8e1 | |
parent | bc77e0e0abeed5aff82deae806c103f2e37713f1 (diff) | |
download | chromium_src-f074608f3fe830a7ba2edd347c6fc15203aa6b36.zip chromium_src-f074608f3fe830a7ba2edd347c6fc15203aa6b36.tar.gz chromium_src-f074608f3fe830a7ba2edd347c6fc15203aa6b36.tar.bz2 |
Fix flakiness of TracingBrowserTest.BeginTracingWithWatch test
BUG=146255
Review URL: https://chromiumcodereview.appspot.com/10913097
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155067 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/test/base/tracing_browsertest.cc | 33 | ||||
-rw-r--r-- | content/renderer/render_view_impl.cc | 3 |
2 files changed, 25 insertions, 11 deletions
diff --git a/chrome/test/base/tracing_browsertest.cc b/chrome/test/base/tracing_browsertest.cc index e464737..ad76e50 100644 --- a/chrome/test/base/tracing_browsertest.cc +++ b/chrome/test/base/tracing_browsertest.cc @@ -7,8 +7,12 @@ #include "base/debug/trace_event.h" #include "base/message_loop.h" #include "base/run_loop.h" +#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" +#include "content/public/browser/render_view_host.h" +#include "content/public/browser/web_contents.h" +#include "content/public/test/browser_test_utils.h" #include "testing/gtest/include/gtest/gtest.h" namespace { @@ -21,6 +25,15 @@ const char* g_category = "test_tracing"; const char* g_event = "TheEvent"; class TracingBrowserTest : public InProcessBrowserTest { + protected: + // Execute some no-op javascript on the current tab - this triggers a trace + // event in RenderViewImpl::OnScriptEvalRequest (from the renderer process). + void ExecuteJavascriptOnCurrentTab() { + content::RenderViewHost* rvh = + chrome::GetActiveWebContents(browser())->GetRenderViewHost(); + ASSERT_TRUE(rvh); + ASSERT_TRUE(content::ExecuteJavaScript(rvh, L"", L";")); + } }; void AddEvents(int num) { @@ -28,8 +41,7 @@ void AddEvents(int num) { TRACE_EVENT_INSTANT0(g_category, g_event); } -// This test times out on various builders. See http://crbug.com/146255 . -IN_PROC_BROWSER_TEST_F(TracingBrowserTest, DISABLED_BeginTracingWithWatch) { +IN_PROC_BROWSER_TEST_F(TracingBrowserTest, BeginTracingWithWatch) { base::TimeDelta no_timeout; base::TimeDelta short_timeout = base::TimeDelta::FromMilliseconds(5); std::string json_events; @@ -65,23 +77,26 @@ IN_PROC_BROWSER_TEST_F(TracingBrowserTest, DISABLED_BeginTracingWithWatch) { ASSERT_TRUE(EndTracing(&json_events)); // Child process events from same process. - GURL url1("chrome://tracing"); ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, - "RenderViewImpl::OnNavigate", 2)); - ui_test_utils::NavigateToURL(browser(), url1); - ui_test_utils::NavigateToURL(browser(), url1); + "OnScriptEvalRequest", 2)); + ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); + ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); EXPECT_TRUE(WaitForWatchEvent(no_timeout)); ASSERT_TRUE(EndTracing(&json_events)); // Child process events from different processes. - GURL url2("about:blank"); + GURL url1("chrome://tracing/"); + GURL url2("chrome://credits/"); ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, - "RenderViewImpl::OnNavigate", 2)); + "OnScriptEvalRequest", 2)); // Open two tabs to different URLs to encourage two separate renderer // processes. Each will fire an event that will be counted towards the total. - ui_test_utils::NavigateToURL(browser(), url1); + ui_test_utils::NavigateToURLWithDisposition(browser(), url1, + NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); + ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); ui_test_utils::NavigateToURLWithDisposition(browser(), url2, NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); + ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); EXPECT_TRUE(WaitForWatchEvent(no_timeout)); ASSERT_TRUE(EndTracing(&json_events)); } diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 7bd2986..7fdc448 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -1216,8 +1216,6 @@ void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { // In case LoadRequest failed before DidCreateDataSource was called. pending_navigation_params_.reset(); - - UNSHIPPED_TRACE_EVENT_INSTANT0("test_tracing", "RenderViewImpl::OnNavigate"); } bool RenderViewImpl::IsBackForwardToStaleEntry( @@ -4811,6 +4809,7 @@ void RenderViewImpl::OnScriptEvalRequest(const string16& frame_xpath, const string16& jscript, int id, bool notify_result) { + UNSHIPPED_TRACE_EVENT_INSTANT0("test_tracing", "OnScriptEvalRequest"); EvaluateScript(frame_xpath, jscript, id, notify_result); } |