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

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

Issue 2563383003: DevTools: add extension API to contribute trace events to timeline (Closed)
Patch Set: Review comments + better test Created 4 years 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 function wrapCallFunctionForTimeline(f) 1 function wrapCallFunctionForTimeline(f)
2 { 2 {
3 var script = document.createElement("script"); 3 var script = document.createElement("script");
4 script.textContent = "(" + f.toString() + ")()\n//# sourceURL=wrapCallFuncti onForTimeline.js"; 4 script.textContent = "(" + f.toString() + ")()\n//# sourceURL=wrapCallFuncti onForTimeline.js";
5 document.body.appendChild(script); 5 document.body.appendChild(script);
6 } 6 }
7 7
8 var initialize_Timeline = function() { 8 var initialize_Timeline = function() {
9 9
10 InspectorTest.preloadPanel("timeline"); 10 InspectorTest.preloadPanel("timeline");
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 } 403 }
404 InspectorTest.addObject(formatFields(frame)); 404 InspectorTest.addObject(formatFields(frame));
405 } 405 }
406 406
407 InspectorTest.dumpInvalidations = function(recordType, index, comment) 407 InspectorTest.dumpInvalidations = function(recordType, index, comment)
408 { 408 {
409 var record = InspectorTest.findTimelineRecord(recordType, index || 0); 409 var record = InspectorTest.findTimelineRecord(recordType, index || 0);
410 InspectorTest.addArray(TimelineModel.InvalidationTracker.invalidationEventsF or(record._event), InspectorTest.InvalidationFormatters, "", comment); 410 InspectorTest.addArray(TimelineModel.InvalidationTracker.invalidationEventsF or(record._event), InspectorTest.InvalidationFormatters, "", comment);
411 } 411 }
412 412
413 InspectorTest.dumpFlameChartProvider = function(provider, includeGroups)
414 {
415 var includeGroupsSet = includeGroups && new Set(includeGroups);
416 var timelineData = provider.timelineData();
417 var stackDepth = provider.maxStackDepth();
418 var entriesByLevel = new Multimap();
419
420 for (let i = 0; i < timelineData.entryLevels.length; ++i)
421 entriesByLevel.set(timelineData.entryLevels[i], i);
422
423 for (let groupIndex = 0; groupIndex < timelineData.groups.length; ++groupInd ex) {
424 const group = timelineData.groups[groupIndex];
425 if (includeGroupsSet && !includeGroupsSet.has(group.name))
426 continue;
427 var maxLevel = groupIndex + 1 < timelineData.groups.length ? timelineDat a.groups[groupIndex + 1].firstLevel : stackDepth;
428 InspectorTest.addResult(`Group: ${group.name}`);
429 for (let level = group.startLevel; level < maxLevel; ++level) {
430 InspectorTest.addResult(`Level ${level - group.startLevel}`);
431 var entries = entriesByLevel.get(level);
432 for (const index of entries) {
433 const title = provider.entryTitle(index);
434 const color = provider.entryColor(index);
435 InspectorTest.addResult(`${title} (${color})`);
436 }
437 }
438 }
439 }
440
441 InspectorTest.dumpTimelineFlameChart = function(includeGroups) {
442 const provider = UI.panels.timeline._flameChart._dataProvider;
443 InspectorTest.addResult('Timeline Flame Chart');
444 InspectorTest.dumpFlameChartProvider(provider, includeGroups);
445 }
446
413 InspectorTest.FakeFileReader.prototype = { 447 InspectorTest.FakeFileReader.prototype = {
414 start: function(output) 448 start: function(output)
415 { 449 {
416 this._delegate.onTransferStarted(this); 450 this._delegate.onTransferStarted(this);
417 451
418 var length = this._input.length; 452 var length = this._input.length;
419 var half = (length + 1) >> 1; 453 var half = (length + 1) >> 1;
420 454
421 var chunk = this._input.substring(0, half); 455 var chunk = this._input.substring(0, half);
422 this._loadedSize += chunk.length; 456 this._loadedSize += chunk.length;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 function waitForFrame() 518 function waitForFrame()
485 { 519 {
486 var callback; 520 var callback;
487 var promise = new Promise((fulfill) => callback = fulfill); 521 var promise = new Promise((fulfill) => callback = fulfill);
488 if (window.testRunner) 522 if (window.testRunner)
489 testRunner.capturePixelsAsyncThen(() => window.requestAnimationFrame(cal lback)); 523 testRunner.capturePixelsAsyncThen(() => window.requestAnimationFrame(cal lback));
490 else 524 else
491 window.requestAnimationFrame(callback); 525 window.requestAnimationFrame(callback);
492 return promise; 526 return promise;
493 } 527 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698