Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <title>Sticky positioned element should behave correctly when style changes</tit le> | |
|
flackr
2017/05/31 21:10:23
same as below comment. "behave correctly" is a lit
yigu
2017/05/31 21:31:33
Done.
| |
| 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 beh aves correctly when style changes." /> | |
|
flackr
2017/05/31 21:10:23
Same
yigu
2017/05/31 21:31:33
Done.
| |
| 5 | |
| 6 <script src="/resources/testharness.js"></script> | |
| 7 <script src="/resources/testharnessreport.js"></script> | |
| 8 | |
| 9 <style> | |
| 10 body { | |
| 11 margin: 0; | |
| 12 } | |
| 13 | |
| 14 .container { | |
| 15 overflow: scroll; | |
| 16 width: 200px; | |
| 17 height: 200px; | |
| 18 } | |
| 19 | |
| 20 .spacer { | |
| 21 height: 2000px; | |
| 22 } | |
| 23 | |
| 24 .box { | |
| 25 width: 100px; | |
| 26 height: 100px; | |
| 27 background-color: green; | |
| 28 top: 50px; | |
| 29 } | |
| 30 | |
| 31 .sticky { | |
| 32 position: sticky; | |
| 33 } | |
| 34 </style> | |
| 35 | |
| 36 <div id="scroller" class="container"> | |
| 37 <div id="sticky" class="sticky box"></div> | |
| 38 <div class="spacer"></div> | |
| 39 </div> | |
| 40 | |
| 41 <script> | |
| 42 test(() => { | |
| 43 var element = document.getElementById('sticky'); | |
| 44 assert_equals(element.getBoundingClientRect().top, 50); | |
| 45 document.getElementById('scroller').scrollTop = 100; | |
| 46 assert_equals(element.getBoundingClientRect().top, 50); | |
| 47 sticky.style.position = 'relative'; | |
| 48 assert_equals(element.getBoundingClientRect().top, -50); | |
| 49 sticky.style.position = 'sticky'; | |
| 50 assert_equals(element.getBoundingClientRect().top, 50); | |
| 51 }, 'sticky positioned element should behaves correctly upon style changes.'); | |
|
flackr
2017/05/31 21:10:23
nit: title should exactly reflect the test. How ab
yigu
2017/05/31 21:31:33
Done.
| |
| 52 </script> | |
| 53 | |
| OLD | NEW |