| <html> |
| <head> |
| <style> |
| div#test { |
| display: none; |
| background-color: blue; |
| width: 100px; |
| height: 100px; |
| } |
| </style> |
| <script src="../http/tests/inspector/inspector-test.js"></script> |
| <script src="../http/tests/inspector/timeline-test.js"></script> |
| <script src="tracing-test.js"></script> |
| <script> |
| function initialize_TracingManagerClient() |
| { |
| |
| InspectorTest.TracingManagerClient = function(tracingManager, callback) |
| { |
| this._tracingManager = tracingManager; |
| this._completionCallback = callback; |
| this._tracingModel = InspectorTest.createTracingModel(); |
| } |
| |
| InspectorTest.TracingManagerClient.prototype = { |
| tracingStarted: function() |
| { |
| this._tracingModel.reset(); |
| InspectorTest.evaluateInPage("doWork()", this._tracingManager.stop.bind(this._tracingManager)); |
| }, |
| |
| traceEventsCollected: function(events) |
| { |
| this._tracingModel.addEvents(events); |
| }, |
| |
| tracingComplete: function() |
| { |
| InspectorTest.addResult("Tracing complete"); |
| this._completionCallback(this._tracingModel); |
| }, |
| |
| tracingBufferUsage: function(usage) { }, |
| eventsRetrievalProgress: function(progress) { } |
| } |
| } |
| |
| function doWork() |
| { |
| var element = document.getElementById("test"); |
| element.style.display = "block"; |
| var unused = element.clientWidth; |
| } |
| |
| function test() |
| { |
| var tracingClient = new InspectorTest.TracingManagerClient(InspectorTest.tracingManager, runEventsSanityCheck); |
| InspectorTest.tracingManager.start(tracingClient, "", "", onTracingStarted); |
| |
| function onTracingStarted(error) |
| { |
| InspectorTest.addResult("Tracing started (error: " + JSON.stringify(error) + ")"); |
| } |
| |
| function runEventsSanityCheck(tracingModel) |
| { |
| var events = []; |
| var phaseComplete = 0; |
| var knownEvents = {}; |
| var processes = 0; |
| var threads = 0; |
| |
| tracingModel.sortedProcesses().forEach(function(process) { |
| processes++; |
| process.sortedThreads().forEach(function(thread) { |
| threads++; |
| events = events.concat(thread.events()); |
| }); |
| }); |
| |
| knownEvents["MessageLoop::PostTask"] = 0; |
| knownEvents["v8.callFunction"] = 0; |
| knownEvents["UpdateLayoutTree"] = 0; |
| knownEvents["FrameView::layout"] = 0; |
| |
| for (var i = 0; i < events.length; ++i) { |
| var event = events[i]; |
| if (event.phase === WebInspector.TracingModel.Phase.Complete) |
| ++phaseComplete; |
| if (event.name in knownEvents) |
| ++knownEvents[event.name]; |
| } |
| InspectorTest.assertGreaterOrEqual(events.length, 100, "Too few trace events recorded"); |
| InspectorTest.assertGreaterOrEqual(knownEvents["UpdateLayoutTree"], 1, "Too few UpdateLayoutTree"); |
| InspectorTest.assertGreaterOrEqual(knownEvents["FrameView::layout"], 1, "Too few FrameView::layout"); |
| InspectorTest.assertGreaterOrEqual(phaseComplete, 50, "Too few begin events"); |
| InspectorTest.assertGreaterOrEqual(processes, 2, "Too few processes"); |
| InspectorTest.assertGreaterOrEqual(threads, 4, "Too few threads"); |
| InspectorTest.addResult("Event sanity test done"); |
| InspectorTest.completeTest(); |
| } |
| } |
| |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <div id="test"> |
| </div> |
| </body> |
| </html> |