<style>
.display-when-first-child { display: none; }
.display-when-first-child:first-child { display: block; }
</style>
<div class="display-when-first-child">FAIL</div>
<script>
var test = document.createElement('div');
document.body.insertBefore(test, document.body.firstChild);
if (document.body.innerText.indexOf('FAIL') < 0)
    test.innerText = 'PASS';
if (window.testRunner)
    testRunner.dumpAsText();
</script>
