| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script src="../../../http/tests/inspector/debugger-test.js"></script> | 4 <script src="../../../http/tests/inspector/debugger-test.js"></script> |
| 5 <script src="../resources/timeline-data.js"></script> | 5 <script src="../resources/timeline-data.js"></script> |
| 6 <script> | 6 <script> |
| 7 function test() | 7 function test() |
| 8 { | 8 { |
| 9 var cpuProfile = { | 9 var cpuProfile = { |
| 10 startTime: 10, | 10 startTime: 10, |
| 11 endTime: 20, | 11 endTime: 20, |
| 12 head: { | 12 nodes: [ |
| 13 callFrame: { functionName: "(root)" }, | 13 { |
| 14 hitCount: 0, | 14 id: 0, |
| 15 children: [ | 15 callFrame: { functionName: "(root)" }, |
| 16 { | 16 hitCount: 0, |
| 17 callFrame: { functionName: "foo1" }, | 17 children: [1, 2] |
| 18 hitCount: 100, | 18 }, |
| 19 positionTicks: [{line:1, ticks:10}, {line:2, ticks:20}, {lin
e:3, ticks:30}, {line:4, ticks:40}], | 19 { |
| 20 children: [] | 20 id: 1, |
| 21 }, | 21 callFrame: { functionName: "foo1" }, |
| 22 { | 22 hitCount: 100, |
| 23 callFrame: { functionName: "foo2" }, | 23 positionTicks: [{line:1, ticks:10}, {line:2, ticks:20}, {line:3,
ticks:30}, {line:4, ticks:40}], |
| 24 hitCount: 200, | 24 children: [] |
| 25 positionTicks: [{line:100, ticks:1}, {line:102, ticks:190}], | 25 }, |
| 26 children: [] | 26 { |
| 27 }, | 27 id: 2, |
| 28 { | 28 callFrame: { functionName: "foo2" }, |
| 29 callFrame: { functionName: "null" }, | 29 hitCount: 200, |
| 30 hitCount: 0, | 30 positionTicks: [{line:100, ticks:1}, {line:102, ticks:190}], |
| 31 positionTicks: [], | 31 children: [3] |
| 32 children: [ | 32 }, |
| 33 { | 33 { |
| 34 callFrame: { functionName: "bar" }, | 34 id: 3, |
| 35 hitCount: 300, | 35 callFrame: { functionName: "null" }, |
| 36 positionTicks: [{line:55, ticks:22}], | 36 hitCount: 0, |
| 37 children: [] | 37 positionTicks: [], |
| 38 }, | 38 children: [4, 5] |
| 39 { | 39 }, |
| 40 callFrame: { functionName: "baz" }, | 40 { |
| 41 hitCount: 400, | 41 id: 4, |
| 42 // no positionTicks for the node. | 42 callFrame: { functionName: "bar" }, |
| 43 children: [] | 43 hitCount: 300, |
| 44 } | 44 positionTicks: [{line:55, ticks:22}], |
| 45 ] | 45 children: [] |
| 46 } | 46 }, |
| 47 ] | 47 { |
| 48 } | 48 id: 5, |
| 49 callFrame: { functionName: "baz" }, |
| 50 hitCount: 400, |
| 51 // no positionTicks for the node. |
| 52 children: [] |
| 53 } |
| 54 ] |
| 49 }; | 55 }; |
| 50 | 56 |
| 51 InspectorTest.addSniffer(WebInspector.CodeMirrorTextEditor.prototype, "setGu
tterDecoration", decorationAdded, true); | 57 InspectorTest.addSniffer(WebInspector.CodeMirrorTextEditor.prototype, "setGu
tterDecoration", decorationAdded, true); |
| 52 InspectorTest.showScriptSource("timeline-data.js", frameRevealed); | 58 InspectorTest.showScriptSource("timeline-data.js", frameRevealed); |
| 53 | 59 |
| 54 function decorationAdded(line, type, element) | 60 function decorationAdded(line, type, element) |
| 55 { | 61 { |
| 56 InspectorTest.addResult(`${line} ${type} ${element.textContent} ${elemen
t.style.backgroundColor}`); | 62 InspectorTest.addResult(`${line} ${type} ${element.textContent} ${elemen
t.style.backgroundColor}`); |
| 57 } | 63 } |
| 58 | 64 |
| 59 function setUrls(url, node) | |
| 60 { | |
| 61 node.callFrame.url = url; | |
| 62 node.children.forEach(setUrls.bind(null, url)); | |
| 63 } | |
| 64 | |
| 65 function frameRevealed(frame) | 65 function frameRevealed(frame) |
| 66 { | 66 { |
| 67 var url = frame.uiSourceCode().url(); | 67 var url = frame.uiSourceCode().url(); |
| 68 InspectorTest.addResult(InspectorTest.formatters.formatAsURL(url)); | 68 InspectorTest.addResult(InspectorTest.formatters.formatAsURL(url)); |
| 69 setUrls(url, cpuProfile.head); | 69 cpuProfile.nodes.forEach(n => n.callFrame.url = url); |
| 70 var lineProfile = new WebInspector.LineLevelProfile.instance(); | 70 var lineProfile = new WebInspector.LineLevelProfile.instance(); |
| 71 lineProfile.appendCPUProfile(new WebInspector.CPUProfileDataModel(cpuPro
file)); | 71 lineProfile.appendCPUProfile(new WebInspector.CPUProfileDataModel(cpuPro
file)); |
| 72 setTimeout(() => InspectorTest.completeTest(), 0); | 72 setTimeout(() => InspectorTest.completeTest(), 0); |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 </script> | 76 </script> |
| 77 </head> | 77 </head> |
| 78 <body onload="runTest()"> | 78 <body onload="runTest()"> |
| 79 Tests that a line-level CPU profile is shown in the text editor. | 79 Tests that a line-level CPU profile is shown in the text editor. |
| 80 </body> | 80 </body> |
| 81 </html> | 81 </html> |
| OLD | NEW |