<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<script src="../../editing/editing.js"></script>
<div id="div" contenteditable="true"></div>
<script>
description('This tests for a bug when moving the caret backward through '
    + 'a misspelled word. Once the caret is no longer adjacent to it, '
    + 'it should be marked as misspelled.');

jsTestIsAsync = true;

if (window.internals) {
    internals.settings.setUnifiedTextCheckerEnabled(true);
    internals.settings.setAsynchronousSpellCheckingEnabled(true);
}

var div = document.getElementById("div");
div.focus();
document.execCommand("InsertText", false, "This sentence ends with a misspelled word asd.");

moveSelectionBackwardByCharacterCommand();
moveSelectionBackwardByCharacterCommand();
moveSelectionBackwardByCharacterCommand();
moveSelectionBackwardByCharacterCommand();
moveSelectionBackwardByCharacterCommand();
moveSelectionBackwardByCharacterCommand();

if (window.internals)
    shouldBecomeEqual("internals.hasSpellingMarker(42, 3)", "true", finishJSTest);
</script>
<script src="../../resources/js-test-post.js"></script>
</html>
