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

Unified 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 side-by-side diff with in-line comments
Download patch
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..80bca50d33c1efb2a692ce24ae007a4f0ec8e252
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/cpu-profiler/console-profile.js
@@ -0,0 +1,43 @@
+(async function(testRunner) {
+ let {page, session, dp} = await testRunner.startBlank('Tests that console.profile/profileEnd will record CPU profile when inspector front-end is connected.');
+
+ function fail(message) {
+ testRunner.log('FAIL: ' + message);
+ testRunner.completeTest();
+ }
+
+ function findFunctionInProfile(nodes, functionName) {
+ return nodes.some(n => n.callFrame.functionName === functionName);
+ }
+
+ var headers = [];
+ dp.Profiler.onConsoleProfileFinished(messageObject => {
+ headers.push({profile: messageObject['params']['profile'], title: messageObject['params']['title']});
+ });
+
+ dp.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') {
+ testRunner.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));
+ testRunner.log('SUCCESS: found "collectProfiles" function in the profile');
+ testRunner.completeTest();
+ return;
+ }
+ }
+
+ fail('Cannot find "42" profile header');
+})

Powered by Google App Engine
This is Rietveld 408576698