tor-browser

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

scrollbar-width-015.html (2753B)


      1 <!doctype html>
      2 <meta charset="utf-8">
      3 <title>CSS Scrollbars: scrollbar-width on scrollable areas correctly interacts with ::-webkit-scrollbar</title>
      4 <link rel="author" title="Luke Warlow" href="mailto:luke@warlow.dev" />
      5 <link rel="help" href="https://drafts.csswg.org/css-scrollbars-1/#width-compat" />
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <script src="/css/support/parsing-testcommon.js"></script>
      9 <style>
     10  .container {
     11    overflow: auto;
     12    height: 200px;
     13    width: 200px;
     14    margin: 1px;
     15    padding: 0px;
     16    border: none;
     17    background: deepskyblue;
     18  }
     19 
     20  .content {
     21    height: 300px;
     22    width: 100%;
     23    background: lightsalmon;
     24  }
     25 
     26  .container.auto {
     27    scrollbar-width: auto;
     28  }
     29 
     30  /* This is so that browsers that don't implement the WebKit prefix still pass the test */
     31  @supports not selector(::-webkit-scrollbar) {
     32    .container.auto {
     33      overflow: hidden;
     34    }
     35  }
     36 
     37  ::-webkit-scrollbar {
     38    display: none;
     39  }
     40 
     41  .container.thin {
     42    scrollbar-width: thin;
     43  }
     44 </style>
     45 <script>
     46  function performTest() {
     47    setup({ explicit_done: true });
     48 
     49    // ltr
     50 
     51    test(function () {
     52      let container = document.getElementById('container_auto');
     53      let content = document.getElementById('content_auto');
     54      assert_equals(container.scrollWidth, 200, "auto scrollWidth");
     55      assert_equals(container.clientWidth, 200, "auto clientWidth");
     56      assert_equals(container.offsetLeft, content.offsetLeft, "auto offsetLeft");
     57      assert_equals(container.clientWidth, content.clientWidth, "auto clientWidth");
     58      assert_equals(container.offsetWidth, content.offsetWidth, "auto offsetWidth");
     59    }, "scrollbar-width auto defers to ::-webkit-scrollbar");
     60 
     61    test(function () {
     62      let container = document.getElementById('container_thin');
     63      let content = document.getElementById('content_thin');
     64      assert_less_than(container.scrollWidth, container.offsetWidth, "thin scrollWidth");
     65      assert_less_than(container.clientWidth, container.offsetWidth, "thin clientWidth");
     66      assert_equals(container.offsetLeft, content.offsetLeft, "thin offsetLeft");
     67      assert_equals(container.clientWidth, content.clientWidth, "thin clientWidth");
     68      assert_not_equals(container.offsetWidth, content.offsetWidth, "thin offsetWidth");
     69    }, "scrollbar-width thin overrides ::-webkit-scrollbar");
     70 
     71    done();
     72  }
     73 </script>
     74 
     75 <body onload="performTest()">
     76 
     77  Test scrollbar-width: vertical scrollbar
     78 
     79  <div class="container auto" id="container_auto">
     80    <div class="content" id="content_auto">auto</div>
     81  </div>
     82 
     83  <div class="container thin" id="container_thin">
     84    <div class="content" id="content_thin">thin</div>
     85  </div>
     86 
     87 </body>