<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script src="resources/js-test-selection-shared.js"></script>
<script src="../../resources/ui-helper.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
if (window.internals)
    internals.settings.setEditingBehavior('mac');

description("Test that setSelectedRange resets the selection granularity to CharacterGranularity.");

var textarea = document.createElement('textarea');
textarea.value = "foo bar baz";
document.body.appendChild(textarea);

var rect = textarea.getBoundingClientRect();
var x = rect.left + 10;
var y = rect.top + 10;
if (window.eventSender) {
    eventSender.mouseMoveTo(x, y);
    eventSender.mouseDown();
    eventSender.mouseUp();
    eventSender.mouseDown();
    eventSender.mouseUp();
}

textarea.setSelectionRange(0, 3);
document.execCommand('delete');

// Calling setSelectionRange should reset the granularity to CharacterGranularity, which means
// execCommand('delete') should *not* do a smart delete.
if (textarea.value == " bar baz")
    testPassed("PASSED");
else
    testFailed("FAILED. textarea value should be \" bar baz\" and was \"" + textarea.value + "\"");
    
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>
