<!DOCTYPE html>
<html>
<head>
    <script src="../../resources/js-test.js"></script>
    <script src="../../resources/ui-helper.js"></script>
    <script src="../editing.js"></script>
    <script>
        jsTestIsAsync = true;

        addEventListener("load", async () => {
            description("This test verifies that enabling or disabling platform spell checking preferences influences the presence of spelling markers in the document. Requires WebKitTestRunner.");

            document.getElementById("editor").focus();

            if (!window.internals || !window.testRunner)
                return;

            await UIHelper.setContinuousSpellCheckingEnabled(false);
            testPassed("Turned continuous spell checking off.");

            [..."zzr "].map(typeCharacterCommand);
            shouldBeFalse("internals.hasSpellingMarker(0, 3)");

            await UIHelper.setContinuousSpellCheckingEnabled(true);
            testPassed("Turned continuous spell checking on.");

            deleteCommand();
            typeCharacterCommand(" ");
            shouldBeTrue("internals.hasSpellingMarker(0, 3)");

            await UIHelper.setContinuousSpellCheckingEnabled(false);
            testPassed("Turned continuous spell checking off again.");

            deleteCommand();
            typeCharacterCommand(" ");
            shouldBeFalse("internals.hasSpellingMarker(0, 3)");

            finishJSTest();
        });
    </script>
</head>
<body>
<textarea id="editor"></textarea>
</body>
</html>
