| OLD | NEW |
| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 var categories = "-*,disabled-by-default-devtools.timeline*,devtools.timelin
e," + WebInspector.TracingModel.TopLevelEventCategory; | 86 var categories = "-*,disabled-by-default-devtools.timeline*,devtools.timelin
e," + WebInspector.TracingModel.TopLevelEventCategory; |
| 87 if (additionalCategories) | 87 if (additionalCategories) |
| 88 categories += "," + additionalCategories; | 88 categories += "," + additionalCategories; |
| 89 var timelinePanel = WebInspector.panels.timeline; | 89 var timelinePanel = WebInspector.panels.timeline; |
| 90 var timelineController = InspectorTest.timelineController(); | 90 var timelineController = InspectorTest.timelineController(); |
| 91 timelinePanel._timelineController = timelineController; | 91 timelinePanel._timelineController = timelineController; |
| 92 timelineController._startRecordingWithCategories(categories, enableJSSamplin
g, tracingStarted); | 92 timelineController._startRecordingWithCategories(categories, enableJSSamplin
g, tracingStarted); |
| 93 | 93 |
| 94 function tracingStarted() | 94 function tracingStarted() |
| 95 { | 95 { |
| 96 InspectorTest.invokePageFunctionAsync(functionName, onPageActionsDone); | 96 InspectorTest.callFunctionInPageAsync(functionName).then(onPageActionsDo
ne); |
| 97 } | 97 } |
| 98 | 98 |
| 99 function onPageActionsDone() | 99 function onPageActionsDone() |
| 100 { | 100 { |
| 101 InspectorTest.addSniffer(WebInspector.panels.timeline, "loadingComplete"
, callback) | 101 InspectorTest.addSniffer(WebInspector.panels.timeline, "loadingComplete"
, callback) |
| 102 timelineController.stopRecording(); | 102 timelineController.stopRecording(); |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 | 105 |
| 106 InspectorTest.timelineModel = function() | 106 InspectorTest.timelineModel = function() |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 { | 166 { |
| 167 InspectorTest.stopTimeline(doneCallback); | 167 InspectorTest.stopTimeline(doneCallback); |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 | 170 |
| 171 InspectorTest.invokeAsyncWithTimeline = function(functionName, doneCallback) | 171 InspectorTest.invokeAsyncWithTimeline = function(functionName, doneCallback) |
| 172 { | 172 { |
| 173 InspectorTest.startTimeline(step1); | 173 InspectorTest.startTimeline(step1); |
| 174 function step1() | 174 function step1() |
| 175 { | 175 { |
| 176 InspectorTest.invokePageFunctionAsync(functionName, step2); | 176 InspectorTest.callFunctionInPageAsync(functionName).then(step2); |
| 177 } | 177 } |
| 178 | 178 |
| 179 function step2() | 179 function step2() |
| 180 { | 180 { |
| 181 InspectorTest.stopTimeline(InspectorTest.safeWrap(doneCallback)); | 181 InspectorTest.stopTimeline(InspectorTest.safeWrap(doneCallback)); |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 | 184 |
| 185 InspectorTest.loadTimelineRecords = function(records) | 185 InspectorTest.loadTimelineRecords = function(records) |
| 186 { | 186 { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 { | 454 { |
| 455 return new InspectorTest.FakeFileReader(timelineData, delegate, timeline
._saveToFile.bind(timeline)); | 455 return new InspectorTest.FakeFileReader(timelineData, delegate, timeline
._saveToFile.bind(timeline)); |
| 456 } | 456 } |
| 457 | 457 |
| 458 InspectorTest.override(WebInspector.TimelineLoader, "_createFileReader", cre
ateFileReader); | 458 InspectorTest.override(WebInspector.TimelineLoader, "_createFileReader", cre
ateFileReader); |
| 459 timeline._loadFromFile({}); | 459 timeline._loadFromFile({}); |
| 460 } | 460 } |
| 461 | 461 |
| 462 }; | 462 }; |
| 463 | 463 |
| 464 function generateFrames(count, callback) | 464 function generateFrames(count) |
| 465 { | 465 { |
| 466 makeFrame(); | 466 var promise = Promise.resolve(); |
| 467 function makeFrame() | 467 for (let i = count; i > 0; --i) |
| 468 promise = promise.then(changeBackgroundAndWaitForFrame.bind(null, i)); |
| 469 return promise; |
| 470 |
| 471 function changeBackgroundAndWaitForFrame(i) |
| 468 { | 472 { |
| 469 document.body.style.backgroundColor = count & 1 ? "rgb(200, 200, 200)" :
"rgb(240, 240, 240)"; | 473 document.body.style.backgroundColor = i & 1 ? "rgb(200, 200, 200)" : "rg
b(240, 240, 240)"; |
| 470 if (!--count) { | 474 return waitForFrame(); |
| 471 callback(); | |
| 472 return; | |
| 473 } | |
| 474 if (window.testRunner) | |
| 475 testRunner.capturePixelsAsyncThen(requestAnimationFrame.bind(window,
makeFrame)); | |
| 476 else | |
| 477 window.requestAnimationFrame(makeFrame); | |
| 478 } | 475 } |
| 479 } | 476 } |
| 477 |
| 478 function waitForFrame() |
| 479 { |
| 480 var callback; |
| 481 var promise = new Promise((fulfill) => callback = fulfill); |
| 482 if (window.testRunner) |
| 483 testRunner.capturePixelsAsyncThen(() => window.requestAnimationFrame(cal
lback)); |
| 484 else |
| 485 window.requestAnimationFrame(callback); |
| 486 return promise; |
| 487 } |
| OLD | NEW |