tor-browser

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

first-line-allowed-properties.html (2892B)


      1 <!DOCTYPE html>
      2 <title>CSS Test: Properties allowed on ::first-line pseudo elements</title>
      3 <link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#first-line-styling">
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <style>
      7  #target::first-line {}
      8  #target { visibility: hidden; }
      9 </style>
     10 <div id="target">text</div>
     11 <script>
     12  let style;
     13  const target = document.querySelector("#target");
     14  const defaultComputedStyle = getComputedStyle(target);
     15 
     16  test(() => {
     17    var styleRule = document.styleSheets[0].cssRules[0];
     18    assert_equals(styleRule.selectorText, "#target::first-line", "make sure we have the correct style rule");
     19    style = styleRule.style;
     20  }, "retrieve style rule");
     21 
     22  const validProperties = {
     23    backgroundAttachment: "fixed",
     24    backgroundBlendMode: "hue",
     25    backgroundClip: "padding-box",
     26    backgroundColor: "rgb(10, 20, 30)",
     27    backgroundImage: "linear-gradient(rgb(0, 0, 0), rgb(255, 255, 255))",
     28    backgroundOrigin: "border-box",
     29    backgroundPosition: "50% 50%",
     30    backgroundRepeat: "no-repeat",
     31    backgroundSize: "10px 20px",
     32    color: "rgba(10, 20, 30, 0.4)",
     33    fontFamily: "sans-serif",
     34    fontFeatureSettings: '"vert" 2',
     35    fontKerning: "none",
     36    fontSize: "30px",
     37    fontSizeAdjust: "0.5",
     38    fontStyle: "italic",
     39    fontVariant: "small-caps",
     40    fontWeight: "900",
     41    fontVariationSettings: '"XHGT" 0.7',
     42    letterSpacing: "12px",
     43    opacity: "0.5",
     44    textDecoration: "overline wavy rgb(10, 20, 30)",
     45    textJustify: "none",
     46    textShadow: "rgb(10, 20, 30) 10px 20px 30px",
     47    textTransform: "capitalize",
     48    textUnderlinePosition: "under",
     49    verticalAlign: "12%",
     50    wordSpacing: "12px"
     51  };
     52 
     53  const invalidProperties = {
     54    border: "40px dotted rgb(10, 20, 30)",
     55    borderImage: "linear-gradient(rgb(0, 0, 0), rgb(255, 255, 255)) 10% / 20 / 30px repeat",
     56    borderRadius: "10px 20px",
     57    margin: "10px 20px 30px 40px",
     58    padding: "10px 20px 30px 40px",
     59    position: "absolute",
     60    transition: "transform 1s",
     61    transform: "rotate(45deg)",
     62    wordBreak: "break-all"
     63  };
     64 
     65  function testFirstLineProperty(property, rule, expected, reason) {
     66    test(function() {
     67      style[property] = "";
     68      style[property] = rule;
     69      assert_equals(getComputedStyle(target, "::first-line")[property], expected);
     70      style[property] = "";
     71    }, reason);
     72  }
     73 
     74  for (let property in validProperties) {
     75    testFirstLineProperty(property, validProperties[property], validProperties[property],
     76                            property + " should be applied to first-line pseudo elements.");
     77  }
     78 
     79  for (let property in invalidProperties) {
     80    testFirstLineProperty(property, invalidProperties[property], defaultComputedStyle[property],
     81                            property + " should not be applied to first-line pseudo elements.");
     82  }
     83 </script>