<html>
<head>
<script>
if (window.testRunner)
testRunner.dumpAsText();
function log(message)
{
var txt = document.createTextNode(message);
document.getElementById("logger").appendChild(txt);
document.getElementById("logger").appendChild(document.createElement('br'));
}
function logAutoCompleteAPIResult(input)
{
if (internals.elementShouldAutoComplete(input))
log("Element does autocomplete");
else
log("Element does *not* autocomplete");
}
function runTest()
{
if (!window.testRunner) {
alert("This test can only be run in DumpRenderTree");
return;
}
var form = document.getElementById("autoForm");
var input = document.getElementById("autoInput");
// Test with no autocomplete attribute on the <form>
logAutoCompleteAPIResult(input);
input.setAttribute("autocomplete", "cheese");
logAutoCompleteAPIResult(input);
input.setAttribute("autocomplete", "off");
logAutoCompleteAPIResult(input);
input.setAttribute("autocomplete", "on");
logAutoCompleteAPIResult(input);
input.setAttribute("autocomplete", "cheese");
logAutoCompleteAPIResult(input);
input.removeAttribute("autocomplete");
logAutoCompleteAPIResult(input);
// Test with autocomplete="off" on the <form>
form.setAttribute("autocomplete", "off");
logAutoCompleteAPIResult(input);
input.setAttribute("autocomplete", "cheese");
logAutoCompleteAPIResult(input);
input.setAttribute("autocomplete", "off");
logAutoCompleteAPIResult(input);
input.setAttribute("autocomplete", "on");
logAutoCompleteAPIResult(input);
input.setAttribute("autocomplete", "cheese");
logAutoCompleteAPIResult(input);
input.removeAttribute("autocomplete");
logAutoCompleteAPIResult(input);
}
</script>
</head>
<body onload="runTest();">
<div id="logger"></div>
<form id="autoForm" method="post">
<input type="text" id="autoInput"/>
</form>
This test exercises the WebKit API "elementDoesAutoComplete:" to make sure that API clients get the correct answer about whether or not a an element should autocomplete.
</body>
</html>