tor-browser

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

match-media-parsing.html (2214B)


      1 <!DOCTYPE html>
      2 <link rel="help" href="https://drafts.csswg.org/css-syntax-3/#parse-comma-separated-list-of-component-values">
      3 <script type="text/javascript" src="/resources/testharness.js"></script>
      4 <script type="text/javascript" src="/resources/testharnessreport.js"></script>
      5 
      6 <script>
      7 function test_parsing(query, expected) {
      8    if(expected === undefined)
      9        expected = query;
     10 
     11    test(() => {
     12        const match = window.matchMedia(query);
     13        assert_equals(match.media, expected)
     14    }, "Test parsing '" + query + "' with matchMedia");
     15 }
     16 
     17 function test_resolution_parsing() {
     18    test_parsing("(min-resolution: 1x)");
     19    test_parsing("(min-resolution: calc(1x))", "(min-resolution: calc(1dppx))");
     20    test_parsing("(resolution: 2x)");
     21    test_parsing("(resolution: calc(2x))", "(resolution: calc(2dppx))");
     22    test_parsing("(max-resolution: 7x)");
     23    test_parsing("(max-resolution: calc(7x))", "(max-resolution: calc(7dppx))");
     24 
     25    test_parsing("(resolution: 2dppx)");
     26    test_parsing("(resolution: 600dpi)");
     27    test_parsing("(resolution: 77dpcm)");
     28 
     29    test_parsing("(resolution: calc(1x + 2x))", "(resolution: calc(3dppx))");
     30    test_parsing("(resolution: calc(5x - 2x))", "(resolution: calc(3dppx))");
     31    test_parsing("(resolution: calc(1x * 3))", "(resolution: calc(3dppx))");
     32    test_parsing("(resolution: calc(6x / 2))", "(resolution: calc(3dppx))");
     33 }
     34 
     35 test_parsing("", "");
     36 test_parsing(" ", "");
     37 test_parsing("all", "all");
     38 test_parsing(" all", "all");
     39 test_parsing("   all   ", "all");
     40 test_parsing("all,all", "all, all");
     41 test_parsing(" all , all ", "all, all");
     42 test_parsing("(color)", "(color)");
     43 test_parsing("(color", "(color)");
     44 test_parsing(" (color)", "(color)");
     45 test_parsing(" ( color  )  ", "(color)");
     46 test_parsing(" ( color   ", "(color)");
     47 test_parsing("color)", "not all");
     48 test_parsing("  color)", "not all");
     49 test_parsing("  color ), ( color", "not all, (color)");
     50 test_parsing(" foo ", "foo");
     51 test_parsing(",", "not all, not all");
     52 test_parsing(" , ", "not all, not all");
     53 test_parsing(",,", "not all, not all, not all");
     54 test_parsing("  ,  ,  ", "not all, not all, not all");
     55 test_parsing(" foo,", "foo, not all");
     56 
     57 test_resolution_parsing();
     58 </script>