tor-browser

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

scrollWidthHeight-overflow-visible-negative-margins.html (2570B)


      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 {
     14    width: 20px;
     15    flex-direction: column;
     16  }
     17  #target > div {
     18    background-color: green;
     19    margin: -5px -7px;
     20  }
     21 
     22  #target > div > div {
     23    height: 20px;
     24    width: 20px;
     25  }
     26 </style>
     27 <div id="target">
     28  <div><div></div></div>
     29  <div><div></div></div>
     30  <div><div></div></div>
     31  <div><div></div></div>
     32 </div>
     33 <script>
     34 let target = document.getElementById("target");
     35 // "clip" is not really scrollable, but should match as well.
     36 for (let overflow of ["visible", "hidden", "auto", "scroll", "clip"]) {
     37  // First one creates no overflow, last one does create overflow.
     38  // TODO(emilio): Figure out why the overflow padding and some of the grid cases
     39  // are not interoperable across platforms / engines. Maybe scrollbar-width dependent?
     40  for (let padding of ["10px 20px" /* , "2px" */]) {
     41    for (let border of ["0", "3px solid"]) {
     42      for (let display of ["flex", "block", "flow-root", "inline-block", "inline-flex", /*  "grid", "inline-grid" */]) {
     43        test(function() {
     44          let [expectedOverflowY, expectedOverflowX] = padding == "10px 20px" ? [0, 0] : [3, 5];
     45          target.style.overflow = overflow;
     46          target.style.display = display;
     47          target.style.border = border;
     48          target.style.padding = padding;
     49          let sh = target.scrollHeight;
     50          let sw = target.scrollWidth;
     51          let ch = target.clientHeight;
     52          let cw = target.clientWidth;
     53          assert_equals(sh, ch + expectedOverflowY, `scrollHeight expecting ${expectedOverflowY}px of overflow`);
     54          assert_equals(sw, cw + expectedOverflowX, `scrollWidth expecting ${expectedOverflowX}px of overflow`);
     55        }, `scroll{Width,Height} with negative margins with overflow: ${overflow}, padding: ${padding}, border: ${border}, display: ${display}`);
     56      }
     57    }
     58  }
     59 }
     60 </script>