Chromium Code Reviews| 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')); | |
|
flackr
2017/01/23 16:43:50
Can we have a test which inserts the sticky elemen
smcgruer
2017/01/24 15:26:30
Fantastic idea. This actually helped expose that m
| |
| 55 assert_equals(sticky.offsetTop, 120); | |
| 56 }, "offsetTop should be correct for sticky after script-caused layout"); | |
| 57 | |
| 58 test(function() { | |
| 59 var scroller = document.getElementById('scroller'); | |
| 60 var sticky = document.getElementById('sticky'); | |
| 61 scroller.scrollTop = 100; | |
| 62 scroller.scrollLeft = 50; | |
| 63 scroller.append(document.createElement('div')); | |
| 64 assert_equals(sticky.offsetLeft, 100); | |
| 65 }, "offsetLeft should be correct for sticky after script-caused layout"); | |
|
flackr
2017/01/23 16:43:50
offsetTop and offsetLeft could probably be a singl
smcgruer
2017/01/24 15:26:30
Done.
| |
| 66 </script> | |
| OLD | NEW |