tor-browser

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

calc-infinity-nan-computed.html (4782B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <meta charset="utf-8">
      5 <title>Infinity and NaN: calc() computed value.</title>
      6 <link rel="author" title="Seokho Song"  href="mailto:0xdevssh@gmail.com">
      7 <link rel="help" href="https://drafts.csswg.org/css-values/#calc-type-checking">
      8 <script src="/resources/testharness.js"></script>
      9 <script src="/resources/testharnessreport.js"></script>
     10 <script src="/css/support/computed-testcommon.js"></script>
     11 </head>
     12 <body>
     13 <div id="target"></div>
     14 <script>
     15 const REALLY_LARGE = 1e6;
     16 const REALLY_LARGE_NEGATIVE = -REALLY_LARGE;
     17 
     18 // For <length>
     19 test_computed_value("width", "calc(NaN * 1px)", "0px");
     20 test_computed_value("width", "calc(NaN * 1%)", "0px");
     21 testComputedValueGreaterOrLowerThan("width", "calc(infinity * 1px)", REALLY_LARGE);
     22 testComputedValueGreaterOrLowerThan("width", "calc(infinity * 1%)", REALLY_LARGE);
     23 testComputedValueGreaterOrLowerThan("width", "calc(infinity * 1cm)", REALLY_LARGE);
     24 test_computed_value("width", "calc(NaN * 1rem)", "0px");
     25 test_computed_value("width", "calc(10.135262721212548pc - 199pt / NaN)", "0px");
     26 
     27 test_computed_value("width", "max(15px, NaN * 1px)", "0px");
     28 test_computed_value("width", "max(NaN * 1px, 15px)", "0px");
     29 test_computed_value("width", "max(-15px, NaN * 1px)", "0px");
     30 test_computed_value("width", "max(NaN * 1px, -15px)", "0px");
     31 test_computed_value("width", "min(15px, NaN * 1px)", "0px");
     32 test_computed_value("width", "min(NaN * 1px, 15px)", "0px");
     33 test_computed_value("width", "min(-15px, NaN * 1px)", "0px");
     34 test_computed_value("width", "min(NaN * 1px, -15px)", "0px");
     35 
     36 test_computed_value("width", "calc(infinity * 1px - infinity * 1%)", "0px");
     37 testComputedValueGreaterOrLowerThan("width", "calc(infinity * 1px + infinity * 1%)", REALLY_LARGE);
     38 test_computed_value("width", "calc(min(NaN * 1px, infinity * 1px) + max(infinity * 1px, -infinity * 1px))", "0px");
     39 test_computed_value("width", "calc(infinity * 1px - max(infinity * 1%, 0%))", "0px");
     40 
     41 testComputedValueGreaterOrLowerThan("width", "calc(max(infinity * 1px, 10px))", REALLY_LARGE);
     42 
     43 testComputedValueGreaterOrLowerThan("margin-left", "calc(-infinity * 1px)", REALLY_LARGE_NEGATIVE);
     44 testComputedValueGreaterOrLowerThan("margin-left", "calc(min(1px, -infinity * 1%))", REALLY_LARGE_NEGATIVE);
     45 
     46 testComputedValueGreaterOrLowerThan("margin-left", "calc(-infinity * 1%)", REALLY_LARGE_NEGATIVE);
     47 testComputedValueGreaterOrLowerThan("margin-left", "calc(max(10000px, 0px) + min(-infinity * 1px, infinity * 1px))", REALLY_LARGE_NEGATIVE);
     48 
     49 testComputedValueGreaterOrLowerThan("margin-left", "calc(-infinity * 1px - infinity * 1px)", REALLY_LARGE_NEGATIVE);
     50 testComputedValueGreaterOrLowerThan("margin-left", "calc(min(-infinity * 1px, 10px))", REALLY_LARGE_NEGATIVE);
     51 
     52 // For <time>
     53 test_computed_value("animation-duration", "calc(NaN * 1s)", "0s");
     54 testComputedValueGreaterOrLowerThan("animation-duration", "calc(infinity * 1s)", REALLY_LARGE);
     55 testComputedValueGreaterOrLowerThan("animation-duration", "calc(1 / 0 * 1s)", REALLY_LARGE);
     56 testComputedValueGreaterOrLowerThan("animation-duration", "calc(max(infinity * 1s, 10s)", REALLY_LARGE);
     57 
     58 testComputedValueGreaterOrLowerThan("transition-delay", "calc(-infinity* 1s)", REALLY_LARGE_NEGATIVE);
     59 testComputedValueGreaterOrLowerThan("transition-delay", "calc(max(10000s, 0s) + min(-infinity * 1s, infinity * 1s))", REALLY_LARGE_NEGATIVE);
     60 testComputedValueGreaterOrLowerThan("transition-delay", "calc(min(-infinity * 1s, 10s))", REALLY_LARGE_NEGATIVE);
     61 
     62 // For <angle>
     63 testTransformValuesCloseTo("rotate(calc(infinity * 1deg))", 0.0001, "rotate(0deg)");
     64 testTransformValuesCloseTo("rotate(calc(-infinity * 1deg))", 0.0001, "rotate(0deg)");
     65 testTransformValuesCloseTo("rotate(calc(NaN * 1deg))", 0.0001, "rotate(0deg)");
     66 
     67 testTransformValuesCloseTo("rotate(calc(infinity * 1turn))", 0.0001, "rotate(0deg)");
     68 testTransformValuesCloseTo("rotate(calc(-infinity * 1turn))", 0.0001, "rotate(0deg)");
     69 testTransformValuesCloseTo("rotate(calc(NaN * 1turn))", 0.0001, "rotate(0deg)");
     70 
     71 testTransformValuesCloseTo("rotate(calc(infinity * 1rad))", 0.0001, "rotate(0deg)");
     72 testTransformValuesCloseTo("rotate(calc(-infinity * 1rad))", 0.0001, "rotate(0deg)");
     73 testTransformValuesCloseTo("rotate(calc(NaN * 1rad))", 0.0001, "rotate(0deg)");
     74 
     75 testTransformValuesCloseTo("rotate(calc(infinity * 1grad))", 0.0001, "rotate(0deg)");
     76 testTransformValuesCloseTo("rotate(calc(-infinity * 1grad))", 0.0001, "rotate(0deg)");
     77 testTransformValuesCloseTo("rotate(calc(NaN * 1grad))", 0.0001, "rotate(0deg)");
     78 
     79 // For <number>
     80 testComputedValueGreaterOrLowerThan("scale", "calc(max(infinity, 10))", REALLY_LARGE);
     81 testComputedValueGreaterOrLowerThan("scale", "calc(infinity)", REALLY_LARGE);
     82 testComputedValueGreaterOrLowerThan("scale", "calc(-infinity * 10)", REALLY_LARGE_NEGATIVE);
     83 
     84 </script>
     85 </body>
     86 </html>