<!DOCTYPE html>
<script src="../../resources/ahem.js"></script>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<!-- Updating display property should let selection show the element. -->
<style>
  div { font-family: Ahem}
</style>
<div id="r1">foo</div>
<div id="r2" style="display: none">bar</div>
<div id="r3">baz</div>
<script>
  getSelection().setBaseAndExtent(r1, 0, r3, 1);
  runAfterLayoutAndPaint(function() {
    r2.style.display = 'block';
  }, true);
</script>
