<head>
<script src="../../resources/js-test.js"></script>
<script>
function countAutofilledElements() {
return document.querySelectorAll(':-webkit-autofill').length;
}
function test() {
if (window.testRunner) {
testRunner.dumpAsText();
}
var field = document.getElementById('field');
var select = document.getElementById('select');
var textarea = document.getElementById('textarea');
if (window.internals) {
internals.setAutofilled(field, true);
internals.setAutofilled(select, true);
internals.setAutofilled(textarea, true);
} else {
testFailed('This test requires a LayoutTestController.');
return;
}
shouldBe('countAutofilledElements()', '3');
shouldBe('document.querySelectorAll(\':autofill\').length', '3');
var form = document.getElementById('form');
form.reset();
shouldBe('countAutofilledElements()', '0');
shouldBe('document.querySelectorAll(\':autofill\').length', '0');
}
</script>
<style>
#tf {
color: #FFFFFF;
background-color: #FFFFFF;
}
</style>
</head>
<body onload="test()">
This tests that a field's autofilled state is reverted when the form is reset. It can only be run using the test harness.<br>
<form id="form">
<input type="text" id="field">
<select id="select"></select>
<textarea id="textarea"></textarea>
</form>
<div id="console"></div>
</body>