tor-browser

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

calc-background-position-003.html (2423B)


      1 <!DOCTYPE html>
      2 
      3  <meta charset="UTF-8">
      4 
      5  <title>CSS Values and Units Test: serialization of 'background-position' when specified with calc() function</title>
      6 
      7  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">
      8  <link rel="help" href="https://www.w3.org/TR/css-values-4/#calc-serialize">
      9 
     10  <meta content="This test verifies how 6 calc() functions are serialized for 'background-position'." name="assert">
     11 
     12  <script src="/resources/testharness.js"></script>
     13 
     14  <script src="/resources/testharnessreport.js"></script>
     15 
     16  <div id="target"></div>
     17 
     18  <script>
     19  function startTesting()
     20  {
     21 
     22  var targetElement = document.getElementById("target");
     23 
     24    function verifySerialization(specified_value, serialization_expected, description)
     25    {
     26 
     27    test(function()
     28      {
     29 
     30      targetElement.style.backgroundPosition = specified_value;
     31 
     32      assert_equals(targetElement.style.backgroundPosition, serialization_expected);
     33 
     34      }, description);
     35    }
     36 
     37  /*
     38    verifySerialization(specified_value, serialization_expected, description)
     39  */
     40 
     41    verifySerialization("calc(2px + 3px) calc(4px + 5px)", "calc(5px) calc(9px)", "testing background-position: calc(2px + 3px) calc(4px + 5px)");
     42 
     43    verifySerialization("calc(18px - 7px) calc(19px - 7px)", "calc(11px) calc(12px)", "testing background-position: calc(18px - 7px) calc(19px - 7px)");
     44 
     45    verifySerialization("calc(4 * 5px) calc(6px * 4)", "calc(20px) calc(24px)", "testing background-position: calc(4 * 5px) calc(6px * 4)");
     46 
     47    verifySerialization("calc(100px / 4) calc(119px / 7)", "calc(25px) calc(17px)", "testing background-position: calc(100px / 4) calc(119px / 7)");
     48 
     49  /*
     50    verifySerialization(specified_value, serialization_expected, description)
     51  */
     52 
     53    verifySerialization("calc(6px + 21%) calc(7em + 22%)", "calc(21% + 6px) calc(22% + 7em)", "testing background-position: calc(6px + 21%) calc(7em + 22%)");
     54 
     55    verifySerialization("calc(-8px + 23%) calc(-9em + 24%)", "calc(23% - 8px) calc(24% - 9em)", "testing background-position: calc(-8px + 23%) calc(-9em + 24%)");
     56 
     57  /*
     58 
     59  "
     60  Sort the terms in the following order:
     61 
     62    The number, if present
     63 
     64    The percentage, if present
     65 
     66    The dimensions, ordered by their units ASCII case-insensitive alphabetically
     67  "
     68  https://www.w3.org/TR/css-values-4/#math-function-serialize-a-summation
     69 
     70  */
     71 
     72  }
     73 
     74  startTesting();
     75 
     76  </script>