tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

position-sticky-dynamic-ancestor-001.html (1821B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <meta name="viewport" content="width=device-width">
      4 <title>Dynamic sticky position change doesn't break inner sticky positioned items</title>
      5 <link rel="help" href="https://drafts.csswg.org/css-position-3/#sticky-position">
      6 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1908242">
      7 <link rel="author" title="Emilio Cobos" href="mailto:emilio@crisal.io">
      8 <link rel="author" title="Mozilla" href="https://mozilla.org">
      9 <script src="/resources/testharness.js"></script>
     10 <script src="/resources/testharnessreport.js"></script>
     11 <style>
     12  body {
     13    margin: 0;
     14    display: flex;
     15  }
     16 
     17  #content {
     18    border: 10px dashed gray;
     19    height: 600vh;
     20  }
     21 
     22  #sidebar {
     23    align-self: start;
     24    background-color: white;
     25    border: 10px dashed gray;
     26    top: 0;
     27  }
     28 
     29  #sidebar-header {
     30    position: sticky;
     31    top: 0;
     32    background-color: rgba(255, 0, 0, .5);
     33  }
     34 
     35  #sidebar-content {
     36    padding: 5px;
     37    height: 200vh;
     38  }
     39 </style>
     40 <div id=content>
     41  CONTENT
     42 </div>
     43 <div id=sidebar>
     44  <div id=sidebar-header>
     45    SIDEBAR TOP STICKY
     46  </div>
     47  <div id=sidebar-content>
     48    SIDEBAR CONTENT
     49  </div>
     50 </div>
     51 <script>
     52 let sidebar = document.getElementById("sidebar");
     53 let sidebarHeader = document.getElementById("sidebar-header");
     54 test(function() {
     55  // Make the header and sidebar stick.
     56  window.scrollTo(0, 100);
     57  assert_less_than(sidebar.getBoundingClientRect().top, 0, "Sidebar should not be stuck (yet)");
     58  assert_equals(sidebarHeader.getBoundingClientRect().top, 0, "Sidebar header should be stuck");
     59  sidebar.style.position = "sticky";
     60  assert_equals(sidebar.getBoundingClientRect().top, 0, "Sidebar should be stuck now");
     61  assert_equals(sidebarHeader.getBoundingClientRect().top, 10, "Sidebar header should be stuck under sidebar border");
     62 });
     63 </script>