OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
5 <script src="../resources/common.js"></script> | 5 <script src="../resources/common.js"></script> |
6 <script src="../resources/picker-common.js"></script> | 6 <script src="../resources/picker-common.js"></script> |
7 </head> | 7 </head> |
8 <body> | 8 <body> |
9 <select id="menu"> | 9 <select id="menu"> |
10 <option>foo</option> | 10 <option>foo</option> |
11 <option selected>bar</option> | 11 <option selected>bar</option> |
12 <option>baz</option> | 12 <option>baz</option> |
13 </select> | 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> |
14 <script> | 45 <script> |
15 var menuElement = document.getElementById('menu'); | 46 var menuElement = document.getElementById('menu'); |
| 47 var menuElement2 = document.getElementById('menu2'); |
16 var picker = null; | 48 var picker = null; |
17 eventSender.clearTouchPoints(); | 49 eventSender.clearTouchPoints(); |
18 openPicker(menuElement, function () { | 50 openPicker(menuElement, function () { |
19 picker = window.internals.pagePopupWindow.global.picker; | 51 picker = window.internals.pagePopupWindow.global.picker; |
20 shouldBeEqualToString('picker._selectElement.value', '1'); | 52 shouldBeEqualToString('picker._selectElement.value', '1'); |
21 shouldBeEqualToString('menuElement.value', 'bar'); | 53 shouldBeEqualToString('menuElement.value', 'bar'); |
22 | 54 |
23 var position = elementCenterPosition(picker._selectElement.children[0]); | 55 var position = elementCenterPosition(picker._selectElement.children[0]); |
24 eventSender.addTouchPoint(position[0], position[1]); | 56 eventSender.addTouchPoint(position[0], position[1]); |
25 eventSender.touchStart(); | 57 eventSender.touchStart(); |
26 shouldBeEqualToString('picker._selectElement.value', '0'); | 58 shouldBeEqualToString('picker._selectElement.value', '0'); |
27 | 59 |
28 position = elementCenterPosition(picker._selectElement.children[2]); | 60 position = elementCenterPosition(picker._selectElement.children[2]); |
29 eventSender.updateTouchPoint(0, position[0], position[1]); | 61 eventSender.updateTouchPoint(0, position[0], position[1]); |
30 eventSender.touchMove(); | 62 eventSender.touchMove(); |
31 shouldBeEqualToString('picker._selectElement.value', '2'); | 63 shouldBeEqualToString('picker._selectElement.value', '2'); |
32 | 64 |
33 eventSender.releaseTouchPoint(0); | 65 eventSender.releaseTouchPoint(0); |
34 eventSender.touchEnd(); | 66 eventSender.touchEnd(); |
35 | 67 |
36 shouldBeNull('window.internals.pagePopupWindow'); | 68 shouldBeNull('window.internals.pagePopupWindow'); |
37 shouldBeEqualToString('menuElement.value', 'baz'); | 69 shouldBeEqualToString('menuElement.value', 'baz'); |
38 | 70 |
39 finishJSTest(); | 71 test2(); |
40 }, function () { | 72 }, function () { |
41 testFailed('picker didn\'t open') | 73 testFailed('picker didn\'t open') |
42 finishJSTest(); | 74 finishJSTest(); |
43 }); | 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 } |
44 </script> | 118 </script> |
45 </body> | 119 </body> |
46 </html> | 120 </html> |
OLD | NEW |