| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 }, 'Reset should select the first option element in the list of options that is
not disabled to true'); | 42 }, 'Reset should select the first option element in the list of options that is
not disabled to true'); |
| 43 | 43 |
| 44 test(function() { | 44 test(function() { |
| 45 var select = document.createElement('select'); | 45 var select = document.createElement('select'); |
| 46 select.innerHTML = '<option>foo</option><option>bar</option>'; | 46 select.innerHTML = '<option>foo</option><option>bar</option>'; |
| 47 document.body.appendChild(select); | 47 document.body.appendChild(select); |
| 48 select.selectedIndex = -1; | 48 select.selectedIndex = -1; |
| 49 select.removeChild(select.lastChild); | 49 select.removeChild(select.lastChild); |
| 50 assert_equals(select.selectedIndex, 0); | 50 assert_equals(select.selectedIndex, 0); |
| 51 }, 'Removing an OPTION from a SELECT element should reset selection.'); | 51 }, 'Removing an OPTION from a SELECT element should reset selection.'); |
| 52 |
| 53 test(function() { |
| 54 var select = document.createElement('select'); |
| 55 select.multiple = true; |
| 56 select.innerHTML = '<option selected>foo</option><option selected>bar</optio
n>'; |
| 57 document.body.appendChild(select); |
| 58 select.removeAttribute('multiple'); |
| 59 assert_equals(select.selectedOptions.length, 1); |
| 60 assert_equals(select.selectedIndex, 0, 'The first selected OPTION should be
chosen.'); |
| 61 |
| 62 select.selectedIndex = -1; |
| 63 select.multiple = true; |
| 64 select.multiple = false; |
| 65 assert_equals(select.selectedOptions.length, 1); |
| 66 assert_equals(select.selectedIndex, 0); |
| 67 }, 'Changing multiple SELECT to single should reset selection.'); |
| 52 </script> | 68 </script> |
| 53 </body> | 69 </body> |
| OLD | NEW |