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

Side by Side Diff: test/inspector/cpu-profiler/console-profile.js

Issue 2390733002: [inspector] Make InspectorTest.sendCommand* private (Closed)
Patch Set: addressed comments Created 4 years, 2 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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project 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 print("Tests that console.profile/profileEnd will record CPU profile when inspec tor front-end is connected."); 5 print("Tests that console.profile/profileEnd will record CPU profile when inspec tor front-end is connected.");
6 6
7 InspectorTest.evaluateInPage(` 7 InspectorTest.addScript(`
8 function collectProfiles() 8 function collectProfiles()
9 { 9 {
10 console.profile("outer"); 10 console.profile("outer");
11 console.profile(42); 11 console.profile(42);
12 console.profileEnd("outer"); 12 console.profileEnd("outer");
13 console.profileEnd(42); 13 console.profileEnd(42);
14 }`); 14 }`);
15 15
16 InspectorTest.fail = function(message) 16 InspectorTest.fail = function(message)
17 { 17 {
18 InspectorTest.log("FAIL: " + message); 18 InspectorTest.log("FAIL: " + message);
19 InspectorTest.completeTest(); 19 InspectorTest.completeTest();
20 } 20 }
21 21
22 InspectorTest.sendCommand("Profiler.enable", {}); 22 Protocol.Profiler.enable();
23 InspectorTest.sendCommand("Runtime.evaluate", { expression: "collectProfiles()"} , didCollectProfiles); 23 Protocol.Runtime.evaluate({ expression: "collectProfiles()"}).then(didCollectPro files);
24 24
25 var headers = []; 25 var headers = [];
26 InspectorTest.eventHandler["Profiler.consoleProfileFinished"] = function(message Object) 26 Protocol.Profiler.onConsoleProfileFinished(function(messageObject)
27 { 27 {
28 headers.push({ 28 headers.push({
29 profile: messageObject["params"]["profile"], 29 profile: messageObject["params"]["profile"],
30 title: messageObject["params"]["title"] 30 title: messageObject["params"]["title"]
31 }); 31 });
32 } 32 });
33 33
34 function didCollectProfiles(messageObject) 34 function didCollectProfiles(messageObject)
35 { 35 {
36 if (headers.length !== 2) 36 if (headers.length !== 2)
37 return InspectorTest.fail("Cannot retrive headers: " + JSON.stringify(messag eObject, null, 4)); 37 return InspectorTest.fail("Cannot retrive headers: " + JSON.stringify(messag eObject, null, 4));
38 for (var i = 0; i < headers.length; i++) { 38 for (var i = 0; i < headers.length; i++) {
39 if (headers[i].title === "42") { 39 if (headers[i].title === "42") {
40 checkInnerProfile(headers[i].profile); 40 checkInnerProfile(headers[i].profile);
41 return; 41 return;
42 } 42 }
43 } 43 }
44 InspectorTest.fail("Cannot find '42' profile header"); 44 InspectorTest.fail("Cannot find '42' profile header");
45 } 45 }
46 46
47 function checkInnerProfile(profile) 47 function checkInnerProfile(profile)
48 { 48 {
49 InspectorTest.log("SUCCESS: retrieved '42' profile"); 49 InspectorTest.log("SUCCESS: retrieved '42' profile");
50 if (!findFunctionInProfile(profile.nodes, "collectProfiles")) 50 if (!findFunctionInProfile(profile.nodes, "collectProfiles"))
51 return InspectorTest.fail("collectProfiles function not found in the profile : " + JSON.stringify(profile, null, 4)); 51 return InspectorTest.fail("collectProfiles function not found in the profile : " + JSON.stringify(profile, null, 4));
52 InspectorTest.log("SUCCESS: found 'collectProfiles' function in the profile"); 52 InspectorTest.log("SUCCESS: found 'collectProfiles' function in the profile");
53 InspectorTest.completeTest(); 53 InspectorTest.completeTest();
54 } 54 }
55 55
56 function findFunctionInProfile(nodes, functionName) 56 function findFunctionInProfile(nodes, functionName)
57 { 57 {
58 return nodes.some(n => n.callFrame.functionName === functionName); 58 return nodes.some(n => n.callFrame.functionName === functionName);
59 } 59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698