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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/html/semantics/forms/the-select-element/selected-index.html

Issue 2711183003: Import wpt@a7e9c2abcf65b78fcf1c246fec6681c74e1bc352 (Closed)
Patch Set: Update test expectations and baselines. Created 3 years, 9 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 <meta charset=utf-8> 2 <meta charset=utf-8>
3 <title>HTMLSelectElement selectedIndex</title> 3 <title>HTMLSelectElement selectedIndex</title>
4 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharness.js"></script>
5 <script src="/resources/testharnessreport.js"></script> 5 <script src="/resources/testharnessreport.js"></script>
6 <div id=log></div> 6 <div id=log></div>
7 7
8 <form id=form> 8 <form id=form>
9 <select id=empty></select> 9 <select id=empty></select>
10 10
(...skipping 10 matching lines...) Expand all
21 <option></option> 21 <option></option>
22 </select> 22 </select>
23 23
24 <select id=selected> 24 <select id=selected>
25 <option></option> 25 <option></option>
26 <option selected></option> 26 <option selected></option>
27 </select> 27 </select>
28 </form> 28 </form>
29 29
30 <script> 30 <script>
31 function assertSelectedIndex(select, value) {
32 assert_equals(select.selectedIndex, value);
33 assert_equals(select.options.selectedIndex, value);
34 }
35
31 test(function () { 36 test(function () {
32 var select = document.getElementById('empty'); 37 var select = document.getElementById('empty');
33 assert_equals(select.selectedIndex, -1); 38 assertSelectedIndex(select, -1);
34 }, "get empty"); 39 }, "get empty");
35 40
36 test(function () { 41 test(function () {
37 var select = document.getElementById('default'); 42 var select = document.getElementById('default');
38 assert_equals(select.selectedIndex, 0); 43 assertSelectedIndex(select, 0);
39 }, "get default"); 44 }, "get default");
40 45
41 test(function () { 46 test(function () {
42 var select = document.getElementById('disabled'); 47 var select = document.getElementById('disabled');
43 assert_equals(select.selectedIndex, 1); 48 assertSelectedIndex(select, 1);
44 }, "get disabled"); 49 }, "get disabled");
45 50
46 test(function () { 51 test(function () {
47 var select = document.getElementById('selected'); 52 var select = document.getElementById('selected');
48 assert_equals(select.selectedIndex, 1); 53 assertSelectedIndex(select, 1);
49 }, "get unselected"); 54 }, "get unselected");
50 55
51 test(function () { 56 test(function () {
52 var select = document.getElementById('empty'); 57 var select = document.getElementById('empty');
53 select.selectedIndex = 1; 58 select.selectedIndex = 1;
54 assert_equals(select.selectedIndex, -1); 59 assertSelectedIndex(select, -1);
55 }, "set empty"); 60 }, "set empty (HTMLSelectElement)");
61
62 test(function () {
63 var select = document.getElementById('empty');
64 select.options.selectedIndex = 1;
65 assertSelectedIndex(select, -1);
66 }, "set empty (HTMLOptionsCollection)");
56 67
57 test(function () { 68 test(function () {
58 var select = document.getElementById('default'); 69 var select = document.getElementById('default');
59 assert_equals(select.selectedIndex, 0); 70 assertSelectedIndex(select, 0);
60 select.selectedIndex = 2; 71 select.selectedIndex = 2;
61 assert_equals(select.selectedIndex, 2); 72 assertSelectedIndex(select, 2);
62 }, "set"); 73 this.add_cleanup(() => select.selectedIndex = 0);
74 }, "set (HTMLSelectElement)");
75
76 test(function () {
77 var select = document.getElementById('default');
78 assertSelectedIndex(select, 0);
79 select.options.selectedIndex = 2;
80 assertSelectedIndex(select, 2);
81 this.add_cleanup(() => select.selectedIndex = 0);
82 }, "set (HTMLOptionsCollection)");
63 83
64 test(function () { 84 test(function () {
65 var select = document.getElementById('selected'); 85 var select = document.getElementById('selected');
66 var form = document.getElementById('form'); 86 var form = document.getElementById('form');
67 assert_equals(select.selectedIndex, 1); 87 assertSelectedIndex(select, 1);
68 select.selectedIndex = 0; 88 select.selectedIndex = 0;
69 assert_equals(select.selectedIndex, 0); 89 assertSelectedIndex(select, 0);
70 form.reset(); 90 form.reset();
71 assert_equals(select.selectedIndex, 1); 91 assertSelectedIndex(select, 1);
72 }, "set and reset"); 92 }, "set and reset (HTMLSelectElement)");
93
94 test(function () {
95 var select = document.getElementById('selected');
96 var form = document.getElementById('form');
97 assertSelectedIndex(select, 1);
98 select.options.selectedIndex = 0;
99 assertSelectedIndex(select, 0);
100 form.reset();
101 assertSelectedIndex(select, 1);
102 }, "set and reset (HTMLOptionsCollection)");
73 </script> 103 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698