OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <script src="../../../resources/js-test.js"></script> | |
5 <script src="../resources/common.js"></script> | |
6 <script src="../resources/picker-common.js"></script> | |
7 </head> | |
8 <body> | |
9 <select id="menu"> | |
10 <option>foo</option> | |
11 <option selected>bar</option> | |
12 <option>baz</option> | |
13 </select> | |
14 <select id="menu2"> | |
15 <option>1</option> | |
16 <option selected>2</option> | |
17 <option>3</option> | |
18 <option>4</option> | |
19 <option>5</option> | |
20 <option>6</option> | |
21 <option>7</option> | |
22 <option>8</option> | |
23 <option>9</option> | |
24 <option>10</option> | |
25 <option>11</option> | |
26 <option>12</option> | |
27 <option>13</option> | |
28 <option>14</option> | |
29 <option>15</option> | |
30 <option>16</option> | |
31 <option>17</option> | |
32 <option>18</option> | |
33 <option>19</option> | |
34 <option>20</option> | |
35 <option>21</option> | |
36 <option>22</option> | |
37 <option>23</option> | |
38 <option>24</option> | |
39 <option>25</option> | |
40 <option>26</option> | |
41 <option>27</option> | |
42 <option>28</option> | |
43 <option>29</option> | |
44 </select> | |
45 <script> | |
46 var menuElement = document.getElementById('menu'); | |
47 var menuElement2 = document.getElementById('menu2'); | |
48 var picker = null; | |
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'); | |
54 | |
55 var position = elementCenterPosition(picker._selectElement.children[0]); | |
56 eventSender.addTouchPoint(position[0], position[1]); | |
57 eventSender.touchStart(); | |
58 shouldBeEqualToString('picker._selectElement.value', '0'); | |
59 | |
60 position = elementCenterPosition(picker._selectElement.children[2]); | |
61 eventSender.updateTouchPoint(0, position[0], position[1]); | |
62 eventSender.touchMove(); | |
63 shouldBeEqualToString('picker._selectElement.value', '2'); | |
64 | |
65 eventSender.releaseTouchPoint(0); | |
66 eventSender.touchEnd(); | |
67 | |
68 shouldBeNull('window.internals.pagePopupWindow'); | |
69 shouldBeEqualToString('menuElement.value', 'baz'); | |
70 | |
71 test2(); | |
72 }, function () { | |
73 testFailed('picker didn\'t open') | |
74 finishJSTest(); | |
75 }); | |
76 | |
77 function test2() { | |
78 openPicker(menuElement2, function () { | |
79 picker = window.internals.pagePopupWindow.global.picker; | |
80 shouldBeEqualToString('picker._selectElement.value', '1'); | |
81 shouldBeEqualToString('menuElement2.value', '2'); | |
82 | |
83 var position = elementCenterPosition(picker._selectElement.children[2]); | |
84 eventSender.addTouchPoint(position[0], position[1]); | |
85 eventSender.touchStart(); | |
86 shouldBeEqualToString('picker._selectElement.value', '2'); | |
87 | |
88 position = elementCenterPosition(picker._selectElement.children[3]); | |
89 eventSender.updateTouchPoint(0, position[0], position[1]); | |
90 eventSender.touchMove(); | |
91 shouldBeEqualToString('picker._selectElement.value', '3'); | |
92 | |
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); | |
100 }, function () { | |
101 testFailed('picker didn\'t open') | |
102 finishJSTest(); | |
103 }); | |
104 } | |
105 | |
106 function test2AfterScrollEvent() { | |
107 // touchmove event fires before the scroll event so the selection will chang
e. | |
108 shouldBeEqualToString('picker._selectElement.value', '0'); | |
109 eventSender.releaseTouchPoint(0); | |
110 eventSender.touchEnd(); | |
111 eventSender.gestureScrollEnd(0, 0); | |
112 | |
113 shouldNotBe('window.internals.pagePopupWindow', 'null'); | |
114 shouldBeEqualToString('menuElement2.value', '2'); | |
115 | |
116 finishJSTest(); | |
117 } | |
118 </script> | |
119 </body> | |
120 </html> | |
OLD | NEW |