chromium/third_party/blink/web_tests/fast/forms/textfield-to-password-on-focus.html

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script>
if (window.testRunner) {
    testRunner.waitUntilDone();
    testRunner.dumpAsText();
}

function changeToPasswordField(textField)
{
    textField.setAttribute("type", "password");
}

function test()
{
    if (!window.testRunner)
        return;
    var field = document.getElementById("field").focus();
    // Need short delay because changing input type doesn't set selection in the
    // input element immediately because layout is dirty.
    setTimeout(function() {
        eventSender.keyDown("p");
        eventSender.keyDown("a");
        eventSender.keyDown("s");
        eventSender.keyDown("s");

        shouldBe('field.value', "'pass'");
        isSuccessfullyParsed();

        testRunner.notifyDone();
    }, 0);
}
</script>
</head>
<body onload="test()">
<ol><li>Hit Tab key to focus input field.</li><li>Type some text.</li></ol>
<input type="text" id="field" onfocus="changeToPasswordField(this)">
<hr>
<p id="description"></p>
<div id="console"></div>
<script>
description("Test for <a href=\"https://bugs.webkit.org/show_bug.cgi?id=18900\">Bug 18900: Password field has focus but can't type text (i.rememberthemilk.com)</a>");
</script>
</body>
</html>