Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: third_party/WebKit/LayoutTests/inspector/tracing.html

Issue 2717393003: [DevTools] Turn starting tracing into promise. (Closed)
Patch Set: more work Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <style> 3 <style>
4 div#test { 4 div#test {
5 display: none; 5 display: none;
6 background-color: blue; 6 background-color: blue;
7 width: 100px; 7 width: 100px;
8 height: 100px; 8 height: 100px;
9 } 9 }
10 </style> 10 </style>
11 <script src="../http/tests/inspector/inspector-test.js"></script> 11 <script src="../http/tests/inspector/inspector-test.js"></script>
12 <script src="../http/tests/inspector/timeline-test.js"></script> 12 <script src="../http/tests/inspector/timeline-test.js"></script>
13 <script src="tracing-test.js"></script> 13 <script src="tracing-test.js"></script>
14 <script> 14 <script>
15 function initialize_TracingManagerClient() 15 function initialize_TracingManagerClient()
16 { 16 {
17 17
18 InspectorTest.TracingManagerClient = function(tracingManager, callback) 18 InspectorTest.TracingManagerClient = function(callback)
19 { 19 {
20 this._tracingManager = tracingManager;
21 this._completionCallback = callback; 20 this._completionCallback = callback;
22 this._tracingModel = InspectorTest.createTracingModel(); 21 this._tracingModel = InspectorTest.createTracingModel();
23 } 22 }
24 23
25 InspectorTest.TracingManagerClient.prototype = { 24 InspectorTest.TracingManagerClient.prototype = {
26 tracingStarted: function()
27 {
28 this._tracingModel.reset();
29 InspectorTest.evaluateInPage("doWork()", this._tracingManager.stop.bind( this._tracingManager));
30 },
31
32 traceEventsCollected: function(events) 25 traceEventsCollected: function(events)
33 { 26 {
34 this._tracingModel.addEvents(events); 27 this._tracingModel.addEvents(events);
35 }, 28 },
36 29
37 tracingComplete: function() 30 tracingComplete: function()
38 { 31 {
39 InspectorTest.addResult("Tracing complete"); 32 InspectorTest.addResult("Tracing complete");
40 this._completionCallback(this._tracingModel); 33 this._completionCallback(this._tracingModel);
41 }, 34 },
42 35
43 tracingBufferUsage: function(usage) { }, 36 tracingBufferUsage: function(usage) { },
44 eventsRetrievalProgress: function(progress) { } 37 eventsRetrievalProgress: function(progress) { }
45 } 38 }
46 } 39 }
47 40
48 function doWork() 41 function doWork()
49 { 42 {
50 var element = document.getElementById("test"); 43 var element = document.getElementById("test");
51 element.style.display = "block"; 44 element.style.display = "block";
52 var unused = element.clientWidth; 45 var unused = element.clientWidth;
53 } 46 }
54 47
55 function test() 48 function test()
56 { 49 {
57 var tracingClient = new InspectorTest.TracingManagerClient(InspectorTest.tra cingManager, runEventsSanityCheck); 50 var tracingClient = new InspectorTest.TracingManagerClient(runEventsSanityCh eck);
58 InspectorTest.tracingManager.start(tracingClient, "", "", onTracingStarted); 51 var tracingManager = InspectorTest.tracingManager;
59 52 tracingManager.start(tracingClient, "", "").then(() => {
alph 2017/02/28 03:11:24 await
60 function onTracingStarted(error) 53 InspectorTest.addResult("Tracing started");
61 { 54 tracingClient._tracingModel.reset();
62 InspectorTest.addResult("Tracing started (error: " + JSON.stringify(erro r) + ")"); 55 InspectorTest.evaluateInPage("doWork()", tracingManager.stop.bind(tracin gManager));
63 } 56 });
64 57
65 function runEventsSanityCheck(tracingModel) 58 function runEventsSanityCheck(tracingModel)
66 { 59 {
67 var events = []; 60 var events = [];
68 var phaseComplete = 0; 61 var phaseComplete = 0;
69 var knownEvents = {}; 62 var knownEvents = {};
70 var processes = 0; 63 var processes = 0;
71 var threads = 0; 64 var threads = 0;
72 65
73 tracingModel.sortedProcesses().forEach(function(process) { 66 tracingModel.sortedProcesses().forEach(function(process) {
(...skipping 27 matching lines...) Expand all
101 } 94 }
102 } 95 }
103 96
104 </script> 97 </script>
105 </head> 98 </head>
106 <body onload="runTest()"> 99 <body onload="runTest()">
107 <div id="test"> 100 <div id="test">
108 </div> 101 </div>
109 </body> 102 </body>
110 </html> 103 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698