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

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

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 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 InspectorTest.invokeWithTracing = function(functionName, callback, additionalCat egories, enableJSSampling) 85 InspectorTest.invokeWithTracing = function(functionName, callback, additionalCat egories, enableJSSampling)
86 { 86 {
87 var categories = "-*,disabled-by-default-devtools.timeline*,devtools.timelin e," + SDK.TracingModel.TopLevelEventCategory; 87 var categories = "-*,disabled-by-default-devtools.timeline*,devtools.timelin e," + SDK.TracingModel.TopLevelEventCategory;
88 if (additionalCategories) 88 if (additionalCategories)
89 categories += "," + additionalCategories; 89 categories += "," + additionalCategories;
90 var timelinePanel = UI.panels.timeline; 90 var timelinePanel = UI.panels.timeline;
91 var timelineController = InspectorTest.timelineController(); 91 var timelineController = InspectorTest.timelineController();
92 timelinePanel._timelineController = timelineController; 92 timelinePanel._timelineController = timelineController;
93 timelineController._startRecordingWithCategories(categories, enableJSSamplin g, tracingStarted); 93 timelineController._startRecordingWithCategories(categories, enableJSSamplin g).then(tracingStarted);
alph 2017/02/28 03:11:24 await
dgozman 2017/02/28 08:59:01 No, thanks :-)
94 94
95 function tracingStarted() 95 function tracingStarted()
96 { 96 {
97 timelinePanel._recordingStarted();
97 InspectorTest.callFunctionInPageAsync(functionName).then(onPageActionsDo ne); 98 InspectorTest.callFunctionInPageAsync(functionName).then(onPageActionsDo ne);
98 } 99 }
99 100
100 function onPageActionsDone() 101 function onPageActionsDone()
101 { 102 {
102 InspectorTest.runWhenTimelineIsReady(callback); 103 InspectorTest.runWhenTimelineIsReady(callback);
103 timelineController.stopRecording(); 104 timelineController.stopRecording();
104 } 105 }
105 } 106 }
106 107
(...skipping 30 matching lines...) Expand all
137 } 138 }
138 139
139 InspectorTest.runWhenTimelineIsReady = function(callback) 140 InspectorTest.runWhenTimelineIsReady = function(callback)
140 { 141 {
141 InspectorTest.addSniffer(UI.panels.timeline, "loadingComplete", () => callba ck()); 142 InspectorTest.addSniffer(UI.panels.timeline, "loadingComplete", () => callba ck());
142 } 143 }
143 144
144 InspectorTest.startTimeline = function(callback) 145 InspectorTest.startTimeline = function(callback)
145 { 146 {
146 var panel = UI.panels.timeline; 147 var panel = UI.panels.timeline;
147 InspectorTest.addSniffer(panel, "recordingStarted", callback); 148 InspectorTest.addSniffer(panel, "_recordingStarted", callback);
148 panel._toggleRecording(); 149 panel._toggleRecording();
149 }; 150 };
150 151
151 InspectorTest.stopTimeline = function(callback) 152 InspectorTest.stopTimeline = function(callback)
152 { 153 {
153 InspectorTest.runWhenTimelineIsReady(callback); 154 InspectorTest.runWhenTimelineIsReady(callback);
154 UI.panels.timeline._toggleRecording(); 155 UI.panels.timeline._toggleRecording();
155 }; 156 };
156 157
157 InspectorTest.evaluateWithTimeline = function(actions, doneCallback) 158 InspectorTest.evaluateWithTimeline = function(actions, doneCallback)
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 function waitForFrame() 445 function waitForFrame()
445 { 446 {
446 var callback; 447 var callback;
447 var promise = new Promise((fulfill) => callback = fulfill); 448 var promise = new Promise((fulfill) => callback = fulfill);
448 if (window.testRunner) 449 if (window.testRunner)
449 testRunner.capturePixelsAsyncThen(() => window.requestAnimationFrame(cal lback)); 450 testRunner.capturePixelsAsyncThen(() => window.requestAnimationFrame(cal lback));
450 else 451 else
451 window.requestAnimationFrame(callback); 452 window.requestAnimationFrame(callback);
452 return promise; 453 return promise;
453 } 454 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698