<!DOCTYPE html>
<html>
<head>
    <script src="../../resources/js-test-pre.js"></script>
</head>
<body>
    <div id="editable" contenteditable onbeforeinput=beforeinput(event)></div>
    <script type="text/javascript">
        description("To manually test this, type \"hllo\" and trigger spell checking. Select a spell checking candidate.");

        editable.focus();

        if (window.eventSender && window.internals) {
            eventSender.keyDown("h");
            eventSender.keyDown("l");
            eventSender.keyDown("l");
            eventSender.keyDown("o");
            internals.handleAcceptedCandidate("hello", 0, 4);
        }

        function beforeinput(event)
        {
            if (event.inputType !== "insertReplacementText")
                return;

            window.replacementRange = event.getTargetRanges()[0];
            shouldBe("replacementRange.startOffset", "0");
            shouldBe("replacementRange.endOffset", "4");
            shouldBe("replacementRange.startContainer", "editable.childNodes[0]");
            shouldBe("replacementRange.endContainer", "editable.childNodes[0]");
            event.preventDefault();
        }
    </script>
    <script src="../../resources/js-test-post.js"></script>
</body>
</html>