<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
<html>
<meta name="viewport" content="width=device-width">
<head>
<script src="../../../resources/js-test.js"></script>
<script src="../../../resources/ui-helper.js"></script>
<script>
jsTestIsAsync = true;

function getTextContentTypeAfterFocusingInput() {
    return new Promise(async (resolve) => {
        await UIHelper.activateAndWaitForInputSessionAt(75, 75);
        const textContentType = await UIHelper.textContentType();
        field.blur();
        await UIHelper.waitForKeyboardToHide();
        resolve(textContentType);
    });
}

async function runTest() {
    if (!window.testRunner) {
        description(`This test requires WebKitTestRunner.`);
        return;
    }

    textContentTypeForLoneTextField = await getTextContentTypeAfterFocusingInput();
    shouldBe("textContentTypeForLoneTextField", "''");

    let passwordField = document.createElement("input");
    passwordField.setAttribute("type", "password");
    document.body.appendChild(passwordField);
    textContentTypeForTextFieldBeforePassword = await getTextContentTypeAfterFocusingInput();
    shouldBe("textContentTypeForTextFieldBeforePassword", "'username'");

    passwordField.remove();
    field.setAttribute("autocomplete", "username");
    textContentTypeForTextFieldWithAutocompleteUsername = await getTextContentTypeAfterFocusingInput();
    shouldBe("textContentTypeForTextFieldWithAutocompleteUsername", "'username'");

    finishJSTest();
}
</script>
</head>

<body onload="runTest()">
<input id="field" style="width: 320px; height: 568px;"></input>
</body>
</html>