<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="../../../resources/js-test.js"></script>
    <script src="../../../resources/ui-helper.js"></script>
    <style>
        iframe {
            width: 0;
            height: 100%;
            position: fixed;
            top: 0;
            left: 0;
            border: 0;
        }

        body, html {
            width: 100%;
            height: 100%;
        }

        button {
            padding: 1em;
        }
    </style>
</head>
<body>
    <iframe srcdoc="<body contenteditable>"></iframe>
    <button id="focus">Focus the hidden frame</button>
    <script>
        jsTestIsAsync = true;
        description("This test verifies that selection UI is suppressed when focusing an element inside an empty subframe. To run the test manually, tap the button and check that a blue selection caret is not visible.");

        const focusButton = document.getElementById("focus");
        focusButton.addEventListener("click", event => {
            document.querySelector("iframe").contentDocument.body.focus();
            event.preventDefault();
        });

        addEventListener("load", async () => {
            await UIHelper.activateElementAndWaitForInputSession(focusButton);
            caretRect = await UIHelper.getUICaretViewRect();
            shouldBe("caretRect.width", "0");
            shouldBe("caretRect.height", "0");
            document.activeElement.blur();
            await UIHelper.waitForKeyboardToHide();
            finishJSTest();
        });
    </script>
</body>
</html>