tor-browser

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

starting-style-parsing.html (1257B)


      1 <!doctype html>
      2 <title>@starting-style: parsing</title>
      3 <link rel="help" href="https://drafts.csswg.org/css-transitions-2/#at-ruledef-starting-style">
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <main id=main></main>
      7 <script>
      8  function test_valid(actual, expected) {
      9    if (expected === undefined)
     10      expected = actual;
     11    test(t => {
     12      t.add_cleanup(() => main.replaceChildren());
     13      let style = document.createElement('style');
     14      style.textContent = `${actual}{}`;
     15      main.append(style);
     16      assert_equals(style.sheet.rules.length, 1);
     17      let rule = style.sheet.rules[0];
     18      assert_equals(rule.cssText, `${expected} {\n}`);
     19    }, `${actual} is valid`);
     20  }
     21 
     22  function test_invalid(actual) {
     23    test(t => {
     24      t.add_cleanup(() => main.replaceChildren());
     25      let style = document.createElement('style');
     26      style.textContent = `${actual}{}`;
     27      main.append(style);
     28      assert_equals(style.sheet.rules.length, 0);
     29    }, `${actual} is not valid`);
     30  }
     31 
     32  test_valid('@starting-style');
     33 
     34  test_invalid('@starting-style div');
     35  test_invalid('@starting-style ()');
     36  test_invalid('@starting-style ( {}');
     37  test_invalid('@starting-style }');
     38 </script>