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

Side by Side Diff: chrome/test/base/tracing_browsertest.cc

Issue 518583003: Don't take a fake UGI every time we execute Javascript. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix styling Created 6 years, 3 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 "chrome/test/base/tracing.h" 5 #include "chrome/test/base/tracing.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 10 matching lines...) Expand all
21 using tracing::BeginTracingWithWatch; 21 using tracing::BeginTracingWithWatch;
22 using tracing::WaitForWatchEvent; 22 using tracing::WaitForWatchEvent;
23 using tracing::EndTracing; 23 using tracing::EndTracing;
24 24
25 const char* g_category = "test_tracing"; 25 const char* g_category = "test_tracing";
26 const char* g_event = "TheEvent"; 26 const char* g_event = "TheEvent";
27 27
28 class TracingBrowserTest : public InProcessBrowserTest { 28 class TracingBrowserTest : public InProcessBrowserTest {
29 protected: 29 protected:
30 // Execute some no-op javascript on the current tab - this triggers a trace 30 // Execute some no-op javascript on the current tab - this triggers a trace
31 // event in RenderFrameImpl::OnJavaScriptExecuteRequest (from the renderer 31 // event in RenderFrameImpl::OnJavaScriptExecuteRequestForTests (from the
32 // process). 32 // renderer process).
33 void ExecuteJavascriptOnCurrentTab() { 33 void ExecuteJavascriptOnCurrentTab() {
34 content::RenderViewHost* rvh = browser()->tab_strip_model()-> 34 content::RenderViewHost* rvh = browser()->tab_strip_model()->
35 GetActiveWebContents()->GetRenderViewHost(); 35 GetActiveWebContents()->GetRenderViewHost();
36 ASSERT_TRUE(rvh); 36 ASSERT_TRUE(rvh);
37 ASSERT_TRUE(content::ExecuteScript(rvh, ";")); 37 ASSERT_TRUE(content::ExecuteScript(rvh, ";"));
38 } 38 }
39 }; 39 };
40 40
41 void AddEvents(int num) { 41 void AddEvents(int num) {
42 for (int i = 0; i < num; ++i) 42 for (int i = 0; i < num; ++i)
(...skipping 30 matching lines...) Expand all
73 ASSERT_TRUE(EndTracing(&json_events)); 73 ASSERT_TRUE(EndTracing(&json_events));
74 74
75 // Multi event after wait. 75 // Multi event after wait.
76 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, g_event, 5)); 76 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, g_event, 5));
77 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&AddEvents, 5)); 77 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&AddEvents, 5));
78 EXPECT_TRUE(WaitForWatchEvent(no_timeout)); 78 EXPECT_TRUE(WaitForWatchEvent(no_timeout));
79 ASSERT_TRUE(EndTracing(&json_events)); 79 ASSERT_TRUE(EndTracing(&json_events));
80 80
81 // Child process events from same process. 81 // Child process events from same process.
82 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, 82 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category,
83 "OnJavaScriptExecuteRequest", 2)); 83 "OnJavaScriptExecuteRequestForTests", 2));
84 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); 84 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab());
85 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); 85 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab());
86 EXPECT_TRUE(WaitForWatchEvent(no_timeout)); 86 EXPECT_TRUE(WaitForWatchEvent(no_timeout));
87 ASSERT_TRUE(EndTracing(&json_events)); 87 ASSERT_TRUE(EndTracing(&json_events));
88 88
89 // Child process events from different processes. 89 // Child process events from different processes.
90 GURL url1("chrome://tracing/"); 90 GURL url1("chrome://tracing/");
91 GURL url2("chrome://credits/"); 91 GURL url2("chrome://credits/");
92 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, 92 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category,
93 "OnJavaScriptExecuteRequest", 2)); 93 "OnJavaScriptExecuteRequestForTests", 2));
94 // Open two tabs to different URLs to encourage two separate renderer 94 // Open two tabs to different URLs to encourage two separate renderer
95 // processes. Each will fire an event that will be counted towards the total. 95 // processes. Each will fire an event that will be counted towards the total.
96 ui_test_utils::NavigateToURLWithDisposition(browser(), url1, 96 ui_test_utils::NavigateToURLWithDisposition(browser(), url1,
97 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 97 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
98 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); 98 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab());
99 ui_test_utils::NavigateToURLWithDisposition(browser(), url2, 99 ui_test_utils::NavigateToURLWithDisposition(browser(), url2,
100 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 100 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
101 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); 101 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab());
102 EXPECT_TRUE(WaitForWatchEvent(no_timeout)); 102 EXPECT_TRUE(WaitForWatchEvent(no_timeout));
103 ASSERT_TRUE(EndTracing(&json_events)); 103 ASSERT_TRUE(EndTracing(&json_events));
104 } 104 }
105 105
106 } // namespace 106 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_browsertest.cc ('k') | content/browser/frame_host/render_frame_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698