Chromium Code Reviews| 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 | 5 |
| 6 var animation; | 6 var animation; |
| 7 | 7 |
| 8 function startAnimation() | 8 function startAnimation() |
| 9 { | 9 { |
| 10 animation = node.animate([{ width: "100px" }, { width: "200px" }], 2000); | 10 animation = node.animate([{ width: "100px" }, { width: "200px" }], 2000); |
| 11 } | 11 } |
| 12 | 12 |
| 13 function getWidth() | 13 function getWidth() |
| 14 { | 14 { |
| 15 return node.offsetWidth; | 15 return node.offsetWidth; |
| 16 } | 16 } |
| 17 | 17 |
| 18 function rafWidth(resolve, reject) | 18 function rafWidth() |
| 19 { | 19 { |
| 20 function frameCallback() | 20 var callback; |
| 21 { | 21 var promise = new Promise((fulfill) => callback = fulfill); |
| 22 resolve(node.offsetWidth); | |
| 23 } | |
| 24 | |
| 25 if (window.testRunner) | 22 if (window.testRunner) |
| 26 testRunner.layoutAndPaintAsyncThen(frameCallback); | 23 testRunner.layoutAndPaintAsyncThen(() => callback(node.offsetWidth)); |
| 24 return promise; | |
| 27 } | 25 } |
| 28 | 26 |
| 29 window.debugTest = true; | |
| 30 function test() | 27 function test() |
| 31 { | 28 { |
| 32 InspectorTest.eventHandler["Animation.animationStarted"] = onStarted; | 29 InspectorTest.eventHandler["Animation.animationStarted"] = onStarted; |
| 33 InspectorTest.sendCommand("Animation.enable", {}); | 30 InspectorTest.sendCommand("Animation.enable", {}); |
| 34 InspectorTest.evaluateInPage("startAnimation()", function() {}); | 31 InspectorTest.evaluateInPage("startAnimation()", function() {}); |
| 35 | 32 |
| 36 function onStarted(response) | 33 function onStarted(response) |
| 37 { | 34 { |
| 38 InspectorTest.log("Animation started"); | 35 InspectorTest.log("Animation started"); |
| 39 InspectorTest.sendCommand("Animation.setPaused", { animations: [ respons e.params.animation.id ], paused: true }, animPaused); | 36 InspectorTest.sendCommand("Animation.setPaused", { animations: [ respons e.params.animation.id ], paused: true }, animPaused); |
| 40 } | 37 } |
| 41 | 38 |
| 42 function animPaused() | 39 function animPaused() |
| 43 { | 40 { |
| 44 InspectorTest.evaluateInPage("getWidth()", saveWidth); | 41 InspectorTest.evaluateInPage("getWidth()", saveWidth); |
| 45 } | 42 } |
| 46 | 43 |
| 47 function saveWidth(nodeWidth) | 44 function saveWidth(nodeWidth) |
| 48 { | 45 { |
| 49 var width = nodeWidth; | 46 InspectorTest.evaluateInPageAsync("rafWidth()") |
| 50 InspectorTest.invokePageFunctionPromise("rafWidth", []).then(function(re sult) { | 47 .then((result) => InspectorTest.log(result === nodeWidth)) |
| 51 InspectorTest.log(result === width); | 48 .then(() => InspectorTest.completeTest()); |
|
dgozman
2016/08/03 19:20:31
Don't do chain then() for synchronous code please.
kozy
2016/08/03 20:35:23
Done.
| |
| 52 InspectorTest.completeTest(); | |
| 53 }); | |
| 54 } | 49 } |
| 55 } | 50 } |
| 56 | 51 |
| 57 </script> | 52 </script> |
| 58 </head> | 53 </head> |
| 59 <body onload="runTest()"> | 54 <body onload="runTest()"> |
| 60 Tests that the animation is correctly paused. | 55 Tests that the animation is correctly paused. |
| 61 <div id="node" style="background-color: red; height: 100px"></div> | 56 <div id="node" style="background-color: red; height: 100px"></div> |
| 62 </body> | 57 </body> |
| 63 </html> | 58 </html> |
| OLD | NEW |