tor-browser

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

input-preprocessing.html (1311B)


      1 <!doctype html>
      2 <title>Input Preprocessing</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <style>
      6 
      7 foo { color: blue; }
      8 
      9 </style>
     10 
     11 <meta name="author" title="Tab Atkins-Bittner">
     12 <link rel=help href="https://drafts.csswg.org/css-syntax/#input-preprocessing">
     13 
     14 <script>
     15 
     16 function roundtripIdent(str) {
     17    const rule = document.styleSheets[0].cssRules[0];
     18    rule.selectorText = "original-ident";
     19    rule.selectorText = str;
     20    // Check for parse error.
     21    if(rule.selectorText == "original-ident") return "parse error";
     22    return rule.selectorText;
     23 }
     24 function testParsing(input, expected) {
     25    test(()=>{
     26        assert_equals(roundtripIdent(input), expected);
     27    }, `"${input}" becomes "${expected}"`);
     28 }
     29 
     30 /* Can't figure out how to test the newline normalization... */
     31 
     32 /* NULL becomes FFFD */
     33 testParsing("foo\x00", "foo\ufffd");
     34 testParsing("f\x00oo", "f\ufffdoo");
     35 testParsing("\x00foo", "\ufffdfoo");
     36 testParsing("\x00", "\ufffd");
     37 testParsing("\x00\x00\x00", "\ufffd\ufffd\ufffd");
     38 
     39 /* surrogates become FFFD */
     40 testParsing("foo\ud800", "foo\ufffd");
     41 testParsing("f\ud800oo", "f\ufffdoo");
     42 testParsing("\ud800foo", "\ufffdfoo");
     43 testParsing("\ud800", "\ufffd");
     44 testParsing("\ud800\ud800\ud800", "\ufffd\ufffd\ufffd");
     45 
     46 </script>