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 class="scroller" id="scroller"> |
| 30 <div class="padding" id="padding"></div> |
| 31 </div> |
| 32 |
| 33 <div class="scroller" id="scroller2"> |
| 34 <div class="padding" id="padding2"></div> |
| 35 </div> |
| 36 |
| 37 <script> |
| 38 if (window.internals) { |
| 39 internals.settings.setCSSStickyPositionEnabled(true); |
| 40 } |
| 41 |
| 42 test(function() { |
| 43 var scroller = document.getElementById('scroller'); |
| 44 scroller.scrollTop = 100; |
| 45 scroller.scrollLeft = 50; |
| 46 |
| 47 var sticky = document.createElement('div'); |
| 48 sticky.className = 'sticky'; |
| 49 scroller.insertBefore(sticky, document.getElementById('padding')); |
| 50 |
| 51 assert_equals(sticky.offsetTop, scroller.scrollTop + 20); |
| 52 assert_equals(sticky.offsetLeft, scroller.scrollLeft + 50); |
| 53 }, "offsetTop/offsetLeft should be correct for sticky after insertion"); |
| 54 |
| 55 test(function() { |
| 56 var scroller = document.getElementById('scroller2'); |
| 57 scroller.scrollTop = 100; |
| 58 scroller.scrollLeft = 50; |
| 59 |
| 60 var sticky = document.createElement('div'); |
| 61 sticky.className = 'sticky'; |
| 62 scroller.insertBefore(sticky, document.getElementById('padding2')); |
| 63 |
| 64 assert_equals(sticky.getBoundingClientRect().top, 120); |
| 65 assert_equals(sticky.getBoundingClientRect().left, 50); |
| 66 }, "getBoundingClientRect should be correct for sticky after insertion"); |
| 67 |
| 68 |
| 69 </script> |
OLD | NEW |