Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 | 2 |
| 3 <html> | 3 <html> |
| 4 <head> | 4 <head> |
| 5 <meta charset="utf-8"> | |
| 6 <script src="../resources/testharness.js"></script> | |
| 7 <script src="../resources/testharnessreport.js"></script> | |
| 5 <style> | 8 <style> |
| 6 #container { | 9 #container { |
| 7 position: relative; | 10 position: relative; |
| 8 width: 400px; | 11 width: 400px; |
| 9 height: 100px; | 12 height: 100px; |
| 10 border: 1px solid black; | 13 border: 1px solid black; |
| 11 } | 14 } |
| 12 #box { | 15 #box { |
| 13 position: absolute; | 16 position: absolute; |
| 14 left: 0px; | 17 left: 0px; |
| 15 height: 100px; | 18 height: 100px; |
| 16 width: 100px; | 19 width: 100px; |
| 17 background-color: blue; | 20 background-color: blue; |
| 18 transition-duration: 1s; | 21 transition-duration: 1s; |
| 19 transition-timing-function: linear; | 22 transition-timing-function: linear; |
| 20 } | 23 } |
| 21 </style> | 24 </style> |
| 22 <script> | |
| 23 if (window.testRunner) { | |
| 24 testRunner.dumpAsText(); | |
| 25 testRunner.waitUntilDone(); | |
| 26 } | |
| 27 | |
| 28 function startTransition() | |
| 29 { | |
| 30 var box = document.getElementById('box'); | |
| 31 box.style.left = '300px'; | |
| 32 box.style.opacity = 0.5; | |
| 33 window.setTimeout(function() { | |
| 34 box.style.left = '0px'; | |
| 35 | |
| 36 window.setTimeout(function() { | |
| 37 var boxPos = parseInt(window.getComputedStyle(box).left); | |
| 38 document.getElementById('result').innerHTML = (boxPos < 200) ? "PASS" : "FAIL"; | |
| 39 if (window.testRunner) | |
| 40 testRunner.notifyDone(); | |
| 41 }, 250); | |
| 42 }, 500); | |
| 43 } | |
| 44 window.addEventListener('load', startTransition, false) | |
| 45 </script> | |
| 46 </head> | 25 </head> |
| 47 <body> | 26 <body> |
| 48 | 27 |
| 49 <p>Box should start moving left after left style is reset after 500ms</p> | |
| 50 <div id="container"> | 28 <div id="container"> |
| 51 <div id="box"> | 29 <div id="box"> |
| 52 </div> | 30 </div> |
| 53 </div> | 31 </div> |
| 54 <div id="result"> | 32 <script> |
| 55 </div> | 33 'use strict'; |
| 34 | |
| 35 function waitForProgress() { | |
|
alancutter (OOO until 2018)
2017/01/11 04:17:29
Please link to bug here as explanation.
Eric Willigers
2017/01/11 06:11:41
Done.
| |
| 36 var initialLeft = getComputedStyle(box).left; | |
| 37 return new Promise(resolve => { | |
| 38 function poll() { | |
| 39 var currentLeft = getComputedStyle(box).left; | |
| 40 if (currentLeft === initialLeft) { | |
| 41 requestAnimationFrame(poll); | |
| 42 } else { | |
| 43 resolve(); | |
| 44 } | |
| 45 } | |
| 46 requestAnimationFrame(poll); | |
| 47 }); | |
| 48 } | |
| 49 | |
| 50 async_test(t => { | |
| 51 box.offsetTop; // Force style recalc | |
| 52 box.style.left = '300px'; | |
| 53 box.style.opacity = 0.5; | |
| 54 var previousLeft; | |
| 55 waitForProgress().then(() => { | |
| 56 previousLeft = getComputedStyle(box).left; | |
| 57 box.style.left = '0px'; | |
| 58 }).then(waitForProgress).then(t.step_func_done(() => { | |
| 59 var currentLeft = getComputedStyle(box).left; | |
| 60 assert_less_than(parseFloat(currentLeft), parseFloat(previousLeft)); | |
|
alancutter (OOO until 2018)
2017/01/10 08:42:42
We should see progress after a single raf.
Eric Willigers
2017/01/11 03:47:22
Ideally we would.
See https://bugs.chromium.org/p/
| |
| 61 })); | |
| 62 }, 'Box should start moving left after left style is reset'); | |
| 63 </script> | |
| 56 </body> | 64 </body> |
| 57 </html> | 65 </html> |
| OLD | NEW |