OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <body> | 2 <body> |
3 <script src="../../../resources/testharness.js"></script> | 3 <script src="../../../resources/testharness.js"></script> |
4 <script src="../../../resources/testharnessreport.js"></script> | 4 <script src="../../../resources/testharnessreport.js"></script> |
5 <link rel="help" href="https://html.spec.whatwg.org/multipage/forms.html#ask-for
-a-reset"> | 5 <link rel="help" href="https://html.spec.whatwg.org/multipage/forms.html#ask-for
-a-reset"> |
6 <div id="log"></div> | 6 <div id="log"></div> |
7 <script> | 7 <script> |
8 test(function() { | 8 test(function() { |
9 var select = document.createElement('select'); | 9 var select = document.createElement('select'); |
10 select.innerHTML = '<option>foo</option>'; | 10 select.innerHTML = '<option>foo</option>'; |
(...skipping 11 matching lines...) Expand all Loading... |
22 document.body.appendChild(select); | 22 document.body.appendChild(select); |
23 select.innerHTML = '<option>foo</option>'; | 23 select.innerHTML = '<option>foo</option>'; |
24 assert_equals(select.selectedIndex, 0); | 24 assert_equals(select.selectedIndex, 0); |
25 select.value = ''; | 25 select.value = ''; |
26 assert_equals(select.selectedIndex, -1); | 26 assert_equals(select.selectedIndex, -1); |
27 document.body.removeChild(select); | 27 document.body.removeChild(select); |
28 // removeChild shouldn't change selection because it didn't change the | 28 // removeChild shouldn't change selection because it didn't change the |
29 // option list. | 29 // option list. |
30 assert_equals(select.selectedIndex, -1); | 30 assert_equals(select.selectedIndex, -1); |
31 }, 'Removing a SELECT tree from another tree should not reset selection.'); | 31 }, 'Removing a SELECT tree from another tree should not reset selection.'); |
| 32 |
| 33 test(function() { |
| 34 var form = document.createElement('form'); |
| 35 document.body.appendChild(form); |
| 36 var select = document.createElement('select'); |
| 37 form.appendChild(select); |
| 38 select.innerHTML = '<option disabled>Apple</option><option>Banana</option><o
ption>Cherry</option>'; |
| 39 assert_equals(select.selectedIndex, 1); |
| 40 form.reset(); |
| 41 assert_equals(select.selectedIndex, 1); |
| 42 }, 'Reset should select the first option element in the list of options that is
not disabled to true'); |
32 </script> | 43 </script> |
33 </body> | 44 </body> |
OLD | NEW |