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

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: unified 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() {
2 let {page, session, Protocol} = await InspectorTest.startBlank('Tests that con sole.profile/profileEnd will record CPU profile when inspector front-end is conn ected.');
3
4 function fail(message) {
5 InspectorTest.log('FAIL: ' + message);
6 InspectorTest.completeTest();
7 }
8
9 function findFunctionInProfile(nodes, functionName) {
10 return nodes.some(n => n.callFrame.functionName === functionName);
11 }
12
13 var headers = [];
14 Protocol.Profiler.onConsoleProfileFinished(messageObject => {
15 headers.push({profile: messageObject['params']['profile'], title: messageObj ect['params']['title']});
16 });
17
18 Protocol.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 InspectorTest.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 InspectorTest.log('SUCCESS: found "collectProfiles" function in the profil e');
37 InspectorTest.completeTest();
38 return;
39 }
40 }
41
42 fail('Cannot find "42" profile header');
43 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698