<!DOCTYPE html>
<html>
<body>
<p id="description">This test setting suggested values on an input element
and a textarea element. The dump below should have the "suggested value"
instead of "initial value".</p>
<pre><input id="test" type="text" value="initial value"><input id="month" type="month"><textarea id="textarea"></textarea><select id="select"><option>initial value</option><option>suggested value</option></select></pre>
<script src="../../resources/dump-as-markup.js"></script>
<script>
var input = document.getElementById('test');
var month = document.getElementById('month');
var textarea = document.getElementById('textarea');
textarea.value = 'initial value';
var select = document.getElementById('select');
select.selectedIndex = 0;
var result = document.getElementById('result');
if (!window.internals)
testFailed('This test requires internals object');
else {
input.focus();
input.selectionStart = input.selectionEnd = 0;
internals.setSuggestedValue(input, 'suggested value');
internals.setSuggestedValue(month, '2014-01');
internals.setSuggestedValue(textarea, 'suggested value');
internals.setSuggestedValue(select, 'suggested value');
// Insert another OPTION before the suggested value.
select.insertBefore(new Option('inserted value'), select.lastChild);
Markup.description(document.getElementById('description').textContent)
function addTextResult(value) { input.parentNode.appendChild(document.createTextNode(value + ': ' + eval(value))); }
addTextResult('input.value');
addTextResult('internals.suggestedValue(input)');
addTextResult('input.selectionStart');
addTextResult('input.selectionEnd');
addTextResult('month.value');
addTextResult('internals.suggestedValue(month)');
addTextResult('textarea.value');
addTextResult('internals.suggestedValue(textarea)');
addTextResult('select.value');
addTextResult('internals.suggestedValue(select)');
select.removeChild(select.lastChild);
addTextResult('internals.suggestedValue(select)');
Markup.dump(input.parentNode);
}
</script>
</body>
</html>