tor-browser

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

scrollWidthHeight-contain-layout.html (2051B)


      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=1931490">
      9 <title>scroll{Width,Height} with contain: layout</title>
     10 <script src="/resources/testharness.js"></script>
     11 <script src="/resources/testharnessreport.js"></script>
     12 <style>
     13  #target {
     14    contain: layout;
     15    height: 0;
     16    width: 0;
     17  }
     18 </style>
     19 <div id="target">
     20  <div style="height: 2000px"></div>
     21 </div>
     22 <script>
     23 let target = document.getElementById("target");
     24 // "clip" is not really scrollable, but should match as well.
     25 for (let overflow of ["hidden", "auto", "scroll", "clip"]) {
     26  for (let padding of ["0", "2px"]) {
     27    for (let border of ["0", "3px solid"]) {
     28      for (let display of ["flex", "block", "flow-root", "inline-block", "inline-flex", "grid", "inline-grid", "inline"]) {
     29        test(function() {
     30          target.style.display = display;
     31          target.style.border = border;
     32          target.style.padding = padding;
     33          let visibleH = target.scrollHeight;
     34          let visibleW = target.scrollWidth;
     35          target.style.overflow = overflow;
     36          let scrollableH = target.scrollHeight;
     37          let scrollableW = target.scrollWidth;
     38          assert_equals(visibleH, scrollableH, "scrollHeight should match for visible and " + overflow);
     39          assert_equals(visibleW, scrollableW, "scrollWidth should match for visible and " + overflow);
     40          target.style.overflow = "";
     41          target.style.display = "";
     42        }, `scroll{Width,Height} should match with contain: layout for display: ${display}, overflow: ${overflow}, padding: ${padding}, border: ${border}`);
     43      }
     44    }
     45  }
     46 }
     47 </script>