| OLD | NEW |
| (Empty) |
| 1 <html> | |
| 2 <head> | |
| 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> | |
| 4 <script> | |
| 5 function collectProfiles() | |
| 6 { | |
| 7 console.profile("outer"); | |
| 8 console.profile(42); | |
| 9 console.profileEnd("outer"); | |
| 10 console.profileEnd(42); | |
| 11 } | |
| 12 | |
| 13 function test() | |
| 14 { | |
| 15 InspectorTest.fail = function(message) | |
| 16 { | |
| 17 InspectorTest.log("FAIL: " + message); | |
| 18 InspectorTest.completeTest(); | |
| 19 } | |
| 20 | |
| 21 InspectorTest.sendCommand("Profiler.enable", {}); | |
| 22 InspectorTest.sendCommand("Runtime.evaluate", { expression: "collectProfiles
()"}, didCollectProfiles); | |
| 23 | |
| 24 var headers = []; | |
| 25 InspectorTest.eventHandler["Profiler.consoleProfileFinished"] = function(mes
sageObject) | |
| 26 { | |
| 27 headers.push({ | |
| 28 profile: messageObject["params"]["profile"], | |
| 29 title: messageObject["params"]["title"] | |
| 30 }); | |
| 31 } | |
| 32 | |
| 33 function didCollectProfiles(messageObject) | |
| 34 { | |
| 35 if (headers.length !== 2) | |
| 36 return InspectorTest.fail("Cannot retrive headers: " + JSON.stringif
y(messageObject, null, 4)); | |
| 37 for (var i = 0; i < headers.length; i++) { | |
| 38 if (headers[i].title === "42") { | |
| 39 checkInnerProfile(headers[i].profile); | |
| 40 return; | |
| 41 } | |
| 42 } | |
| 43 InspectorTest.fail("Cannot find '42' profile header"); | |
| 44 } | |
| 45 | |
| 46 function checkInnerProfile(profile) | |
| 47 { | |
| 48 InspectorTest.log("SUCCESS: retrieved '42' profile"); | |
| 49 if (!findFunctionInProfile(profile.nodes, "collectProfiles")) | |
| 50 return InspectorTest.fail("collectProfiles function not found in the
profile: " + JSON.stringify(profile, null, 4)); | |
| 51 InspectorTest.log("SUCCESS: found 'collectProfiles' function in the prof
ile"); | |
| 52 InspectorTest.completeTest(); | |
| 53 } | |
| 54 | |
| 55 function findFunctionInProfile(nodes, functionName) | |
| 56 { | |
| 57 return nodes.some(n => n.callFrame.functionName === functionName); | |
| 58 } | |
| 59 } | |
| 60 </script> | |
| 61 </head> | |
| 62 <body onload="runTest()"> | |
| 63 <p> | |
| 64 Tests that console.profile/profileEnd will record CPU profile when inspector fro
nt-end is connected.<br> | |
| 65 </p> | |
| 66 </body> | |
| 67 </html> | |
| OLD | NEW |