4 <script src=
"../../../resources/js-test.js"></script>
5 <select id=
"select1" multiple
size=
"4">
12 description('Tapping on listbox items should toggle selection.');
14 function tapOption(select
, index
) {
15 var itemHeight
= Math
.floor(select
.offsetHeight
/ select
.size
);
17 var y
= border
+ index
* itemHeight
;
20 if (window
.eventSender
) {
21 eventSender
.gestureTap(select
.offsetLeft
+ border
, select
.offsetTop
+ y
- window
.pageYOffset
+ itemHeight
/ 2);
25 function getSelectedValues(select
) {
26 var selectedValues
= [];
27 for (var i
= 0; i
< select
.options
.length
; i
++) {
28 var option
= select
.options
[i
];
30 selectedValues
.push(option
.value
);
32 return selectedValues
.join(',');
35 var select
= document
.getElementById('select1');
37 if (!window
.eventSender
) {
38 debug('Tap on the options and see if it toggles the selection.');
40 shouldBeEqualToString('getSelectedValues(select)', '');
43 shouldBeEqualToString('getSelectedValues(select)', '1');
45 shouldBeEqualToString('getSelectedValues(select)', '1,2');
47 shouldBeEqualToString('getSelectedValues(select)', '1,2,3');
49 shouldBeEqualToString('getSelectedValues(select)', '1,2,3');
51 shouldBeEqualToString('getSelectedValues(select)', '1,3');
53 shouldBeEqualToString('getSelectedValues(select)', '3');
55 shouldBeEqualToString('getSelectedValues(select)', '');