<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
<html>
<head>
    <meta charset="utf8">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <script src="../../../resources/js-test.js"></script>
    <script src="../../../resources/ui-helper.js"></script>
    <style>
        #editor {
            max-width: 200px;
        }
    </style>
    <script>
        jsTestIsAsync = true;

        addEventListener("load", async () => {
            description(`This test verifies that inserting an auto-corrected text after an image does not remove the image.`);

            addEventListener("input", event => testPassed(`Observed input event of inputType ${event.inputType}`));

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

            editor = document.getElementById("editor");
            await UIHelper.activateElementAndWaitForInputSession(editor);
            await UIHelper.applyAutocorrection("The", "");
            shouldBe("document.activeElement", "editor");
            shouldBe("editor.children.length", "1");
            shouldBeTrue("editor.children[0] instanceof HTMLImageElement");
            editor.blur();
            await UIHelper.waitForKeyboardToHide();
            finishJSTest();
        });
    </script>
</head>
<body>
    <div contenteditable id="editor">
        <img src="../resources/abe.png">
    </div>
    <div id="description"></div>
    <div id="console"></div>
</body>

</html>
