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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/cpu-profiler/console-profile.js

Issue 2942573003: [DevTools] New harness for inspector-protocol layout tests (Closed)
Patch Set: Protocol -> dp Created 3 years, 6 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
(Empty)
1 (async function(testRunner) {
2 let {page, session, dp} = await testRunner.startBlank('Tests that console.prof ile/profileEnd will record CPU profile when inspector front-end is connected.');
3
4 function fail(message) {
5 testRunner.log('FAIL: ' + message);
6 testRunner.completeTest();
7 }
8
9 function findFunctionInProfile(nodes, functionName) {
10 return nodes.some(n => n.callFrame.functionName === functionName);
11 }
12
13 var headers = [];
14 dp.Profiler.onConsoleProfileFinished(messageObject => {
15 headers.push({profile: messageObject['params']['profile'], title: messageObj ect['params']['title']});
16 });
17
18 dp.Profiler.enable();
19 await session.evaluate(`
20 (function collectProfiles() {
21 console.profile('outer');
22 console.profile(42);
23 console.profileEnd('outer');
24 console.profileEnd(42);
25 })();
26 `);
27
28 if (headers.length !== 2)
29 return fail('Cannot retrive headers: ' + JSON.stringify(messageObject, null, 4));
30
31 for (var i = 0; i < headers.length; i++) {
32 if (headers[i].title === '42') {
33 testRunner.log('SUCCESS: retrieved "42" profile');
34 if (!findFunctionInProfile(headers[i].profile.nodes, 'collectProfiles'))
35 return fail('collectProfiles function not found in the profile: ' + JSON .stringify(headers[i].profile, null, 4));
36 testRunner.log('SUCCESS: found "collectProfiles" function in the profile') ;
37 testRunner.completeTest();
38 return;
39 }
40 }
41
42 fail('Cannot find "42" profile header');
43 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698