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

Unified 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: a 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/inspector/timeline-test.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/timeline-test.js b/third_party/WebKit/LayoutTests/http/tests/inspector/timeline-test.js
index 5df5b56ada75dc47b7a091e02da4ca97e2eaa0c5..43075d747c8162edac27d9d44f9a6a16d8f9170a 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/timeline-test.js
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/timeline-test.js
@@ -93,7 +93,7 @@ InspectorTest.invokeWithTracing = function(functionName, callback, additionalCat
function tracingStarted()
{
- InspectorTest.invokePageFunctionAsync(functionName, onPageActionsDone);
+ InspectorTest.callFunctionInPageAsync(functionName).then(onPageActionsDone);
}
function onPageActionsDone()
@@ -173,7 +173,7 @@ InspectorTest.invokeAsyncWithTimeline = function(functionName, doneCallback)
InspectorTest.startTimeline(step1);
function step1()
{
- InspectorTest.invokePageFunctionAsync(functionName, step2);
+ InspectorTest.callFunctionInPageAsync(functionName).then(step2);
}
function step2()
@@ -461,19 +461,27 @@ InspectorTest.loadTimeline = function(timelineData)
};
-function generateFrames(count, callback)
+function generateFrames(count)
{
- makeFrame();
- function makeFrame()
+ var promise = Promise.resolve();
+ for (let i = count; i > 0; --i)
+ promise = promise.then(changeBackgroundAndWaitForFrame.bind(null, i));
+ return promise;
+
+ function changeBackgroundAndWaitForFrame(i)
{
- document.body.style.backgroundColor = count & 1 ? "rgb(200, 200, 200)" : "rgb(240, 240, 240)";
- if (!--count) {
- callback();
- return;
- }
- if (window.testRunner)
- testRunner.capturePixelsAsyncThen(requestAnimationFrame.bind(window, makeFrame));
- else
- window.requestAnimationFrame(makeFrame);
+ document.body.style.backgroundColor = i & 1 ? "rgb(200, 200, 200)" : "rgb(240, 240, 240)";
+ return waitForFrame();
}
}
+
+function waitForFrame()
+{
+ var callback;
+ var promise = new Promise((fulfill) => callback = fulfill);
+ if (window.testRunner)
+ testRunner.capturePixelsAsyncThen(() => window.requestAnimationFrame(callback));
+ else
+ window.requestAnimationFrame(callback);
+ return promise;
+}

Powered by Google App Engine
This is Rietveld 408576698