| <!DOCTYPE html> |
| <title>Changing the ancestor scroller of a position:sticky element should not crash</title> |
| <link rel="help" href="https://www.w3.org/TR/css-position-3/#sticky-pos" /> |
| <meta name="assert" content="This test checks that changing the ancestor scroller of a position:sticky element should not crash." /> |
| |
| <script src="../../../resources/testharness.js"></script> |
| <script src="../../../resources/testharnessreport.js"></script> |
| |
| <style> |
| .outerScroller { |
| position: relative; |
| overflow: scroll; |
| height: 500px; |
| width: 100px; |
| } |
| |
| .innerScroller { |
| position: relative; |
| height: 100px; |
| } |
| |
| .sticky { |
| position: sticky; |
| top: 0; |
| height: 50px; |
| width: 50px; |
| } |
| |
| .padding { |
| height: 200px; |
| } |
| </style> |
| |
| <div class='outerScroller'> |
| <div class='innerScroller'> |
| <div class='sticky'></div> |
| <div class='padding'></div> |
| </div> |
| </div> |
| |
| <script> |
| test(() => { |
| var outerScroller = document.querySelector('.outerScroller'); |
| var innerScroller = document.querySelector('.innerScroller'); |
| var sticky = document.querySelector('.sticky'); |
| |
| // Querying the offsetTop will force compositing inputs update, setting the |
| // outer scroller as the ancestor scroller of the sticky element. |
| var offsetTop = sticky.offsetTop; |
| |
| // Make the outer scroller non-scrollable (i.e. overflow: visible), and the |
| // inner scroller into an actual scroller. |
| outerScroller.style.overflow = 'visible'; |
| innerScroller.style.overflow = 'scroll'; |
| |
| // Querying the offsetTop will force compositing inputs update. This update will |
| // change the ancestor scroller from the (now non-scrollable) outer scroller |
| // to the inner one, and should not crash. |
| offsetTop = sticky.offsetTop; |
| }, 'Transitioning a sticky away from an ancestor overflow layer that does not have a scrollable area should not crash'); |
| </script> |