<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script src="../editing.js"></script>

<script>
function runTest() {
    jsTestIsAsync = true;

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

    document.getElementById("editor").focus();
    for (const character of "It's muhc to late too finish this.")
        typeCharacterCommand(character);

    if (!window.testRunner) {
        document.getElementById("description").innerHTML = `To manually test, verify that there are correction markers
            below <strong>muhc</strong> as well as <strong>to</strong> and <strong>too</strong> on macOS Mojave.`;
        return;
    }

    shouldBecomeEqual("internals.hasSpellingMarker(5, 4)", "true", () => {
        shouldBeTrue("!internals.sentenceRetroCorrectionEnabled || internals.hasSpellingMarker(10, 2)", "true");
        shouldBeTrue("!internals.sentenceRetroCorrectionEnabled || internals.hasSpellingMarker(18, 3)", "true");
        finishJSTest();
    });
}
</script>
</head>

<body>
    <div id="description"></div>
    <div contenteditable style="margin-bottom: 1em; border: 1px orange dashed;" id="editor"></div>
    <script>
        runTest();
    </script>
    <script src="../../resources/js-test-post.js"></script>
</body>
</html>
