OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../resources/js-test.js"></script> | 2 <script src="../../resources/js-test.js"></script> |
3 <div id="output"></div> | 3 <div id="output"></div> |
4 <script> | 4 <script> |
5 description("Tests that select elements cap their size to the size attribute
and to 4 when no size is specified."); | 5 description("Tests that select elements cap their size to the size attribute
and to 4 when no size is specified."); |
6 | 6 |
7 function getElemById(elemId) { | 7 function getElemById(elemId) { |
8 return document.getElementById(elemId); | 8 return document.getElementById(elemId); |
9 } | 9 } |
10 | 10 |
11 function clientHeight(elemId) { | 11 function clientHeight(elemId) { |
12 return getElemById(elemId).clientHeight; | 12 return getElemById(elemId).clientHeight; |
13 } | 13 } |
14 | 14 |
15 function multipleOfElement(elemId, multiple) { | |
16 return clientHeight(elemId) * multiple + (multiple - 1); | |
17 } | |
18 | |
19 function addSelect(id, numOptions) | 15 function addSelect(id, numOptions) |
20 { | 16 { |
21 var select = document.createElement("select2"); | 17 var select = document.createElement("select2"); |
22 var html = '<select multiple id="' + id + '">'; | 18 var html = '<select multiple id="' + id + '">'; |
23 for (var i = 0; i <= numOptions; i++) | 19 for (var i = 0; i <= numOptions; i++) |
24 html += '<option value="' + i + '">' + i + '</option>'; | 20 html += '<option value="' + i + '">' + i + '</option>'; |
25 getElemById('output').innerHTML += html + '</select>'; | 21 getElemById('output').innerHTML += html + '</select>'; |
26 } | 22 } |
27 | 23 |
28 addSelect('select1', 10); | 24 addSelect('select1', 10); |
29 addSelect('select2', 16); | 25 addSelect('select2', 16); |
30 | 26 |
31 shouldBe("clientHeight('select2')", "clientHeight('select1')"); | 27 shouldBe("clientHeight('select2')", "clientHeight('select1')"); |
32 shouldBeTrue("getElemById('select2').setAttribute('size', '4'); clientHeight
('select2') == clientHeight('select1')"); | 28 shouldBeTrue("getElemById('select2').setAttribute('size', '4'); clientHeight
('select2') == clientHeight('select1')"); |
33 shouldBeTrue("getElemById('select2').setAttribute('size', '5'); clientHeight
('select2') > clientHeight('select1')"); | 29 shouldBeTrue("getElemById('select2').setAttribute('size', '5'); clientHeight
('select2') > clientHeight('select1')"); |
34 shouldBeTrue("getElemById('select2').setAttribute('size', '8'); clientHeight
('select2') == multipleOfElement('select1', 2)"); | |
35 shouldBeTrue("getElemById('select2').setAttribute('size', '12'); clientHeigh
t('select2') == multipleOfElement('select1', 3)"); | |
36 shouldBeTrue("getElemById('select2').setAttribute('size', '16'); clientHeigh
t('select2') == multipleOfElement('select1', 4)"); | |
37 </script> | 30 </script> |
OLD | NEW |