tor-browser

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

scrollWidthHeight-overflow-visible-margin-collapsing.html (2132B)


      1 <!doctype html>
      2 <meta charset="utf-8">
      3 <meta name="viewport" content="width=device-width, initial-scale=1">
      4 <link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
      5 <link rel="author" title="Mozilla" href="https://mozilla.org">
      6 <link rel="help" href="https://drafts.csswg.org/cssom-view/#dom-element-scrollwidth">
      7 <link rel="help" href="https://drafts.csswg.org/cssom-view/#dom-element-scrollheight">
      8 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1936156">
      9 <title>scroll{Width,Height} shouldn't account for collapsed margins, in order not to report unnecessary overflow</title>
     10 <script src="/resources/testharness.js"></script>
     11 <script src="/resources/testharnessreport.js"></script>
     12 <style>
     13  #target div {
     14    height: 20px;
     15    min-width: 20px;
     16    background-color: green;
     17    margin: 20px 10px;
     18  }
     19 </style>
     20 <div id="target">
     21  <div>
     22    <div></div>
     23  </div>
     24  <div></div>
     25  <div></div>
     26  <div></div>
     27 </div>
     28 <script>
     29 let target = document.getElementById("target");
     30 // "clip" is not really scrollable, but should match as well.
     31 for (let overflow of ["visible", "hidden", "auto", "scroll", "clip"]) {
     32  for (let padding of ["0", "2px"]) {
     33    for (let border of ["0", "3px solid"]) {
     34      for (let display of ["flex", "block", "flow-root", "inline-block", "inline-flex", "grid", "inline-grid"]) {
     35        test(function() {
     36          target.style.overflow = overflow;
     37          target.style.display = display;
     38          target.style.border = border;
     39          target.style.padding = padding;
     40          let sh = target.scrollHeight;
     41          let sw = target.scrollWidth;
     42          let ch = target.clientHeight;
     43          let cw = target.clientWidth;
     44          assert_equals(sh, ch, "scrollHeight should match clientHeight, since there's no overflow");
     45          assert_equals(sw, cw, "scrollWidth should match clientWidth, since there's no overflow");
     46        }, `scroll{Width,Height} with margins should match client{Width,Height} if there would be no overflow width overflow: ${overflow}, padding: ${padding}, border: ${border}, display: ${display}`);
     47      }
     48    }
     49  }
     50 }
     51 </script>