<html>
<head>
<style>
#highlighted
{
white-space: pre-wrap;
}
</style>
  <script>
    function debug(str) {
        pre = document.getElementById('console');
        pre.appendChild(document.createTextNode(str + '\n'));
    }

    function runTest() {
        if (window.testRunner)
            testRunner.dumpAsText()

        var str = '____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________'
        var div = document.getElementById('highlighted');
        div.innerHTML = '<div>' + str + '\n</div>'
        debug(div.innerHTML);

        // Test crash
        var sel = getSelection();
        sel.setPosition(div.firstChild, 0);
    
        var range = sel.getRangeAt(0);
        var span = document.createElement('SPAN');
        range.insertNode(span);
        debug(div.innerHTML);
    }
  </script>
</head>
<body onload="runTest()">
  This tests that inserting a span into a selection of a div with lots of non-word-broken characters doesn't crash.
  <div id="highlighted"></div>
  <pre id="console"></pre>
</body>
</html>
