tor-browser

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

at-container-serialization.html (2446B)


      1 <!doctype html>
      2 <title>CSS Container Queries: @container serialization</title>
      3 <link rel="help" href="https://drafts.csswg.org/css-conditional-5/#container-queries">
      4 <link rel="help" href="https://drafts.csswg.org/cssom/#serialize-a-css-rule">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="support/cq-testcommon.js"></script>
      8 <style id="testSheet">
      9  @container (width=100px) {
     10    @container \!-name (inline-size > 200px    ) {
     11      #id { color: lime }
     12    }
     13    #id { color: green }
     14  }
     15 </style>
     16 <main id="cq-main"></main>
     17 <script>
     18  setup(() => assert_implements_size_container_queries());
     19 
     20  const rules = testSheet.sheet.cssRules;
     21 
     22  test(() => {
     23    assert_equals(rules.length, 1);
     24    assert_equals(rules[0].cssRules.length, 2);
     25 
     26    assert_equals(rules[0].conditionText, "(width = 100px)");
     27    assert_equals(rules[0].cssRules[0].conditionText, "\\!-name (inline-size > 200px)");
     28  }, "Serialization of conditionText");
     29 
     30  test(() => {
     31    assert_equals(rules[0].cssRules[0].cssText, "@container \\!-name (inline-size > 200px) {\n  #id { color: lime; }\n}");
     32  }, "Serialization of inner @container rule");
     33 
     34  test(() => {
     35    assert_equals(rules[0].cssText, "@container (width = 100px) {\n  @container \\!-name (inline-size > 200px) {\n  #id { color: lime; }\n}\n  #id { color: green; }\n}");
     36  }, "Serialization of nested @container rule");
     37 
     38  const testCases = [
     39    ["(  wiDTh  )", "(width)"],
     40    ["(width:100px)", "(width: 100px)"],
     41    ["(min-width:  100px)", "(min-width: 100px)"],
     42    ["(   MAX-WIDTH:100px  )", "(max-width: 100px)"],
     43    ["(width > 100px)", "(width > 100px)"],
     44    ["(width < 100px)", "(width < 100px)"],
     45    ["(widTH >= 100px)", "(width >= 100px)"],
     46    ["(width <= 100px)", "(width <= 100px)"],
     47    ["(10px < width < 100px)", "(10px < width < 100px)"],
     48    ["(10px <=  width  <=  100px)", "(10px <= width <= 100px)"],
     49    ["(100px>WIDTH>10px)", "(100px > width > 10px)"],
     50    ["(  100px >= width >= 10px  )", "(100px >= width >= 10px)"],
     51    ["(calc(1em + 1px) >= width >= max(10em, 10px))", "(calc(1em + 1px) >= width >= max(10em, 10px))"],
     52    ["(width),(height) ,--foo ,--bar", "(width), (height), --foo, --bar"],
     53    ["  --NAMe   ", "--NAMe"],
     54    ["NAMe   (inline-sizE  < 1300px )", "NAMe (inline-size < 1300px)"],
     55  ];
     56 
     57  for (testCase of testCases) {
     58    test_cq_condition_serialization(testCase[0], testCase[1]);
     59  }
     60 </script>