| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>Sticky positioned element should be observable by getBoundingClientRect.<
/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 sticky positioned element |
| 5 should be observable by getBoundingClientRect." /> |
| 6 |
| 7 <script src="/resources/testharness.js"></script> |
| 8 <script src="/resources/testharnessreport.js"></script> |
| 9 |
| 10 <style> |
| 11 body { |
| 12 margin: 0; |
| 13 } |
| 14 |
| 15 .container { |
| 16 overflow: scroll; |
| 17 width: 200px; |
| 18 height: 200px; |
| 19 } |
| 20 |
| 21 .spacer { |
| 22 height: 2000px; |
| 23 } |
| 24 |
| 25 .box { |
| 26 width: 100px; |
| 27 height: 100px; |
| 28 background-color: green; |
| 29 top: 50px; |
| 30 } |
| 31 |
| 32 .sticky { |
| 33 position: sticky; |
| 34 } |
| 35 </style> |
| 36 |
| 37 <div id="scroller" class="container"> |
| 38 <div id="sticky" class="sticky box"></div> |
| 39 <div class="spacer"></div> |
| 40 </div> |
| 41 |
| 42 <script> |
| 43 test(() => { |
| 44 var element = document.getElementById('sticky'); |
| 45 assert_equals(element.getBoundingClientRect().top, 50); |
| 46 document.getElementById('scroller').scrollTop = 100; |
| 47 assert_equals(element.getBoundingClientRect().top, 50); |
| 48 sticky.style.position = 'relative'; |
| 49 assert_equals(element.getBoundingClientRect().top, -50); |
| 50 sticky.style.position = 'sticky'; |
| 51 assert_equals(element.getBoundingClientRect().top, 50); |
| 52 }, 'sticky positioned element should be observable by getBoundingClientRect.'); |
| 53 </script> |
| 54 |
| OLD | NEW |