OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> | 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> |
4 <script> | 4 <script> |
5 function collectProfiles() | 5 function collectProfiles() |
6 { | 6 { |
7 console.profile("outer"); | 7 console.profile("outer"); |
8 console.profile(42); | 8 console.profile(42); |
9 console.profileEnd("outer"); | 9 console.profileEnd("outer"); |
10 console.profileEnd(42); | 10 console.profileEnd(42); |
(...skipping 28 matching lines...) Expand all Loading... |
39 checkInnerProfile(headers[i].profile); | 39 checkInnerProfile(headers[i].profile); |
40 return; | 40 return; |
41 } | 41 } |
42 } | 42 } |
43 InspectorTest.fail("Cannot find '42' profile header"); | 43 InspectorTest.fail("Cannot find '42' profile header"); |
44 } | 44 } |
45 | 45 |
46 function checkInnerProfile(profile) | 46 function checkInnerProfile(profile) |
47 { | 47 { |
48 InspectorTest.log("SUCCESS: retrieved '42' profile"); | 48 InspectorTest.log("SUCCESS: retrieved '42' profile"); |
49 var root = profile.head; | 49 if (!findFunctionInProfile(profile.nodes, "collectProfiles")) |
50 if (!findFunctionInProfile(root, "collectProfiles")) | |
51 return InspectorTest.fail("collectProfiles function not found in the
profile: " + JSON.stringify(profile, null, 4)); | 50 return InspectorTest.fail("collectProfiles function not found in the
profile: " + JSON.stringify(profile, null, 4)); |
52 InspectorTest.log("SUCCESS: found 'collectProfiles' function in the prof
ile"); | 51 InspectorTest.log("SUCCESS: found 'collectProfiles' function in the prof
ile"); |
53 InspectorTest.completeTest(); | 52 InspectorTest.completeTest(); |
54 } | 53 } |
55 | 54 |
56 function findFunctionInProfile(node, functionName) | 55 function findFunctionInProfile(nodes, functionName) |
57 { | 56 { |
58 if (node.callFrame.functionName === functionName) | 57 return nodes.some(n => n.callFrame.functionName === functionName); |
59 return true; | |
60 var children = node.children; | |
61 for (var i = 0; i < children.length; ++i) | |
62 if (findFunctionInProfile(children[i], functionName)) | |
63 return true; | |
64 return false; | |
65 } | 58 } |
66 } | 59 } |
67 </script> | 60 </script> |
68 </head> | 61 </head> |
69 <body onload="runTest()"> | 62 <body onload="runTest()"> |
70 <p> | 63 <p> |
71 Tests that console.profile/profileEnd will record CPU profile when inspector fro
nt-end is connected.<br> | 64 Tests that console.profile/profileEnd will record CPU profile when inspector fro
nt-end is connected.<br> |
72 </p> | 65 </p> |
73 </body> | 66 </body> |
74 </html> | 67 </html> |
OLD | NEW |