tor-browser

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

unclosed-constructs.html (857B)


      1 <!doctype html>
      2 <title>Unclosed Constructs Are Valid</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 
      6 <meta name="author" title="Tab Atkins-Bittner">
      7 <link rel=help href="https://drafts.csswg.org/css-syntax/#rule-defs">
      8 
      9 <!--
     10 Tests that unclosed constructs are valid and match grammars,
     11 because grammar-matching only sees the "block",
     12 not the opening/closing characters themselves.
     13 -->
     14 
     15 <script>
     16 
     17 function validSelector(str) {
     18    try {
     19        document.querySelector(str);
     20        return true;
     21    } catch(e) {
     22        return false;
     23    }
     24 }
     25 function shouldBeValid(str) {
     26    test(()=>{
     27        assert_true(validSelector(str));
     28    }, `"${str}" is a valid selector`)
     29 }
     30 
     31 shouldBeValid("[foo]");
     32 shouldBeValid("[foo");
     33 shouldBeValid(":nth-child(1)");
     34 shouldBeValid(":nth-child(1");
     35 
     36 </script>