| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script> |
| 3 if (window.internals) { |
| 4 internals.settings.setCSSStickyPositionEnabled(true); |
| 5 } |
| 6 </script> |
| 7 |
| 8 <html> |
| 9 <head> |
| 10 <style> |
| 11 html { |
| 12 overflow: hidden; /* hide scrollbars */ |
| 13 } |
| 14 |
| 15 body { |
| 16 margin: 0; |
| 17 } |
| 18 |
| 19 .container { |
| 20 height: 2000px; |
| 21 } |
| 22 |
| 23 .box { |
| 24 height: 50px; |
| 25 } |
| 26 |
| 27 .sticky { |
| 28 position: sticky; |
| 29 top: 50px; |
| 30 background-color: green; |
| 31 } |
| 32 </style> |
| 33 <script> |
| 34 if (window.testRunner) |
| 35 testRunner.waitUntilDone() |
| 36 |
| 37 function doTest() |
| 38 { |
| 39 const sticky = document.querySelector('.sticky'); |
| 40 sticky.style.position = 'relative'; |
| 41 |
| 42 // Force layout. |
| 43 sticky.offsetTop; |
| 44 |
| 45 sticky.style.position = 'sticky'; |
| 46 |
| 47 window.requestAnimationFrame(function() { |
| 48 window.scrollTo(0, 100); |
| 49 if (window.testRunner) |
| 50 testRunner.notifyDone(); |
| 51 }); |
| 52 } |
| 53 |
| 54 window.addEventListener('load', function() { |
| 55 // We require the compositings inputs to be clean (and thus the initial |
| 56 // sticky position to be calculated) before we stat changing things. |
| 57 // Force this by waiting for a double rAF. |
| 58 window.requestAnimationFrame(function() { |
| 59 window.requestAnimationFrame(doTest); |
| 60 }); |
| 61 }); |
| 62 </script> |
| 63 </head> |
| 64 <body> |
| 65 <div class="container"> |
| 66 <div class="sticky box"></div> |
| 67 </div> |
| 68 </body> |
| 69 </html> |
| OLD | NEW |