| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> | 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> |
| 4 <script> | 4 <script> |
| 5 function startAnimation() | 5 function startAnimation() |
| 6 { | 6 { |
| 7 node.animate([{ width: "1000px" }, { width: "2000px" }], 1000); | 7 node.animate([{ width: "1000px" }, { width: "2000px" }], 1000); |
| 8 } | 8 } |
| 9 | 9 |
| 10 function rafWidth(resolve, reject) | 10 function rafWidth(resolve, reject) |
| 11 { | 11 { |
| 12 function frameCallback() | 12 var callback; |
| 13 { | 13 var promise = new Promise((fulfill) => callback = fulfill); |
| 14 resolve(node.offsetWidth); | |
| 15 } | |
| 16 | |
| 17 if (window.testRunner) | 14 if (window.testRunner) |
| 18 testRunner.layoutAndPaintAsyncThen(frameCallback); | 15 testRunner.layoutAndPaintAsyncThen(() => callback(node.offsetWidth)); |
| 16 return promise; |
| 19 } | 17 } |
| 20 | 18 |
| 21 function test() | 19 function test() |
| 22 { | 20 { |
| 23 InspectorTest.eventHandler["Animation.animationStarted"] = onStarted; | 21 InspectorTest.eventHandler["Animation.animationStarted"] = onStarted; |
| 24 InspectorTest.sendCommand("Animation.enable", {}); | 22 InspectorTest.sendCommand("Animation.enable", {}); |
| 25 InspectorTest.evaluateInPage("startAnimation()", function() {}); | 23 InspectorTest.evaluateInPage("startAnimation()", function() {}); |
| 26 | 24 |
| 27 function onStarted(response) | 25 function onStarted(response) |
| 28 { | 26 { |
| 29 InspectorTest.log("Animation started"); | 27 InspectorTest.log("Animation started"); |
| 30 seekAnimation(response.params.animation.id); | 28 seekAnimation(response.params.animation.id); |
| 31 } | 29 } |
| 32 | 30 |
| 33 function seekAnimation(id) | 31 function seekAnimation(id) |
| 34 { | 32 { |
| 35 InspectorTest.sendCommand("Animation.seekAnimations", { animations: [ id
], currentTime: 2000 }, logWidth); | 33 InspectorTest.sendCommand("Animation.seekAnimations", { animations: [ id
], currentTime: 2000 }, logWidth); |
| 36 } | 34 } |
| 37 | 35 |
| 38 function logWidth() | 36 function logWidth() |
| 39 { | 37 { |
| 40 InspectorTest.invokePageFunctionPromise("rafWidth", []).then(function(re
sult) { | 38 InspectorTest.evaluateInPageAsync("rafWidth()") |
| 41 InspectorTest.log(result); | 39 .then(function(result) { |
| 42 InspectorTest.completeTest(); | 40 InspectorTest.log(result); |
| 43 }); | 41 InspectorTest.completeTest(); |
| 42 }); |
| 44 } | 43 } |
| 45 } | 44 } |
| 46 | 45 |
| 47 </script> | 46 </script> |
| 48 </head> | 47 </head> |
| 49 <body onload="runTest()"> | 48 <body onload="runTest()"> |
| 50 <div id="node" style="background-color: red; height: 100px; width: 100px"></
div> | 49 <div id="node" style="background-color: red; height: 100px; width: 100px"></
div> |
| 51 </body> | 50 </body> |
| 52 </html> | 51 </html> |
| OLD | NEW |