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