| 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 // It may take a number of frames before the property updates. |
| 36 // https://bugs.chromium.org/p/chromium/issues/detail?id=679981 |
| 37 function waitForProgress() { |
| 38 var initialLeft = getComputedStyle(box).left; |
| 39 return new Promise(resolve => { |
| 40 function poll() { |
| 41 var currentLeft = getComputedStyle(box).left; |
| 42 if (currentLeft === initialLeft) { |
| 43 requestAnimationFrame(poll); |
| 44 } else { |
| 45 resolve(); |
| 46 } |
| 47 } |
| 48 requestAnimationFrame(poll); |
| 49 }); |
| 50 } |
| 51 |
| 52 async_test(t => { |
| 53 box.offsetTop; // Force style recalc |
| 54 box.style.left = '300px'; |
| 55 box.style.opacity = 0.5; |
| 56 var previousLeft; |
| 57 waitForProgress().then(() => { |
| 58 previousLeft = getComputedStyle(box).left; |
| 59 box.style.left = '0px'; |
| 60 }).then(waitForProgress).then(t.step_func_done(() => { |
| 61 var currentLeft = getComputedStyle(box).left; |
| 62 assert_less_than(parseFloat(currentLeft), parseFloat(previousLeft)); |
| 63 })); |
| 64 }, 'Box should start moving left after left style is reset'); |
| 65 </script> |
| 56 </body> | 66 </body> |
| 57 </html> | 67 </html> |
| OLD | NEW |