OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/testharness.js"></script> |
| 3 <script src="../../../resources/testharnessreport.js"></script> |
| 4 <style> |
| 5 body { |
| 6 margin: 0; |
| 7 } |
| 8 |
| 9 #scroller { |
| 10 height: 100px; |
| 11 width: 200px; |
| 12 overflow: scroll; |
| 13 } |
| 14 |
| 15 .padding { |
| 16 width: 400px; |
| 17 height: 500px; |
| 18 } |
| 19 |
| 20 #sticky { |
| 21 width: 25px; |
| 22 height: 25px; |
| 23 position: sticky; |
| 24 top: 20px; |
| 25 left: 50px; |
| 26 } |
| 27 </style> |
| 28 |
| 29 <div id="scroller"> |
| 30 <div id="sticky"></div> |
| 31 <div class="padding"></div> |
| 32 </div> |
| 33 |
| 34 <script> |
| 35 if (window.internals) { |
| 36 internals.settings.setCSSStickyPositionEnabled(true); |
| 37 } |
| 38 |
| 39 test(function() { |
| 40 var scroller = document.getElementById('scroller'); |
| 41 var sticky = document.getElementById('sticky'); |
| 42 scroller.scrollTop = 100; |
| 43 scroller.scrollLeft = 50; |
| 44 scroller.append(document.createElement('div')); |
| 45 assert_equals(sticky.getBoundingClientRect().top, 20); |
| 46 assert_equals(sticky.getBoundingClientRect().left, 50); |
| 47 }, "getBoundingClientRect should be correct for sticky after script-caused layou
t"); |
| 48 |
| 49 test(function() { |
| 50 var scroller = document.getElementById('scroller'); |
| 51 var sticky = document.getElementById('sticky'); |
| 52 scroller.scrollTop = 100; |
| 53 scroller.scrollLeft = 50; |
| 54 scroller.append(document.createElement('div')); |
| 55 assert_equals(sticky.offsetTop, 120); |
| 56 assert_equals(sticky.offsetLeft, 100); |
| 57 }, "offsetTop/offsetLeft should be correct for sticky after script-caused layout
"); |
| 58 </script> |
OLD | NEW |