4 <p id=
"description">This test setting suggested values on an input element
5 and a textarea element. The dump below should have the
"suggested value"
6 instead of
"initial value".
</p>
7 <pre><input id=
"test" type=
"text" value=
"initial value"><input id=
"month" type=
"month"><textarea id=
"textarea"></textarea><select id=
"select"><option>CA
</option><option>TX
</option></select></pre>
8 <script src=
"../../resources/dump-as-markup.js"></script>
11 var input
= document
.getElementById('test');
12 var month
= document
.getElementById('month');
13 var textarea
= document
.getElementById('textarea');
14 textarea
.value
= 'initial value';
15 var select
= document
.getElementById('select');
16 select
.selectedIndex
= -1;
17 var result
= document
.getElementById('result');
18 if (!window
.internals
)
19 testFailed('This test requires internals object');
22 input
.selectionStart
= input
.selectionEnd
= 0;
24 internals
.setSuggestedValue(input
, 'suggested value');
25 internals
.setSuggestedValue(month
, '2014-01');
26 internals
.setSuggestedValue(textarea
, 'suggested value');
27 internals
.setSuggestedValue(select
, 'TX');
29 Markup
.description(document
.getElementById('description').textContent
)
31 function addTextResult(value
) { input
.parentNode
.appendChild(document
.createTextNode(value
+ ': ' + eval(value
))); }
32 addTextResult('input.value');
33 addTextResult('internals.suggestedValue(input)');
34 addTextResult('input.selectionStart');
35 addTextResult('input.selectionEnd');
36 addTextResult('month.value');
37 addTextResult('internals.suggestedValue(month)');
38 addTextResult('textarea.value');
39 addTextResult('internals.suggestedValue(textarea)');
40 addTextResult('select.value');
41 addTextResult('internals.suggestedValue(select)');
43 Markup
.dump(input
.parentNode
);