<html>
<body>
<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=21060">bug 21060</a>:
Range#surroundContents incorrectly throws BAD_BOUNDARYPOINTS_ERR.</p>

<p style="visibility:hidden">Hello, <em>Range</em> world!</p>

<script type="text/javascript">
    if (window.testRunner)
        testRunner.dumpAsText();


  var range = document.createRange();
  var em = document.getElementsByTagName('em')[0];
  range.selectNode(em);
  var strong = document.createElement('strong');
  try {
    range.surroundContents(strong);
    var markup = document.getElementsByTagName("p")[1].innerHTML;
    document.write((markup == 'Hello, <strong><em>Range</em></strong> world!') ?
        "PASS" : ("FAIL: incorrect resulting markup, '" + markup.replace(/</g, "&lt;") + "'"));
  } catch (ex) {
    document.write("FAIL: " + ex);
  }

</script>

</body>
</html>
