tor-browser

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

getComputedStyle-resolved-min-max-clamping.html (1773B)


      1 <!doctype html>
      2 <meta charset="utf-8">
      3 <title>CSSOM: resolved values of the width and height when the element generates no box or are a non-replaced inline aren't clamped by min-width / max-width</title>
      4 <link rel="help" href="https://drafts.csswg.org/cssom/#resolved-value">
      5 <link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
      6 <link rel="author" title="Mozilla" href="https://mozilla.org">
      7 <script src=/resources/testharness.js></script>
      8 <script src=/resources/testharnessreport.js></script>
      9 <span id="non-replaced-inline"></span>
     10 <div id="display-none" style="display: none"></div>
     11 <div id="display-contents" style="display: contents"></div>
     12 <script>
     13 test(function() {
     14  for (const e of document.querySelectorAll("[id]")) {
     15    const cs = getComputedStyle(e);
     16    for (const prop of ["width", "height"]) {
     17      e.style.setProperty("min-" + prop, "10px");
     18      e.style.setProperty("max-" + prop, "50px");
     19 
     20      e.style.setProperty(prop, "10%");
     21      assert_equals(cs[prop], "10%", `${e.id}: ${prop} with percentages returns percentages`);
     22 
     23      e.style.setProperty(prop, "15px");
     24      assert_equals(cs[prop], "15px", `${e.id}: ${prop} with value in range returns computed value`);
     25 
     26      e.style.setProperty(prop, "1px");
     27      assert_equals(cs[prop], "1px", `${e.id}: ${prop} with value out of range isn't clamped by min-${prop}`);
     28 
     29      e.style.setProperty(prop, "60px");
     30      assert_equals(cs[prop], "60px", `${e.id}: ${prop} with value out of range isn't clamped by max-${prop}`);
     31 
     32      e.style.removeProperty(prop);
     33      e.style.removeProperty("min-" + prop);
     34      e.style.removeProperty("max-" + prop);
     35    }
     36  }
     37 }, "Resolved value of width / height when there's no used value isn't clamped by min/max properties");
     38 </script>