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

Side by Side Diff: LayoutTests/http/tests/inspector/timeline-test.js

Issue 461323003: DevTools: Make Timeline tests use only model records (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/inspector/timeline/timeline-bound-function.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 var initialize_Timeline = function() { 1 var initialize_Timeline = function() {
2 2
3 // Scrub values when printing out these properties in the record or data field. 3 // Scrub values when printing out these properties in the record or data field.
4 InspectorTest.timelinePropertyFormatters = { 4 InspectorTest.timelinePropertyFormatters = {
5 children: "formatAsTypeName", 5 children: "formatAsTypeName",
6 endTime: "formatAsTypeName", 6 endTime: "formatAsTypeName",
7 requestId: "formatAsTypeName", 7 requestId: "formatAsTypeName",
8 startTime: "formatAsTypeName", 8 startTime: "formatAsTypeName",
9 stackTrace: "formatAsTypeName", 9 stackTrace: "formatAsTypeName",
10 url: "formatAsURL", 10 url: "formatAsURL",
(...skipping 22 matching lines...) Expand all
33 return WebInspector.panels.timeline._currentViews[0]._presentationModel; 33 return WebInspector.panels.timeline._currentViews[0]._presentationModel;
34 } 34 }
35 35
36 InspectorTest.timelineModel = function() 36 InspectorTest.timelineModel = function()
37 { 37 {
38 return WebInspector.panels.timeline._model; 38 return WebInspector.panels.timeline._model;
39 } 39 }
40 40
41 InspectorTest.startTimeline = function(callback) 41 InspectorTest.startTimeline = function(callback)
42 { 42 {
43 InspectorTest._timelineRecords = [];
44 var panel = WebInspector.inspectorView.panel("timeline"); 43 var panel = WebInspector.inspectorView.panel("timeline");
45 panel.toggleTimelineButton.toggled = true; 44 panel.toggleTimelineButton.toggled = true;
46 panel._model._collectionEnabled = true; 45 panel._model._collectionEnabled = true;
47 panel._userInitiatedRecording = true; 46 panel._userInitiatedRecording = true;
48 panel._model._currentTarget = WebInspector.targetManager.mainTarget(); 47 panel._model._currentTarget = WebInspector.targetManager.mainTarget();
49 TimelineAgent.start(5, true, undefined, true, false, callback); 48 TimelineAgent.start(5, true, undefined, true, false, callback);
50 function addRecord(record)
51 {
52 InspectorTest._timelineRecords.push(record);
53 for (var i = 0; record.children && i < record.children.length; ++i)
54 addRecord(record.children[i]);
55 }
56 InspectorTest._addTimelineEvent = function(event)
57 {
58 addRecord(event.data);
59 }
60 WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.E ventTypes.TimelineEventRecorded, InspectorTest._addTimelineEvent);
61 }; 49 };
62 50
63 InspectorTest.stopTimeline = function(callback) 51 InspectorTest.stopTimeline = function(callback)
64 { 52 {
65 function didStop(error) 53 function didStop(error)
66 { 54 {
67 if (error) 55 if (error)
68 testRunner.logToStderr("error: " + error); 56 testRunner.logToStderr("error: " + error);
69 WebInspector.timelineManager.removeEventListener(WebInspector.TimelineMa nager.EventTypes.TimelineEventRecorded, InspectorTest._addTimelineEvent);
70 var panel = WebInspector.inspectorView.panel("timeline"); 57 var panel = WebInspector.inspectorView.panel("timeline");
71 panel.toggleTimelineButton.toggled = false; 58 panel.toggleTimelineButton.toggled = false;
72 panel._userInitiatedRecording = false; 59 panel._userInitiatedRecording = false;
73 callback(InspectorTest._timelineRecords); 60 callback();
74 } 61 }
75 TimelineAgent.stop(didStop); 62 TimelineAgent.stop(didStop);
76 }; 63 };
77 64
78 InspectorTest.evaluateWithTimeline = function(actions, doneCallback) 65 InspectorTest.evaluateWithTimeline = function(actions, doneCallback)
79 { 66 {
80 InspectorTest.startTimeline(step1); 67 InspectorTest.startTimeline(step1);
81 function step1() 68 function step1()
82 { 69 {
83 InspectorTest.evaluateInPage(actions, step2); 70 InspectorTest.evaluateInPage(actions, step2);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 InspectorTest.printTimelineRecords(typeName); 104 InspectorTest.printTimelineRecords(typeName);
118 if (includeTimeStamps) { 105 if (includeTimeStamps) {
119 InspectorTest.addResult("Timestamp records: "); 106 InspectorTest.addResult("Timestamp records: ");
120 InspectorTest.printTimestampRecords(typeName); 107 InspectorTest.printTimestampRecords(typeName);
121 } 108 }
122 InspectorTest.completeTest(); 109 InspectorTest.completeTest();
123 } 110 }
124 InspectorTest.evaluateWithTimeline(actions, callback); 111 InspectorTest.evaluateWithTimeline(actions, callback);
125 }; 112 };
126 113
127 InspectorTest.filterTimelineRecords = function(typeName, firstOnly)
128 {
129 var filteredRecords = [];
130 filterRecords(typeName, InspectorTest._timelineRecords);
131 return filteredRecords;
132
133 function filterRecords(typeName, records)
134 {
135 if (!records)
136 return false;
137 for (var i = 0; i < records.length; ++i) {
138 var recordTypeName = (typeof records[i].type === "string") ? records [i].type : records[i].type();
139 if (typeName && recordTypeName === WebInspector.TimelineModel.Record Type[typeName]) {
140 filteredRecords.push(records[i]);
141 if (firstOnly)
142 return true;
143 }
144 if (filterRecords(typeName, records[i].children))
145 return true;
146 }
147 return false;
148 }
149 }
150
151 InspectorTest.printTimelineRecords = function(typeName, formatter) 114 InspectorTest.printTimelineRecords = function(typeName, formatter)
152 { 115 {
153 InspectorTest.innerPrintTimelineRecords(InspectorTest._timelineRecords, type Name, formatter); 116 InspectorTest.timelineModel().forAllRecords(InspectorTest._printTimlineRecor d.bind(InspectorTest, typeName, formatter));
154 }; 117 };
155 118
156 InspectorTest.printTimelinePresentationRecords = function(typeName, formatter) 119 InspectorTest.printTimelinePresentationRecords = function(typeName, formatter)
157 { 120 {
158 InspectorTest.innerPrintTimelinePresentationRecords(WebInspector.panels.time line._model.records(), typeName, formatter); 121 InspectorTest.innerPrintTimelinePresentationRecords(WebInspector.panels.time line._model.records(), typeName, formatter);
159 }; 122 };
160 123
161 InspectorTest.printTimestampRecords = function(typeName, formatter) 124 InspectorTest.printTimestampRecords = function(typeName, formatter)
162 { 125 {
163 InspectorTest.innerPrintTimelineRecords(InspectorTest.timelineModel().eventD ividerRecords(), typeName, formatter); 126 InspectorTest.innerPrintTimelineRecords(InspectorTest.timelineModel().eventD ividerRecords(), typeName, formatter);
164 }; 127 };
165 128
166 InspectorTest.innerPrintTimelineRecords = function(records, typeName, formatter) 129 InspectorTest.innerPrintTimelineRecords = function(records, typeName, formatter)
167 { 130 {
168 for (var i = 0; i < records.length; ++i) { 131 for (var i = 0; i < records.length; ++i)
169 var recordTypeName = (typeof records[i].type === "string") ? records[i]. type : records[i].type(); 132 InspectorTest._printTimlineRecord(typeName, formatter, records[i]);
170 if (typeName && recordTypeName === WebInspector.TimelineModel.RecordType [typeName])
171 InspectorTest.printTimelineRecordProperties(records[i]);
172 if (formatter)
173 formatter(records[i]);
174 }
175 }; 133 };
176 134
135 InspectorTest._printTimlineRecord = function(typeName, formatter, record)
136 {
137 if (typeName && record.type() === WebInspector.TimelineModel.RecordType[type Name])
138 InspectorTest.printTimelineRecordProperties(record);
139 if (formatter)
140 formatter(record);
141 };
142
143
177 InspectorTest.innerPrintTimelinePresentationRecords = function(records, typeName , formatter) 144 InspectorTest.innerPrintTimelinePresentationRecords = function(records, typeName , formatter)
178 { 145 {
179 for (var i = 0; i < records.length; ++i) { 146 for (var i = 0; i < records.length; ++i) {
180 if (typeName && records[i].type() === WebInspector.TimelineModel.RecordT ype[typeName]) 147 if (typeName && records[i].type() === WebInspector.TimelineModel.RecordT ype[typeName])
181 InspectorTest.printTimelineRecordProperties(records[i]); 148 InspectorTest.printTimelineRecordProperties(records[i]);
182 if (formatter) 149 if (formatter)
183 formatter(records[i]); 150 formatter(records[i]);
184 InspectorTest.innerPrintTimelinePresentationRecords(records[i].children( ), typeName, formatter); 151 InspectorTest.innerPrintTimelinePresentationRecords(records[i].children( ), typeName, formatter);
185 } 152 }
186 }; 153 };
187 154
188 // Dump just the record name, indenting output on separate lines for subrecords 155 // Dump just the record name, indenting output on separate lines for subrecords
189 InspectorTest.dumpTimelineRecord = function(record, detailsCallback, level, filt erTypes) 156 InspectorTest.dumpTimelineRecord = function(record, detailsCallback, level, filt erTypes)
190 { 157 {
191 if (typeof level !== "number") 158 if (typeof level !== "number")
192 level = 0; 159 level = 0;
193 var prefix = ""; 160 var prefix = "";
194 var suffix = ""; 161 var suffix = "";
195 for (var i = 0; i < level ; ++i) 162 for (var i = 0; i < level ; ++i)
196 prefix = "----" + prefix; 163 prefix = "----" + prefix;
197 if (level > 0) 164 if (level > 0)
198 prefix = prefix + "> "; 165 prefix = prefix + "> ";
199 if (record.type === WebInspector.TimelineModel.RecordType.TimeStamp 166 if (record.type() === WebInspector.TimelineModel.RecordType.TimeStamp
200 || record.type === WebInspector.TimelineModel.RecordType.ConsoleTime) { 167 || record.type() === WebInspector.TimelineModel.RecordType.ConsoleTime) {
201 suffix = " : " + record.data.message; 168 suffix = " : " + record.data().message;
202 } 169 }
203 if (detailsCallback) 170 if (detailsCallback)
204 suffix += " " + detailsCallback(record); 171 suffix += " " + detailsCallback(record);
205 InspectorTest.addResult(prefix + InspectorTest._timelineAgentTypeToString(re cord.type) + suffix); 172 InspectorTest.addResult(prefix + InspectorTest._timelineAgentTypeToString(re cord.type()) + suffix);
206 173
207 var numChildren = record.children ? record.children.length : 0; 174 var children = record.children();
175 var numChildren = children.length;
208 for (var i = 0; i < numChildren; ++i) { 176 for (var i = 0; i < numChildren; ++i) {
209 if (filterTypes && filterTypes.indexOf(record.children[i].type) == -1) 177 if (filterTypes && filterTypes.indexOf(children[i].type()) == -1)
210 continue; 178 continue;
211 InspectorTest.dumpTimelineRecord(record.children[i], detailsCallback, le vel + 1, filterTypes); 179 InspectorTest.dumpTimelineRecord(children[i], detailsCallback, level + 1 , filterTypes);
212 } 180 }
213 } 181 }
214 182
215 InspectorTest.dumpTimelineModelRecord = function(record, level) 183 InspectorTest.dumpTimelineModelRecord = function(record, level)
216 { 184 {
217 if (typeof level !== "number") 185 if (typeof level !== "number")
218 level = 0; 186 level = 0;
219 var prefix = ""; 187 var prefix = "";
220 for (var i = 0; i < level ; ++i) 188 for (var i = 0; i < level ; ++i)
221 prefix = "----" + prefix; 189 prefix = "----" + prefix;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 245
278 InspectorTest._timelineAgentTypeToString = function(numericType) 246 InspectorTest._timelineAgentTypeToString = function(numericType)
279 { 247 {
280 for (var prop in WebInspector.TimelineModel.RecordType) { 248 for (var prop in WebInspector.TimelineModel.RecordType) {
281 if (WebInspector.TimelineModel.RecordType[prop] === numericType) 249 if (WebInspector.TimelineModel.RecordType[prop] === numericType)
282 return prop; 250 return prop;
283 } 251 }
284 return undefined; 252 return undefined;
285 }; 253 };
286 254
287 InspectorTest.findPresentationRecord = function(type) 255 InspectorTest.findFirstTimelineRecord = function(type)
288 { 256 {
289 var result; 257 var result;
290 function findByType(record) 258 function findByType(record)
291 { 259 {
292 if (record.type() !== type) 260 if (record.type() !== type)
293 return false; 261 return false;
294 result = record; 262 result = record;
295 return true; 263 return true;
296 } 264 }
297 WebInspector.inspectorView.panel("timeline")._model.forAllRecords(findByType ); 265 InspectorTest.timelineModel().forAllRecords(findByType);
298 return result; 266 return result;
299 } 267 }
300 268
301 InspectorTest.FakeFileReader = function(input, delegate, callback) 269 InspectorTest.FakeFileReader = function(input, delegate, callback)
302 { 270 {
303 this._delegate = delegate; 271 this._delegate = delegate;
304 this._callback = callback; 272 this._callback = callback;
305 this._input = input; 273 this._input = input;
306 this._loadedSize = 0; 274 this._loadedSize = 0;
307 this._fileSize = input.length; 275 this._fileSize = input.length;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 return this._fileSize; 332 return this._fileSize;
365 }, 333 },
366 334
367 fileName: function() 335 fileName: function()
368 { 336 {
369 return "fakeFile"; 337 return "fakeFile";
370 } 338 }
371 }; 339 };
372 340
373 }; 341 };
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/inspector/timeline/timeline-bound-function.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698