tor-browser

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

invalid-inner-rules.html (1353B)


      1 <!doctype html>
      2 <title>Simple CSSOM manipulation of subrules</title>
      3 <link rel="author" title="Steinar H. Gunderson" href="mailto:sesse@chromium.org">
      4 <link rel="help" href="https://drafts.csswg.org/css-nesting-1/">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 
      8 <style id="ss">
      9 div {
     10  /* This is not a conditional rule, and thus cannot be in nesting context. */
     11  @font-face {
     12    &.a { font-size: 10px; }
     13  }
     14 
     15  @media screen {
     16    &.a { color: red; }
     17 
     18    /* Same. */
     19    @font-face {
     20      &.a { font-size: 10px; }
     21    }
     22  }
     23 }
     24 </style>
     25 
     26 <script>
     27  test(() => {
     28    let [ss] = document.styleSheets;
     29    assert_equals(ss.cssRules.length, 1);
     30 
     31    // The @font-face rule should be ignored.
     32    assert_equals(ss.cssRules[0].cssText,
     33 `div {
     34  @media screen {
     35  &.a { color: red; }
     36 }
     37 }`);
     38  });
     39 
     40  test(() => {
     41    let [ss] = document.styleSheets;
     42    assert_equals(ss.cssRules.length, 1);
     43    assert_throws_dom('HierarchyRequestError',
     44      () => { ss.cssRules[0].cssRules[0].insertRule('@font-face {}', 0); });
     45    assert_throws_dom('HierarchyRequestError',
     46      () => { ss.cssRules[0].insertRule('@font-face {}', 0); });
     47 
     48    // The @font-face rules should be ignored (again).
     49    assert_equals(ss.cssRules[0].cssText,
     50 `div {
     51  @media screen {
     52  &.a { color: red; }
     53 }
     54 }`);
     55  });
     56 </script>