Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / suggested-value.html
blobe95babcac6f9ee9822eece4cfa4856aab574811c
1 <!DOCTYPE html>
2 <html>
3 <body>
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>
9 <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');
20 else {
21 input.focus();
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);
46 </script>
47 </body>
48 </html>