| 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/timeline-test.js"></script> | 4 <script src="../../../http/tests/inspector/timeline-test.js"></script> |
| 5 <script> | 5 <script> |
| 6 function performActions() | 6 function performActions() |
| 7 { | 7 { |
| 8 var callback; | 8 var callback; |
| 9 var promise = new Promise((fulfill) => callback = fulfill); | 9 var promise = new Promise((fulfill) => callback = fulfill); |
| 10 var square = document.getElementById("square"); | 10 var square = document.getElementById("square"); |
| 11 step1(); | 11 step1(); |
| 12 | 12 |
| 13 function step1() | 13 function step1() |
| 14 { | 14 { |
| 15 square.style.backgroundColor = "red"; | 15 square.style.backgroundColor = "red"; |
| 16 testRunner.layoutAndPaintAsyncThen(step2); | 16 testRunner.layoutAndPaintAsyncThen(step2); |
| 17 } | 17 } |
| 18 | 18 |
| 19 function step2() | 19 function step2() |
| 20 { | 20 { |
| 21 square.style.backgroundColor = "black"; | 21 square.style.backgroundColor = "black"; |
| 22 testRunner.layoutAndPaintAsyncThen(callback); | 22 testRunner.layoutAndPaintAsyncThen(callback); |
| 23 } | 23 } |
| 24 return promise; | 24 return promise; |
| 25 } | 25 } |
| 26 | 26 |
| 27 function test() | 27 function test() |
| 28 { | 28 { |
| 29 var panel = WebInspector.panels.timeline; | 29 var panel = UI.panels.timeline; |
| 30 | 30 |
| 31 panel._captureLayersAndPicturesSetting.set(true); | 31 panel._captureLayersAndPicturesSetting.set(true); |
| 32 panel._onModeChanged(); | 32 panel._onModeChanged(); |
| 33 | 33 |
| 34 InspectorTest.invokeAsyncWithTimeline("performActions", onRecordingDone); | 34 InspectorTest.invokeAsyncWithTimeline("performActions", onRecordingDone); |
| 35 var paintEvents = []; | 35 var paintEvents = []; |
| 36 function onRecordingDone() | 36 function onRecordingDone() |
| 37 { | 37 { |
| 38 var events = InspectorTest.timelineModel()._mainThreadEvents; | 38 var events = InspectorTest.timelineModel()._mainThreadEvents; |
| 39 for (var event of events) { | 39 for (var event of events) { |
| 40 if (event.name === WebInspector.TimelineModel.RecordType.Paint) { | 40 if (event.name === TimelineModel.TimelineModel.RecordType.Paint) { |
| 41 paintEvents.push(event); | 41 paintEvents.push(event); |
| 42 if (!WebInspector.TimelineData.forEvent(event).picture) | 42 if (!TimelineModel.TimelineData.forEvent(event).picture) |
| 43 InspectorTest.addResult("Event without picture at " + paintE
vents.length); | 43 InspectorTest.addResult("Event without picture at " + paintE
vents.length); |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 if (paintEvents.length < 2) | 47 if (paintEvents.length < 2) |
| 48 throw new Error("FAIL: Expect at least two paint events"); | 48 throw new Error("FAIL: Expect at least two paint events"); |
| 49 | 49 |
| 50 InspectorTest.addSniffer(panel, "_appendDetailsTabsForTraceEventAndShowD
etails", onRecordDetailsReady, false); | 50 InspectorTest.addSniffer(panel, "_appendDetailsTabsForTraceEventAndShowD
etails", onRecordDetailsReady, false); |
| 51 panel.select(WebInspector.TimelineSelection.fromTraceEvent(paintEvents[0
]), WebInspector.TimelinePanel.DetailsTab.PaintProfiler); | 51 panel.select(Timeline.TimelineSelection.fromTraceEvent(paintEvents[0]),
Timeline.TimelinePanel.DetailsTab.PaintProfiler); |
| 52 } | 52 } |
| 53 | 53 |
| 54 function onRecordDetailsReady() | 54 function onRecordDetailsReady() |
| 55 { | 55 { |
| 56 var updateCount = 0; | 56 var updateCount = 0; |
| 57 var paintProfilerView = panel._lazyPaintProfilerView._paintProfilerView; | 57 var paintProfilerView = panel._lazyPaintProfilerView._paintProfilerView; |
| 58 InspectorTest.addSniffer(paintProfilerView, "_update", onPaintProfilerUp
date, true); | 58 InspectorTest.addSniffer(paintProfilerView, "_update", onPaintProfilerUp
date, true); |
| 59 | 59 |
| 60 function onPaintProfilerUpdate() | 60 function onPaintProfilerUpdate() |
| 61 { | 61 { |
| 62 // No snapshot, not a real update yet -- wait for another update! | 62 // No snapshot, not a real update yet -- wait for another update! |
| 63 if (!paintProfilerView._snapshot) | 63 if (!paintProfilerView._snapshot) |
| 64 return; | 64 return; |
| 65 var logSize = paintProfilerView._log && paintProfilerView._log.lengt
h ? ">0" : "0"; | 65 var logSize = paintProfilerView._log && paintProfilerView._log.lengt
h ? ">0" : "0"; |
| 66 InspectorTest.addResult("Paint " + updateCount + " log size: " + log
Size); | 66 InspectorTest.addResult("Paint " + updateCount + " log size: " + log
Size); |
| 67 if (updateCount++) | 67 if (updateCount++) |
| 68 InspectorTest.completeTest(); | 68 InspectorTest.completeTest(); |
| 69 else | 69 else |
| 70 panel.select(WebInspector.TimelineSelection.fromTraceEvent(paint
Events[1]), WebInspector.TimelinePanel.DetailsTab.PaintProfiler); | 70 panel.select(Timeline.TimelineSelection.fromTraceEvent(paintEven
ts[1]), Timeline.TimelinePanel.DetailsTab.PaintProfiler); |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 } | 74 } |
| 75 | 75 |
| 76 </script> | 76 </script> |
| 77 </head> | 77 </head> |
| 78 | 78 |
| 79 <body onload="runTest()"> | 79 <body onload="runTest()"> |
| 80 <p> | 80 <p> |
| 81 Tests that paint profiler is properly update when an event is selected in Flame
Chart | 81 Tests that paint profiler is properly update when an event is selected in Flame
Chart |
| 82 </p> | 82 </p> |
| 83 | 83 |
| 84 <div id="square" style="width: 40px; height: 40px"></div> | 84 <div id="square" style="width: 40px; height: 40px"></div> |
| 85 | 85 |
| 86 </body> | 86 </body> |
| 87 </html> | 87 </html> |
| OLD | NEW |