position-sticky-root-scroller.html (821B)
1 <!DOCTYPE html> 2 <title>position:sticky should operate correctly for the root scroller</title> 3 <link rel="help" href="https://www.w3.org/TR/css-position-3/#sticky-pos" /> 4 <meta name="assert" content="This test checks that position:sticky elements work when using the root (document) scroller" /> 5 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 9 <style> 10 body { 11 /* Assumption: 3000px is taller than any user agents test window size. */ 12 height: 3000px; 13 } 14 15 #sticky { 16 position: sticky; 17 top: 50px; 18 width: 200px; 19 height: 200px; 20 background-color: green; 21 } 22 </style> 23 24 <div id="sticky"></div> 25 26 <script> 27 test(() => { 28 window.scrollTo(0, 700); 29 assert_equals(sticky.offsetTop, 700 + 50); 30 }, 'Sticky elements work with the root (document) scroller'); 31 </script>