| Index: third_party/WebKit/LayoutTests/inspector-protocol/cpu-profiler/console-profile.js
|
| diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/cpu-profiler/console-profile.js b/third_party/WebKit/LayoutTests/inspector-protocol/cpu-profiler/console-profile.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c1bcab2cc2e0bde7ecfa88303ccffb365a9021a7
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/inspector-protocol/cpu-profiler/console-profile.js
|
| @@ -0,0 +1,43 @@
|
| +(async function() {
|
| + let {page, session, Protocol} = await InspectorTest.startBlank('Tests that console.profile/profileEnd will record CPU profile when inspector front-end is connected.');
|
| +
|
| + function fail(message) {
|
| + InspectorTest.log('FAIL: ' + message);
|
| + InspectorTest.completeTest();
|
| + }
|
| +
|
| + function findFunctionInProfile(nodes, functionName) {
|
| + return nodes.some(n => n.callFrame.functionName === functionName);
|
| + }
|
| +
|
| + var headers = [];
|
| + Protocol.Profiler.onConsoleProfileFinished(messageObject => {
|
| + headers.push({profile: messageObject['params']['profile'], title: messageObject['params']['title']});
|
| + });
|
| +
|
| + Protocol.Profiler.enable();
|
| + await session.evaluate(`
|
| + (function collectProfiles() {
|
| + console.profile('outer');
|
| + console.profile(42);
|
| + console.profileEnd('outer');
|
| + console.profileEnd(42);
|
| + })();
|
| + `);
|
| +
|
| + if (headers.length !== 2)
|
| + return fail('Cannot retrive headers: ' + JSON.stringify(messageObject, null, 4));
|
| +
|
| + for (var i = 0; i < headers.length; i++) {
|
| + if (headers[i].title === '42') {
|
| + InspectorTest.log('SUCCESS: retrieved "42" profile');
|
| + if (!findFunctionInProfile(headers[i].profile.nodes, 'collectProfiles'))
|
| + return fail('collectProfiles function not found in the profile: ' + JSON.stringify(headers[i].profile, null, 4));
|
| + InspectorTest.log('SUCCESS: found "collectProfiles" function in the profile');
|
| + InspectorTest.completeTest();
|
| + return;
|
| + }
|
| + }
|
| +
|
| + fail('Cannot find "42" profile header');
|
| +})();
|
|
|