blob: e5d4b43fea0689f9a6089571f13301634dc29fe3 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test.js"></script>
<div id="test"></div>
<script>
description("Ensure that extending a selection to trailing spaces does not cause exceptions.");
var div = document.getElementById('test');
var selection = window.getSelection();
function testIt(text) {
var len = text.length;
div.textContent = text;
selection.collapse(div.firstChild, 0);
try {
selection.extend(div.firstChild, len);
} catch (e) {
testFailed(div.outerHTML + ': ' + String(e.toString()));
return;
}
try {
selection.extend(div.firstChild, len + 1);
testFailed(div.outerHTML + ': ' + String(e.toString()));
return;
} catch (e) {
}
testPassed(div.outerHTML);
}
testIt('0123');
testIt('012 ');
testIt('012 ');
testIt('012\n');
testIt('012\n\n');
div.textContent = '';
</script>
</body>
</html>