blob: bf54c4b3d4f07d7b552d384b2da6c064e7f81663 [file] [log] [blame]
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
<html>
<head>
<meta name="viewport" content="initial-scale=1.0">
<script src="../../resources/ui-helper.js"></script>
<link rel="stylesheet" href="resources/test.css">
</head>
<body>
<p>This tests that a text placeholder that is inserted and removed from a text field visually looks as if it never was inserted to begin with. This test can only be run in WebKitTestRunner or DumpRenderTree.</p>
<input id="input" class="test" type="text" value="Hello from Cupertino!">
<script>
if (window.testRunner)
testRunner.waitUntilDone();
async function runTest()
{
let input = document.getElementById("input");
if (window.testRunner)
await UIHelper.activateElementAndWaitForInputSession(input);
else
await UIHelper.callFunctionAndWaitForEvent(() => input.focus(), input, "focus");
let positionOfFrom = input.value.indexOf("from");
input.setSelectionRange(positionOfFrom, positionOfFrom);
let placeholderElement = null;
if (window.internals) {
// Because we are using the Ahem font almost all glyphs have the same width.
let glyphWidth = parseInt(window.getComputedStyle(input, null).fontSize, 10);
placeholderElement = internals.insertTextPlaceholder(5 * glyphWidth, 0 /* height */);
console.assert(placeholderElement);
}
// Defocus field to hide the cursor.
await UIHelper.callFunctionAndWaitForEvent(() => input.blur(), input, "blur");
if (window.internals)
internals.removeTextPlaceholder(placeholderElement);
if (window.testRunner)
testRunner.notifyDone();
}
runTest();
</script>
</body>
</html>