<html>
<head>
<style>
div { color:black }
</style>
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body onload="test()">
<script>
window.jsTestIsAsync = true;
description("Test that CSS rules don't lose custom properties on GC when only reachable through its declarations.");

function test()
{
    var sheet = document.styleSheets[0];
    style = sheet.cssRules[0].style;
    style.parentRule.foo = "bar";
    document.getElementsByTagName("head")[0].removeChild(document.getElementsByTagName("style")[0]);
    sheet = null;

    gc();
    setTimeout(function() {
        gc();
        shouldBe('style.parentRule.foo', '"bar"');
        finishJSTest();
    }, 0);
}
</script>
<foo id="mystyle" style="display:none">.div { color: white; }</foo>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>
