[DevTools] Removed InspectorTest.invokeFunctionInPageAsync

BUG=632875
R=caseq@chromium.org

Review-Url: https://codereview.chromium.org/2208963002
Cr-Commit-Position: refs/heads/master@{#411813}
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/resources/protocol-test.html b/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/resources/protocol-test.html
index fc3cbd3a..637c75e 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/resources/protocol-test.html
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/resources/protocol-test.html
@@ -285,7 +285,7 @@
 
 InspectorTest.evaluateInPageAsync = function(expression)
 {
-    return InspectorTest.sendCommandPromise("Runtime.evaluate", { "expression": expression, awaitPromise: true }).then((message) => message.result.result.value);
+    return InspectorTest.sendCommandPromise("Runtime.evaluate", { "expression": expression, awaitPromise: true, returnByValue: true }).then((message) => message.result.result.value);
 }
 
 InspectorTest.completeTestIfError = function(messageObject)
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/tracing-test.js b/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/tracing-test.js
index 230a012..7524497 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/tracing-test.js
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/tracing-test.js
@@ -126,43 +126,8 @@
 
     function onStart()
     {
-        InspectorTest.invokePageFunctionAsync(functionName, done);
+        InspectorTest.evaluateInPageAsync(functionName + "()").then((data) => InspectorTest.stopTracing((devtoolsEvents) => callback(devtoolsEvents, data)));
     }
-
-    function done()
-    {
-        InspectorTest.stopTracing(callback);
-    }
-}
-
-InspectorTest._lastEvalId = 0;
-InspectorTest._pendingEvalRequests = {};
-
-InspectorTest.invokePageFunctionAsync = function(functionName, callback)
-{
-    var id = ++InspectorTest._lastEvalId;
-    InspectorTest._pendingEvalRequests[id] = callback;
-    var asyncEvalWrapper = function(callId, functionName)
-    {
-        function evalCallback(result)
-        {
-            evaluateInFrontend("InspectorTest.didInvokePageFunctionAsync(" + callId + ", " + JSON.stringify(result) + ");");
-        }
-        eval(functionName + "(" + evalCallback + ")");
-    }
-    InspectorTest.evaluateInPage("(" + asyncEvalWrapper.toString() + ")(" + id + ", unescape('" + escape(functionName) + "'))", function() { });
-}
-
-InspectorTest.didInvokePageFunctionAsync = function(callId, value)
-{
-    var callback = InspectorTest._pendingEvalRequests[callId];
-
-    if (!callback) {
-        InspectorTest.addResult("Missing callback for async eval " + callId + ", perhaps callback invoked twice?");
-        return;
-    }
-    delete InspectorTest._pendingEvalRequests[callId];
-    callback(value);
 }
 
 }
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/console-fetch-logging-expected.txt b/third_party/WebKit/LayoutTests/http/tests/inspector/console-fetch-logging-expected.txt
index a45e940..950b974 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/console-fetch-logging-expected.txt
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/console-fetch-logging-expected.txt
@@ -11,17 +11,17 @@
 Tests that fetch logging works when XMLHttpRequest Logging is Enabled and doesn't show logs when it is Disabled.
 
 console-fetch-logging.html:4 sending a GET request to resources/xhr-exists.html
-network-test.js:48 Fetch complete: GET "http://127.0.0.1:8000/inspector/resources/xhr-exists.html".makeFetch @ network-test.js:48requestHelper @ console-fetch-logging.html:11step1 @ console-fetch-logging.html:21makeRequests @ console-fetch-logging.html:16(anonymous function) @ VM:1(anonymous function) @ VM:11(anonymous function) @ VM:16
+network-test.js:48 Fetch complete: GET "http://127.0.0.1:8000/inspector/resources/xhr-exists.html".makeFetch @ network-test.js:48requestHelper @ console-fetch-logging.html:11step1 @ console-fetch-logging.html:24makeRequests @ console-fetch-logging.html:18(anonymous function) @ VM:1
 console-fetch-logging.html:4 sending a GET request to resources/xhr-does-not-exist.html
-network-test.js:48 GET http://127.0.0.1:8000/inspector/resources/xhr-does-not-exist.html 404 (Not Found)makeFetch @ network-test.js:48requestHelper @ console-fetch-logging.html:11step2 @ console-fetch-logging.html:27
-network-test.js:48 Fetch complete: GET "http://127.0.0.1:8000/inspector/resources/xhr-does-not-exist.html".makeFetch @ network-test.js:48requestHelper @ console-fetch-logging.html:11step2 @ console-fetch-logging.html:27
+network-test.js:48 GET http://127.0.0.1:8000/inspector/resources/xhr-does-not-exist.html 404 (Not Found)makeFetch @ network-test.js:48requestHelper @ console-fetch-logging.html:11step2 @ console-fetch-logging.html:30
+network-test.js:48 Fetch complete: GET "http://127.0.0.1:8000/inspector/resources/xhr-does-not-exist.html".makeFetch @ network-test.js:48requestHelper @ console-fetch-logging.html:11step2 @ console-fetch-logging.html:30
 console-fetch-logging.html:4 sending a POST request to resources/post-target.cgi
-network-test.js:48 Fetch complete: POST "http://127.0.0.1:8000/inspector/resources/post-target.cgi".makeFetch @ network-test.js:48requestHelper @ console-fetch-logging.html:11step3 @ console-fetch-logging.html:33
+network-test.js:48 Fetch complete: POST "http://127.0.0.1:8000/inspector/resources/post-target.cgi".makeFetch @ network-test.js:48requestHelper @ console-fetch-logging.html:11step3 @ console-fetch-logging.html:36
 console-fetch-logging.html:4 sending a GET request to http://localhost:8000/inspector/resources/xhr-exists.html
 console-fetch-logging.html:1 Fetch API cannot load http://localhost:8000/inspector/resources/xhr-exists.html. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
 console-fetch-logging.html:4 sending a GET request to resources/xhr-exists.html
 console-fetch-logging.html:4 sending a GET request to resources/xhr-does-not-exist.html
-network-test.js:48 GET http://127.0.0.1:8000/inspector/resources/xhr-does-not-exist.html 404 (Not Found)makeFetch @ network-test.js:48requestHelper @ console-fetch-logging.html:11step2 @ console-fetch-logging.html:27
+network-test.js:48 GET http://127.0.0.1:8000/inspector/resources/xhr-does-not-exist.html 404 (Not Found)makeFetch @ network-test.js:48requestHelper @ console-fetch-logging.html:11step2 @ console-fetch-logging.html:30
 console-fetch-logging.html:4 sending a POST request to resources/post-target.cgi
 console-fetch-logging.html:4 sending a GET request to http://localhost:8000/inspector/resources/xhr-exists.html
 console-fetch-logging.html:1 Fetch API cannot load http://localhost:8000/inspector/resources/xhr-exists.html. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/console-fetch-logging.html b/third_party/WebKit/LayoutTests/http/tests/inspector/console-fetch-logging.html
index 5be77c4..6ec9885 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/console-fetch-logging.html
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/console-fetch-logging.html
@@ -13,12 +13,15 @@
     {
         setTimeout(callback, 0);
     }
-    makeFetch(url, {method: method}, delayCallback);
+    makeFetch(url, {method: method}).then(delayCallback);
 }
 
-function makeRequests(callback)
+function makeRequests()
 {
+    var callback;
+    var promise = new Promise((fulfill) => callback = fulfill);
     step1();
+    return promise;
 
     function step1()
     {
@@ -53,7 +56,7 @@
     {
         function callback()
         {
-            InspectorTest.invokePageFunctionAsync("makeRequests", step2);
+            InspectorTest.callFunctionInPageAsync("makeRequests").then(step2);
         }
         InspectorTest.NetworkAgent.setMonitoringXHREnabled(true, callback);
     }
@@ -62,7 +65,7 @@
     {
         function callback()
         {
-            InspectorTest.invokePageFunctionAsync("makeRequests", step3);
+            InspectorTest.callFunctionInPageAsync("makeRequests").then(step3);
         }
         InspectorTest.NetworkAgent.setMonitoringXHREnabled(false, callback);
     }
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/inspector-test.js b/third_party/WebKit/LayoutTests/http/tests/inspector/inspector-test.js
index c734b2d..8aff486 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/inspector-test.js
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/inspector-test.js
@@ -110,56 +110,6 @@
     }
 }
 
-InspectorTest.waitForOverlayRepaint = function(callback)
-{
-    InspectorTest.invokePageFunctionAsync("requestAnimationFrame", callback);
-}
-
-var lastEvalId = 0;
-var pendingEvalRequests = {};
-
-/**
- * @param {string} functionName
- * @param {...} varArgs
- * @param {function()} callback
- */
-InspectorTest.invokePageFunctionAsync = function(functionName, varArgs)
-{
-    var id = ++lastEvalId;
-    var args = Array.prototype.slice.call(arguments, 1);
-    var callback = args.pop();
-    pendingEvalRequests[id] = InspectorTest.safeWrap(callback);
-    var asyncEvalWrapper = function(callId, functionName, argsString)
-    {
-        function evalCallback(result)
-        {
-            testRunner.evaluateInWebInspector(evalCallbackCallId, "InspectorTest.didInvokePageFunctionAsync(" + callId + ", " + JSON.stringify(result) + ");");
-        }
-        var argsArray = argsString.replace(/^\[(.*)\]$/, "$1");
-        if (argsArray.length)
-            argsArray += ",";
-        try {
-            eval(functionName + "(" + argsArray + evalCallback + ")");
-        } catch(e) {
-            InspectorTest.addResult("Error: " + e);
-            evalCallback(String(e));
-        }
-    }
-    var escapedJSONArgs = JSON.stringify(JSON.stringify(args));
-    InspectorTest.evaluateInPage("(" + asyncEvalWrapper.toString() + ")(" + id + ", unescape('" + escape(functionName) + "')," + escapedJSONArgs + ")");
-}
-
-InspectorTest.didInvokePageFunctionAsync = function(callId, value)
-{
-    var callback = pendingEvalRequests[callId];
-    if (!callback) {
-        InspectorTest.addResult("Missing callback for async eval " + callId + ", perhaps callback invoked twice?");
-        return;
-    }
-    delete pendingEvalRequests[callId];
-    callback(value);
-}
-
 InspectorTest.check = function(passCondition, failureText)
 {
     if (!passCondition)
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/network-test.js b/third_party/WebKit/LayoutTests/http/tests/inspector/network-test.js
index 3025527b..92d9867 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/network-test.js
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/network-test.js
@@ -43,9 +43,9 @@
     makeXHR(args.method, args.url, args.async, args.user, args.password, args.headers || [], args.withCredentials, args.payload, args.type, xhrLoadedCallback);
 }
 
-function makeFetch(url, requestInitializer, callback)
+function makeFetch(url, requestInitializer)
 {
-    fetch(url, requestInitializer).then(callback).catch(callback);
+    return fetch(url, requestInitializer).catch(e => e);
 }
 
 var initialize_NetworkTest = function() {
@@ -117,7 +117,7 @@
 
 InspectorTest.makeFetch = function(url, requestInitializer, callback)
 {
-    InspectorTest.invokePageFunctionAsync("makeFetch", url, requestInitializer, callback);
+    InspectorTest.callFunctionInPageAsync("makeFetch", [url, requestInitializer]).then(callback);
 }
 
 InspectorTest.HARPropertyFormatters = {
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/network/network-eventsource.html b/third_party/WebKit/LayoutTests/http/tests/inspector/network/network-eventsource.html
index 4851bfc..7bd39fe 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/network/network-eventsource.html
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/network/network-eventsource.html
@@ -4,11 +4,14 @@
 <script src="../network-test.js"></script>
 <script>
 
-function receiveEvent(callback)
+function receiveEvent()
 {
+    var callback;
+    var promise = new Promise((fulfill) => callback = fulfill);
     var es = new EventSource("resources/event-stream.asis");
     es.onmessage = onMessage;
     es.onerror = onError;
+    return promise;
     function onMessage(data)
     {
         output("got event: " + event.data);
@@ -24,7 +27,7 @@
 function test()
 {
     InspectorTest.recordNetwork();
-    InspectorTest.invokePageFunctionAsync("receiveEvent", step2);
+    InspectorTest.callFunctionInPageAsync("receiveEvent").then(step2);
 
     function step2()
     {
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/resources/extension-main.js b/third_party/WebKit/LayoutTests/http/tests/inspector/resources/extension-main.js
index 5bd6c2e..63c40089 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/resources/extension-main.js
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/resources/extension-main.js
@@ -16,7 +16,7 @@
     for (var property in object)
         propertyNames.push(property);
     propertyNames.sort();
-    
+
     for (var i = 0; i < propertyNames.length; ++i) {
         var prop = propertyNames[i];
         var prefixWithName = prefix + "    " + prop + " : ";
@@ -52,7 +52,7 @@
 
 function invokePageFunctionAsync(functionName, callback)
 {
-    evaluateOnFrontend("InspectorTest.invokePageFunctionAsync('" + functionName + "', reply)", callback);
+    evaluateOnFrontend("InspectorTest.callFunctionInPageAsync('" + functionName + "').then(() => reply())", callback);
 }
 
 function output(message)
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 5df5b56a..43075d74 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 @@
 
     function tracingStarted()
     {
-        InspectorTest.invokePageFunctionAsync(functionName, onPageActionsDone);
+        InspectorTest.callFunctionInPageAsync(functionName).then(onPageActionsDone);
     }
 
     function onPageActionsDone()
@@ -173,7 +173,7 @@
     InspectorTest.startTimeline(step1);
     function step1()
     {
-        InspectorTest.invokePageFunctionAsync(functionName, step2);
+        InspectorTest.callFunctionInPageAsync(functionName).then(step2);
     }
 
     function step2()
@@ -461,19 +461,27 @@
 
 };
 
-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;
+}
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/timeline-script-parse.html b/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/timeline-script-parse.html
index ce66fb8..5431a42c 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/timeline-script-parse.html
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/timeline-script-parse.html
@@ -5,13 +5,16 @@
 <script src="../network-test.js"></script>
 <script>
 
-function performActions(callback)
+function performActions()
 {
+    var callback;
+    var promise = new Promise((fulfill) => callback = fulfill);
     var script = document.createElement("script");
     script.src = "resources/timeline-script-parse.php";
     script.async = true;
     script.onload = callback;
     document.body.appendChild(script);
+    return promise;
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/timeline-xhr-event.html b/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/timeline-xhr-event.html
index 8e56779..bda38cc 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/timeline-xhr-event.html
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/timeline-xhr-event.html
@@ -5,13 +5,16 @@
 <script src="../network-test.js"></script>
 <script>
 
-function performActions(callback)
+function performActions()
 {
+    var callback;
+    var promise = new Promise((fulfill) => callback = fulfill);
     var xhr = new XMLHttpRequest();
     xhr.open("GET", "network/resources/resource.php", true);
     xhr.onload = callback;  // This is necessary for XHRLoad event.
     xhr.onreadystatechange = function () { };  // This is necessary for XHRReadyStateChange event.
     xhr.send(null);
+    return promise;
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/timeline-xhr-response-type-blob-event.html b/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/timeline-xhr-response-type-blob-event.html
index 6b6c6c3..3646f48 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/timeline-xhr-response-type-blob-event.html
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/timeline-xhr-response-type-blob-event.html
@@ -5,8 +5,10 @@
 <script src="../network-test.js"></script>
 <script>
 
-function performActions(callback)
+function performActions()
 {
+    var callback;
+    var promise = new Promise((fulfill) => callback = fulfill);
     var xhr = new XMLHttpRequest();
     xhr.responseType = "blob";
     xhr.open("GET", "network/resources/resource.php", true);
@@ -19,6 +21,7 @@
             callback();
     }
     xhr.send(null);
+    return promise;
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/websocket/timeline-websocket-event.html b/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/websocket/timeline-websocket-event.html
index 29a5270ac..bb263a7 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/websocket/timeline-websocket-event.html
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/websocket/timeline-websocket-event.html
@@ -4,10 +4,10 @@
 <script src="../../timeline-test.js"></script>
 <script>
 
-function performActions(callback)
+function performActions()
 {
     var ws = new WebSocket("ws://127.0.0.1:8880/simple");
-    ws.onclose = callback;
+    return new Promise((fulfill) => ws.onclose = fulfill);
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/timeline/fetch-as-stream.html b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/fetch-as-stream.html
index f855237..9915d15 100644
--- a/third_party/WebKit/LayoutTests/inspector-protocol/timeline/fetch-as-stream.html
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/fetch-as-stream.html
@@ -11,12 +11,11 @@
 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
 <script type="text/javascript" src="../../http/tests/inspector-protocol/tracing-test.js"></script>
 <script>
-function performActions(callback)
+function performActions()
 {
     var element = document.getElementById("test");
     element.style.display = "block";
     var unused = element.clientWidth;
-    callback();
 }
 
 function test()
@@ -25,7 +24,7 @@
 
     function onStart()
     {
-        InspectorTest.invokePageFunctionAsync("performActions", evalDone);
+        InspectorTest.evaluateInPage("performActions()", evalDone);
     }
 
     function evalDone()
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-dispatchEvent.html b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-dispatchEvent.html
index 408512a4..8d946ea 100644
--- a/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-dispatchEvent.html
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-dispatchEvent.html
@@ -4,7 +4,7 @@
 <script type="text/javascript" src="../../http/tests/inspector-protocol/tracing-test.js"></script>
 <script>
 
-function performAction(callback)
+function performAction()
 {
     var div = document.querySelector("#my-div");
     div.addEventListener("click", function(e) {  }, false);
@@ -12,7 +12,7 @@
 
     var iframe = document.createElement("iframe");
     div.appendChild(iframe);
-    callback();
+    return Promise.resolve();
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-layout.html b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-layout.html
index f9a3484a..f998ee4 100644
--- a/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-layout.html
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-layout.html
@@ -10,12 +10,12 @@
 <script type="text/javascript" src="../../http/tests/inspector-protocol/tracing-test.js"></script>
 <script>
 
-function performActions(callback)
+function performActions()
 {
     var div = document.querySelector("#myDiv");
     div.classList.add("my-class");
     div.offsetWidth;
-    callback();
+    return Promise.resolve();
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-raf-expected.txt b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-raf-expected.txt
index 99b45c7d..c7986ef9 100644
--- a/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-raf-expected.txt
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-raf-expected.txt
@@ -1,6 +1,5 @@
 DIV
 Recording started
-SUCCESS: testFunctionRequestAnimationFrame
 Tracing complete
 RequestAnimationFrame has frame: true
 RequestAnimationFrame frames match: true
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-raf.html b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-raf.html
index 61d0a958..8aaf9aa 100644
--- a/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-raf.html
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-raf.html
@@ -4,33 +4,26 @@
 <script type="text/javascript" src="../../http/tests/inspector-protocol/tracing-test.js"></script>
 <script>
 
-function performActions(callback)
+function performActions()
 {
-    var rafId1 = requestAnimationFrame(function()
-    {
-        evaluateInFrontend("InspectorTest.testFunctionRequestAnimationFrame(" + rafId1 + ", " + rafId2 + ")");
-        callback();
-    });
-
-    var rafId2 = requestAnimationFrame(function() { });
+    var callback;
+    var promise = new Promise((fulfill) => callback = fulfill);
+    var rafId2;
+    var rafId1 = requestAnimationFrame(() => callback({ rafId1: rafId1, rafId2: rafId2 }));
+    rafId2 = requestAnimationFrame(function() { });
     cancelAnimationFrame(rafId2);
+    return promise;
 }
 
 function test()
 {
     InspectorTest.invokeAsyncWithTracing("performActions", finish);
 
-    var firedRaf;
-    var canceledRaf;
-    InspectorTest.testFunctionRequestAnimationFrame = function(rafId1, rafId2)
+    function finish(devtoolsEvents, data)
     {
-        firedRaf = rafId1;
-        canceledRaf = rafId2;
-        InspectorTest.log("SUCCESS: testFunctionRequestAnimationFrame");
-    }
+        var firedRaf = data.rafId1;
+        var canceledRaf = data.rafId2;
 
-    function finish(devtoolsEvents)
-    {
         function hasRafId(id, e) { return e.args.data.id === id}
 
         var raf1 = InspectorTest.findEvent("RequestAnimationFrame", "I", hasRafId.bind(this, firedRaf));
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-timer.html b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-timer.html
index d0d4e2d2..78b64b5 100644
--- a/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-timer.html
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-timer.html
@@ -4,8 +4,10 @@
 <script type="text/javascript" src="../../http/tests/inspector-protocol/tracing-test.js"></script>
 <script>
 
-function performActions(callback)
+function performActions()
 {
+    var callback;
+    var promise = new Promise((fulfill) => callback = fulfill);
     var timerId = setTimeout(function()
     {
         evaluateInFrontend("InspectorTest.testFunctionTimerFired(" + timerId + ", " + timerId2 + ")");
@@ -14,7 +16,7 @@
 
     var timerId2 = setTimeout(function() { }, 0);
     clearTimeout(timerId2);
-    return timerId;
+    return promise;
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/elements/css-rule-hover-highlights-selectors.html b/third_party/WebKit/LayoutTests/inspector/elements/css-rule-hover-highlights-selectors.html
index 1795954..62a3434 100644
--- a/third_party/WebKit/LayoutTests/inspector/elements/css-rule-hover-highlights-selectors.html
+++ b/third_party/WebKit/LayoutTests/inspector/elements/css-rule-hover-highlights-selectors.html
@@ -9,6 +9,11 @@
 </style>
 <script>
 
+function requestAnimationFramePromise()
+{
+    return new Promise(fulfill => requestAnimationFrame(fulfill));
+}
+
 function buildShadowDOM()
 {
     var host = document.querySelector("body");
@@ -42,7 +47,7 @@
             {
                 var section = InspectorTest.firstMatchedStyleSection();
                 section._highlight();
-                InspectorTest.waitForOverlayRepaint(onHighlighted);
+                InspectorTest.callFunctionInPageAsync("requestAnimationFramePromise").then(onHighlighted)
             }
 
             function onHighlighted()
@@ -64,7 +69,7 @@
             {
                 var section = InspectorTest.firstMatchedStyleSection();
                 section._highlight();
-                InspectorTest.waitForOverlayRepaint(onHighlighted);
+                InspectorTest.callFunctionInPageAsync("requestAnimationFramePromise").then(onHighlighted)
             }
 
             function onHighlighted()
diff --git a/third_party/WebKit/LayoutTests/inspector/extensions/extensions-resources.html b/third_party/WebKit/LayoutTests/inspector/extensions/extensions-resources.html
index 31573919..b45d798 100644
--- a/third_party/WebKit/LayoutTests/inspector/extensions/extensions-resources.html
+++ b/third_party/WebKit/LayoutTests/inspector/extensions/extensions-resources.html
@@ -5,12 +5,15 @@
 <script src="../../http/tests/inspector/extensions-test.js"></script>
 <script src="../../http/tests/inspector/debugger-test.js"></script>
 <script type="text/javascript">
-function loadFrame(callback)
+function loadFrame()
 {
+    var callback;
+    var promise = new Promise((fulfill) => callback = fulfill);
     var iframe = document.createElement("iframe");
     iframe.src = "resources/subframe.html";
     iframe.addEventListener("load", callback);
     document.body.appendChild(iframe);
+    return promise;
 }
 
 function logMessage()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing-session-id.html b/third_party/WebKit/LayoutTests/inspector/tracing-session-id.html
index d90cea8c..fe5b0a8 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing-session-id.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing-session-id.html
@@ -6,7 +6,7 @@
 <script>
 function test()
 {
-    InspectorTest.invokeWithTracing("(function(callback) { callback(); })", processTracingEvents);
+    InspectorTest.evaluateWithTimeline("(function() {})", processTracingEvents);
 
     function processTracingEvents()
     {
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/anonymous-image-object.html b/third_party/WebKit/LayoutTests/inspector/tracing/anonymous-image-object.html
index 47b299a..9c3ef519 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/anonymous-image-object.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/anonymous-image-object.html
@@ -9,8 +9,10 @@
 <script src="../../http/tests/inspector/timeline-test.js"></script>
 <script>
 
-function doActions(callback)
+function doActions()
 {
+    var callback;
+    var promise = new Promise((fulfill) => callback = fulfill);
     document.getElementById("marker").classList.add("marker");
     var img = document.createElement("img");
     img.src = "resources/test.bmp";
@@ -19,6 +21,7 @@
     {
         testRunner.layoutAndPaintAsyncThen(callback);
     }
+    return promise;
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/decode-resize.html b/third_party/WebKit/LayoutTests/inspector/tracing/decode-resize.html
index 2a0d305..830f37b 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/decode-resize.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/decode-resize.html
@@ -37,26 +37,24 @@
     ["./resources/big.png", "150", "150"]
 ];
 
-function showImages(callback)
+function showImages()
 {
-    var nextImageIndex = 0;
+    var promise = Promise.resolve();
+    for (let image of images) {
+        promise = promise
+            .then(() => addImage(image))
+            .then(() => new Promise((fulfill) => testRunner.layoutAndPaintAsyncThen(fulfill)));
+    }
+    return promise.then(() => generateFrames(3));
 
-    addImages();
-
-    function addImages()
+    function addImage(image)
     {
-        if (nextImageIndex >= images.length) {
-            // Allow several frames for image decoding to complete on rasterizer threads.
-            generateFrames(3, callback);
-            return;
-        }
-
         var imgContainer = document.createElement("div");
         imgContainer.className = "img-container";
         document.body.appendChild(imgContainer);
 
         var imgElement = document.createElement("img");
-        imgElement.addEventListener("load", testRunner.layoutAndPaintAsyncThen.bind(testRunner, addImages));
+        var promise = new Promise((fulfill) => imgElement.onload = fulfill);
         imgContainer.appendChild(imgElement);
 
         var backgroundElement = document.createElement("div");
@@ -67,16 +65,16 @@
         borderElement.className = "border";
         document.body.appendChild(borderElement);
 
-        var image = images[nextImageIndex++];
         imgElement.width = image[1];
         imgElement.height = image[2];
         imgElement.src = image[0];
         backgroundElement.style.backgroundImage = "url(" + image[0] + "?background)";
         borderElement.style.borderImage = "url(" + image[0] + "?border)";
+
+        return promise;
     }
 }
 
-
 function test()
 {
     InspectorTest.invokeWithTracing("showImages", InspectorTest.safeWrap(onTracingComplete));
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/frame-model-instrumentation.html b/third_party/WebKit/LayoutTests/inspector/tracing/frame-model-instrumentation.html
index 73abca0..a6eb416 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/frame-model-instrumentation.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/frame-model-instrumentation.html
@@ -5,9 +5,9 @@
 <script src="../tracing-test.js"></script>
 
 <script>
-function doActions(callback)
+function doActions()
 {
-    generateFrames(3, callback);
+    return generateFrames(3);
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/scroll-invalidations.html b/third_party/WebKit/LayoutTests/inspector/tracing/scroll-invalidations.html
index fc6d9b20..58ca711a 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/scroll-invalidations.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/scroll-invalidations.html
@@ -4,11 +4,12 @@
 <script src="../../http/tests/inspector/inspector-test.js"></script>
 <script src="../../http/tests/inspector/timeline-test.js"></script>
 <script>
-function scrollAndDisplay(callback)
+function scrollAndDisplay()
 {
     scrollTo(0, 200);
     if (window.testRunner)
-        testRunner.layoutAndPaintAsyncThen(callback);
+        return new Promise((fulfill) => testRunner.layoutAndPaintAsyncThen(fulfill));
+    return Promise.reject();
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-js/timeline-gc-event.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-js/timeline-gc-event.html
index bf1d5cd..fb71eb6 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-js/timeline-gc-event.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-js/timeline-gc-event.html
@@ -4,12 +4,13 @@
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
 
-function produceGarbageForGCEvents(callback)
+function produceGarbageForGCEvents()
 {
     if (window.testRunner) {
         window.gc();
-        testRunner.layoutAndPaintAsyncThen(callback);
+        return new Promise((fulfill) => testRunner.layoutAndPaintAsyncThen(fulfill));
     }
+    return Promise.reject();
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-js/timeline-script-id-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-js/timeline-script-id-expected.txt
index e908e613..cf78174 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-js/timeline-script-id-expected.txt
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-js/timeline-script-id-expected.txt
@@ -2,14 +2,14 @@
 
 It expects two FunctionCall for InjectedScript, two TimerInstall events, two FunctionCall events and one TimerRemove event to be logged with performActions.js script name and some line number.
 
-detailsTextContent for TimerInstall event: 'performActions.js:3'
-details.textContent for TimerInstall event: 'performActions.js:3'
-detailsTextContent for TimerInstall event: 'performActions.js:4'
-details.textContent for TimerInstall event: 'performActions.js:4'
-detailsTextContent for FunctionCall event: 'performActions.js:7'
-details.textContent for FunctionCall event: 'intervalTimerWork @ performActions.js:7'
-detailsTextContent for FunctionCall event: 'performActions.js:7'
-details.textContent for FunctionCall event: 'intervalTimerWork @ performActions.js:7'
-detailsTextContent for TimerRemove event: 'performActions.js:11'
-details.textContent for TimerRemove event: 'performActions.js:11'
+detailsTextContent for TimerInstall event: 'performActions.js:5'
+details.textContent for TimerInstall event: 'performActions.js:5'
+detailsTextContent for TimerInstall event: 'performActions.js:6'
+details.textContent for TimerInstall event: 'performActions.js:6'
+detailsTextContent for FunctionCall event: 'performActions.js:10'
+details.textContent for FunctionCall event: 'intervalTimerWork @ performActions.js:10'
+detailsTextContent for FunctionCall event: 'performActions.js:10'
+details.textContent for FunctionCall event: 'intervalTimerWork @ performActions.js:10'
+detailsTextContent for TimerRemove event: 'performActions.js:14'
+details.textContent for TimerRemove event: 'performActions.js:14'
 
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-js/timeline-script-id.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-js/timeline-script-id.html
index b0e22aa7..a2d24aa 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-js/timeline-script-id.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-js/timeline-script-id.html
@@ -6,11 +6,14 @@
 
 function test()
 {
-    function performActions(callback)
+    function performActions()
     {
+        var callback;
+        var promise = new Promise((fulfill) => callback = fulfill);
         var timerOne = setTimeout("1 + 1", 10);
         var timerTwo = setInterval(intervalTimerWork, 20);
         var iteration = 0;
+        return promise;
 
         function intervalTimerWork()
         {
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-layout/timeline-layout-with-invalidations-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-layout/timeline-layout-with-invalidations-expected.txt
index 4ddcd95..973d3fad 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-layout/timeline-layout-with-invalidations-expected.txt
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-layout/timeline-layout-with-invalidations-expected.txt
@@ -6,7 +6,7 @@
 Running: testLocalFrame
 first layout invalidations[
     {
-        cause : {reason: Style changed, stackTrace: .../inspector/tracing/timeline-layout/timeline-layout-with-invalidations.html:11}
+        cause : {reason: Style changed, stackTrace: .../inspector/tracing/timeline-layout/timeline-layout-with-invalidations.html:10}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -19,7 +19,7 @@
 ]
 second layout invalidations[
     {
-        cause : {reason: Style changed, stackTrace: .../inspector/tracing/timeline-layout/timeline-layout-with-invalidations.html:13}
+        cause : {reason: Style changed, stackTrace: .../inspector/tracing/timeline-layout/timeline-layout-with-invalidations.html:12}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -34,7 +34,7 @@
 Running: testSubframe
 first layout invalidations[
     {
-        cause : {reason: Style changed, stackTrace: .../inspector/tracing/timeline-layout/timeline-layout-with-invalidations.html:23}
+        cause : {reason: Style changed, stackTrace: .../inspector/tracing/timeline-layout/timeline-layout-with-invalidations.html:19}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -47,7 +47,7 @@
 ]
 second layout invalidations[
     {
-        cause : {reason: Style changed, stackTrace: .../inspector/tracing/timeline-layout/timeline-layout-with-invalidations.html:25}
+        cause : {reason: Style changed, stackTrace: .../inspector/tracing/timeline-layout/timeline-layout-with-invalidations.html:21}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-layout/timeline-layout-with-invalidations.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-layout/timeline-layout-with-invalidations.html
index 0c16a28..f91a977 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-layout/timeline-layout-with-invalidations.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-layout/timeline-layout-with-invalidations.html
@@ -4,28 +4,22 @@
 <script src="../../../http/tests/inspector/inspector-test.js"></script>
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
-function display(callback)
+function display()
 {
-    requestAnimationFrame(function() {
-        document.getElementById("testElement").style.width = "100px";
-        var forceLayout1 = document.body.offsetTop;
-        document.getElementById("testElement").style.width = "110px";
-        var forceLayout2 = document.body.offsetTop;
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    document.getElementById("testElement").style.width = "100px";
+    var forceLayout1 = document.body.offsetTop;
+    document.getElementById("testElement").style.width = "110px";
+    var forceLayout2 = document.body.offsetTop;
+    return waitForFrame();
 }
 
-function updateSubframeAndDisplay(callback)
+function updateSubframeAndDisplay()
 {
-    requestAnimationFrame(function() {
-        frames[0].document.body.children[0].style.width = "10px";
-        var forceLayout1 = frames[0].document.body.offsetTop;
-        frames[0].document.body.children[0].style.width = "20px";
-        var forceLayout2 = frames[0].document.body.offsetTop;
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    frames[0].document.body.children[0].style.width = "10px";
+    var forceLayout1 = frames[0].document.body.offsetTop;
+    frames[0].document.body.children[0].style.width = "20px";
+    var forceLayout2 = frames[0].document.body.offsetTop;
+    return waitForFrame();
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-animation-frame-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-animation-frame-expected.txt
index 2022df56..0d7b14d 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-animation-frame-expected.txt
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-animation-frame-expected.txt
@@ -13,7 +13,7 @@
     startTime : <number>
     type : "RequestAnimationFrame"
 }
-Text details for RequestAnimationFrame: timeline-animation-frame.html:8
+Text details for RequestAnimationFrame: timeline-animation-frame.html:10
 FireAnimationFrame Properties:
 {
     data : {
@@ -25,7 +25,7 @@
     startTime : <number>
     type : "FireAnimationFrame"
 }
-Text details for FireAnimationFrame: timeline-animation-frame.html:8
+Text details for FireAnimationFrame: timeline-animation-frame.html:10
 CancelAnimationFrame Properties:
 {
     data : {
@@ -39,5 +39,5 @@
     startTime : <number>
     type : "CancelAnimationFrame"
 }
-Text details for CancelAnimationFrame: timeline-animation-frame.html:11
+Text details for CancelAnimationFrame: timeline-animation-frame.html:13
 
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-animation-frame.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-animation-frame.html
index 6556301..05e61177 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-animation-frame.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-animation-frame.html
@@ -3,8 +3,10 @@
 <script src="../../../http/tests/inspector/inspector-test.js"></script>
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
-function performActions(callback)
+function performActions()
 {
+    var callback;
+    var promise = new Promise((fulfill) => callback = fulfill);
     var requestId = window.requestAnimationFrame(animationFrameCallback);
     function animationFrameCallback()
     {
@@ -12,6 +14,7 @@
         if (callback)
             callback();
     }
+    return promise;
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-event-causes-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-event-causes-expected.txt
index 7099f38..383abeb 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-event-causes-expected.txt
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-event-causes-expected.txt
@@ -2,10 +2,10 @@
 
 
 Running: testTimerInstall
-PASS - record contained Timer InstalledsetTimeoutFunction @ setTimeoutFunction.js:
+PASS - record contained Timer InstalledPromise @ setTimeoutFunction.js:
 
 Running: testRequestAnimationFrame
-PASS - record contained Animation Frame RequestedrequestAnimationFrameFunction @ requestAnimationFrameFunction.js:
+PASS - record contained Animation Frame RequestedPromise @ requestAnimationFrameFunction.js:
 
 Running: testStyleRecalc
 PASS - record contained First InvalidatedstyleRecalcFunction @ styleRecalcFunction.js:
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-event-causes.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-event-causes.html
index 5b98db76..92ba023 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-event-causes.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-event-causes.html
@@ -15,9 +15,9 @@
     InspectorTest.runTestSuite([
         function testTimerInstall(next)
         {
-            function setTimeoutFunction(callback)
+            function setTimeoutFunction()
             {
-                setTimeout(callback, 0);
+                return new Promise((fulfill) => setTimeout(fulfill, 0));
             }
 
             var source = setTimeoutFunction.toString();
@@ -35,7 +35,7 @@
                 WebInspector.TimelineUIUtils._generateCauses(event, InspectorTest.timelineModel().targetByEvent(event), null, contentHelper);
                 var causes = contentHelper.element.deepTextContent();
                 InspectorTest.check(causes, "Should generate causes");
-                checkStringContains(causes, "Timer InstalledsetTimeoutFunction @ setTimeoutFunction.js:");
+                checkStringContains(causes, "Timer InstalledPromise @ setTimeoutFunction.js:");
                 next();
             }
         },
@@ -44,7 +44,7 @@
         {
             function requestAnimationFrameFunction(callback)
             {
-                requestAnimationFrame(callback);
+                return new Promise((fulfill) => requestAnimationFrame(fulfill));
             }
 
             var source = requestAnimationFrameFunction.toString();
@@ -62,7 +62,7 @@
                 WebInspector.TimelineUIUtils._generateCauses(event, InspectorTest.timelineModel().targetByEvent(event), null, contentHelper);
                 var causes = contentHelper.element.deepTextContent();
                 InspectorTest.check(causes, "Should generate causes");
-                checkStringContains(causes, "Animation Frame RequestedrequestAnimationFrameFunction @ requestAnimationFrameFunction.js:");
+                checkStringContains(causes, "Animation Frame RequestedPromise @ requestAnimationFrameFunction.js:");
                 next();
             }
         },
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-grouped-invalidations-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-grouped-invalidations-expected.txt
index 2b3be27..fbf25beb 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-grouped-invalidations-expected.txt
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-grouped-invalidations-expected.txt
@@ -6,7 +6,7 @@
 S
 paint invalidations[
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-misc/timeline-grouped-invalidations.html:12}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-misc/timeline-grouped-invalidations.html:14}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -17,7 +17,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-misc/timeline-grouped-invalidations.html:13}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-misc/timeline-grouped-invalidations.html:15}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -28,7 +28,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-misc/timeline-grouped-invalidations.html:12}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-misc/timeline-grouped-invalidations.html:14}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -39,7 +39,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-misc/timeline-grouped-invalidations.html:13}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-misc/timeline-grouped-invalidations.html:15}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -50,7 +50,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-misc/timeline-grouped-invalidations.html:12}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-misc/timeline-grouped-invalidations.html:14}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -61,7 +61,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-misc/timeline-grouped-invalidations.html:13}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-misc/timeline-grouped-invalidations.html:15}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -72,7 +72,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-misc/timeline-grouped-invalidations.html:12}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-misc/timeline-grouped-invalidations.html:14}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -83,7 +83,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-misc/timeline-grouped-invalidations.html:13}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-misc/timeline-grouped-invalidations.html:15}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -94,6 +94,6 @@
         type : "StyleRecalcInvalidationTracking"
     }
 ]
-PASS - record contained Inline CSS style declaration was mutated for [ DIV class='testElement' ], [ DIV class='testElement' ], and 2 others. (anonymous function) @ timeline-grouped-invalidations.html:12
-PASS - record contained Inline CSS style declaration was mutated for [ DIV class='testElement' ], [ DIV class='testElement' ], and 2 others. (anonymous function) @ timeline-grouped-invalidations.html:13
+PASS - record contained Inline CSS style declaration was mutated for [ DIV class='testElement' ], [ DIV class='testElement' ], and 2 others. (anonymous function) @ timeline-grouped-invalidations.html:14
+PASS - record contained Inline CSS style declaration was mutated for [ DIV class='testElement' ], [ DIV class='testElement' ], and 2 others. (anonymous function) @ timeline-grouped-invalidations.html:15
 
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-grouped-invalidations.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-grouped-invalidations.html
index fa44b06..da70bf2 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-grouped-invalidations.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-grouped-invalidations.html
@@ -4,8 +4,10 @@
 <script src="../../../http/tests/inspector/inspector-test.js"></script>
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
-function display(callback)
+function display()
 {
+    var callback;
+    var promise = new Promise((fulfill) => callback = fulfill);
     requestAnimationFrame(function() {
         var testElements = document.body.getElementsByClassName("testElement");
         for (var i = 0; i < testElements.length; i++) {
@@ -15,6 +17,7 @@
         if (window.testRunner)
             testRunner.layoutAndPaintAsyncThen(callback);
     });
+    return promise;
 }
 
 function test()
@@ -34,8 +37,8 @@
         WebInspector.TimelineUIUtils._generateCauses(event, target, null, contentHelper);
         var invalidationsTree = contentHelper.element.getElementsByClassName("invalidations-tree")[0];
         var invalidations = invalidationsTree.shadowRoot.textContent;
-        checkStringContains(invalidations, "Inline CSS style declaration was mutated for [ DIV class='testElement' ], [ DIV class='testElement' ], and 2 others. (anonymous function) @ timeline-grouped-invalidations.html:12");
-        checkStringContains(invalidations, "Inline CSS style declaration was mutated for [ DIV class='testElement' ], [ DIV class='testElement' ], and 2 others. (anonymous function) @ timeline-grouped-invalidations.html:13");
+        checkStringContains(invalidations, "Inline CSS style declaration was mutated for [ DIV class='testElement' ], [ DIV class='testElement' ], and 2 others. (anonymous function) @ timeline-grouped-invalidations.html:14");
+        checkStringContains(invalidations, "Inline CSS style declaration was mutated for [ DIV class='testElement' ], [ DIV class='testElement' ], and 2 others. (anonymous function) @ timeline-grouped-invalidations.html:15");
         InspectorTest.completeTest();
     });
 
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-load-event.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-load-event.html
index f059bb51..d133e07 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-load-event.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-load-event.html
@@ -3,8 +3,10 @@
 <script src="../../../http/tests/inspector/inspector-test.js"></script>
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
-function display(callback)
+function display()
 {
+    var callback;
+    var promise = new Promise((fulfill) => callback = fulfill);
     if (window.testRunner)
         testRunner.setCanOpenWindows(true);
     var popup = window.open("data:text/html,<b>Hello, world</b>");
@@ -12,6 +14,7 @@
     {
         requestAnimationFrame(testRunner.capturePixelsAsyncThen.bind(testRunner, callback));
     }
+    return promise;
 }
 
 function test()
@@ -21,7 +24,7 @@
 
     function pageReloaded()
     {
-        InspectorTest.invokePageFunctionAsync("display", displayDone);
+        InspectorTest.callFunctionInPageAsync("display").then(displayDone);
     }
 
     function displayDone()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-receive-response-event.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-receive-response-event.html
index efec261..49f3a4e 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-receive-response-event.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-misc/timeline-receive-response-event.html
@@ -4,8 +4,10 @@
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
 
-function performActions(callback)
+function performActions()
 {
+    var callback;
+    var promise = new Promise((fulfill) => callback = fulfill);
     var image = new Image();
     image.onload = bar;
     image.src = "../resources/anImage.png";
@@ -16,6 +18,7 @@
         image.onload = function(event) { callback(); }  // do not pass event argument to the callback.
         image.src = "../resources/anotherImage.png";
     }
+    return promise;
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-network/timeline-network-received-data.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-network/timeline-network-received-data.html
index 34954c0..ae17be6 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-network/timeline-network-received-data.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-network/timeline-network-received-data.html
@@ -4,30 +4,18 @@
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
 
-function performActions(callback)
+function performActions()
 {
-    function onImageLoad()
-    {
-        window._imageLoaded = true;
-        if (window._scriptEvaluated)
-            callback();
-    }
-
-    function scriptEvaluated()
-    {
-        window._scriptEvaluated = true;
-        if (window._imageLoaded)
-            callback();
-    }
-
     var image = new Image();
-    image.onload = onImageLoad;
+    var imagePromise = new Promise((fulfill) => image.onload = fulfill);
     image.src = "../resources/anImage.png";
+
+    var scriptPromise = new Promise((fulfill) => window.timelineNetworkResourceEvaluated = fulfill);
     var script = document.createElement("script");
     script.src = "timeline-network-resource.js";
     document.body.appendChild(script);
 
-    window.timelineNetworkResourceEvaluated = scriptEvaluated;
+    return Promise.all([imagePromise, scriptPromise]);
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-network/timeline-network-resource-details-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-network/timeline-network-resource-details-expected.txt
index 5276c3b..2051ff30 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-network/timeline-network-resource-details-expected.txt
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-network/timeline-network-resource-details-expected.txt
@@ -6,7 +6,7 @@
 Request Method: GET
 Priority: Low
 Mime Type: string
-Initiator: timeline-network-resource-details.html:22
+Initiator: timeline-network-resource-details.html:15
 URL: anImage.png
 Duration: string
 Request Method: GET
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-network/timeline-network-resource-details.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-network/timeline-network-resource-details.html
index 58da539f..9f075cf1 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-network/timeline-network-resource-details.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-network/timeline-network-resource-details.html
@@ -4,23 +4,18 @@
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
 
-function performActions(callback)
+function performActions()
 {
-    function onRequestFinished()
-    {
-        if (!--requestsPending)
-            callback();
-    }
-
-    var requestsPending = 2;
     var image = new Image();
-    image.onload = onRequestFinished;
+    var imagePromise = new Promise((fulfill) => image.onload = fulfill);
     image.src = "../resources/anImage.png";
 
     var script = document.createElement("script");
     script.src = "timeline-network-resource.js";
     document.body.appendChild(script);
-    window.timelineNetworkResourceEvaluated = onRequestFinished;
+    var scriptPromise = new Promise((fulfill) => window.timelineNetworkResourceEvaluated = fulfill);
+
+    return Promise.all([imagePromise, scriptPromise]);
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-network/timeline-network-resource.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-network/timeline-network-resource.html
index e5de92e0b..545d0d4 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-network/timeline-network-resource.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-network/timeline-network-resource.html
@@ -6,12 +6,13 @@
 
 var scriptUrl = "timeline-network-resource.js";
 
-function performActions(callback) 
+function performActions()
 {
-    window.timelineNetworkResourceEvaluated = callback;
+    var promise = new Promise((fulfill) => window.timelineNetworkResourceEvaluated = fulfill);
     var script = document.createElement("script");
     script.src = scriptUrl;
     document.body.appendChild(script);
+    return promise;
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/layer-tree.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/layer-tree.html
index 5a3715c3e..f408ffe9 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/layer-tree.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/layer-tree.html
@@ -6,7 +6,7 @@
 <script src="../../tracing-test.js"></script>
 
 <script>
-function doActions(callback)
+function doActions()
 {
     var div = document.createElement("div");
     div.id = "b4";
@@ -16,7 +16,7 @@
     var style = document.createElement("style");
     style.textContent = ".layer { transform: translateZ(10px); opacity: 0.8; }";
     document.head.appendChild(style);
-    generateFrames(3, callback);
+    return generateFrames(3);
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/paint-profiler-update.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/paint-profiler-update.html
index b8b5d787..7a0b2ec 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/paint-profiler-update.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/paint-profiler-update.html
@@ -3,8 +3,10 @@
 <script src="../../../http/tests/inspector/inspector-test.js"></script>
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
-function performActions(callback)
+function performActions()
 {
+    var callback;
+    var promise = new Promise((fulfill) => callback = fulfill);
     var square = document.getElementById("square");
     step1();
 
@@ -19,6 +21,7 @@
         square.style.backgroundColor = "black";
         testRunner.layoutAndPaintAsyncThen(callback);
     }
+    return promise;
 }
 
 function test()
@@ -36,7 +39,7 @@
         for (var event of events) {
             if (event.name === WebInspector.TimelineModel.RecordType.Paint) {
                 paintEvents.push(event);
-                if (!event.picture) 
+                if (!event.picture)
                     InspectorTest.addResult("Event without picture at " + paintEvents.length);
             }
         }
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations-expected.txt
index dcc6f15..4f28de0 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations-expected.txt
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations-expected.txt
@@ -5,7 +5,7 @@
 PASS
 first style recalc[
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations.html:10}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations.html:9}
         changedAttribute : undefined
         changedClass : "red"
         changedId : undefined
@@ -19,7 +19,7 @@
 ]
 second style recalc[
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations.html:12}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations.html:11}
         changedAttribute : undefined
         changedClass : "snow"
         changedId : undefined
@@ -31,7 +31,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations.html:12}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations.html:11}
         changedAttribute : undefined
         changedClass : "red"
         changedId : undefined
@@ -45,7 +45,7 @@
 ]
 first paint[
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations.html:10}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations.html:9}
         changedAttribute : undefined
         changedClass : "red"
         changedId : undefined
@@ -57,7 +57,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations.html:12}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations.html:11}
         changedAttribute : undefined
         changedClass : "snow"
         changedId : undefined
@@ -69,7 +69,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations.html:12}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations.html:11}
         changedAttribute : undefined
         changedClass : "red"
         changedId : undefined
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations.html
index 0d9381c..69b8172 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations.html
@@ -4,16 +4,13 @@
 <script src="../../../http/tests/inspector/inspector-test.js"></script>
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
-function multipleStyleRecalcsAndDisplay(callback)
+function multipleStyleRecalcsAndDisplay()
 {
-    requestAnimationFrame(function() {
-        document.getElementById("testElementOne").className = "red";
-        var forceStyleRecalc1 = document.body.offsetTop;
-        document.getElementById("testElementOne").className = "snow";
-        var forceStyleRecalc2 = document.body.offsetTop;
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    document.getElementById("testElementOne").className = "red";
+    var forceStyleRecalc1 = document.body.offsetTop;
+    document.getElementById("testElementOne").className = "snow";
+    var forceStyleRecalc2 = document.body.offsetTop;
+    return waitForFrame();
 }
 
 
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-expected.txt
index aeab905..d75299c 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-expected.txt
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-expected.txt
@@ -6,7 +6,7 @@
 Running: testLocalFrame
 paint invalidations[
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations.html:10}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations.html:9}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -17,7 +17,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations.html:11}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations.html:10}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -28,7 +28,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Style changed, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations.html:12}
+        cause : {reason: Style changed, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations.html:11}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -43,7 +43,7 @@
 Running: testSubframe
 second paint invalidations[
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations.html:21}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations.html:17}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -54,7 +54,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Style changed, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations.html:22}
+        cause : {reason: Style changed, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations.html:18}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -65,7 +65,7 @@
         type : "LayoutInvalidationTracking"
     }
     {
-        cause : {reason: Unknown, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations.html:22}
+        cause : {reason: Unknown, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations.html:18}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node-expected.txt
index 040d739..f251fd46 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node-expected.txt
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node-expected.txt
@@ -5,7 +5,7 @@
 Running: testLocalFrame
 paint invalidations[
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html:10}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html:9}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -16,7 +16,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html:12}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html:11}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -27,7 +27,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Style changed, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html:13}
+        cause : {reason: Style changed, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html:12}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -38,7 +38,7 @@
         type : "LayoutInvalidationTracking"
     }
     {
-        cause : {reason: Removed from layout, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html:14}
+        cause : {reason: Removed from layout, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html:13}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -49,7 +49,7 @@
         type : "LayoutInvalidationTracking"
     }
     {
-        cause : {reason: Removed from layout, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html:14}
+        cause : {reason: Removed from layout, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html:13}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -64,7 +64,7 @@
 Running: testSubframe
 second paint invalidations[
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html:24}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html:20}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -75,7 +75,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Style changed, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html:25}
+        cause : {reason: Style changed, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html:21}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -86,7 +86,7 @@
         type : "LayoutInvalidationTracking"
     }
     {
-        cause : {reason: Removed from layout, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html:26}
+        cause : {reason: Removed from layout, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html:22}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html
index 33eadbf..3d924cc 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.html
@@ -4,29 +4,23 @@
 <script src="../../../http/tests/inspector/inspector-test.js"></script>
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
-function display(callback)
+function display()
 {
-    requestAnimationFrame(function() {
-        document.body.style.backgroundColor = "blue";
-        var element = document.getElementById("testElement");
-        element.style.width = "100px";
-        var forceLayout = document.body.offsetTop;
-        element.parentElement.removeChild(element);
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    document.body.style.backgroundColor = "blue";
+    var element = document.getElementById("testElement");
+    element.style.width = "100px";
+    var forceLayout = document.body.offsetTop;
+    element.parentElement.removeChild(element);
+    return waitForFrame();
 }
 
-function updateSubframeAndDisplay(callback)
+function updateSubframeAndDisplay()
 {
-    requestAnimationFrame(function() {
-        var element = frames[0].document.body.children[0];
-        element.style.width = "200px";
-        var forceLayout = frames[0].document.body.offsetTop;
-        element.parentElement.removeChild(element);
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    var element = frames[0].document.body.children[0];
+    element.style.width = "200px";
+    var forceLayout = frames[0].document.body.offsetTop;
+    element.parentElement.removeChild(element);
+    return waitForFrame();
 }
 
 function test()
@@ -41,7 +35,6 @@
             InspectorTest.invokeAsyncWithTimeline("display", function() {
                 var record = InspectorTest.findFirstTimelineRecord(WebInspector.TimelineModel.RecordType.Paint);
                 InspectorTest.addArray(record._event.invalidationTrackingEvents, InspectorTest.InvalidationFormatters, "", "paint invalidations");
-
                 next();
             });
         },
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations.html
index 32c5fb2..e9672a99 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-layout-invalidations.html
@@ -4,25 +4,19 @@
 <script src="../../../http/tests/inspector/inspector-test.js"></script>
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
-function display(callback)
+function display()
 {
-    requestAnimationFrame(function() {
-        document.body.style.backgroundColor = "blue";
-        document.getElementById("testElement").style.width = "100px";
-        var forceLayout = document.body.offsetTop;
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    document.body.style.backgroundColor = "blue";
+    document.getElementById("testElement").style.width = "100px";
+    var forceLayout = document.body.offsetTop;
+    return waitForFrame();
 }
 
-function updateSubframeAndDisplay(callback)
+function updateSubframeAndDisplay()
 {
-    requestAnimationFrame(function() {
-        frames[0].document.body.children[0].style.width = "200px";
-        var forceLayout = frames[0].document.body.offsetTop;
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    frames[0].document.body.children[0].style.width = "200px";
+    var forceLayout = frames[0].document.body.offsetTop;
+    return waitForFrame();
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-style-recalc-invalidations-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-style-recalc-invalidations-expected.txt
index ae8173b..d316259a0 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-style-recalc-invalidations-expected.txt
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-style-recalc-invalidations-expected.txt
@@ -6,7 +6,7 @@
 Running: testLocalFrame
 first paint invalidations[
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-style-recalc-invalidations.html:10}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-style-recalc-invalidations.html:9}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -17,7 +17,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-style-recalc-invalidations.html:11}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-style-recalc-invalidations.html:10}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -32,7 +32,7 @@
 Running: testSubframe
 second paint invalidations[
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-style-recalc-invalidations.html:20}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-paint/timeline-paint-with-style-recalc-invalidations.html:16}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-style-recalc-invalidations.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-style-recalc-invalidations.html
index 9cb6312..bea8789 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-style-recalc-invalidations.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint-with-style-recalc-invalidations.html
@@ -4,23 +4,17 @@
 <script src="../../../http/tests/inspector/inspector-test.js"></script>
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
-function display(callback)
+function display()
 {
-    requestAnimationFrame(function() {
-        document.body.style.backgroundColor = "blue";
-        document.getElementById("testElement").style.backgroundColor = "salmon";
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    document.body.style.backgroundColor = "blue";
+    document.getElementById("testElement").style.backgroundColor = "salmon";
+    return waitForFrame();
 }
 
-function updateSubframeAndDisplay(callback)
+function updateSubframeAndDisplay()
 {
-    requestAnimationFrame(function() {
-        frames[0].document.body.children[0].style.backgroundColor = "green";
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    frames[0].document.body.children[0].style.backgroundColor = "green";
+    return waitForFrame();
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint.html
index a49206c..855d02e 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/timeline-paint.html
@@ -4,22 +4,16 @@
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
 
-function display(callback)
+function display()
 {
-    requestAnimationFrame(function() {
-        document.body.style.backgroundColor = "blue";
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    document.body.style.backgroundColor = "blue";
+    return waitForFrame();
 }
 
-function updateSubframeAndDisplay(callback)
+function updateSubframeAndDisplay()
 {
-    requestAnimationFrame(function() {
-        frames[0].document.body.children[0].style.backgroundColor = "green";
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    frames[0].document.body.children[0].style.backgroundColor = "green";
+    return waitForFrame();
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/update-layer-tree.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/update-layer-tree.html
index a62404e..32e686c 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/update-layer-tree.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-paint/update-layer-tree.html
@@ -12,14 +12,12 @@
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
 
-function doActions(callback)
+function doActions()
 {
     var layer = document.createElement("div");
     layer.classList.add("layer");
     document.getElementById("parent-layer").appendChild(layer);
-
-    if (window.testRunner)
-        testRunner.layoutAndPaintAsyncThen(callback);
+    return new Promise((fulfill) => testRunner.layoutAndPaintAsyncThen(fulfill));
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/parse-author-style-sheet.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/parse-author-style-sheet.html
index 91c39511..59ffabfa 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/parse-author-style-sheet.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/parse-author-style-sheet.html
@@ -5,14 +5,14 @@
 <script src="../../tracing-test.js"></script>
 <script>
 
-function importStyle(onComplete)
+function importStyle()
 {
     var link = document.createElement('link');
     link.setAttribute('rel', 'stylesheet');
     link.type = 'text/css';
     link.href = '../resources/style.css';
-    document.head.appendChild(link);    
-    link.onload = onComplete.bind(this, null);
+    document.head.appendChild(link);
+    return new Promise((fulfill) => link.onload = fulfill);
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types-expected.txt
index 3234b879..b362410 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types-expected.txt
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types-expected.txt
@@ -7,7 +7,7 @@
 Running: testClassName
 [
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:10}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:9}
         changedAttribute : undefined
         changedClass : "red"
         changedId : undefined
@@ -19,7 +19,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:11}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:10}
         changedAttribute : undefined
         changedClass : "red"
         changedId : undefined
@@ -37,7 +37,7 @@
 Running: testId
 [
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:32}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:25}
         changedAttribute : undefined
         changedClass : undefined
         changedId : "testElementFour"
@@ -49,7 +49,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:33}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:26}
         changedAttribute : undefined
         changedClass : undefined
         changedId : "testElementFive"
@@ -65,7 +65,7 @@
 Running: testStyleAttributeChange
 [
     {
-        cause : {reason: StyleSheetChange, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:43}
+        cause : {reason: StyleSheetChange, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:33}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -76,7 +76,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: StyleSheetChange, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:44}
+        cause : {reason: StyleSheetChange, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:34}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -91,7 +91,7 @@
 Running: testAttributeChange
 [
     {
-        cause : {reason: Attribute, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:54}
+        cause : {reason: Attribute, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:41}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -102,7 +102,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Attribute, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:55}
+        cause : {reason: Attribute, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:42}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -113,7 +113,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:54}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:41}
         changedAttribute : "dir"
         changedClass : undefined
         changedId : undefined
@@ -125,7 +125,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:55}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:42}
         changedAttribute : "dir"
         changedClass : undefined
         changedId : undefined
@@ -141,7 +141,7 @@
 Running: testPseudoChange
 [
     {
-        cause : {reason: PseudoClass, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:67}
+        cause : {reason: PseudoClass, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html:51}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html
index d805373..7154898 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-all-invalidator-types.html
@@ -4,72 +4,54 @@
 <script src="../../../http/tests/inspector/inspector-test.js"></script>
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
-function changeClassNameAndDisplay(callback)
+function changeClassNameAndDisplay()
 {
-    requestAnimationFrame(function() {
-        document.getElementById("testElementOne").className = "red";
-        document.getElementById("testElementTwo").className = "red";
-        var forceStyleRecalc = document.body.offsetTop;
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    document.getElementById("testElementOne").className = "red";
+    document.getElementById("testElementTwo").className = "red";
+    var forceStyleRecalc = document.body.offsetTop;
+    return waitForFrame();
 }
 
-function changeIdWithoutStyleChangeAndDisplay(callback)
+function changeIdWithoutStyleChangeAndDisplay()
 {
-    requestAnimationFrame(function() {
-        document.getElementById("testElementOne").id = "testElementNoMatchingStyles1";
-        document.getElementById("testElementTwo").id = "testElementNoMatchingStyles2";
-        var forceStyleRecalc = document.body.offsetTop;
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    document.getElementById("testElementOne").id = "testElementNoMatchingStyles1";
+    document.getElementById("testElementTwo").id = "testElementNoMatchingStyles2";
+    var forceStyleRecalc = document.body.offsetTop;
+    return waitForFrame();
 }
 
-function changeIdAndDisplay(callback)
+function changeIdAndDisplay()
 {
-    requestAnimationFrame(function() {
-        document.getElementById("testElementNoMatchingStyles1").id = "testElementFour";
-        document.getElementById("testElementNoMatchingStyles2").id = "testElementFive";
-        var forceStyleRecalc = document.body.offsetTop;
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    document.getElementById("testElementNoMatchingStyles1").id = "testElementFour";
+    document.getElementById("testElementNoMatchingStyles2").id = "testElementFive";
+    var forceStyleRecalc = document.body.offsetTop;
+    return waitForFrame();
 }
 
-function changeStyleAttributeAndDisplay(callback)
+function changeStyleAttributeAndDisplay()
 {
-    requestAnimationFrame(function() {
-        document.getElementById("testElementFour").setAttribute("style", "color: purple");
-        document.getElementById("testElementFive").setAttribute("style", "color: pink");
-        var forceStyleRecalc = document.body.offsetTop;
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    document.getElementById("testElementFour").setAttribute("style", "color: purple");
+    document.getElementById("testElementFive").setAttribute("style", "color: pink");
+    var forceStyleRecalc = document.body.offsetTop;
+    return waitForFrame();
 }
 
-function changeAttributeAndDisplay(callback)
+function changeAttributeAndDisplay()
 {
-    requestAnimationFrame(function() {
-        document.getElementById("testElementFour").setAttribute("dir", "rtl");
-        document.getElementById("testElementFive").setAttribute("dir", "rtl");
-        var forceStyleRecalc = document.body.offsetTop;
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    document.getElementById("testElementFour").setAttribute("dir", "rtl");
+    document.getElementById("testElementFive").setAttribute("dir", "rtl");
+    var forceStyleRecalc = document.body.offsetTop;
+    return waitForFrame();
 }
 
-function changePseudoAndDisplay(callback)
+function changePseudoAndDisplay()
 {
-    requestAnimationFrame(function() {
-        var element1 = document.getElementById("testElementFour");
-        var element2 = document.getElementById("testElementFive");
-        eventSender.mouseMoveTo(element2.offsetLeft + 2, element2.offsetTop + 2);
-        requestAnimationFrame(function() {
-            var forceStyleRecalc = document.body.offsetTop;
-            if (window.testRunner)
-                testRunner.layoutAndPaintAsyncThen(callback);
-        });
+    var element1 = document.getElementById("testElementFour");
+    var element2 = document.getElementById("testElementFive");
+    eventSender.mouseMoveTo(element2.offsetLeft + 2, element2.offsetTop + 2);
+    return waitForFrame().then(function() {
+        var forceStyleRecalc = document.body.offsetTop;
+        return waitForFrame();
     });
 }
 
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations-expected.txt
index ae643db..f5b2caca 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations-expected.txt
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations-expected.txt
@@ -8,7 +8,7 @@
 Running: testLocalFrame
 first recalc style invalidations[
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:10}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:9}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -19,7 +19,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:11}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:10}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -34,7 +34,7 @@
 Running: multipleStyleRecalcs
 first recalc style invalidations[
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:25}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:21}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -47,7 +47,7 @@
 ]
 second recalc style invalidations[
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:27}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:23}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -58,7 +58,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:28}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:24}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -71,7 +71,7 @@
 ]
 third recalc style invalidations[
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:30}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:26}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -82,7 +82,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:31}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:27}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -93,7 +93,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:32}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:28}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -108,7 +108,7 @@
 Running: testSubframe
 first recalc style invalidations[
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:43}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:35}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
@@ -119,7 +119,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:44}
+        cause : {reason: Inline CSS style declaration was mutated, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html:36}
         changedAttribute : undefined
         changedClass : undefined
         changedId : undefined
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html
index 3cac78a4..0123f07 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-with-invalidations.html
@@ -4,48 +4,38 @@
 <script src="../../../http/tests/inspector/inspector-test.js"></script>
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
-function changeStylesAndDisplay(callback)
+function changeStylesAndDisplay()
 {
-    requestAnimationFrame(function() {
-        document.getElementById("testElementOne").style.color = "red";
-        document.getElementById("testElementTwo").style.color = "blue";
-        var forceLayout = document.body.offsetTop;
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    document.getElementById("testElementOne").style.color = "red";
+    document.getElementById("testElementTwo").style.color = "blue";
+    var forceLayout = document.body.offsetTop;
+    return waitForFrame();
 }
 
-function changeMultipleStylesAndDisplay(callback)
+function changeMultipleStylesAndDisplay()
 {
-    requestAnimationFrame(function() {
-        var elementOne = document.getElementById("testElementOne");
-        var elementTwo = document.getElementById("testElementTwo");
-        var elementThree = document.getElementById("testElementThree");
+    var elementOne = document.getElementById("testElementOne");
+    var elementTwo = document.getElementById("testElementTwo");
+    var elementThree = document.getElementById("testElementThree");
 
-        elementOne.style.backgroundColor = "orangered";
-        var forceStyleRecalc1 = document.body.offsetTop;
-        elementOne.style.color = "mediumvioletred";
-        elementTwo.style.color = "deepskyblue";
-        var forceStyleRecalc2 = document.body.offsetTop;
-        elementOne.style.color = "tomato";
-        elementTwo.style.color = "mediumslateblue";
-        elementThree.style.color = "mediumspringgreen";
-        var forceStyleRecalc3 = document.body.offsetTop;
-
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    elementOne.style.backgroundColor = "orangered";
+    var forceStyleRecalc1 = document.body.offsetTop;
+    elementOne.style.color = "mediumvioletred";
+    elementTwo.style.color = "deepskyblue";
+    var forceStyleRecalc2 = document.body.offsetTop;
+    elementOne.style.color = "tomato";
+    elementTwo.style.color = "mediumslateblue";
+    elementThree.style.color = "mediumspringgreen";
+    var forceStyleRecalc3 = document.body.offsetTop;
+    return waitForFrame();
 }
 
-function changeSubframeStylesAndDisplay(callback)
+function changeSubframeStylesAndDisplay()
 {
-    requestAnimationFrame(function() {
-        frames[0].document.body.style.backgroundColor = "papayawhip";
-        frames[0].document.body.children[0].style.width = "200px";
-        var forceLayout = frames[0].document.body.offsetTop;
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    frames[0].document.body.style.backgroundColor = "papayawhip";
+    frames[0].document.body.children[0].style.width = "200px";
+    var forceLayout = frames[0].document.body.offsetTop;
+    return waitForFrame();
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations-expected.txt
index 2d1031b..83f5bb5 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations-expected.txt
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations-expected.txt
@@ -8,7 +8,7 @@
 Running: testLocalFrame
 first recalculate styles[
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:10}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:9}
         changedAttribute : undefined
         changedClass : "red"
         changedId : undefined
@@ -20,7 +20,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:11}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:10}
         changedAttribute : undefined
         changedClass : "red"
         changedId : undefined
@@ -36,7 +36,7 @@
 Running: multipleStyleRecalcs
 first recalculate styles[
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:24}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:20}
         changedAttribute : undefined
         changedClass : "green"
         changedId : undefined
@@ -48,7 +48,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:24}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:20}
         changedAttribute : undefined
         changedClass : "red"
         changedId : undefined
@@ -62,7 +62,7 @@
 ]
 second recalculate styles[
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:26}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:22}
         changedAttribute : undefined
         changedClass : "blue"
         changedId : undefined
@@ -74,7 +74,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:26}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:22}
         changedAttribute : undefined
         changedClass : "green"
         changedId : undefined
@@ -86,7 +86,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:27}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:23}
         changedAttribute : undefined
         changedClass : "blue"
         changedId : undefined
@@ -98,7 +98,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:27}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:23}
         changedAttribute : undefined
         changedClass : "red"
         changedId : undefined
@@ -112,7 +112,7 @@
 ]
 third recalculate styles[
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:29}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:25}
         changedAttribute : undefined
         changedClass : "snow"
         changedId : undefined
@@ -124,7 +124,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:29}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:25}
         changedAttribute : undefined
         changedClass : "blue"
         changedId : undefined
@@ -136,7 +136,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:30}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:26}
         changedAttribute : undefined
         changedClass : "snow"
         changedId : undefined
@@ -148,7 +148,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:30}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:26}
         changedAttribute : undefined
         changedClass : "blue"
         changedId : undefined
@@ -160,7 +160,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:31}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:27}
         changedAttribute : undefined
         changedClass : "snow"
         changedId : undefined
@@ -176,7 +176,7 @@
 Running: testSubframe
 first recalculate styles[
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:45}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:38}
         changedAttribute : undefined
         changedClass : "green"
         changedId : undefined
@@ -190,7 +190,7 @@
 ]
 second recalculate styles[
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:47}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:40}
         changedAttribute : undefined
         changedClass : "blue"
         changedId : undefined
@@ -202,7 +202,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:47}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:40}
         changedAttribute : undefined
         changedClass : "green"
         changedId : undefined
@@ -214,7 +214,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:48}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:41}
         changedAttribute : undefined
         changedClass : "blue"
         changedId : undefined
@@ -228,7 +228,7 @@
 ]
 third recalculate styles[
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:50}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:43}
         changedAttribute : undefined
         changedClass : "snow"
         changedId : undefined
@@ -240,7 +240,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:50}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:43}
         changedAttribute : undefined
         changedClass : "blue"
         changedId : undefined
@@ -252,7 +252,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:51}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:44}
         changedAttribute : undefined
         changedClass : "snow"
         changedId : undefined
@@ -264,7 +264,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:51}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:44}
         changedAttribute : undefined
         changedClass : "blue"
         changedId : undefined
@@ -276,7 +276,7 @@
         type : "StyleRecalcInvalidationTracking"
     }
     {
-        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:52}
+        cause : {reason: Element has pending invalidation list, stackTrace: .../inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html:45}
         changedAttribute : undefined
         changedClass : "snow"
         changedId : undefined
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html
index 5ab8b8e..400a439 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.html
@@ -4,56 +4,47 @@
 <script src="../../../http/tests/inspector/inspector-test.js"></script>
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
-function changeStylesAndDisplay(callback)
+function changeStylesAndDisplay()
 {
-    requestAnimationFrame(function() {
-        document.getElementById("testElementOne").className = "red";
-        document.getElementById("testElementTwo").className = "red";
-        var forceStyleRecalc = document.body.offsetTop;
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    document.getElementById("testElementOne").className = "red";
+    document.getElementById("testElementTwo").className = "red";
+    var forceStyleRecalc = document.body.offsetTop;
+    return waitForFrame();
 }
 
-function changeMultipleStylesAndDisplay(callback)
+function changeMultipleStylesAndDisplay()
 {
-    requestAnimationFrame(function() {
-        var elementOne = document.getElementById("testElementOne");
-        var elementTwo = document.getElementById("testElementTwo");
-        var elementThree = document.getElementById("testElementThree");
-        elementOne.className = "green";
-        var forceStyleRecalc1 = document.body.offsetTop;
-        elementOne.className = "blue";
-        elementTwo.className = "blue";
-        var forceStyleRecalc2 = document.body.offsetTop;
-        elementOne.className = "snow";
-        elementTwo.className = "snow";
-        elementThree.className = "snow";
-        var forceStyleRecalc3 = document.body.offsetTop;
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    var elementOne = document.getElementById("testElementOne");
+    var elementTwo = document.getElementById("testElementTwo");
+    var elementThree = document.getElementById("testElementThree");
+    elementOne.className = "green";
+    var forceStyleRecalc1 = document.body.offsetTop;
+    elementOne.className = "blue";
+    elementTwo.className = "blue";
+    var forceStyleRecalc2 = document.body.offsetTop;
+    elementOne.className = "snow";
+    elementTwo.className = "snow";
+    elementThree.className = "snow";
+    var forceStyleRecalc3 = document.body.offsetTop;
+    return waitForFrame();
 }
 
-function changeMultipleSubframeStylesAndDisplay(callback)
+function changeMultipleSubframeStylesAndDisplay()
 {
-    requestAnimationFrame(function() {
-        var innerDocument = frames[0].document;
-        var elementOne = innerDocument.getElementById("testElementOne");
-        var elementTwo = innerDocument.getElementById("testElementTwo");
-        var elementThree = innerDocument.getElementById("testElementThree");
-        elementOne.className = "green";
-        var forceStyleRecalc1 = innerDocument.body.offsetTop;
-        elementOne.className = "blue";
-        elementTwo.className = "blue";
-        var forceStyleRecalc2 = innerDocument.body.offsetTop;
-        elementOne.className = "snow";
-        elementTwo.className = "snow";
-        elementThree.className = "snow";
-        var forceStyleRecalc3 = innerDocument.body.offsetTop;
-        if (window.testRunner)
-            testRunner.layoutAndPaintAsyncThen(callback);
-    });
+    var innerDocument = frames[0].document;
+    var elementOne = innerDocument.getElementById("testElementOne");
+    var elementTwo = innerDocument.getElementById("testElementTwo");
+    var elementThree = innerDocument.getElementById("testElementThree");
+    elementOne.className = "green";
+    var forceStyleRecalc1 = innerDocument.body.offsetTop;
+    elementOne.className = "blue";
+    elementTwo.className = "blue";
+    var forceStyleRecalc2 = innerDocument.body.offsetTop;
+    elementOne.className = "snow";
+    elementTwo.className = "snow";
+    elementThree.className = "snow";
+    var forceStyleRecalc3 = innerDocument.body.offsetTop;
+    return waitForFrame();
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-time/timeline-timer-expected.txt b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-time/timeline-timer-expected.txt
index 4875c48..747ec425 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-time/timeline-timer-expected.txt
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-time/timeline-timer-expected.txt
@@ -15,7 +15,7 @@
     startTime : <number>
     type : "TimerInstall"
 }
-Text details for TimerInstall: timeline-timer.html:9
+Text details for TimerInstall: timeline-timer.html:11
 TimerInstall Properties:
 {
     data : {
@@ -31,7 +31,7 @@
     startTime : <number>
     type : "TimerInstall"
 }
-Text details for TimerInstall: timeline-timer.html:10
+Text details for TimerInstall: timeline-timer.html:12
 TimerFire Properties:
 {
     data : {
@@ -43,7 +43,7 @@
     startTime : <number>
     type : "TimerFire"
 }
-Text details for TimerFire: timeline-timer.html:9
+Text details for TimerFire: timeline-timer.html:11
 TimerFire Properties:
 {
     data : {
@@ -55,7 +55,7 @@
     startTime : <number>
     type : "TimerFire"
 }
-Text details for TimerFire: timeline-timer.html:10
+Text details for TimerFire: timeline-timer.html:12
 TimerFire Properties:
 {
     data : {
@@ -67,7 +67,7 @@
     startTime : <number>
     type : "TimerFire"
 }
-Text details for TimerFire: timeline-timer.html:10
+Text details for TimerFire: timeline-timer.html:12
 TimerRemove Properties:
 {
     data : {
@@ -81,7 +81,7 @@
     startTime : <number>
     type : "TimerRemove"
 }
-Text details for TimerRemove: timeline-timer.html:17
+Text details for TimerRemove: timeline-timer.html:19
 FunctionCall Properties:
 {
     data : {
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-time/timeline-timer-fired-from-eval-call-site.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-time/timeline-timer-fired-from-eval-call-site.html
index 7bc3e4d..408bebd 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-time/timeline-timer-fired-from-eval-call-site.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-time/timeline-timer-fired-from-eval-call-site.html
@@ -4,10 +4,10 @@
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
 
-function performActions(callback)
+function performActions()
 {
-    window.callWhenDone = callback;
-    var content = "" + 
+    var promise = new Promise((fulfill) => window.callWhenDone = fulfill);
+    var content = "" +
         "var fn2 = function() {" +
         "    console.markTimeline(\"Script evaluated\");" +
         "    window.callWhenDone();" +
@@ -23,6 +23,7 @@
     scriptElement.appendChild(contentNode);
     document.body.appendChild(scriptElement);
     document.body.removeChild(scriptElement);
+    return promise;
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-time/timeline-timer.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-time/timeline-timer.html
index beaed25..4b6370c5 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-time/timeline-timer.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-time/timeline-timer.html
@@ -4,8 +4,10 @@
 <script src="../../../http/tests/inspector/timeline-test.js"></script>
 <script>
 
-function performActions(callback)
+function performActions()
 {
+    var callback;
+    var promise = new Promise((fulfill) => callback = fulfill);
     var timerOne = setTimeout("1 + 1", 10);
     var timerTwo = setInterval(intervalTimerWork, 20);
     var iteration = 0;
@@ -17,6 +19,7 @@
         clearInterval(timerTwo);
         callback();
     }
+    return promise;
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/worker-events.html b/third_party/WebKit/LayoutTests/inspector/tracing/worker-events.html
index 54a66c6..52544d0a 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/worker-events.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/worker-events.html
@@ -25,15 +25,11 @@
     }
 }
 
-function startSecondWorker(onActionComplete)
+function startSecondWorker()
 {
     worker2 = new Worker("resources/worker.js");
     worker2.postMessage("");
-    worker2.onmessage = function(event)
-    {
-        onActionComplete();
-        worker2.onmessage = null;
-    }
+    return new Promise((fulfill) => worker2.onmessage = fulfill);
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/worker-js-frames.html b/third_party/WebKit/LayoutTests/inspector/tracing/worker-js-frames.html
index 8be42e0..efb2a97 100644
--- a/third_party/WebKit/LayoutTests/inspector/tracing/worker-js-frames.html
+++ b/third_party/WebKit/LayoutTests/inspector/tracing/worker-js-frames.html
@@ -33,8 +33,10 @@
     }
 }
 
-function startSecondWorker(onActionComplete)
+function startSecondWorker()
 {
+    var callback;
+    var promise = new Promise((fulfill) => callback = fulfill);
     // Make sure there is at least one trace event recorded for the first worker.
     worker1.onmessage = gotResponseFromFirstWorker;
     worker1.postMessage("");
@@ -50,9 +52,10 @@
         {
             worker2.onmessage = null;
             makeDOMEvent();
-            onActionComplete();
+            callback();
         }
     }
+    return promise;
 }
 
 function test()
diff --git a/third_party/WebKit/LayoutTests/virtual/threaded/inspector/tracing/idle-callback-expected.txt b/third_party/WebKit/LayoutTests/virtual/threaded/inspector/tracing/idle-callback-expected.txt
index 91a580f..524a294 100644
--- a/third_party/WebKit/LayoutTests/virtual/threaded/inspector/tracing/idle-callback-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/threaded/inspector/tracing/idle-callback-expected.txt
@@ -14,21 +14,6 @@
     startTime : <number>
     type : "RequestIdleCallback"
 }
-Text details for RequestIdleCallback: idle-callback.html:8
-RequestIdleCallback Properties:
-{
-    data : {
-        frame : <string>
-        id : <number>
-        stackTrace : <object>
-        timeout : 0
-    }
-    endTime : <number>
-    frameId : <string>
-    stackTrace : <object>
-    startTime : <number>
-    type : "RequestIdleCallback"
-}
 Text details for RequestIdleCallback: idle-callback.html:10
 RequestIdleCallback Properties:
 {
@@ -44,7 +29,22 @@
     startTime : <number>
     type : "RequestIdleCallback"
 }
-Text details for RequestIdleCallback: idle-callback.html:13
+Text details for RequestIdleCallback: idle-callback.html:12
+RequestIdleCallback Properties:
+{
+    data : {
+        frame : <string>
+        id : <number>
+        stackTrace : <object>
+        timeout : 0
+    }
+    endTime : <number>
+    frameId : <string>
+    stackTrace : <object>
+    startTime : <number>
+    type : "RequestIdleCallback"
+}
+Text details for RequestIdleCallback: idle-callback.html:15
 CancelIdleCallback Properties:
 {
     data : {
@@ -58,7 +58,7 @@
     startTime : <number>
     type : "CancelIdleCallback"
 }
-Text details for CancelIdleCallback: idle-callback.html:9
+Text details for CancelIdleCallback: idle-callback.html:11
 FireIdleCallback Properties:
 {
     data : {
@@ -72,7 +72,7 @@
     startTime : <number>
     type : "FireIdleCallback"
 }
-Text details for FireIdleCallback: idle-callback.html:10
+Text details for FireIdleCallback: idle-callback.html:12
 FireIdleCallback Properties:
 {
     data : {
@@ -86,6 +86,6 @@
     startTime : <number>
     type : "FireIdleCallback"
 }
-Text details for FireIdleCallback: idle-callback.html:13
+Text details for FireIdleCallback: idle-callback.html:15
 FireIdleCallback has a warning
 
diff --git a/third_party/WebKit/LayoutTests/virtual/threaded/inspector/tracing/idle-callback.html b/third_party/WebKit/LayoutTests/virtual/threaded/inspector/tracing/idle-callback.html
index 6f7ae12..d0437f0 100644
--- a/third_party/WebKit/LayoutTests/virtual/threaded/inspector/tracing/idle-callback.html
+++ b/third_party/WebKit/LayoutTests/virtual/threaded/inspector/tracing/idle-callback.html
@@ -3,8 +3,10 @@
 <script src="../../../../http/tests/inspector/inspector-test.js"></script>
 <script src="../../../../http/tests/inspector/timeline-test.js"></script>
 <script>
-function performActions(callback)
+function performActions()
 {
+    var callback;
+    var promise = new Promise((fulfill) => callback = fulfill);
     var requestId = window.requestIdleCallback(idleCallback);
     window.cancelIdleCallback(requestId);
     window.requestIdleCallback(idleCallback);
@@ -18,6 +20,7 @@
         if (callback)
             callback();
     }
+    return promise;
 }
 
 function test()