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

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

Issue 2208963002: [DevTools] Removed InspectorTest.invokeFunctionInPageAsync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-promise-from-other-tests
Patch Set: fixed tests :( Created 4 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
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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 { 468 promise = promise
469 document.body.style.backgroundColor = count & 1 ? "rgb(200, 200, 200)" : "rgb(240, 240, 240)"; 469 .then(() => document.body.style.backgroundColor = i & 1 ? "rgb(200, 200, 200)" : "rgb(240, 240, 240)")
470 if (!--count) { 470 .then(() => waitForFrame());
caseq 2016/08/10 22:44:55 merge into above?
kozy 2016/08/11 01:34:16 Done.
471 callback();
472 return;
473 }
474 if (window.testRunner)
475 testRunner.capturePixelsAsyncThen(requestAnimationFrame.bind(window, makeFrame));
476 else
477 window.requestAnimationFrame(makeFrame);
478 } 471 }
472 return promise;
479 } 473 }
474
475 function waitForFrame()
476 {
477 var callback;
478 var promise = new Promise((fulfill) => callback = fulfill);
479 if (window.testRunner)
caseq 2016/08/10 22:44:55 inline into the Promise() constructor?
kozy 2016/08/11 01:34:16 Acknowledged.
480 testRunner.capturePixelsAsyncThen(() => window.requestAnimationFrame(cal lback));
481 else
482 window.requestAnimationFrame(callback);
483 return promise;
484 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698