4 <script src=
"../../../resources/js-test.js"></script>
5 <script src=
"../resources/common.js"></script>
6 <script src=
"../resources/picker-common.js"></script>
11 <option selected
>bar
</option>
16 <option selected
>2</option>
46 var menuElement
= document
.getElementById('menu');
47 var menuElement2
= document
.getElementById('menu2');
49 eventSender
.clearTouchPoints();
50 openPicker(menuElement
, function () {
51 picker
= window
.internals
.pagePopupWindow
.global
.picker
;
52 shouldBeEqualToString('picker._selectElement.value', '1');
53 shouldBeEqualToString('menuElement.value', 'bar');
55 var position
= elementCenterPosition(picker
._selectElement
.children
[0]);
56 eventSender
.addTouchPoint(position
[0], position
[1]);
57 eventSender
.touchStart();
58 shouldBeEqualToString('picker._selectElement.value', '0');
60 position
= elementCenterPosition(picker
._selectElement
.children
[2]);
61 eventSender
.updateTouchPoint(0, position
[0], position
[1]);
62 eventSender
.touchMove();
63 shouldBeEqualToString('picker._selectElement.value', '2');
65 eventSender
.releaseTouchPoint(0);
66 eventSender
.touchEnd();
68 shouldBeNull('window.internals.pagePopupWindow');
69 shouldBeEqualToString('menuElement.value', 'baz');
73 testFailed('picker didn\'t open')
78 openPicker(menuElement2
, function () {
79 picker
= window
.internals
.pagePopupWindow
.global
.picker
;
80 shouldBeEqualToString('picker._selectElement.value', '1');
81 shouldBeEqualToString('menuElement2.value', '2');
83 var position
= elementCenterPosition(picker
._selectElement
.children
[2]);
84 eventSender
.addTouchPoint(position
[0], position
[1]);
85 eventSender
.touchStart();
86 shouldBeEqualToString('picker._selectElement.value', '2');
88 position
= elementCenterPosition(picker
._selectElement
.children
[3]);
89 eventSender
.updateTouchPoint(0, position
[0], position
[1]);
90 eventSender
.touchMove();
91 shouldBeEqualToString('picker._selectElement.value', '3');
93 // Moving touch up should scroll and end touch select mode.
94 position
= elementCenterPosition(picker
._selectElement
.children
[0]);
95 eventSender
.updateTouchPoint(0, position
[0], position
[1]);
96 eventSender
.touchMove();
97 eventSender
.gestureScrollBegin(position
[0], position
[1]);
98 eventSender
.gestureScrollUpdate(0, -130);
99 setTimeout(test2AfterScrollEvent
, 1000);
101 testFailed('picker didn\'t open')
106 function test2AfterScrollEvent() {
107 // touchmove event fires before the scroll event so the selection will change.
108 shouldBeEqualToString('picker._selectElement.value', '0');
109 eventSender
.releaseTouchPoint(0);
110 eventSender
.touchEnd();
111 eventSender
.gestureScrollEnd(0, 0);
113 shouldNotBe('window.internals.pagePopupWindow', 'null');
114 shouldBeEqualToString('menuElement2.value', '2');