Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/forms/select/select-ask-for-reset.html

Issue 1838183003: Fix problems on changing 'multiple' state SELECT element to 'single' state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a typo in a comment Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698