OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <body> | 3 <body> |
4 <p id="description">This test setting suggested values on an input element | 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" | 5 and a textarea element. The dump below should have the "suggested value" |
6 instead of "initial value".</p> | 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></pre> | 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> | 8 <script src="../../resources/dump-as-markup.js"></script> |
9 <script> | 9 <script> |
10 | 10 |
11 var input = document.getElementById('test'); | 11 var input = document.getElementById('test'); |
12 var month = document.getElementById('month'); | 12 var month = document.getElementById('month'); |
13 var textarea = document.getElementById('textarea'); | 13 var textarea = document.getElementById('textarea'); |
14 textarea.value = "initial value"; | 14 textarea.value = "initial value"; |
| 15 var select = document.getElementById('select'); |
| 16 select.selectedIndex = -1; |
15 var result = document.getElementById('result'); | 17 var result = document.getElementById('result'); |
16 if (!window.internals) | 18 if (!window.internals) |
17 testFailed('This test requires internals object'); | 19 testFailed('This test requires internals object'); |
18 else { | 20 else { |
19 input.focus(); | 21 input.focus(); |
20 input.selectionStart = input.selectionEnd = 0; | 22 input.selectionStart = input.selectionEnd = 0; |
21 | 23 |
22 internals.setSuggestedValue(input, 'suggested value'); | 24 internals.setSuggestedValue(input, 'suggested value'); |
23 internals.setSuggestedValue(month, '2014-01'); | 25 internals.setSuggestedValue(month, '2014-01'); |
24 internals.setSuggestedValue(textarea, 'suggested value'); | 26 internals.setSuggestedValue(textarea, 'suggested value'); |
| 27 internals.setSuggestedValue(select, 'TX'); |
25 | 28 |
26 Markup.description(document.getElementById('description').textContent) | 29 Markup.description(document.getElementById('description').textContent) |
27 | 30 |
28 function addTextResult(value) { input.parentNode.appendChild(document.create
TextNode(value + ': ' + eval(value))); } | 31 function addTextResult(value) { input.parentNode.appendChild(document.create
TextNode(value + ': ' + eval(value))); } |
29 addTextResult('input.value'); | 32 addTextResult('input.value'); |
30 addTextResult('internals.suggestedValue(input)'); | 33 addTextResult('internals.suggestedValue(input)'); |
31 addTextResult('input.selectionStart'); | 34 addTextResult('input.selectionStart'); |
32 addTextResult('input.selectionEnd'); | 35 addTextResult('input.selectionEnd'); |
33 addTextResult('month.value'); | 36 addTextResult('month.value'); |
34 addTextResult('internals.suggestedValue(month)'); | 37 addTextResult('internals.suggestedValue(month)'); |
35 addTextResult('textarea.value'); | 38 addTextResult('textarea.value'); |
36 addTextResult('internals.suggestedValue(textarea)'); | 39 addTextResult('internals.suggestedValue(textarea)'); |
37 | 40 addTextResult('select.value'); |
| 41 addTextResult('internals.suggestedValue(select)'); |
| 42 |
38 Markup.dump(input.parentNode); | 43 Markup.dump(input.parentNode); |
39 } | 44 } |
40 | 45 |
41 </script> | 46 </script> |
42 </body> | 47 </body> |
43 </html> | 48 </html> |
OLD | NEW |