<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
<script>
function testTextIndent(testContent, characterIndex)
{
    document.body.innerHTML = testContent;
    var editor = document.getElementById('textIndentTest');
    editor.focus();

    var caretRect = textInputController.firstRectForCharacterRange(0, 0);
    var caretXPosition_withoutTextRender = caretRect[0];

    editor.setSelectionRange(0, 0);
    document.execCommand('InsertText', false, 'a');

    caretRect = textInputController.firstRectForCharacterRange(characterIndex, 0);
    var caretXPosition_withTextRender = caretRect[0];
    
    if (caretXPosition_withoutTextRender == caretXPosition_withTextRender)
        return "Success. The caret's x positions of empty&nonempty input field were the same.\n";
    else
        return "Failure. The caret's x position of empty input field was " + caretXPosition_withoutTextRender + ", should have been " + caretXPosition_withTextRender + ".\n"; 
}

function testTextIndentWhenTextAlignsToCenter(textIndent)
{
    document.body.innerHTML = "<input id='textIndentTest' type='text' style='text-align:center;'>";
    var editor = document.getElementById('textIndentTest');
    editor.focus();

    var caretRect = textInputController.firstRectForCharacterRange(0, 0);
    var caretXPosition_withoutTextIndent = caretRect[0];

    editor.blur();
    editor.style.textIndent = textIndent + "px";
    editor.focus();

    caretRect = textInputController.firstRectForCharacterRange(0, 0);
    var caretXPosition_withTextIndent = caretRect[0];

    var desiredCaretXPosition = caretXPosition_withoutTextIndent + textIndent / 2;
    if (desiredCaretXPosition == caretXPosition_withTextIndent)
        return "Success. The caret's x positions was set to desired position when the text-align is center.\n";
    else
        return "Failure. The caret's x position of input field was " + caretXPosition_withTextIndent + ", should have been " + desiredCaretXPosition + ".\n";
}

if (window.testRunner)
    window.testRunner.dumpAsText();

var output = "";
output += testTextIndent("<input id='textIndentTest' type='text' style='text-indent:30px;'></input>", 0);
output += testTextIndent("<input id='textIndentTest' type='text' style='text-indent:-30px;'>", 0);
output += testTextIndent("<input id='textIndentTest' type='text' style='text-indent:30px;text-align:left'>", 0);
output += testTextIndent("<input id='textIndentTest' type='text' style='text-indent:30px;text-align:right'>", 1);
output += testTextIndent("<input id='textIndentTest' type='text' style='text-indent:30px;direction:rtl;'>", 0);
output += testTextIndent("<input id='textIndentTest' type='text' style='text-indent:30px;direction:rtl;text-align:right;'>", 0);
output += testTextIndentWhenTextAlignsToCenter(30);
output += testTextIndentWhenTextAlignsToCenter(-30);
document.body.innerText = output;
</script>
</html>
