<!DOCTYPE html>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>CSSMediaRule deleteRule test</title>
        <style id="style1">
            @media all {
                p { color: red; }
            }
        </style>
        <script>
            function test() {
                var styleSheet = document.getElementById('style1').sheet;
                var mediaRule = styleSheet.cssRules[0];

                mediaRule.insertRule("#test { color: green; }", mediaRule.cssRules.length);
            }
        </script>
    </head>
    <body onload="test();">
        <p id="test">This line should be green.</p>
    </body>
</html>
