tor-browser

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

insertRule-no-index.html (1490B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4    <title>CSS Test: CSSOM StyleSheet insertRule omitted second argument</title>
      5    <link rel="author" title="Sendil Kumar N" href="mailto:sendilkumarn.opensource@gmail.com">
      6    <link rel="help" href="https://drafts.csswg.org/cssom/">
      7    <link rel="help" href="http://www.w3.org/TR/cssom-1/#the-cssrule-interface">
      8    <meta name="flags" content="dom">
      9    <script src="/resources/testharness.js" type="text/javascript"></script>
     10    <script src="/resources/testharnessreport.js" type="text/javascript"></script>
     11    <style id="styleElement">
     12        /* An initial style rule to test where the new rule is inserted relative to this one */
     13        nosuchelement { color: red; }
     14    </style>
     15 </head>
     16 <body>
     17 <div id="log"></div>
     18 <script type="text/javascript">
     19    var sheet = document.getElementById("styleElement").sheet;
     20    test(function() {
     21        assert_equals(sheet.cssRules.length, 1);
     22        sheet.insertRule("p { color: green; }");
     23        assert_equals(sheet.cssRules.length, 2);
     24        assert_equals(sheet.cssRules.item(0).cssText, "p { color: green; }");
     25    }, "insertRule with omitted index argument");
     26 
     27    test(function() {
     28        assert_equals(sheet.cssRules.length, 2);
     29        sheet.insertRule("p { color: yellow; }", undefined);
     30        assert_equals(sheet.cssRules.length, 3);
     31        assert_equals(sheet.cssRules.item(0).cssText, "p { color: yellow; }");
     32    }, "insertRule with undefined index argument");
     33 </script>
     34 </body>
     35 </html>